diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index b9700ce..1f5a406 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -30,6 +30,7 @@ import { CheckCircle, ChevronDown, ChevronUp, + Cloud, Database, ExternalLink, FileText, @@ -3499,6 +3500,219 @@ const OpenListConfigComponent = ({ ); }; +const NetDiskConfigComponent = ({ + config, + refreshConfig, +}: { + config: AdminConfig | null; + refreshConfig: () => Promise; +}) => { + const { alertModal, showAlert, hideAlert } = useAlertModal(); + const { isLoading, withLoading } = useLoadingState(); + const [enabled, setEnabled] = useState(false); + const [cookie, setCookie] = useState(''); + const [savePath, setSavePath] = useState('/'); + const [playTempSavePath, setPlayTempSavePath] = useState('/'); + const [openListTempPath, setOpenListTempPath] = useState('/'); + + useEffect(() => { + const quark = config?.NetDiskConfig?.Quark; + setEnabled(quark?.Enabled || false); + setCookie(quark?.Cookie || ''); + setSavePath(quark?.SavePath || '/'); + setPlayTempSavePath(quark?.PlayTempSavePath || '/'); + setOpenListTempPath(quark?.OpenListTempPath || '/'); + }, [config]); + + const handleSave = async () => { + await withLoading('saveNetDisk', async () => { + const response = await fetch('/api/admin/netdisk', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + action: 'save', + Quark: { + Enabled: enabled, + Cookie: cookie, + SavePath: savePath, + PlayTempSavePath: playTempSavePath, + OpenListTempPath: openListTempPath, + }, + }), + }); + + const data = await response.json(); + if (!response.ok) { + throw new Error(data.error || '保存失败'); + } + + showSuccess('保存成功', showAlert); + await refreshConfig(); + }); + }; + + const handleValidate = async () => { + await withLoading('validateNetDisk', async () => { + try { + const response = await fetch('/api/admin/netdisk', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + action: 'validate', + Quark: { + Cookie: cookie, + SavePath: savePath, + PlayTempSavePath: playTempSavePath, + }, + }), + }); + + const data = await response.json(); + if (!response.ok) { + throw new Error(data.error || '校验失败'); + } + + showSuccess(data.message || '夸克 Cookie 可读', showAlert); + } catch (error) { + showError(error instanceof Error ? error.message : '校验失败', showAlert); + throw error; + } + }); + }; + + return ( +
+
+ + 夸克网盘 + +
+
+
+ + + 夸克网盘说明 + +
+
+

• 转存:把整个分享保存到夸克正式目录。

+

• 立即播放:将分享内所有视频文件转存到临时播放目录,再通过 OpenList 临时目录直接播放。

+

• OpenList 临时目录必须映射到夸克临时播放目录,否则立即播放无法找到文件。

+
+
+ +
+
+

+ 启用夸克网盘 +

+

+ 开启后,网盘搜索中的夸克资源会显示“立即播放”和“转存”按钮 +

+
+ +
+ +
+ +