Skip to content

Commit

Permalink
feat: add https option to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jianzs committed May 17, 2024
1 parent 9d63bdb commit 53674e2
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "qiniu-image-uploader",
"name": "Qiniu Image Uploader",
"version": "1.1.1",
"version": "1.1.2",
"minAppVersion": "0.15.0",
"description": "Uploads images from your clipboard to qiniu.com and embeds uploaded image to your note.",
"author": "Jade Zheng",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sample-plugin",
"version": "1.1.1",
"version": "1.1.2",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export default {
"South China - Guangdong": "South China - Guangdong",
"North America - Los Angeles": "North America - Los Angeles",
"Asia Pacific - Singapore (formerly Southeast Asia)": "Asia Pacific - Singapore (formerly Southeast Asia)",
"HTTPS": "HTTPS",
"HTTPS Desc": "Whether to use HTTPS protocol",
"YES": "Yes",
"NO": "No",
};
4 changes: 4 additions & 0 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export default {
"South China - Guangdong": "华南-广东",
"North America - Los Angeles": "北美-洛杉矶",
"Asia Pacific - Singapore (formerly Southeast Asia)": "亚太-新加坡(原东南亚)",
"HTTPS": "HTTPS",
"HTTPS Desc": "是否使用HTTPS协议",
"YES": "是",
"NO": "否",
};
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export default class QiniuImageUploader extends Plugin {
const fileName = this.genImageName(uploadFile);
await this.uploader!.uploadFile(fileName, uploadFile);

const imageUrl = `http://${this.settings.domain}/${fileName}`;
const schema = this.settings.https === 'Yes' ? 'https' : 'http';

const imageUrl = `${schema}://${this.settings.domain}/${fileName}`;
const markDownImage = `![](${imageUrl})`
QiniuImageUploader.replaceFirstOccurrence(editor, progressText, markDownImage)
}
Expand Down
21 changes: 21 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface PluginSettings {
accessKey: string;
accessSecretKey: string;
bucketName: string;
https: string;
domain: string;
namePrefix: string;
region: string;
Expand All @@ -16,6 +17,7 @@ export const DEFAULT_SETTINGS: PluginSettings = {
accessKey: "",
accessSecretKey: "",
bucketName: "",
https: "No",
domain: "",
namePrefix: "ob-",
region: "z1",
Expand Down Expand Up @@ -96,6 +98,25 @@ export class SettingTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName(t("HTTPS"))
.setDesc(t("HTTPS Desc"))
.addDropdown(dropDown => dropDown
.addOption("Yes", t("YES"))
.addOption("No", t("NO"))
.setValue(this.plugin.settings.https)
.onChange(async (value) => {
this.plugin.settings.region = value;
await this.plugin.saveSettings();
const fiveSecondsMillis = 5_000;
if (value === "Yes") {
new Notice("修改为 HTTPS", fiveSecondsMillis)
} else {
new Notice("修改为 HTTP", fiveSecondsMillis)
}
})
);

new Setting(containerEl)
.setName(t("Domain"))
.setDesc(t("Domain Desc"))
Expand Down
7 changes: 4 additions & 3 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"1.1.1": "0.15.0",
"1.0.0": "0.15.0",
"1.1.0": "0.15.0",
"1.0.0": "0.15.0"
}
"1.1.1": "0.15.0",
"1.1.2": "0.15.0"
}

0 comments on commit 53674e2

Please sign in to comment.