Skip to content

Commit

Permalink
feat: 在导入或导出前弹出确认提示框 (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Nov 11, 2024
1 parent 99995ec commit 36bb89c
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 10 deletions.
13 changes: 11 additions & 2 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,20 @@
"title": "Import / Export",
"button": {
"import": "Import",
"export": "Export"
"export": "Export",
"cancel": "Cancel",
"confirm_import": "OK",
"confirm_export": "Export"
},
"label": {
"confirm_import": "Import Notes",
"confirm_export": "Export Notes"
},
"hints": {
"import_success": "Import Successful",
"export_success": "Export Successful"
"export_success": "Export Successful",
"confirm_import": "Imported clipboard data will overwrite existing data, sure you want to proceed?",
"confirm_export": "The exported data contains all preferences and clipboard contents and is saved in plaintext, so please keep it safe."
}
}
},
Expand Down
13 changes: 11 additions & 2 deletions src/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,20 @@
"title": "インポートとエクスポート",
"button": {
"import": "データをインポート",
"export": "データをエクスポート"
"export": "データをエクスポート",
"cancel": "キャンセル",
"confirm_import": "定義する",
"confirm_export": "導く"
},
"label": {
"confirm_import": "インポートノート",
"confirm_export": "メモのエクスポート"
},
"hints": {
"import_success": "インポート成功",
"export_success": "エクスポート成功"
"export_success": "エクスポート成功",
"confirm_import": "インポートされたクリップボードのデータは既存のデータを上書きします。",
"confirm_export": "エクスポートされたデータには、すべての環境設定とクリップボードの内容が含まれ、平文で保存されますので、安全に保管してください。"
}
}
},
Expand Down
13 changes: 11 additions & 2 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,20 @@
"title": "导入和导出",
"button": {
"import": "导入数据",
"export": "导出数据"
"export": "导出数据",
"cancel": "取消",
"confirm_import": "确定",
"confirm_export": "导出"
},
"label": {
"confirm_import": "导入须知",
"confirm_export": "导出须知"
},
"hints": {
"import_success": "导入成功",
"export_success": "导出成功"
"export_success": "导出成功",
"confirm_import": "导入的剪贴板数据将覆盖现有数据,确定要继续吗?",
"confirm_export": "导出的数据包含所有偏好设置和剪贴板内容,且均以明文形式保存,请妥善保管。"
}
}
},
Expand Down
15 changes: 12 additions & 3 deletions src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,23 @@
}
},
"import_export": {
"title": "導入和導出",
"title": "導入和匯出",
"button": {
"import": "導入數據",
"export": "導出數據"
"export": "匯出數據",
"cancel": "取消",
"confirm_import": "確定",
"confirm_export": "匯出"
},
"label": {
"confirm_import": "導入須知",
"confirm_export": "匯出須知"
},
"hints": {
"import_success": "導入成功",
"export_success": "匯出成功"
"export_success": "匯出成功",
"confirm_import": "導入的剪貼板數據將覆蓋現有數據,確定要繼續嗎?",
"confirm_export": "匯出的數據包含所有偏好設定和剪貼板內容,且均以明文形式保存,請妥善保管。"
}
}
},
Expand Down
30 changes: 29 additions & 1 deletion src/pages/Backup/components/Manual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Icon from "@/components/Icon";
import ProList from "@/components/ProList";
import { emit } from "@tauri-apps/api/event";
import { downloadDir } from "@tauri-apps/api/path";
import { open } from "@tauri-apps/plugin-dialog";
import { confirm, open } from "@tauri-apps/plugin-dialog";
import { Flex, List, message } from "antd";
import type { FC } from "react";
import type { State } from "../..";
Expand All @@ -19,6 +19,20 @@ const Manual: FC<{ state: State }> = (props) => {
// 导入数据
const handleImport = async () => {
try {
const confirmed = await confirm(
t("preference.data_backup.import_export.hints.confirm_import"),
{
kind: "warning",
title: t("preference.data_backup.import_export.label.confirm_import"),
okLabel: t(
"preference.data_backup.import_export.button.confirm_import",
),
cancelLabel: t("preference.data_backup.import_export.button.cancel"),
},
);

if (!confirmed) return;

const path = await open({
filters: [{ name: "", extensions: [extname()] }],
});
Expand Down Expand Up @@ -52,6 +66,20 @@ const Manual: FC<{ state: State }> = (props) => {
// 导出数据
const handleExport = async () => {
try {
const confirmed = await confirm(
t("preference.data_backup.import_export.hints.confirm_export"),
{
kind: "warning",
title: t("preference.data_backup.import_export.hints.export_success"),
okLabel: t(
"preference.data_backup.import_export.button.confirm_export",
),
cancelLabel: t("preference.data_backup.import_export.button.cancel"),
},
);

if (!confirmed) return;

state.spinning = true;

await saveStore(true);
Expand Down

0 comments on commit 36bb89c

Please sign in to comment.