mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
refactor new file download functions to new file
This commit is contained in:
@@ -2,13 +2,13 @@ import { useEffect, FunctionComponent } from 'react'
|
||||
import Prism from 'prismjs'
|
||||
|
||||
import { getExtension } from '../../utils/getFileIcon'
|
||||
import { useStaleSWR } from '../../utils/tools'
|
||||
import { useStaleSWR } from '../../utils/fetchWithSWR'
|
||||
import FourOhFour from '../FourOhFour'
|
||||
import Loading from '../Loading'
|
||||
import DownloadBtn from '../DownloadBtn'
|
||||
|
||||
const CodePreview: FunctionComponent<{ file: any }> = ({ file }) => {
|
||||
const { data, error } = useStaleSWR(file['@microsoft.graph.downloadUrl'])
|
||||
const { data, error } = useStaleSWR({ url: file['@microsoft.graph.downloadUrl'] })
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
|
||||
@@ -11,14 +11,14 @@ import 'katex/dist/katex.min.css'
|
||||
import FourOhFour from '../FourOhFour'
|
||||
import Loading from '../Loading'
|
||||
import DownloadBtn from '../DownloadBtn'
|
||||
import { useStaleSWR } from '../../utils/tools'
|
||||
import { useStaleSWR } from '../../utils/fetchWithSWR'
|
||||
|
||||
const MarkdownPreview: FunctionComponent<{ file: any; path: string; standalone?: boolean }> = ({
|
||||
file,
|
||||
path,
|
||||
standalone = true,
|
||||
}) => {
|
||||
const { data, error } = useStaleSWR(file['@microsoft.graph.downloadUrl'])
|
||||
const { data, error } = useStaleSWR({ url: file['@microsoft.graph.downloadUrl'] })
|
||||
|
||||
// The parent folder of the markdown file, which is also the relative image folder
|
||||
const parentPath = path.substring(0, path.lastIndexOf('/'))
|
||||
|
||||
@@ -3,10 +3,10 @@ import { FunctionComponent } from 'react'
|
||||
import FourOhFour from '../FourOhFour'
|
||||
import Loading from '../Loading'
|
||||
import DownloadBtn from '../DownloadBtn'
|
||||
import { useStaleSWR } from '../../utils/tools'
|
||||
import { useStaleSWR } from '../../utils/fetchWithSWR'
|
||||
|
||||
const TextPreview: FunctionComponent<{ file: any }> = ({ file }) => {
|
||||
const { data, error } = useStaleSWR(file['@microsoft.graph.downloadUrl'])
|
||||
const { data, error } = useStaleSWR({ url: file['@microsoft.graph.downloadUrl'] })
|
||||
if (error) {
|
||||
return (
|
||||
<div className="dark:bg-gray-900 p-3 bg-white rounded">
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useClipboard } from 'use-clipboard-copy'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import toast, { Toaster } from 'react-hot-toast'
|
||||
|
||||
import { getBaseUrl } from '../../utils/tools'
|
||||
import { getBaseUrl } from "../../utils/getBaseUrl"
|
||||
|
||||
export const VideoPreview: FunctionComponent<{ file: any }> = ({ file }) => {
|
||||
const { asPath } = useRouter()
|
||||
|
||||
Reference in New Issue
Block a user