新增CDN全球加速选项

This commit is contained in:
2025-04-20 15:01:40 +08:00
parent f3a3aba1fe
commit 8ff7ab6337
4 changed files with 25 additions and 8 deletions

17
main.ts
View File

@@ -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);
if (this.settings.accelerate) {
resolve(url.replace(this.settings.region, 'accelerate'));
} else {
resolve(url);
}
} catch (error) {
reject(error);
return;
@@ -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();
})
})
}
}

View File

@@ -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",

4
package-lock.json generated
View File

@@ -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"

View File

@@ -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": {