Skip to content

Commit 7ad9aac

Browse files
RenjiYuuseigoogle-labs-jules[bot]CodFrm
authored
✨ 网盘解除绑定 (#1151)
* Treat zero menu limit as unlimited in popup * Update layout to be responsive for mobile devices - Refactored sidebar menu into `SiderMenu` component - Updated `Sider` to use a Drawer on mobile (<768px) - Added hamburger button for mobile navigation - Adjusted content padding and layout for mobile view * Update layout to be responsive for mobile devices - Refactored sidebar menu into `SiderMenu` component - Updated `Sider` to use a Drawer on mobile (<768px) - Added hamburger button for mobile navigation - Adjusted content padding and layout for mobile view - Fixed linting errors * Revert "Mobile Responsive UI for Options Page" * Clarify netdisk unbind labels * Revert "Treat zero menu limit as unlimited in popup" * Clean code --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: 王一之 <yz@ggnb.top>
1 parent 0892fcd commit 7ad9aac

File tree

10 files changed

+89
-11
lines changed

10 files changed

+89
-11
lines changed

packages/filesystem/auth.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { ExtServer, ExtServerApi } from "@App/app/const";
22
import { WarpTokenError } from "./error";
33
import { LocalStorageDAO } from "@App/app/repo/localStorage";
44
import { sleep } from "@App/pkg/utils/utils";
5+
import type { FileSystemType } from "./factory";
56

6-
type NetDiskType = "baidu" | "onedrive" | "googledrive" | "dropbox";
7+
export type NetDiskType = "baidu" | "onedrive" | "googledrive" | "dropbox";
78

89
export function GetNetDiskToken(netDiskType: NetDiskType): Promise<{
910
code: number;
@@ -127,3 +128,21 @@ export async function AuthVerify(netDiskType: NetDiskType, invalid?: boolean) {
127128
}
128129
return token.accessToken;
129130
}
131+
132+
export const netDiskTypeMap: Partial<Record<FileSystemType, NetDiskType>> = {
133+
"baidu-netdsik": "baidu",
134+
onedrive: "onedrive",
135+
googledrive: "googledrive",
136+
dropbox: "dropbox",
137+
};
138+
139+
export async function ClearNetDiskToken(netDiskType: NetDiskType) {
140+
const localStorageDAO = new LocalStorageDAO();
141+
const key = `netdisk:token:${netDiskType}`;
142+
try {
143+
await localStorageDAO.delete(key);
144+
} catch (error) {
145+
// ignore
146+
console.error("ClearNetDiskToken error:", error);
147+
}
148+
}

src/locales/ach-UG/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@
418418
"confirm_leave_page": "crwdns8634:0crwdne8634:0",
419419
"page_in_blacklist": "crwdns8636:0crwdne8636:0",
420420
"baidu_netdisk": "crwdns8638:0crwdne8638:0",
421+
"netdisk_unbind": "Unbind {{provider}}",
422+
"netdisk_unbind_confirm": "Unbind the {{provider}} account?",
423+
"netdisk_unbind_success": "{{provider}} account unbound",
424+
"netdisk_unbind_error": "Failed to unbind {{provider}} account",
421425
"save_only_current_group": "crwdns8640:0crwdne8640:0",
422426
"script_import_result": "crwdns8642:0crwdne8642:0",
423427
"failure_info": "crwdns8644:0crwdne8644:0",
@@ -537,4 +541,4 @@
537541
"subscribe_update_desc": "crwdns12856:0{{newScripts}}crwdnd12856:0{{deletedScripts}}crwdne12856:0"
538542
},
539543
"loading": "crwdns12870:0crwdne12870:0"
540-
}
544+
}

src/locales/de-DE/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "Derzeit im Bearbeitungsstatus. Das Navigieren zu anderen Seiten führt zum Verlust des aktuellen Inhalts. Navigieren?",
421421
"page_in_blacklist": "Die aktuelle Seite ist auf der Blacklist und kann keine Skripte verwenden",
422422
"baidu_netdisk": "Baidu Netdisk",
423+
"netdisk_unbind": "{{provider}} trennen",
424+
"netdisk_unbind_confirm": "Das {{provider}}-Konto trennen?",
425+
"netdisk_unbind_success": "{{provider}}-Konto getrennt",
426+
"netdisk_unbind_error": "{{provider}}-Konto konnte nicht getrennt werden",
423427
"save_only_current_group": "Speichern ist nur für die aktuelle Gruppe wirksam",
424428
"script_import_result": "Skript-Import-Ergebnis",
425429
"failure_info": "Fehlerinformationen",
@@ -551,4 +555,4 @@
551555
"maybe_later": "Vielleicht später",
552556
"settings_hint": "Sie können diese Option jederzeit in den Einstellungen ändern."
553557
}
554-
}
558+
}

src/locales/en-US/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "Currently editing status. Leaving this page will lose the current content. Do you want to leave?",
421421
"page_in_blacklist": "The current page is blacklisted, cannot use script",
422422
"baidu_netdisk": "BaiduNetdisk",
423+
"netdisk_unbind": "Unbind {{provider}}",
424+
"netdisk_unbind_confirm": "Unbind the {{provider}} account?",
425+
"netdisk_unbind_success": "{{provider}} account unbound",
426+
"netdisk_unbind_error": "Failed to unbind {{provider}} account",
423427
"save_only_current_group": "Save only for current group",
424428
"script_import_result": "Script Import Results",
425429
"failure_info": "Failure Information",
@@ -551,4 +555,4 @@
551555
"maybe_later": "Maybe Later",
552556
"settings_hint": "You can change this option in settings at any time."
553557
}
554-
}
558+
}

src/locales/ja-JP/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "現在編集中です。他のページに移動すると現在の内容が失われます。移動しますか?",
421421
"page_in_blacklist": "現在のページはブラックリストにあり、スクリプトを使用できません",
422422
"baidu_netdisk": "百度ネットディスク",
423+
"netdisk_unbind": "{{provider}} の連携を解除",
424+
"netdisk_unbind_confirm": "{{provider}} のアカウント連携を解除しますか?",
425+
"netdisk_unbind_success": "{{provider}} のアカウント連携を解除しました",
426+
"netdisk_unbind_error": "{{provider}} のアカウント解除に失敗しました",
423427
"save_only_current_group": "保存は現在のグループにのみ有効です",
424428
"script_import_result": "スクリプトインポート結果",
425429
"failure_info": "失敗情報",
@@ -551,4 +555,4 @@
551555
"maybe_later": "後で",
552556
"settings_hint": "設定ページでいつでも変更できます。"
553557
}
554-
}
558+
}

src/locales/ru-RU/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "В настоящее время идет редактирование. Переход на другую страницу приведет к потере текущего содержимого. Продолжить переход?",
421421
"page_in_blacklist": "Текущая страница находится в черном списке, невозможно использовать скрипты",
422422
"baidu_netdisk": "Baidu Netdisk",
423+
"netdisk_unbind": "Отвязать {{provider}}",
424+
"netdisk_unbind_confirm": "Отвязать аккаунт {{provider}}?",
425+
"netdisk_unbind_success": "Аккаунт {{provider}} отвязан",
426+
"netdisk_unbind_error": "Не удалось отвязать аккаунт {{provider}}",
423427
"save_only_current_group": "Сохранение действует только для текущей группы",
424428
"script_import_result": "Результат импорта скрипта",
425429
"failure_info": "Информация об ошибке",
@@ -551,4 +555,4 @@
551555
"maybe_later": "Может быть позже",
552556
"settings_hint": "Вы можете изменить эту опцию в настройках в любое время."
553557
}
554-
}
558+
}

src/locales/vi-VN/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"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?",
421421
"page_in_blacklist": "Trang hiện tại nằm trong danh sách đen, không thể sử dụng script",
422422
"baidu_netdisk": "Baidunetdisk",
423+
"netdisk_unbind": "Hủy liên kết {{provider}}",
424+
"netdisk_unbind_confirm": "Hủy liên kết tài khoản {{provider}}?",
425+
"netdisk_unbind_success": "Đã hủy liên kết tài khoản {{provider}}",
426+
"netdisk_unbind_error": "Không thể hủy liên kết tài khoản {{provider}}",
423427
"save_only_current_group": "Chỉ lưu cho nhóm hiện tại",
424428
"script_import_result": "Kết quả nhập script",
425429
"failure_info": "Thông tin thất bại",
@@ -551,4 +555,4 @@
551555
"maybe_later": "Để sau",
552556
"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."
553557
}
554-
}
558+
}

src/locales/zh-CN/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "当前正在编辑状态,跳转其它页面将会丢失当前内容,是否跳转?",
421421
"page_in_blacklist": "当前页面在黑名单中,无法使用脚本",
422422
"baidu_netdisk": "百度网盘",
423+
"netdisk_unbind": "解除绑定 {{provider}}",
424+
"netdisk_unbind_confirm": "确定解除 {{provider}} 账号绑定吗?",
425+
"netdisk_unbind_success": "已解除 {{provider}} 账号绑定",
426+
"netdisk_unbind_error": "解除 {{provider}} 账号失败",
423427
"save_only_current_group": "保存只对当前组有效",
424428
"script_import_result": "脚本导入结果",
425429
"failure_info": "失败信息",
@@ -551,4 +555,4 @@
551555
"maybe_later": "暂不启用",
552556
"settings_hint": "你可以随时在设置中修改此选项。"
553557
}
554-
}
558+
}

src/locales/zh-TW/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@
420420
"confirm_leave_page": "目前正在編輯狀態,跳轉其他頁面將會遺失目前內容,是否跳轉?",
421421
"page_in_blacklist": "目前頁面在黑名單中,無法使用腳本",
422422
"baidu_netdisk": "百度網盤",
423+
"netdisk_unbind": "解除綁定 {{provider}}",
424+
"netdisk_unbind_confirm": "確定解除 {{provider}} 帳號綁定嗎?",
425+
"netdisk_unbind_success": "已解除 {{provider}} 帳號綁定",
426+
"netdisk_unbind_error": "解除 {{provider}} 帳號失敗",
423427
"save_only_current_group": "儲存僅對目前群組有效",
424428
"script_import_result": "腳本匯入結果",
425429
"failure_info": "失敗資訊",
@@ -551,4 +555,4 @@
551555
"maybe_later": "暫不啟用",
552556
"settings_hint": "你可以隨時在設定中修改此選項。"
553557
}
554-
}
558+
}

src/pages/components/FileSystemParams/index.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from "react";
2-
import { Input, Select, Space } from "@arco-design/web-react";
2+
import { Button, Input, Message, Popconfirm, Select, Space } from "@arco-design/web-react";
33
import type { FileSystemType } from "@Packages/filesystem/factory";
44
import FileSystemFactory from "@Packages/filesystem/factory";
55
import { useTranslation } from "react-i18next";
6+
import { ClearNetDiskToken, netDiskTypeMap } from "@Packages/filesystem/auth";
67

78
const FileSystemParams: React.FC<{
89
preNode: React.ReactNode | string;
@@ -21,6 +22,7 @@ const FileSystemParams: React.FC<{
2122
}) => {
2223
const fsParams = FileSystemFactory.params();
2324
const { t } = useTranslation();
25+
const actionButtons = [...actionButton];
2426

2527
const fileSystemList: {
2628
key: FileSystemType;
@@ -48,6 +50,31 @@ const FileSystemParams: React.FC<{
4850
},
4951
];
5052

53+
const netDiskType = netDiskTypeMap[fileSystemType];
54+
55+
if (netDiskType) {
56+
const netDiskName = fileSystemList.find((item) => item.key === fileSystemType)?.name;
57+
58+
actionButtons.push(
59+
<Popconfirm
60+
key="netdisk-unbind"
61+
title={t("netdisk_unbind_confirm", { provider: netDiskName })}
62+
onOk={async () => {
63+
try {
64+
await ClearNetDiskToken(netDiskType);
65+
Message.success(t("netdisk_unbind_success", { provider: netDiskName })!);
66+
} catch (error) {
67+
Message.error(`${t("netdisk_unbind_error", { provider: netDiskName })}: ${String(error)}`);
68+
}
69+
}}
70+
>
71+
<Button type="primary" status="danger">
72+
{t("netdisk_unbind", { provider: netDiskName })}
73+
</Button>
74+
</Popconfirm>
75+
);
76+
}
77+
5178
return (
5279
<>
5380
<Space>
@@ -65,7 +92,7 @@ const FileSystemParams: React.FC<{
6592
</Select.Option>
6693
))}
6794
</Select>
68-
{actionButton.map((item) => item)}
95+
{actionButtons.map((item) => item)}
6996
</Space>
7097
<Space
7198
style={{

0 commit comments

Comments
 (0)