From c701ce600f90c392fe9f07131e5a438374dabb6a Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 23 Aug 2023 16:46:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 ++--- README_zh_CN.md | 26 +--- siyuan/i18n/en_US.json | 4 +- siyuan/i18n/zh_CN.json | 4 +- siyuan/index.ts | 26 +++- siyuan/invoke/widgetInvoke.ts | 47 +++++- siyuan/topbar.ts | 20 +++ src/components/publish/BatchPublishIndex.vue | 26 +++- .../publish/SinglePublishDoPublish.vue | 16 +- .../publish/form/PublishDescription.vue | 2 +- src/components/set/GeneralSetting.vue | 3 + src/components/set/preference/AiSetting.vue | 77 ++++++++++ .../set/preference/PreferenceSetting.vue | 22 --- src/components/test/ChatgptTest.vue | 4 +- src/composables/useChatGPT.ts | 23 ++- src/composables/useVueRouter.ts | 7 + src/locales/en_US.ts | 26 +++- src/locales/zh_CN.ts | 4 +- src/models/publishPreferenceCfg.ts | 16 ++ src/pages/AiChat.vue | 144 ++++++++++++++++++ src/pages/Test.vue | 18 ++- 21 files changed, 447 insertions(+), 106 deletions(-) create mode 100644 src/components/set/preference/AiSetting.vue create mode 100644 src/pages/AiChat.vue diff --git a/README.md b/README.md index 4bde9fa9..ad7f58f5 100644 --- a/README.md +++ b/README.md @@ -8,32 +8,18 @@ Publish articles from siyuan-note to platforms such as Yuque, Notion, Cnblogs, W Support features such as fast publishing, image bed management, platform expansion, smart labels, etc. -> **Front Announcement 1: The first version `1.9.0` for Publish Tools that supports release view and AI beta early adopter is released!** -> -> **Front Announcement 2: Version `1.8.0` released with full support for image upload in the Publish Tools!** - -Tips: Zhihu uses the image upload of the Zhihu platform, Yuque, Notion, and Hexo need Picgo plugin support, and the Metaweblog series platform supports both Picgo plugin and self-contained image upload (install Picgo plugin to use Picgo plugin, otherwise use their own platform) - -We recommend that you use the `uninstall->install` method to update. If the configuration is abnormal, please backup `[workspace]/data/storage/syp/sy-p-plus-cfg.json` , and then delete it, this configuration file will be automatically initialized the first time it is used. - -In later releases, the release configuration will only be backward compatible to `1.6.0+`. - -## Recent critical updates and bug fixes - -- Support multiple publishing views, simple mode, detailed mode and source mode -- Support to modify summary, tags, classification, knowledge space -- The Hexo platform supports custom modification of YAML -- Yuque, Notion, and Hexo support image links, and automatic upload requires Picgo plugin support -- Zhihu platform supports automatic image upload -- When the Picgo plugin is not installed, some platforms can use the built-in image upload, such as Cnblogs, Typecho, WordPress -- Support replacing picture bed image links with Picgo plugin -- Fixed the issue that the release preview of the authorization code mode was invalidated -- Support publishing to Zhihu -- Support for publishing to Hexo -- Support for publishing to Notion -- Support for Yuque, Cnblogs, Metaweblog, Typecho, WordPress -- Support automatic generation of article aliases -- Support for changing the default knowledge base +**Front Row Announcement: the first AI-integrated version `1.10.0` of the Publish Tool is released!** + +We recommend updating using the `uninstall->install` method. If there are any configuration issues, please back up `[workspace]/data/storage/syp/sy-p-plus-cfg.json`, then delete it, as this configuration file will be automatically initialized on first use. + +## Recent Key Updates and Bug Fixes + +- Support for manually generating titles, summaries, tags, and categories through AI. +- AI integration. +- Support for multiple publishing views: simple mode, detailed mode, and source code mode. +- Support for summaries, tags, categories, and knowledge spaces. +- Platforms that do not support image link replacement can use the platform's built-in image upload interface. +- Support for replacing image links with the Picgo plugin, if available. ## Platform List diff --git a/README_zh_CN.md b/README_zh_CN.md index 1ebdae06..2369367f 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -6,34 +6,18 @@ 将思源笔记的文章发布到语雀、Notion、Cnblogs、WordPress、Typecho、Hexo、知乎 等平台,支持极速发布、图床管理、平台扩展、智能标签等特色功能。 -> **前排公告1:发布工具首个支持发布视图以及AI公测尝鲜的版本 `1.9.0` 发布!** -> -> **前排公告2:发布工具完整支持图片上传的版本 `1.8.0` 发布!** - -温馨提示:知乎使用知乎平台的图片上传,语雀、Notion、Hexo需要Picgo插件支持,Metaweblog系列平台同时支持Picgo插件和自带图片上传(安装了Picgo插件使用Picgo插件,否则使用自带) +> **前排公告:发布工具首个AI集成版本 `1.10.0` 发布!** 我们建议您使用 `卸载->安装` 方法进行更新。如果配置异常,请备份 `[workspace]/data/storage/syp/sy-p-plus-cfg.json` ,然后删除,这个配置文件会在第一次使用时自动初始化。 -在更高版本中,发布配置将仅向后兼容到 `1.6.0+` 。 - ## 最近的关键更新与 Bug 修复 +- 支持手动通过AI生成标题、摘要、标签、分类 +- AI集成 - 支持多种发布视图,简单模式、详细模式和源码模式 -- 支持修改摘要、标签、分类、知识空间 -- Hexo 平台支持自定义修改 YAML -- 语雀、Notion、Hexo支持图片链接,自动上传需要Picgo插件支持 -- 知乎平台支持图片自动上传 -- 未安装Picgo插件时,部分平台可使用自带的图片上传,例如博客园、Typecho、WordPress -- 提供不支持图片链接替换的平台使用平台自带的图片上传接口 -- 所有平台迁移到官方的正向代理,极大的提升性能 +- 支持摘要、标签、分类、知识空间 +- 不支持图片链接替换的平台支持使用平台自带的图片上传接口 - 支持使用Picgo插件的情况下替换图床图片链接 -- 修复授权码模式发布预览失效问题 -- 支持发布到知乎 -- 支持发布到 Hexo -- 支持发布到 Notion -- 支持语雀、博客园、Metaweblog、Typecho、WordPress -- 支持自动生成文章别名 -- 语雀支持更改默认知识库 ## 平台列表 diff --git a/siyuan/i18n/en_US.json b/siyuan/i18n/en_US.json index 076cf2d5..a5107436 100644 --- a/siyuan/i18n/en_US.json +++ b/siyuan/i18n/en_US.json @@ -16,5 +16,7 @@ "publishTo": "Publish to...", "batchSync": "Batch sync", "publishNormal": "Publish normal", - "extendFunction": "Extended functionality" + "extendFunction": "Extended functionality", + "aiChat": "AI chat", + "aiChatTab": "AI chat tab" } \ No newline at end of file diff --git a/siyuan/i18n/zh_CN.json b/siyuan/i18n/zh_CN.json index 74dff09b..b6d51f5c 100644 --- a/siyuan/i18n/zh_CN.json +++ b/siyuan/i18n/zh_CN.json @@ -16,5 +16,7 @@ "publishTo": "一键发布", "batchSync": "批量分发", "publishNormal": "常规发布", - "extendFunction": "扩展功能" + "extendFunction": "扩展功能", + "aiChat": "AI聊天", + "aiChatTab": "AI聊天(Tab版)" } diff --git a/siyuan/index.ts b/siyuan/index.ts index 9398bfd5..3ae6688c 100644 --- a/siyuan/index.ts +++ b/siyuan/index.ts @@ -23,7 +23,7 @@ * questions. */ -import { App, getFrontend, IObject, Plugin } from "siyuan" +import { App, getFrontend, IModel, IObject, Plugin } from "siyuan" import { SiyuanConfig, SiyuanKernelApi } from "zhi-siyuan-api" import { createSiyuanAppLogger } from "./appLogger" import { WidgetInvoke } from "./invoke/widgetInvoke" @@ -32,12 +32,14 @@ import { Topbar } from "./topbar" import "./index.styl" export default class PublisherPlugin extends Plugin { - private logger - private topbar + private logger: any + private topbar: Topbar public isMobile: boolean public kernelApi: SiyuanKernelApi - private widgetInvoke + private widgetInvoke: WidgetInvoke + customTabObject: () => IModel + public tabInstance: any constructor(options: { app: App; id: string; name: string; i18n: IObject }) { super(options) @@ -61,5 +63,21 @@ export default class PublisherPlugin extends Plugin { onload() { // 初始化菜单 this.topbar.initTopbar() + // 初始化自定义Tab + this.initCustomTab() + } + + private initCustomTab() { + const that = this + this.customTabObject = this.addTab({ + type: "publisher-plugin-custom-tab", + async init() { + this.element.innerHTML = `

加载中...

` + }, + destroy() { + delete that.tabInstance + that.logger.info("publisher custopm tab destroyed") + }, + }) } } diff --git a/siyuan/invoke/widgetInvoke.ts b/siyuan/invoke/widgetInvoke.ts index 14999876..bff1cc8c 100644 --- a/siyuan/invoke/widgetInvoke.ts +++ b/siyuan/invoke/widgetInvoke.ts @@ -29,7 +29,7 @@ import PageUtil from "../utils/pageUtil" import { showIframeDialog } from "../iframeDialog" import PublisherPlugin from "../index" import { StrUtil } from "zhi-common" -import { showMessage } from "siyuan" +import { openTab, showMessage } from "siyuan" /** * 挂件相关 @@ -56,6 +56,22 @@ export class WidgetInvoke { await this.showPage(`/?id=${pageId}`) } + public async showPublisherAiChatDialog() { + let pageId: string | undefined = PageUtil.getPageId() + if (pageId == "") { + pageId = undefined + } + await this.showPage(`/ai/chat?id=${pageId}`) + } + + public async showPublisherAiChatTab() { + let pageId: string | undefined = PageUtil.getPageId() + if (pageId == "") { + pageId = undefined + } + this.showTab(`/ai/chat?id=${pageId}`) + } + public async showPublisherSinglePublishDialog() { let pageId: string | undefined = PageUtil.getPageId() if (pageId == "") { @@ -120,4 +136,33 @@ export class WidgetInvoke { showIframeDialog(this.pluginInstance, url, w, h, noscroll) } } + + private showTab(pageUrl: string, noscroll?: boolean) { + // 自定义tab + this.pluginInstance.tabInstance = openTab({ + app: this.pluginInstance.app, + custom: { + id: "publisher-ai-tab", + icon: "iconAccount", + title: this.pluginInstance.i18n.aiChatTab, + // @ts-expect-error + fn: this.pluginInstance.customTabObject, + }, + }) + const url = `/plugins/siyuan-plugin-publisher/#${pageUrl}` + this.logger.info("will show webview page =>", url) + // 有高度问题,参考下面的 + // this.pluginInstance.tabInstance.panelElement.innerHTML = ` + //
+ // + // + //
` + + // 参考 https://github.com/zuoez02/siyuan-plugin-webview-flomo/blob/main/index.js#L380C20-L382C29 + this.pluginInstance.tabInstance.panelElement.innerHTML = ` +
+ +
` + } } diff --git a/siyuan/topbar.ts b/siyuan/topbar.ts index c544c5e8..f41e061f 100644 --- a/siyuan/topbar.ts +++ b/siyuan/topbar.ts @@ -193,6 +193,26 @@ export class Topbar { }, }) + // AI聊天 + menu.addSeparator() + menu.addItem({ + iconHTML: ``, + label: this.pluginInstance.i18n.aiChat, + click: () => { + this.widgetInvoke.showPublisherAiChatDialog() + }, + }) + + // AI聊天Tab版 + menu.addSeparator() + menu.addItem({ + iconHTML: ``, + label: this.pluginInstance.i18n.aiChatTab, + click: () => { + this.widgetInvoke.showPublisherAiChatTab() + }, + }) + // 扩展功能 menu.addSeparator() menu.addItem({ diff --git a/src/components/publish/BatchPublishIndex.vue b/src/components/publish/BatchPublishIndex.vue index 85a83d5a..7f241afc 100644 --- a/src/components/publish/BatchPublishIndex.vue +++ b/src/components/publish/BatchPublishIndex.vue @@ -42,13 +42,12 @@ import { IPublishCfg } from "~/src/types/IPublishCfg.ts" import { PageEditMode } from "~/src/models/pageEditMode.ts" import EditModeSelect from "~/src/components/publish/form/EditModeSelect.vue" import PublishTime from "~/src/components/publish/form/PublishTime.vue" -import AiSwitch from "~/src/components/publish/form/AiSwitch.vue" -import { isDev } from "~/src/utils/constants.ts" import { ICategoryConfig } from "~/src/types/ICategoryConfig.ts" import { SiyuanAttr } from "zhi-siyuan-api" import { DistributionPattern } from "~/src/models/distributionPattern.ts" import _ from "lodash" import PublishTitle from "~/src/components/publish/form/PublishTitle.vue" +import { useChatGPT } from "~/src/composables/useChatGPT.ts" const logger = createAppLogger("publisher-index") @@ -295,6 +294,17 @@ const handleRefresh = () => { BrowserUtil.reloadPage() } +const chckedChatGPTEnabled = () => { + let flag = false + try { + useChatGPT() + flag = true + } catch (e) { + logger.error(t("main.opt.failure") + "=>", e) + } + return flag +} + onMounted(async () => { // ================== // 初始化开始 @@ -311,7 +321,7 @@ onMounted(async () => { // ================== // 这里可以控制一些功能开关 - formData.useAi = isDev + formData.useAi = chckedChatGPTEnabled() formData.editType = PageEditMode.EditMode_simple }) @@ -353,11 +363,11 @@ onMounted(async () => {
diff --git a/src/components/publish/SinglePublishDoPublish.vue b/src/components/publish/SinglePublishDoPublish.vue index ef793c67..23e82581 100644 --- a/src/components/publish/SinglePublishDoPublish.vue +++ b/src/components/publish/SinglePublishDoPublish.vue @@ -44,13 +44,12 @@ import { PageEditMode } from "~/src/models/pageEditMode.ts" import EditModeSelect from "~/src/components/publish/form/EditModeSelect.vue" import PublishTime from "~/src/components/publish/form/PublishTime.vue" import { isDev } from "~/src/utils/constants.ts" -import AiSwitch from "~/src/components/publish/form/AiSwitch.vue" import { pre } from "~/src/utils/import/pre.ts" import { ICategoryConfig } from "~/src/types/ICategoryConfig.ts" import PublishKnowledgeSpace from "~/src/components/publish/form/PublishKnowledgeSpace.vue" import { SiyuanAttr } from "zhi-siyuan-api" -import Adaptors from "~/src/adaptors" import PublishTitle from "~/src/components/publish/form/PublishTitle.vue" +import { useChatGPT } from "~/src/composables/useChatGPT.ts" const logger = createAppLogger("single-publish-do-publish") @@ -355,6 +354,17 @@ const initPage = async () => { } } +const chckedChatGPTEnabled = () => { + let flag = false + try { + useChatGPT() + flag = true + } catch (e) { + logger.error(t("main.opt.failure") + "=>", e) + } + return flag +} + onMounted(async () => { logger.info("获取到的ID为=>", id) // ================== @@ -392,7 +402,7 @@ onMounted(async () => { // ================== // 这里可以控制一些功能开关 - formData.useAi = isDev + formData.useAi = chckedChatGPTEnabled() formData.editType = PageEditMode.EditMode_simple }) diff --git a/src/components/publish/form/PublishDescription.vue b/src/components/publish/form/PublishDescription.vue index f70461eb..7dfe57c2 100644 --- a/src/components/publish/form/PublishDescription.vue +++ b/src/components/publish/form/PublishDescription.vue @@ -100,7 +100,7 @@ const handleMakeDesc = async () => { // ElMessage.success(t("main.opt.success")) } catch (e) { logger.error(t("main.opt.failure") + "=>", e) - ElMessage.error(t("main.opt.failure") + "=>", e) + ElMessage.error(t("main.opt.failure") + "=>"+ e) } formData.isDescLoading = false diff --git a/src/components/set/GeneralSetting.vue b/src/components/set/GeneralSetting.vue index 68753dad..444ecbbc 100644 --- a/src/components/set/GeneralSetting.vue +++ b/src/components/set/GeneralSetting.vue @@ -36,6 +36,9 @@ const { t } = useVueI18n() + + + diff --git a/src/components/set/preference/AiSetting.vue b/src/components/set/preference/AiSetting.vue new file mode 100644 index 00000000..3242d8be --- /dev/null +++ b/src/components/set/preference/AiSetting.vue @@ -0,0 +1,77 @@ + + + + + + + diff --git a/src/components/set/preference/PreferenceSetting.vue b/src/components/set/preference/PreferenceSetting.vue index cb0c345c..cabf334c 100644 --- a/src/components/set/preference/PreferenceSetting.vue +++ b/src/components/set/preference/PreferenceSetting.vue @@ -44,27 +44,5 @@ const publishPreferenceSettingForm = getPublishPreferenceSetting() - - - - - - - - - diff --git a/src/components/test/ChatgptTest.vue b/src/components/test/ChatgptTest.vue index 8517d594..3deedcf9 100644 --- a/src/components/test/ChatgptTest.vue +++ b/src/components/test/ChatgptTest.vue @@ -35,7 +35,6 @@ const logger = createAppLogger("chatgpt-test") // uses const { t } = useVueI18n() -const { chat } = useChatGPT() // datas const inputText = ref("") @@ -52,6 +51,7 @@ const sendMessage = async () => { formData.isLoading = true try { + const { chat } = useChatGPT() const chatText = await chat(inputText.value) if (StrUtil.isEmptyString(chatText)) { ElMessage.error("请求错误,请在底部偏好设置修改请求地址和ChatGPT key!") @@ -62,7 +62,7 @@ const sendMessage = async () => { inputText.value = "" } catch (e) { logger.error(t("main.opt.failure") + "=>", e) - ElMessage.error(t("main.opt.failure") + "=>", e) + ElMessage.error(t("main.opt.failure") + "=>" + e) } finally { formData.isLoading = false } diff --git a/src/composables/useChatGPT.ts b/src/composables/useChatGPT.ts index 17f98836..cbd8c1ac 100644 --- a/src/composables/useChatGPT.ts +++ b/src/composables/useChatGPT.ts @@ -29,7 +29,7 @@ import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from "chatgpt" import { Utils } from "~/src/utils/utils.ts" import { isDev } from "~/src/utils/constants.ts" import { createAppLogger } from "~/src/utils/appLogger.ts" -import { useVueI18n } from "~/src/composables/useVueI18n.ts" +import { SiyuanDevice } from "zhi-device" /** * 创建一个用于与 ChatGPT 服务进行交互的钩子 @@ -39,14 +39,30 @@ import { useVueI18n } from "~/src/composables/useVueI18n.ts" */ const useChatGPT = () => { const logger = createAppLogger("use-chatgpt") - const { t } = useVueI18n() - const { getReadOnlyPublishPreferenceSetting } = usePublishPreferenceSetting() + const { getReadOnlyPublishPreferenceSetting, getPublishPreferenceSetting } = usePublishPreferenceSetting() + const changablePref = getPublishPreferenceSetting() const pref = getReadOnlyPublishPreferenceSetting() // 创建 ChatGPTAPI 实例 let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI try { + // 检测是否使用思源笔记的配置 + const win = SiyuanDevice.siyuanWindow() + const snAiCfg = win?.siyuan?.config?.ai?.openAI + logger.info("try load win.siyuan.config =>", snAiCfg) + // 使用思源笔记的配置 + if (snAiCfg) { + changablePref.value.experimentalUseSiyuanNoteAIConfig = true + changablePref.value.experimentalAIProxyUrl = snAiCfg.apiProxy + changablePref.value.experimentalAICode = snAiCfg.apiKey + changablePref.value.experimentalAIBaseUrl = snAiCfg.apiBaseURL + logger.info("use siyuan-note ai config") + } else { + changablePref.value.experimentalUseSiyuanNoteAIConfig = false + logger.info("use custom ai config") + } + // 设置了代理地址创建代理实例,否则使用官方实例 if (!StrUtil.isEmptyString(pref.value.experimentalAIProxyUrl)) { api = new ChatGPTUnofficialProxyAPI({ @@ -68,6 +84,7 @@ const useChatGPT = () => { } catch (e) { // 初始化 API 失败时,记录错误但继续执行 logger.error("Failed to initialize ChatGPT API:", e) + throw e } /** diff --git a/src/composables/useVueRouter.ts b/src/composables/useVueRouter.ts index cde62da4..ca30807c 100644 --- a/src/composables/useVueRouter.ts +++ b/src/composables/useVueRouter.ts @@ -47,6 +47,7 @@ import ZhihuTest from "~/src/components/test/ZhihuTest.vue" import Test from "~/src/pages/Test.vue" import About from "~/src/pages/About.vue" import ChatgptTest from "~/src/components/test/ChatgptTest.vue" +import AiChat from "~/src/pages/AiChat.vue" const routes: RouteRecordRaw[] = [ // 极速发布 @@ -60,6 +61,12 @@ const routes: RouteRecordRaw[] = [ { path: "/", component: BatchPublish }, { path: "/publish/batchPublish", component: BatchPublish }, + // AI + { + path: "/ai/chat", + component: AiChat, + }, + // 测试 { path: "/test", diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts index 4c941e52..7972593c 100644 --- a/src/locales/en_US.ts +++ b/src/locales/en_US.ts @@ -275,9 +275,12 @@ export default { "page.no.id": "pageId fetch error", "main.read.mode": "Readonly", "main.edit.mode": "Editable", - "main.read.mode.tip1": "Tips: The multi-platform distribution mode will display the built-in public YAML, and the general release can display the platform's custom YAML.", - "main.read.mode.tip2": "To identify the uniqueness of the article, slug modifications are ignored and other attributes can be synchronized.", - "main.read.mode.tip3": "!!! This feature is advanced, if you are unclear about the YAML syntax and purpose, do not modify it!!", + "main.read.mode.tip1": + "Tips: The multi-platform distribution mode will display the built-in public YAML, and the general release can display the platform's custom YAML.", + "main.read.mode.tip2": + "To identify the uniqueness of the article, slug modifications are ignored and other attributes can be synchronized.", + "main.read.mode.tip3": + "!!! This feature is advanced, if you are unclear about the YAML syntax and purpose, do not modify it!!", "main.opt.onclick.confirm.tip": "This operation will re -generate all attributes other than alias. If you just want to modify individual attributes, please click the individual function button to operate in the detailed mode. Do you continue?", "main.cat.list.error": "Category list get error", @@ -556,19 +559,26 @@ export default { "setting.blog.siyuan.password": "Siyuan Token", "setting.blog.siyuan.password.tip": "Siyuan Token, which is empty by default", "slogan.make.written.fun": "Let creation return to fun", - "category.batch.not.supported": "Note: Some platforms in the bulk distribution mode do not support public classification, such as Yuque and Zhihu", - "yuque.edit.cate.no.change": "Due to the limitations of the Yuque platform, editing the knowledge base is not supported at the moment. If you want to move a document, click Undelete and then select the new knowledge base publication again", + "category.batch.not.supported": + "Note: Some platforms in the bulk distribution mode do not support public classification, such as Yuque and Zhihu", + "yuque.edit.cate.no.change": + "Due to the limitations of the Yuque platform, editing the knowledge base is not supported at the moment. If you want to move a document, click Undelete and then select the new knowledge base publication again", "main.commonn.cate.title": "Public category", "main.cate.new": "New category", "pref.setting.aicode": "ChatGPT request key", - "pref.setting.aicode.tip": "ChatGPT request key or third-party proxy key, if it is a proxy key, please set the request address", + "pref.setting.aicode.tip": + "ChatGPT request key or third-party proxy key, if it is a proxy key, please set the request address", "pref.setting.ai.baseurl": "ChatGPT request address", "pref.setting.ai.baseurl.tip": "The ChatGPT request address, if it is official ChatGPT, can be left blank", "preference.setting.removeWidgetTag": "Remove the widget HTML", "pref.setting.ai.proxy.url": "ChatGPT proxy address", - "pref.setting.ai.proxy.url.tip": "Can be left blank, note: Filling in the proxy will ignore the ChatGPT request address", + "pref.setting.ai.proxy.url.tip": + "Can be left blank, note: Filling in the proxy will ignore the ChatGPT request address", "main.auto.fetch.title": "Auto fetch title", "main.auto.fetch.cate": "Auto fetch category", - "category.ai.hand": "Due to inconsistent classification systems across platforms, classifications need to be calibrated manually and are not automatically saved", + "category.ai.hand": + "Due to inconsistent classification systems across platforms, classifications need to be calibrated manually and are not automatically saved", "category.ai.enabled": "AI is available, please go to the detailed mode to operate", + "sys.config.ai": "AI configuration", + "config.ai.use.siyuan": "Inside Siyuan notes, you can directly use Siyuan notes to configure, no configuration is required", } diff --git a/src/locales/zh_CN.ts b/src/locales/zh_CN.ts index bd184c81..f343b949 100644 --- a/src/locales/zh_CN.ts +++ b/src/locales/zh_CN.ts @@ -560,5 +560,7 @@ export default { "main.auto.fetch.title": "自动提取标题", "main.auto.fetch.cate": "自动提取分类", "category.ai.hand": "由于各平台分类体系不一致,分类需要手动进行校准,不会自动保存", - "category.ai.enabled": "AI可用,请前往详细模式进行操作", + "category.ai.enabled": "检测到您已经配置AI,可请前往详细模式进行操作", + "sys.config.ai": "AI设置", + "config.ai.use.siyuan": "思源笔记内部,直接使用思源笔记配置,无需配置", } diff --git a/src/models/publishPreferenceCfg.ts b/src/models/publishPreferenceCfg.ts index c05809c3..aaf612d1 100644 --- a/src/models/publishPreferenceCfg.ts +++ b/src/models/publishPreferenceCfg.ts @@ -33,6 +33,16 @@ import { PreferenceConfig } from "zhi-blog-api" * @version 1.9.1 */ class PublishPreferenceCfg extends PreferenceConfig { + /** + * AI 体验码 + */ + public experimentalUseSiyuanNoteAIConfig: boolean + + /** + * AI 体验码 + */ + public experimentalAIEnabled: boolean + /** * AI 体验码 */ @@ -47,6 +57,12 @@ class PublishPreferenceCfg extends PreferenceConfig { * AI 代理地址 */ public experimentalAIProxyUrl?: string + + constructor() { + super() + this.experimentalUseSiyuanNoteAIConfig = true + this.experimentalAIEnabled = false + } } export { PublishPreferenceCfg } diff --git a/src/pages/AiChat.vue b/src/pages/AiChat.vue new file mode 100644 index 00000000..41f57fcb --- /dev/null +++ b/src/pages/AiChat.vue @@ -0,0 +1,144 @@ + + + + + + + \ No newline at end of file diff --git a/src/pages/Test.vue b/src/pages/Test.vue index ddda9dbb..2ec8e58f 100644 --- a/src/pages/Test.vue +++ b/src/pages/Test.vue @@ -77,8 +77,8 @@ const handleGoTest = async (item: any) => {