mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
Standalone raw file redirects (#428)
This commit is contained in:
@@ -11,6 +11,7 @@ import { humanFileSize, formatModifiedDateTime } from '../utils/fileDetails'
|
||||
import { getReadablePath } from '../utils/getReadablePath'
|
||||
|
||||
import { Downloading, Checkbox, ChildIcon, ChildName } from './FileListing'
|
||||
import { getStoredToken } from '../utils/protectedRouteHandler'
|
||||
|
||||
const FileListItem: FC<{ fileContent: OdFolderChildren }> = ({ fileContent: c }) => {
|
||||
return (
|
||||
@@ -45,9 +46,13 @@ const FolderListLayout = ({
|
||||
toast,
|
||||
}) => {
|
||||
const clipboard = useClipboard()
|
||||
const hashedToken = getStoredToken(path)
|
||||
|
||||
const { t } = useTranslation()
|
||||
|
||||
// Get item path from item name
|
||||
const getItemPath = (name: string) => `${path === '/' ? '' : path}/${encodeURIComponent(name)}`
|
||||
|
||||
return (
|
||||
<div className="rounded bg-white dark:bg-gray-900 dark:text-gray-100">
|
||||
<div className="grid grid-cols-12 items-center space-x-2 border-b border-gray-900/10 px-3 dark:border-gray-500/30">
|
||||
@@ -72,7 +77,7 @@ const FolderListLayout = ({
|
||||
title={t('Select files')}
|
||||
/>
|
||||
{totalGenerating ? (
|
||||
<Downloading title={t('Downloading selected files, refresh page to cancel')} />
|
||||
<Downloading title={t('Downloading selected files, refresh page to cancel')} style="p-1.5" />
|
||||
) : (
|
||||
<button
|
||||
title={t('Download selected files')}
|
||||
@@ -113,7 +118,7 @@ const FolderListLayout = ({
|
||||
<FontAwesomeIcon icon={['far', 'copy']} />
|
||||
</span>
|
||||
{folderGenerating[c.id] ? (
|
||||
<Downloading title={t('Downloading folder, refresh page to cancel')} />
|
||||
<Downloading title={t('Downloading folder, refresh page to cancel')} style="px-1.5 py-1" />
|
||||
) : (
|
||||
<span
|
||||
title={t('Download folder')}
|
||||
@@ -134,9 +139,9 @@ const FolderListLayout = ({
|
||||
className="cursor-pointer rounded px-1.5 py-1 hover:bg-gray-300 dark:hover:bg-gray-600"
|
||||
onClick={() => {
|
||||
clipboard.copy(
|
||||
`${getBaseUrl()}/api?path=${getReadablePath(
|
||||
`${path === '/' ? '' : path}/${encodeURIComponent(c.name)}`
|
||||
)}&raw=true`
|
||||
`${getBaseUrl()}/api/raw/?path=${getReadablePath(getItemPath(c.name))}${
|
||||
hashedToken ? `&odpt=${hashedToken}` : ''
|
||||
}`
|
||||
)
|
||||
toast.success(t('Copied raw file permalink.'))
|
||||
}}
|
||||
@@ -146,7 +151,7 @@ const FolderListLayout = ({
|
||||
<a
|
||||
title={t('Download file')}
|
||||
className="cursor-pointer rounded px-1.5 py-1 hover:bg-gray-300 dark:hover:bg-gray-600"
|
||||
href={c['@microsoft.graph.downloadUrl']}
|
||||
href={`/api/raw/?path=${getItemPath(c.name)}${hashedToken ? `&odpt=${hashedToken}` : ''}`}
|
||||
>
|
||||
<FontAwesomeIcon icon={['far', 'arrow-alt-circle-down']} />
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user