diff --git a/packages/filesystem/auth.ts b/packages/filesystem/auth.ts index ef350cfdb..328308457 100644 --- a/packages/filesystem/auth.ts +++ b/packages/filesystem/auth.ts @@ -2,8 +2,9 @@ import { ExtServer, ExtServerApi } from "@App/app/const"; import { WarpTokenError } from "./error"; import { LocalStorageDAO } from "@App/app/repo/localStorage"; import { sleep } from "@App/pkg/utils/utils"; +import type { FileSystemType } from "./factory"; -type NetDiskType = "baidu" | "onedrive" | "googledrive" | "dropbox"; +export type NetDiskType = "baidu" | "onedrive" | "googledrive" | "dropbox"; export function GetNetDiskToken(netDiskType: NetDiskType): Promise<{ code: number; @@ -127,3 +128,21 @@ export async function AuthVerify(netDiskType: NetDiskType, invalid?: boolean) { } return token.accessToken; } + +export const netDiskTypeMap: Partial> = { + "baidu-netdsik": "baidu", + onedrive: "onedrive", + googledrive: "googledrive", + dropbox: "dropbox", +}; + +export async function ClearNetDiskToken(netDiskType: NetDiskType) { + const localStorageDAO = new LocalStorageDAO(); + const key = `netdisk:token:${netDiskType}`; + try { + await localStorageDAO.delete(key); + } catch (error) { + // ignore + console.error("ClearNetDiskToken error:", error); + } +} diff --git a/src/locales/ach-UG/translation.json b/src/locales/ach-UG/translation.json index cddb3ec16..ebe558752 100644 --- a/src/locales/ach-UG/translation.json +++ b/src/locales/ach-UG/translation.json @@ -418,6 +418,10 @@ "confirm_leave_page": "crwdns8634:0crwdne8634:0", "page_in_blacklist": "crwdns8636:0crwdne8636:0", "baidu_netdisk": "crwdns8638:0crwdne8638:0", + "netdisk_unbind": "Unbind {{provider}}", + "netdisk_unbind_confirm": "Unbind the {{provider}} account?", + "netdisk_unbind_success": "{{provider}} account unbound", + "netdisk_unbind_error": "Failed to unbind {{provider}} account", "save_only_current_group": "crwdns8640:0crwdne8640:0", "script_import_result": "crwdns8642:0crwdne8642:0", "failure_info": "crwdns8644:0crwdne8644:0", @@ -537,4 +541,4 @@ "subscribe_update_desc": "crwdns12856:0{{newScripts}}crwdnd12856:0{{deletedScripts}}crwdne12856:0" }, "loading": "crwdns12870:0crwdne12870:0" -} \ No newline at end of file +} diff --git a/src/locales/de-DE/translation.json b/src/locales/de-DE/translation.json index 8350c311c..a0d56e015 100644 --- a/src/locales/de-DE/translation.json +++ b/src/locales/de-DE/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "Derzeit im Bearbeitungsstatus. Das Navigieren zu anderen Seiten führt zum Verlust des aktuellen Inhalts. Navigieren?", "page_in_blacklist": "Die aktuelle Seite ist auf der Blacklist und kann keine Skripte verwenden", "baidu_netdisk": "Baidu Netdisk", + "netdisk_unbind": "{{provider}} trennen", + "netdisk_unbind_confirm": "Das {{provider}}-Konto trennen?", + "netdisk_unbind_success": "{{provider}}-Konto getrennt", + "netdisk_unbind_error": "{{provider}}-Konto konnte nicht getrennt werden", "save_only_current_group": "Speichern ist nur für die aktuelle Gruppe wirksam", "script_import_result": "Skript-Import-Ergebnis", "failure_info": "Fehlerinformationen", @@ -551,4 +555,4 @@ "maybe_later": "Vielleicht später", "settings_hint": "Sie können diese Option jederzeit in den Einstellungen ändern." } -} \ No newline at end of file +} diff --git a/src/locales/en-US/translation.json b/src/locales/en-US/translation.json index 19c3faf70..733d3b0e8 100644 --- a/src/locales/en-US/translation.json +++ b/src/locales/en-US/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "Currently editing status. Leaving this page will lose the current content. Do you want to leave?", "page_in_blacklist": "The current page is blacklisted, cannot use script", "baidu_netdisk": "BaiduNetdisk", + "netdisk_unbind": "Unbind {{provider}}", + "netdisk_unbind_confirm": "Unbind the {{provider}} account?", + "netdisk_unbind_success": "{{provider}} account unbound", + "netdisk_unbind_error": "Failed to unbind {{provider}} account", "save_only_current_group": "Save only for current group", "script_import_result": "Script Import Results", "failure_info": "Failure Information", @@ -551,4 +555,4 @@ "maybe_later": "Maybe Later", "settings_hint": "You can change this option in settings at any time." } -} \ No newline at end of file +} diff --git a/src/locales/ja-JP/translation.json b/src/locales/ja-JP/translation.json index 6d38e61f8..d81202429 100644 --- a/src/locales/ja-JP/translation.json +++ b/src/locales/ja-JP/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "現在編集中です。他のページに移動すると現在の内容が失われます。移動しますか?", "page_in_blacklist": "現在のページはブラックリストにあり、スクリプトを使用できません", "baidu_netdisk": "百度ネットディスク", + "netdisk_unbind": "{{provider}} の連携を解除", + "netdisk_unbind_confirm": "{{provider}} のアカウント連携を解除しますか?", + "netdisk_unbind_success": "{{provider}} のアカウント連携を解除しました", + "netdisk_unbind_error": "{{provider}} のアカウント解除に失敗しました", "save_only_current_group": "保存は現在のグループにのみ有効です", "script_import_result": "スクリプトインポート結果", "failure_info": "失敗情報", @@ -551,4 +555,4 @@ "maybe_later": "後で", "settings_hint": "設定ページでいつでも変更できます。" } -} \ No newline at end of file +} diff --git a/src/locales/ru-RU/translation.json b/src/locales/ru-RU/translation.json index a30cc25b5..ddd1fb407 100644 --- a/src/locales/ru-RU/translation.json +++ b/src/locales/ru-RU/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "В настоящее время идет редактирование. Переход на другую страницу приведет к потере текущего содержимого. Продолжить переход?", "page_in_blacklist": "Текущая страница находится в черном списке, невозможно использовать скрипты", "baidu_netdisk": "Baidu Netdisk", + "netdisk_unbind": "Отвязать {{provider}}", + "netdisk_unbind_confirm": "Отвязать аккаунт {{provider}}?", + "netdisk_unbind_success": "Аккаунт {{provider}} отвязан", + "netdisk_unbind_error": "Не удалось отвязать аккаунт {{provider}}", "save_only_current_group": "Сохранение действует только для текущей группы", "script_import_result": "Результат импорта скрипта", "failure_info": "Информация об ошибке", @@ -551,4 +555,4 @@ "maybe_later": "Может быть позже", "settings_hint": "Вы можете изменить эту опцию в настройках в любое время." } -} \ No newline at end of file +} diff --git a/src/locales/vi-VN/translation.json b/src/locales/vi-VN/translation.json index e67a35f73..95e65ddab 100644 --- a/src/locales/vi-VN/translation.json +++ b/src/locales/vi-VN/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "Hiện đang ở trạng thái chỉnh sửa. Rời khỏi trang này sẽ làm mất nội dung hiện tại. Bạn có muốn rời đi không?", "page_in_blacklist": "Trang hiện tại nằm trong danh sách đen, không thể sử dụng script", "baidu_netdisk": "Baidunetdisk", + "netdisk_unbind": "Hủy liên kết {{provider}}", + "netdisk_unbind_confirm": "Hủy liên kết tài khoản {{provider}}?", + "netdisk_unbind_success": "Đã hủy liên kết tài khoản {{provider}}", + "netdisk_unbind_error": "Không thể hủy liên kết tài khoản {{provider}}", "save_only_current_group": "Chỉ lưu cho nhóm hiện tại", "script_import_result": "Kết quả nhập script", "failure_info": "Thông tin thất bại", @@ -551,4 +555,4 @@ "maybe_later": "Để sau", "settings_hint": "Bạn có thể thay đổi tùy chọn này trong cài đặt bất kỳ lúc nào." } -} \ No newline at end of file +} diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json index 90265b1c9..9655854ce 100644 --- a/src/locales/zh-CN/translation.json +++ b/src/locales/zh-CN/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "当前正在编辑状态,跳转其它页面将会丢失当前内容,是否跳转?", "page_in_blacklist": "当前页面在黑名单中,无法使用脚本", "baidu_netdisk": "百度网盘", + "netdisk_unbind": "解除绑定 {{provider}}", + "netdisk_unbind_confirm": "确定解除 {{provider}} 账号绑定吗?", + "netdisk_unbind_success": "已解除 {{provider}} 账号绑定", + "netdisk_unbind_error": "解除 {{provider}} 账号失败", "save_only_current_group": "保存只对当前组有效", "script_import_result": "脚本导入结果", "failure_info": "失败信息", @@ -551,4 +555,4 @@ "maybe_later": "暂不启用", "settings_hint": "你可以随时在设置中修改此选项。" } -} \ No newline at end of file +} diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json index f4b7d5a4d..129d69e0c 100644 --- a/src/locales/zh-TW/translation.json +++ b/src/locales/zh-TW/translation.json @@ -420,6 +420,10 @@ "confirm_leave_page": "目前正在編輯狀態,跳轉其他頁面將會遺失目前內容,是否跳轉?", "page_in_blacklist": "目前頁面在黑名單中,無法使用腳本", "baidu_netdisk": "百度網盤", + "netdisk_unbind": "解除綁定 {{provider}}", + "netdisk_unbind_confirm": "確定解除 {{provider}} 帳號綁定嗎?", + "netdisk_unbind_success": "已解除 {{provider}} 帳號綁定", + "netdisk_unbind_error": "解除 {{provider}} 帳號失敗", "save_only_current_group": "儲存僅對目前群組有效", "script_import_result": "腳本匯入結果", "failure_info": "失敗資訊", @@ -551,4 +555,4 @@ "maybe_later": "暫不啟用", "settings_hint": "你可以隨時在設定中修改此選項。" } -} \ No newline at end of file +} diff --git a/src/pages/components/FileSystemParams/index.tsx b/src/pages/components/FileSystemParams/index.tsx index de1d88e04..c806d08b5 100644 --- a/src/pages/components/FileSystemParams/index.tsx +++ b/src/pages/components/FileSystemParams/index.tsx @@ -1,8 +1,9 @@ import React from "react"; -import { Input, Select, Space } from "@arco-design/web-react"; +import { Button, Input, Message, Popconfirm, Select, Space } from "@arco-design/web-react"; import type { FileSystemType } from "@Packages/filesystem/factory"; import FileSystemFactory from "@Packages/filesystem/factory"; import { useTranslation } from "react-i18next"; +import { ClearNetDiskToken, netDiskTypeMap } from "@Packages/filesystem/auth"; const FileSystemParams: React.FC<{ preNode: React.ReactNode | string; @@ -21,6 +22,7 @@ const FileSystemParams: React.FC<{ }) => { const fsParams = FileSystemFactory.params(); const { t } = useTranslation(); + const actionButtons = [...actionButton]; const fileSystemList: { key: FileSystemType; @@ -48,6 +50,31 @@ const FileSystemParams: React.FC<{ }, ]; + const netDiskType = netDiskTypeMap[fileSystemType]; + + if (netDiskType) { + const netDiskName = fileSystemList.find((item) => item.key === fileSystemType)?.name; + + actionButtons.push( + { + try { + await ClearNetDiskToken(netDiskType); + Message.success(t("netdisk_unbind_success", { provider: netDiskName })!); + } catch (error) { + Message.error(`${t("netdisk_unbind_error", { provider: netDiskName })}: ${String(error)}`); + } + }} + > + + + ); + } + return ( <> @@ -65,7 +92,7 @@ const FileSystemParams: React.FC<{ ))} - {actionButton.map((item) => item)} + {actionButtons.map((item) => item)}