From 22b82a129af7118a6be878ba6f66f87b2528d856 Mon Sep 17 00:00:00 2001 From: Dian Date: Fri, 31 Jan 2025 21:26:08 +0800 Subject: [PATCH] fix logo add open ai setting --- main.ts | 94 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/main.ts b/main.ts index 47d25bf..79138fe 100644 --- a/main.ts +++ b/main.ts @@ -29,12 +29,11 @@ export default class NemesisPlugin extends Plugin { await this.loadSettings(); console.log("loading plugin"); - console.log("My openai key: " + this.settings.openAiKey); // This creates an icon in the left ribbon. addIcon( "logo", - '' + '' ); const ribbonIconEl = this.addRibbonIcon( "logo", @@ -42,52 +41,57 @@ export default class NemesisPlugin extends Plugin { (evt: MouseEvent) => { // Called when the user clicks the icon. new Notice("This is a notice!"); + console.log("click"); + // console.log(`My openai key: ${this.settings.openAiKey}`); } ); - // Perform additional things with the ribbon - ribbonIconEl.addClass("my-plugin-ribbon-class"); + // todo create and open new view to display the open ai nemesis result + + // use this class to perform additional things with the ribbon + // ribbonIconEl.addClass("my-plugin-ribbon-class"); // This adds a status bar item to the bottom of the app. Does not work on mobile apps. - const statusBarItemEl = this.addStatusBarItem(); - statusBarItemEl.setText("Status Bar Text"); + // const statusBarItemEl = this.addStatusBarItem(); + // statusBarItemEl.setText("asdfasdfasdfasdfs"); // This adds a simple command that can be triggered anywhere - this.addCommand({ - id: "open-sample-modal-simple", - name: "Open sample modal (simple)", - callback: () => { - new SampleModal(this.app).open(); - }, - }); + // this.addCommand({ + // id: "open-sample-modal-simple", + // name: "Open sample modal (simple)", + // callback: () => { + // new SampleModal(this.app).open(); + // }, + // }); // This adds an editor command that can perform some operation on the current editor instance - this.addCommand({ - id: "sample-editor-command", - name: "Sample editor command", - editorCallback: (editor: Editor, view: MarkdownView) => { - console.log(editor.getSelection()); - editor.replaceSelection("Sample Editor Command"); - }, - }); + // get the current text selection in editor and replace it with "Sample Editor Command" + // this.addCommand({ + // id: "sample-editor-command", + // name: "Sample editor command", + // editorCallback: (editor: Editor, view: MarkdownView) => { + // console.log(editor.getSelection()); + // editor.replaceSelection("Sample Editor Command"); + // }, + // }); // This adds a complex command that can check whether the current state of the app allows execution of the command - this.addCommand({ - id: "open-sample-modal-complex", - name: "Open sample modal (complex)", - checkCallback: (checking: boolean) => { - // Conditions to check - const markdownView = - this.app.workspace.getActiveViewOfType(MarkdownView); - if (markdownView) { - // If checking is true, we're simply "checking" if the command can be run. - // If checking is false, then we want to actually perform the operation. - if (!checking) { - new SampleModal(this.app).open(); - } + // this.addCommand({ + // id: "open-sample-modal-complex", + // name: "Open sample modal (complex)", + // checkCallback: (checking: boolean) => { + // // Conditions to check + // const markdownView = + // this.app.workspace.getActiveViewOfType(MarkdownView); + // if (markdownView) { + // // If checking is true, we're simply "checking" if the command can be run. + // // If checking is false, then we want to actually perform the operation. + // if (!checking) { + // new SampleModal(this.app).open(); + // } - // This command will only show up in Command Palette when the check function returns true - return true; - } - }, - }); + // // This command will only show up in Command Palette when the check function returns true + // return true; + // } + // }, + // }); // This adds a settings tab so the user can configure various aspects of the plugin this.addSettingTab(new SampleSettingTab(this.app, this)); @@ -160,5 +164,17 @@ class SampleSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + new Setting(containerEl) + .setName("OpenAI API Key") + .setDesc("Set your OpenAI API key here.") + .addText((text) => + text + .setPlaceholder("Enter OpenAI API key here") + .setValue(this.plugin.settings.mySetting) + .onChange(async (value) => { + this.plugin.settings.openAiKey = value; + await this.plugin.saveSettings(); + }) + ); } }