From 7497b5fae7ac001e95942f1616484ac901b8a55e Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sat, 25 May 2024 15:22:19 +0800 Subject: [PATCH] split export --- src/baseTypes.ts | 8 +++++++- src/importExport.ts | 11 ++++++++++- src/langs/en.json | 5 ++++- src/langs/zh_cn.json | 5 ++++- src/langs/zh_tw.json | 5 ++++- src/settings.ts | 22 ++++++++++++++++++++-- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/baseTypes.ts b/src/baseTypes.ts index feb1d1a..03d8487 100644 --- a/src/baseTypes.ts +++ b/src/baseTypes.ts @@ -106,7 +106,13 @@ export type SyncDirectionType = export type CipherMethodType = "rclone-base64" | "openssl-base64" | "unknown"; -export type QRExportType = "all_but_oauth2" | "dropbox" | "onedrive"; +export type QRExportType = + | "basic_and_advanced" + | "s3" + | "dropbox" + | "onedrive" + | "webdav" + | "webdis"; export interface ProfilerConfig { enablePrinting?: boolean; diff --git a/src/importExport.ts b/src/importExport.ts index a3a9a4f..6401ab8 100644 --- a/src/importExport.ts +++ b/src/importExport.ts @@ -17,14 +17,23 @@ export const exportQrCodeUri = async ( ) => { let settings2: Partial = {}; - if (exportFields === "all_but_oauth2") { + if (exportFields === "basic_and_advanced") { settings2 = cloneDeep(settings); + delete settings2.s3; delete settings2.dropbox; delete settings2.onedrive; + delete settings2.webdav; + delete settings2.webdis; + } else if (exportFields === "s3") { + settings2 = { s3: cloneDeep(settings.s3) }; } else if (exportFields === "dropbox") { settings2 = { dropbox: cloneDeep(settings.dropbox) }; } else if (exportFields === "onedrive") { settings2 = { onedrive: getShrinkedSettings(settings.onedrive) }; + } else if (exportFields === "webdav") { + settings2 = { webdav: cloneDeep(settings.webdav) }; + } else if (exportFields === "webdis") { + settings2 = { webdis: cloneDeep(settings.webdis) }; } delete settings2.vaultRandomID; diff --git a/src/langs/en.json b/src/langs/en.json index 3cbd239..bdf0274 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -302,9 +302,12 @@ "settings_importexport": "Import and Export Partial Settings", "settings_export": "Export", "settings_export_desc": "Export settings by generating a QR code or URI.", - "settings_export_all_but_oauth2_button": "Export Non-Oauth2 Part", + "settings_export_basic_and_advanced_button": "Export Basic And Advanced Part", + "settings_export_s3_button": "Export S3 Part", "settings_export_dropbox_button": "Export Dropbox Part", "settings_export_onedrive_button": "Export OneDrive Part", + "settings_export_webdav_button": "Export Webdav Part", + "settings_export_webdis_button": "Export Webdis Part", "settings_import": "Import", "settings_import_desc": "Paste the exported URI into here and click \"Import\". Or, you can open a camera or scan-qrcode app to scan the QR code.", "settings_import_button": "Import", diff --git a/src/langs/zh_cn.json b/src/langs/zh_cn.json index 56084ef..0026b97 100644 --- a/src/langs/zh_cn.json +++ b/src/langs/zh_cn.json @@ -301,9 +301,12 @@ "settings_importexport": "导入导出部分设置", "settings_export": "导出", "settings_export_desc": "用 QR 码或 URI 导出设置信息。", - "settings_export_all_but_oauth2_button": "导出非 Oauth2 部分", + "settings_export_basic_and_advanced_button": "导出基本或进阶设置", + "settings_export_s3_button": "导出 S3 部分", "settings_export_dropbox_button": "导出 Dropbox 部分", "settings_export_onedrive_button": "导出 OneDrive 部分", + "settings_export_webdav_button": "导出 Webdav 部分", + "settings_export_webdis_button": "导出 Webdis 部分", "settings_import": "导入", "settings_import_desc": "粘贴之前导出的 URI 到这里然后点击“导入”。或,使用拍摄 app 或者扫描 QR 码的 app,来扫描对应的 QR 码。", "settings_import_button": "导入", diff --git a/src/langs/zh_tw.json b/src/langs/zh_tw.json index e2e0d25..72120b0 100644 --- a/src/langs/zh_tw.json +++ b/src/langs/zh_tw.json @@ -300,9 +300,12 @@ "settings_importexport": "匯入匯出部分設定", "settings_export": "匯出", "settings_export_desc": "用 QR 碼或 URI 匯出設定資訊。", - "settings_export_all_but_oauth2_button": "匯出非 Oauth2 部分", + "settings_export_basic_and_advanced_button": "匯出基本或進階設定", + "settings_export_s3_button": "匯出 S3 部分", "settings_export_dropbox_button": "匯出 Dropbox 部分", "settings_export_onedrive_button": "匯出 OneDrive 部分", + "settings_export_webdav_button": "匯出 Webdav 部分", + "settings_export_webdis_button": "匯出 Webdis 部分", "settings_import": "匯入", "settings_import_desc": "貼上之前匯出的 URI 到這裡然後點選“匯入”。或,使用拍攝 app 或者掃描 QR 碼的 app,來掃描對應的 QR 碼。", "settings_import_button": "匯入", diff --git a/src/settings.ts b/src/settings.ts index 116c556..e8dd381 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -2317,15 +2317,21 @@ export class RemotelySaveSettingTab extends PluginSettingTab { importExportDivSetting1.settingEl.addClass("setting-need-wrapping"); importExportDivSetting1 .addButton(async (button) => { - button.setButtonText(t("settings_export_all_but_oauth2_button")); + button.setButtonText(t("settings_export_basic_and_advanced_button")); button.onClick(async () => { new ExportSettingsQrCodeModal( this.app, this.plugin, - "all_but_oauth2" + "basic_and_advanced" ).open(); }); }) + .addButton(async (button) => { + button.setButtonText(t("settings_export_s3_button")); + button.onClick(async () => { + new ExportSettingsQrCodeModal(this.app, this.plugin, "s3").open(); + }); + }) .addButton(async (button) => { button.setButtonText(t("settings_export_dropbox_button")); button.onClick(async () => { @@ -2345,6 +2351,18 @@ export class RemotelySaveSettingTab extends PluginSettingTab { "onedrive" ).open(); }); + }) + .addButton(async (button) => { + button.setButtonText(t("settings_export_webdav_button")); + button.onClick(async () => { + new ExportSettingsQrCodeModal(this.app, this.plugin, "webdav").open(); + }); + }) + .addButton(async (button) => { + button.setButtonText(t("settings_export_webdis_button")); + button.onClick(async () => { + new ExportSettingsQrCodeModal(this.app, this.plugin, "webdis").open(); + }); }); let importSettingVal = "";