diff --git a/src/lang/en/manage.json b/src/lang/en/manage.json index 3596b996d2..5268eb2441 100644 --- a/src/lang/en/manage.json +++ b/src/lang/en/manage.json @@ -13,15 +13,14 @@ "profile": "Profile", "about": "About", "tasks": "Tasks", - "aria2": "Aria2", "upload": "Upload", "copy": "Copy", "backup-restore": "Backup & Restore", "home": "Home", "indexes": "Indexes", "sso": "Single Sign-on", - "qbit": "qBittorrent", - "docs": "Documentation" + "docs": "Documentation", + "offline_download": "Offline Download" }, "title": "AList Manage", "not_admin": "You are not admin user, please login with admin account.", diff --git a/src/lang/en/tasks.json b/src/lang/en/tasks.json index 2aee45fa97..ef8ea956d4 100644 --- a/src/lang/en/tasks.json +++ b/src/lang/en/tasks.json @@ -1,8 +1,6 @@ { - "aria2_down": "Download file to local machine", - "aria2_transfer": "Transfer downloaded file to corresponding storage", - "qbit_down": "Download file to local machine", - "qbit_transfer": "Transfer downloaded file to corresponding storage", + "offline_download": "Download file to local machine", + "offline_download_transfer": "Transfer downloaded file to corresponding storage", "upload": "Upload file to corresponding storage", "copy": "Copy file from a storage to another storage", "done": "Completed", diff --git a/src/pages/home/toolbar/OfflineDownload.tsx b/src/pages/home/toolbar/OfflineDownload.tsx index 717ac73e75..521056ee98 100644 --- a/src/pages/home/toolbar/OfflineDownload.tsx +++ b/src/pages/home/toolbar/OfflineDownload.tsx @@ -1,12 +1,31 @@ import { Box, createDisclosure } from "@hope-ui/solid" import { ModalInput, SelectWrapper } from "~/components" import { useFetch, useRouter, useT } from "~/hooks" -import { offlineDownload, bus, handleRespWithNotifySuccess } from "~/utils" -import { createSignal, onCleanup } from "solid-js" +import { + offlineDownload, + bus, + handleRespWithNotifySuccess, + r, + handleResp, +} from "~/utils" +import { createSignal, onCleanup, onMount } from "solid-js" +import { PResp } from "~/types" export const OfflineDownload = () => { const t = useT() - const [type, setType] = createSignal("aria2") + const [tools, setTools] = createSignal([] as string[]) + const [toolsLoading, reqTool] = useFetch((): PResp => { + return r.get("/public/offline_download_tools") + }) + const [tool, setTool] = createSignal("") + onMount(async () => { + const resp = await reqTool() + handleResp(resp, (data) => { + setTools(data) + setTool(data[0]) + }) + }) + const { isOpen, onOpen, onClose } = createDisclosure() const [loading, ok] = useFetch(offlineDownload) const { pathname } = useRouter() @@ -25,22 +44,21 @@ export const OfflineDownload = () => { type="text" opened={isOpen()} onClose={onClose} - loading={loading()} + loading={toolsLoading() || loading()} tips={t("home.toolbar.offline_download-tips")} topSlot={ setType(v)} - options={[ - { value: "aria2", label: "Aria2" }, - { value: "qbit", label: "qBittorrent" }, - ]} + value={tool()} + onChange={(v) => setTool(v)} + options={tools().map((tool) => { + return { value: tool, label: tool } + })} /> } onSubmit={async (urls) => { - const resp = await ok(pathname(), urls.split("\n"), type()) + const resp = await ok(pathname(), urls.split("\n"), tool()) handleRespWithNotifySuccess(resp, () => { onClose() }) diff --git a/src/pages/manage/sidemenu_items.tsx b/src/pages/manage/sidemenu_items.tsx index 2b7a3e060f..c0008ab41e 100644 --- a/src/pages/manage/sidemenu_items.tsx +++ b/src/pages/manage/sidemenu_items.tsx @@ -9,7 +9,6 @@ import { BsMedium, BsFingerprint, BsFront, - BsCloudArrowDownFill, BsCloudUploadFill, BsSearch, } from "solid-icons/bs" @@ -17,7 +16,7 @@ import { FiLogIn } from "solid-icons/fi" import { SiMetabase } from "solid-icons/si" import { CgDatabase } from "solid-icons/cg" import { OcWorkflow2 } from "solid-icons/oc" -import { IoCopy, IoHome } from "solid-icons/io" +import { IoCopy, IoHome, IoMagnetOutline } from "solid-icons/io" import { Component, lazy } from "solid-js" import { Group, UserRole } from "~/types" import { FaBrandsQuinscape, FaSolidBook, FaSolidDatabase } from "solid-icons/fa" @@ -86,17 +85,23 @@ export const side_menu_items: SideMenuItem[] = [ to: "/@manage/tasks", children: [ { - title: "manage.sidemenu.aria2", - icon: BsCloudArrowDownFill, + title: "manage.sidemenu.offline_download", + icon: IoMagnetOutline, to: "/@manage/tasks/aria2", - component: lazy(() => import("./tasks/Aria2")), - }, - { - title: "manage.sidemenu.qbit", - icon: FaBrandsQuinscape, - to: "/@manage/tasks/qbit", - component: lazy(() => import("./tasks/Qbit")), + component: lazy(() => import("./tasks/offline_download")), }, + // { + // title: "manage.sidemenu.aria2", + // icon: BsCloudArrowDownFill, + // to: "/@manage/tasks/aria2", + // component: lazy(() => import("./tasks/Aria2")), + // }, + // { + // title: "manage.sidemenu.qbit", + // icon: FaBrandsQuinscape, + // to: "/@manage/tasks/qbit", + // component: lazy(() => import("./tasks/Qbit")), + // }, { title: "manage.sidemenu.upload", icon: BsCloudUploadFill, diff --git a/src/pages/manage/tasks/offline_download.tsx b/src/pages/manage/tasks/offline_download.tsx new file mode 100644 index 0000000000..8c6f37924e --- /dev/null +++ b/src/pages/manage/tasks/offline_download.tsx @@ -0,0 +1,15 @@ +import { VStack } from "@hope-ui/solid" +import { useManageTitle } from "~/hooks" +import { TypeTasks } from "./Tasks" + +const OfflineDownload = () => { + useManageTitle("manage.sidemenu.offline_download") + return ( + + + + + ) +} + +export default OfflineDownload diff --git a/src/utils/api.ts b/src/utils/api.ts index 390ab5fc9a..5ccf30c474 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -108,9 +108,9 @@ export const fsNewFile = (path: string, password: string): PEmptyResp => { export const offlineDownload = ( path: string, urls: string[], - type: string, + tool: string, ): PEmptyResp => { - return r.post(`/fs/add_${type}`, { path, urls }) + return r.post(`/fs/add_offline_download`, { path, urls, tool }) } export const fetchText = async (