diff --git a/main.ts b/main.ts index a99ae84..1723dd1 100644 --- a/main.ts +++ b/main.ts @@ -9,6 +9,7 @@ interface CosPicbedPluginSettings { bucket: string; region: string; prefix: string; + accelerate: boolean; } const DEFAULT_SETTINGS: CosPicbedPluginSettings = { @@ -17,6 +18,7 @@ const DEFAULT_SETTINGS: CosPicbedPluginSettings = { bucket: "", region: "", prefix: "", + accelerate: false, }; class CosUploader { @@ -76,7 +78,11 @@ class CosUploader { try { const url = await this.getUrl(fullPath); - resolve(url); + if (this.settings.accelerate) { + resolve(url.replace(this.settings.region, 'accelerate')); + } else { + resolve(url); + } } catch (error) { reject(error); return; @@ -180,7 +186,7 @@ class CosPicbedSettingTab extends PluginSettingTab { }) ); - new Setting(containerEl) + new Setting(containerEl) .setName("Region") .addText((text) => text @@ -204,6 +210,17 @@ class CosPicbedSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + + new Setting(containerEl) + .setName("Accelerate") + .addToggle((toggle) => { + toggle + .setValue(this.plugin.settings.accelerate) + .onChange(async (value) => { + this.plugin.settings.accelerate = value; + await this.plugin.saveSettings(); + }) + }) } } @@ -335,7 +352,7 @@ export default class CosPicbedPlugin extends Plugin { ); const newContent = allContent.replace(/!\[.*?\]\((.*?)\)/g, ""); - editor.setValue(newContent); + editor.setValue(newContent); new Notice(`Deleted ${imageNames.length} images!`); }) diff --git a/manifest.json b/manifest.json index 465feca..b5de255 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "id": "obsidian-cos-picbed", "name": "COS Picbed", - "version": "1.0.2", - "minAppVersion": "1.0.2", + "version": "1.0.3", + "minAppVersion": "1.0.3", "description": "This plug-in is used to automatically upload pictures to Tencent Cloud COS, and supports manual deletion of useless pictures to reduce storage space!", "author": "yv1ing", "authorUrl": "https://github.com/yv1ing", diff --git a/package-lock.json b/package-lock.json index b17ef9d..5d72ffa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-cos-picbed", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-cos-picbed", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "dependencies": { "cos-js-sdk-v5": "^1.8.7" diff --git a/package.json b/package.json index b0d5c71..c4e60f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-cos-picbed", - "version": "1.0.2", + "version": "1.0.3", "description": "This plug-in is used to automatically upload pictures to Tencent Cloud COS, and supports manual deletion of useless pictures to reduce storage space!", "main": "main.js", "scripts": {