From 942e54961ee474d366a9b1637b5f7d68a638f4f3 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sat, 13 Jan 2024 19:37:58 +0800 Subject: [PATCH] unset region per user request --- src/langs/en.json | 2 +- src/langs/zh_cn.json | 2 +- src/langs/zh_tw.json | 2 +- src/remoteForS3.ts | 4 ++-- src/settings.ts | 11 +++++------ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/langs/en.json b/src/langs/en.json index 859017f..1889d07 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -163,7 +163,7 @@ "settings_s3_prod3": "Configuring CORS", "settings_s3_endpoint": "Endpoint", "settings_s3_region": "Region", - "settings_s3_region_desc": "If you are not sure what to enter, you could try the value: us-east-1", + "settings_s3_region_desc": "If you are not sure what to enter, you could try the value: us-east-1 . If you leave it empty, the client will try to ignore this setting.", "settings_s3_accesskeyid": "Access Key ID", "settings_s3_accesskeyid_desc": "Access key ID. Attention: Access key ID and other info are saved locally.", "settings_s3_secretaccesskey": "Secret Access Key", diff --git a/src/langs/zh_cn.json b/src/langs/zh_cn.json index d3635d6..d6d9926 100644 --- a/src/langs/zh_cn.json +++ b/src/langs/zh_cn.json @@ -163,7 +163,7 @@ "settings_s3_prod3": "设置 CORS", "settings_s3_endpoint": "服务地址(Endpoint)", "settings_s3_region": "区域(Region)", - "settings_s3_region_desc": "如果您不知道这个值填什么,可以尝试填写此默认值:us-east-1", + "settings_s3_region_desc": "如果您不知道这个值填什么,可以尝试填写:us-east-1。如果您不填写,客户端会尝试不设置此选项。", "settings_s3_accesskeyid": "Access Key ID", "settings_s3_accesskeyid_desc": "Access key ID。注意:access key ID 和其它信息都会在本地保存。", "settings_s3_secretaccesskey": "Secret Access Key", diff --git a/src/langs/zh_tw.json b/src/langs/zh_tw.json index 1d1a4ef..1deba0a 100644 --- a/src/langs/zh_tw.json +++ b/src/langs/zh_tw.json @@ -163,7 +163,7 @@ "settings_s3_prod3": "設定 CORS", "settings_s3_endpoint": "服務地址(Endpoint)", "settings_s3_region": "區域(Region)", - "settings_s3_region_desc": "如果您不知道這個值填什麼,可以嘗試填寫此預設值:us-east-1", + "settings_s3_region_desc": "如果您不知道這個值填什麼,可以嘗試填寫:us-east-1。如果您不填寫,客戶端會嘗試不設定此選項。", "settings_s3_accesskeyid": "Access Key ID", "settings_s3_accesskeyid_desc": "Access key ID。注意:access key ID 和其它資訊都會在本地儲存。", "settings_s3_secretaccesskey": "Secret Access Key", diff --git a/src/remoteForS3.ts b/src/remoteForS3.ts index 5803d50..7da5fdc 100644 --- a/src/remoteForS3.ts +++ b/src/remoteForS3.ts @@ -277,7 +277,7 @@ export const getS3Client = (s3Config: S3Config) => { if (VALID_REQURL && s3Config.bypassCorsLocally) { s3Client = new S3Client({ - region: s3Config.s3Region, + region: s3Config.s3Region !== "" ? s3Config.s3Region : undefined, endpoint: endpoint, forcePathStyle: s3Config.forcePathStyle, credentials: { @@ -288,7 +288,7 @@ export const getS3Client = (s3Config: S3Config) => { }); } else { s3Client = new S3Client({ - region: s3Config.s3Region, + region: s3Config.s3Region !== "" ? s3Config.s3Region : undefined, endpoint: endpoint, forcePathStyle: s3Config.forcePathStyle, credentials: { diff --git a/src/settings.ts b/src/settings.ts index aa94712..1213501 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1015,13 +1015,13 @@ export class RemotelySaveSettingTab extends PluginSettingTab { .setDesc(t("settings_s3_accuratemtime_desc")) .addDropdown((dropdown) => { dropdown - .addOption("disable", t("disable")) - .addOption("enable", t("enable")); + .addOption("disable", t("disable")) + .addOption("enable", t("enable")); dropdown - .setValue(`${ - this.plugin.settings.s3.useAccurateMTime ? "enable" : "disable" - }`) + .setValue( + `${this.plugin.settings.s3.useAccurateMTime ? "enable" : "disable"}` + ) .onChange(async (val) => { if (val === "enable") { this.plugin.settings.s3.useAccurateMTime = true; @@ -1032,7 +1032,6 @@ export class RemotelySaveSettingTab extends PluginSettingTab { }); }); - let newS3RemotePrefix = this.plugin.settings.s3.remotePrefix || ""; new Setting(s3Div) .setName(t("settings_remoteprefix"))