From e177845e3ba5cce35df170dedf61080970bfcfc7 Mon Sep 17 00:00:00 2001 From: terwer Date: Tue, 10 Dec 2024 21:37:28 +0800 Subject: [PATCH] feat: fix ai bugs --- siyuan/index.ts | 14 +++++++++++--- siyuan/invoke/widgetInvoke.ts | 4 ++-- src/pages/AiChat.vue | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/siyuan/index.ts b/siyuan/index.ts index 3041ff80..0a8cc022 100644 --- a/siyuan/index.ts +++ b/siyuan/index.ts @@ -23,20 +23,20 @@ * questions. */ -import { App, confirm, getFrontend, Model, IObject, Plugin } from "siyuan" +import { App, confirm, getFrontend, IObject, Model, Plugin } from "siyuan" import { SiyuanConfig, SiyuanKernelApi } from "zhi-siyuan-api" import { createSiyuanAppLogger } from "./appLogger" import { WidgetInvoke } from "./invoke/widgetInvoke" import { Topbar } from "./topbar" import { ILogger } from "zhi-lib-base" - -import "./index.styl" import { ConfigManager } from "~/siyuan/store/config.ts" import MenuUtils from "~/siyuan/utils/menuUtils.ts" import { PluginInvoke } from "~/siyuan/invoke/pluginInvoke.ts" import { icons } from "~/siyuan/utils/svg.ts" import { PreferenceConfigManager } from "~/siyuan/store/preferenceConfigManager.ts" +import "./index.styl" + /** * 发布工具插件入口 * @@ -177,5 +177,13 @@ export default class PublisherPlugin extends Plugin { label: this.i18n.publishToQuick, submenu: quickMenus, }) + // AI聊天 + context.push({ + iconHTML: `${icons.iconEye}`, + label: this.i18n.aiChat, + click: async () => { + await this.widgetInvoke.showPublisherAiChatDialog(pageId) + }, + }) } } diff --git a/siyuan/invoke/widgetInvoke.ts b/siyuan/invoke/widgetInvoke.ts index 781b6680..c825bbcf 100644 --- a/siyuan/invoke/widgetInvoke.ts +++ b/siyuan/invoke/widgetInvoke.ts @@ -64,8 +64,8 @@ export class WidgetInvoke { await this.showTab(`/`, this.pluginInstance.i18n.articleManage) } - public async showPublisherAiChatDialog() { - let pageId: string | undefined = WidgetPageUtils.getPageId() + public async showPublisherAiChatDialog(pageId?: string) { + pageId = pageId ?? WidgetPageUtils.getPageId() if (pageId == "") { pageId = undefined } diff --git a/src/pages/AiChat.vue b/src/pages/AiChat.vue index 662a436d..36b22a2e 100644 --- a/src/pages/AiChat.vue +++ b/src/pages/AiChat.vue @@ -176,7 +176,7 @@ const formData = reactive({ chatOutput: "", isLoading: false, showPage: !StrUtil.isEmptyString(id), - usePage: false, + usePage: !StrUtil.isEmptyString(id), siyuanPost: {} as Post, })