mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
Refactor password and notice
This commit is contained in:
@@ -4,8 +4,6 @@ import { markdownToBlocks, } from "@tryfabric/martian";
|
|||||||
import * as yamlFrontMatter from "yaml-front-matter";
|
import * as yamlFrontMatter from "yaml-front-matter";
|
||||||
import * as yaml from "yaml"
|
import * as yaml from "yaml"
|
||||||
import MyPlugin from "main";
|
import MyPlugin from "main";
|
||||||
import { join } from "path";
|
|
||||||
|
|
||||||
export class Upload2Notion {
|
export class Upload2Notion {
|
||||||
app: MyPlugin;
|
app: MyPlugin;
|
||||||
notion: Client;
|
notion: Client;
|
||||||
|
|||||||
52
main.ts
52
main.ts
@@ -24,16 +24,16 @@ interface PluginSettings {
|
|||||||
bannerUrl: string;
|
bannerUrl: string;
|
||||||
notionID: string;
|
notionID: string;
|
||||||
proxy: string;
|
proxy: string;
|
||||||
langConfig: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const langConfig = NoticeMConfig( window.localStorage.getItem('language') || 'en')
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: PluginSettings = {
|
const DEFAULT_SETTINGS: PluginSettings = {
|
||||||
notionAPI: "",
|
notionAPI: "",
|
||||||
databaseID: "",
|
databaseID: "",
|
||||||
bannerUrl: "",
|
bannerUrl: "",
|
||||||
notionID: "",
|
notionID: "",
|
||||||
proxy: "",
|
proxy: "",
|
||||||
langConfig: NoticeMConfig( window.localStorage.getItem('language') || 'en')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class ObsidianSyncNotionPlugin extends Plugin {
|
export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||||
@@ -88,9 +88,9 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
const upload = new Upload2Notion(this);
|
const upload = new Upload2Notion(this);
|
||||||
const res = await upload.syncMarkdownToNotion(basename, markDownData,nowFile, this.app, this.settings)
|
const res = await upload.syncMarkdownToNotion(basename, markDownData,nowFile, this.app, this.settings)
|
||||||
if(res.status === 200){
|
if(res.status === 200){
|
||||||
new Notice(`${this.settings.langConfig["sync-success"]}${basename}`)
|
new Notice(`${langConfig["sync-success"]}${basename}`)
|
||||||
}else {
|
}else {
|
||||||
new Notice(`${this.settings.langConfig["sync-fail"]}${basename}`)
|
new Notice(`${langConfig["sync-fail"]}${basename}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
nowFile,
|
nowFile,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
new Notice(this.settings.langConfig["open-file"]);
|
new Notice(langConfig["open-file"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,28 +142,34 @@ class SampleSettingTab extends PluginSettingTab {
|
|||||||
const notionApiKye = new Setting(containerEl)
|
const notionApiKye = new Setting(containerEl)
|
||||||
.setName("Notion API Token")
|
.setName("Notion API Token")
|
||||||
.setDesc("It's a secret")
|
.setDesc("It's a secret")
|
||||||
.addText((text) =>
|
.addText((text) =>{
|
||||||
text
|
let t = text
|
||||||
.setPlaceholder("Enter your Notion API Token")
|
.setPlaceholder("Enter your Notion API Token")
|
||||||
.setValue(this.plugin.settings.notionAPI)
|
.setValue(this.plugin.settings.notionAPI)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.plugin.settings.notionAPI = value;
|
this.plugin.settings.notionAPI = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
);
|
t.inputEl.type = 'password'
|
||||||
notionApiKye.controlEl.querySelector('input').type='password'
|
return t
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
const notionDatabaseID = new Setting(containerEl)
|
const notionDatabaseID = new Setting(containerEl)
|
||||||
.setName("Database ID")
|
.setName("Database ID")
|
||||||
.setDesc("It's a secret")
|
.setDesc("It's a secret")
|
||||||
.addText((text) =>
|
.addText((text) => {
|
||||||
text
|
let t = text
|
||||||
.setPlaceholder("Enter your Database ID")
|
.setPlaceholder("Enter your Database ID")
|
||||||
.setValue(this.plugin.settings.databaseID)
|
.setValue(this.plugin.settings.databaseID)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.plugin.settings.databaseID = value;
|
this.plugin.settings.databaseID = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
|
t.inputEl.type = 'password'
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
notionDatabaseID.controlEl.querySelector('input').type='password'
|
notionDatabaseID.controlEl.querySelector('input').type='password'
|
||||||
|
|||||||
Reference in New Issue
Block a user