Skip to content

Commit 53674e2

Browse files
committed
feat: add https option to settings
1 parent 9d63bdb commit 53674e2

File tree

8 files changed

+40
-8
lines changed

8 files changed

+40
-8
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "qiniu-image-uploader",
33
"name": "Qiniu Image Uploader",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"minAppVersion": "0.15.0",
66
"description": "Uploads images from your clipboard to qiniu.com and embeds uploaded image to your note.",
77
"author": "Jade Zheng",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-sample-plugin",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/lang/locale/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export default {
3131
"South China - Guangdong": "South China - Guangdong",
3232
"North America - Los Angeles": "North America - Los Angeles",
3333
"Asia Pacific - Singapore (formerly Southeast Asia)": "Asia Pacific - Singapore (formerly Southeast Asia)",
34+
"HTTPS": "HTTPS",
35+
"HTTPS Desc": "Whether to use HTTPS protocol",
36+
"YES": "Yes",
37+
"NO": "No",
3438
};

src/lang/locale/zh-cn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export default {
3131
"South China - Guangdong": "华南-广东",
3232
"North America - Los Angeles": "北美-洛杉矶",
3333
"Asia Pacific - Singapore (formerly Southeast Asia)": "亚太-新加坡(原东南亚)",
34+
"HTTPS": "HTTPS",
35+
"HTTPS Desc": "是否使用HTTPS协议",
36+
"YES": "是",
37+
"NO": "否",
3438
};

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export default class QiniuImageUploader extends Plugin {
6969
const fileName = this.genImageName(uploadFile);
7070
await this.uploader!.uploadFile(fileName, uploadFile);
7171

72-
const imageUrl = `http://${this.settings.domain}/${fileName}`;
72+
const schema = this.settings.https === 'Yes' ? 'https' : 'http';
73+
74+
const imageUrl = `${schema}://${this.settings.domain}/${fileName}`;
7375
const markDownImage = `![](${imageUrl})`
7476
QiniuImageUploader.replaceFirstOccurrence(editor, progressText, markDownImage)
7577
}

src/settings.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface PluginSettings {
66
accessKey: string;
77
accessSecretKey: string;
88
bucketName: string;
9+
https: string;
910
domain: string;
1011
namePrefix: string;
1112
region: string;
@@ -16,6 +17,7 @@ export const DEFAULT_SETTINGS: PluginSettings = {
1617
accessKey: "",
1718
accessSecretKey: "",
1819
bucketName: "",
20+
https: "No",
1921
domain: "",
2022
namePrefix: "ob-",
2123
region: "z1",
@@ -96,6 +98,25 @@ export class SettingTab extends PluginSettingTab {
9698
})
9799
);
98100

101+
new Setting(containerEl)
102+
.setName(t("HTTPS"))
103+
.setDesc(t("HTTPS Desc"))
104+
.addDropdown(dropDown => dropDown
105+
.addOption("Yes", t("YES"))
106+
.addOption("No", t("NO"))
107+
.setValue(this.plugin.settings.https)
108+
.onChange(async (value) => {
109+
this.plugin.settings.region = value;
110+
await this.plugin.saveSettings();
111+
const fiveSecondsMillis = 5_000;
112+
if (value === "Yes") {
113+
new Notice("修改为 HTTPS", fiveSecondsMillis)
114+
} else {
115+
new Notice("修改为 HTTP", fiveSecondsMillis)
116+
}
117+
})
118+
);
119+
99120
new Setting(containerEl)
100121
.setName(t("Domain"))
101122
.setDesc(t("Domain Desc"))

versions.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"1.1.1": "0.15.0",
2+
"1.0.0": "0.15.0",
33
"1.1.0": "0.15.0",
4-
"1.0.0": "0.15.0"
5-
}
4+
"1.1.1": "0.15.0",
5+
"1.1.2": "0.15.0"
6+
}

0 commit comments

Comments
 (0)