diff --git a/README.md b/README.md index ef83b22b..9e5b19ba 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ![](./icon.png) -Publish articles from Siyuan Notes to platforms such as Yuque, Notion, Cnblogs, WordPress, Typecho, Hexo, Zhihu and more. +Publish articles from siyuan-note to platforms such as Yuque, Notion, Cnblogs, WordPress, Typecho, Hexo, Zhihu and more. Support features such as fast publishing, image bed management, platform expansion, smart labels, etc. -> **Front Announcement 1: Release Tool's first platform-wide version `1.8.0` using the forward agent of Siyuan Note!** +> **Front Announcement 1: Publish Tool's first platform-wide version `1.8.0` using the forward agent of Siyuan Note!** > -> **Front Announcement 2: The first version of the release tool that fully supports image upload `1.8.0` is released!** +> **Front Announcement 2: The first version of the Publish Tool that fully supports image upload `1.8.0` is released!** 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) @@ -70,7 +70,7 @@ Names not listed in order disabled at any time - [X] **Dynamic Newly Added**: Support custom adding platform - [ ] **Smart Classification**: Support smart tags, smart slug aliases, smart summaries, and continue to improve -- [X] **Article Binding**: Support linking existing platform articles to Siyuan Notes to facilitate follow-up management, +- [X] **Article Binding**: Support linking existing platform articles to siyuan-note to facilitate follow-up management, support Siyuan->platform one-way synchronization - [X] **Adapt to Theme**: Automatically adapt to dark mode and light mode - [X] **Language support**: multi-language support, support Chinese version and English version diff --git a/siyuan/i18n/en_US.json b/siyuan/i18n/en_US.json index fd2dd64a..076cf2d5 100644 --- a/siyuan/i18n/en_US.json +++ b/siyuan/i18n/en_US.json @@ -8,7 +8,7 @@ "settingPicbed": "Picbed manage", "settingPublish": "Publish setting", "settingPlatform": "Platform setting", - "settingMenuTips": "Let creation return to fun", + "settingAbout": "About", "copyPageId": "Copy pageId", "publisherWidget": "Publisher Widget", "cancel": "Cancel", diff --git a/siyuan/i18n/zh_CN.json b/siyuan/i18n/zh_CN.json index be01e91b..74dff09b 100644 --- a/siyuan/i18n/zh_CN.json +++ b/siyuan/i18n/zh_CN.json @@ -8,7 +8,7 @@ "settingPicbed": "图床设置", "settingPublish": "发布设置", "settingPlatform": "平台设置", - "settingMenuTips": "让创作回归乐趣", + "settingAbout": "关于", "copyPageId": "复制文档ID", "publisherWidget": "挂件版", "cancel": "取消", diff --git a/siyuan/invoke/widgetInvoke.ts b/siyuan/invoke/widgetInvoke.ts index c1a77b36..f776544c 100644 --- a/siyuan/invoke/widgetInvoke.ts +++ b/siyuan/invoke/widgetInvoke.ts @@ -95,6 +95,15 @@ export class WidgetInvoke { await this.showPage(`/setting/general?id=${pageId}`) } + public async showPublisherAboutDialog() { + let pageId: string | undefined = PageUtil.getPageId() + if (pageId == "") { + pageId = undefined + } + this.logger.debug("pageId=>", pageId) + await this.showPage(`/setting/about?id=${pageId}`) + } + private async showPage(pageUrl: string, isReload?: boolean, w?: string, h?: string, noscroll?: boolean) { const deviceType: DeviceTypeEnum = DeviceDetection.getDevice() this.logger.info(`you are from ${deviceType}`) diff --git a/siyuan/topbar.ts b/siyuan/topbar.ts index bb891ad3..c544c5e8 100644 --- a/siyuan/topbar.ts +++ b/siyuan/topbar.ts @@ -254,8 +254,10 @@ export class Topbar { menu.addSeparator() menu.addItem({ icon: "iconSparkles", - label: this.pluginInstance.i18n.settingMenuTips, - type: "readonly", + label: this.pluginInstance.i18n.settingAbout, + click: () => { + this.widgetInvoke.showPublisherAboutDialog() + }, }) if (this.pluginInstance.isMobile) { diff --git a/src/adaptors/base/baseExtendApi.ts b/src/adaptors/base/baseExtendApi.ts index 5f631c89..46382002 100644 --- a/src/adaptors/base/baseExtendApi.ts +++ b/src/adaptors/base/baseExtendApi.ts @@ -53,6 +53,11 @@ class BaseExtendApi extends WebApi implements IBlogApi, IWebApi { private readonly isSiyuanOrSiyuanNewWin: boolean private readonly kernelApi: SiyuanKernelApi + /** + * 构造函数用于创建一个新的实例 + * + * @param api - 一个 BaseBlogApi 或 BaseWebApi 实例,用于与 API 进行通信 + */ constructor(api: BaseBlogApi | BaseWebApi) { super() this.logger = createAppLogger("base-extend-api") @@ -65,7 +70,32 @@ class BaseExtendApi extends WebApi implements IBlogApi, IWebApi { this.kernelApi = kernelApi } + /** + * 在保存前编辑文章 + * + * @param post - 要编辑的文章 + * @param id - 文章的可选 ID + * @param publishCfg - 发布配置的可选参数 + * @returns 一个 Promise,解析为编辑后的文章 + */ public async preEditPost(post: Post, id?: string, publishCfg?: any): Promise { + // 处理图片 + post = await this.handlePictures(post, id, publishCfg) + return post + } + + // ================ + // private methods + // ================ + /** + * 处理图片 + * + * @param post - 要处理图片的 Post 对象 + * @param id - (可选)图片 ID + * @param publishCfg - (可选)发布配置参数 + * @returns 一个 Promise,解析为处理后的 Post 对象 + */ + private async handlePictures(post: Post, id?: string, publishCfg?: any): Promise { const cfg: BlogConfig = publishCfg.cfg const dynCfg: DynamicConfig = publishCfg.dynCfg @@ -163,14 +193,23 @@ class BaseExtendApi extends WebApi implements IBlogApi, IWebApi { return post } - // ================ - // private methods - // ================ + /** + * 检查 Picgo 是否已安装 + * + * @returns 一个 Promise,解析为布尔值,表示是否已安装 Picgo + */ private async checkPicgoInstalled() { // 检测是否安装 picgo 插件 return await isFileExists(this.kernelApi, "/data/plugins/siyuan-plugin-picgo/plugin.json", "text") } + /** + * 读取文件并将其转换为 Base64 编码 + * + * @param url - 要读取的文件的 URL + * @param cfg - 博客配置对象 + * @returns 一个 Promise,解析为文件的 Base64 编码字符串 + */ private async readFileToBase64(url: string, cfg: BlogConfig): Promise { let base64Info: any if (this.isSiyuanOrSiyuanNewWin) { diff --git a/src/adaptors/index.ts b/src/adaptors/index.ts index 75fef918..f782d952 100644 --- a/src/adaptors/index.ts +++ b/src/adaptors/index.ts @@ -212,31 +212,6 @@ class Adaptors { this.logger.debug(`get blogAdaptor from key ${key}`) return blogAdaptor } - - // 新增 preEditPost , 此方法不再需要 - // /** - // * 根据平台key查找YAML适配器 - // * - // * @param key - // * @param newCfg - // */ - // public static async getYamlAdaptor(key: string, newCfg?: any): Promise { - // let yamlAdp = null - // const type: SubPlatformType = getSubPlatformTypeByKey(key) - // - // switch (type) { - // case SubPlatformType.Github_Hexo: { - // const { yamlAdaptor } = await useHexoApi(key, newCfg) - // yamlAdp = yamlAdaptor - // break - // } - // default: { - // break - // } - // } - // this.logger.debug(`get yamlAdaptor from key ${key}=>`, yamlAdp) - // return yamlAdp - // } } export default Adaptors diff --git a/src/components/publish/SinglePublishSelectPlatform.vue b/src/components/publish/SinglePublishSelectPlatform.vue index cbdef7a1..e67c7daa 100644 --- a/src/components/publish/SinglePublishSelectPlatform.vue +++ b/src/components/publish/SinglePublishSelectPlatform.vue @@ -116,7 +116,7 @@ onMounted(async () => { - {{ HtmlUtil.parseHtml(cfg.platformName, 11) }} + {{ StrUtil.upperFirst(HtmlUtil.parseHtml(cfg.platformName, 11)) }} diff --git a/src/components/test/CnblogsTest.vue b/src/components/test/CnblogsTest.vue index 9fb19296..913e1a99 100644 --- a/src/components/test/CnblogsTest.vue +++ b/src/components/test/CnblogsTest.vue @@ -405,26 +405,28 @@ const cnblogsHandleApi = async () => { diff --git a/src/pages/PicgoTest.vue b/src/components/test/PicgoTest.vue similarity index 88% rename from src/pages/PicgoTest.vue rename to src/components/test/PicgoTest.vue index 594dd9cd..312f94b7 100644 --- a/src/pages/PicgoTest.vue +++ b/src/components/test/PicgoTest.vue @@ -27,6 +27,7 @@ import { BrowserUtil } from "zhi-device" import { usePicgoBridge } from "~/src/composables/usePicgoBridge.ts" import { createAppLogger } from "~/src/utils/appLogger.ts" +import { getWidgetId } from "~/src/utils/widgetUtils.ts" const logger = createAppLogger("picgo-test") const { handlePicgo } = usePicgoBridge() @@ -35,7 +36,7 @@ const { handlePicgo } = usePicgoBridge() const props = defineProps({ pageId: { type: String, - default: BrowserUtil.getQueryParam("pageId"), + default: BrowserUtil.getQueryParam("pageId") ?? getWidgetId(), }, }) @@ -46,5 +47,7 @@ const testHandlePicgo = async () => { diff --git a/src/components/test/SiyuanTest.vue b/src/components/test/SiyuanTest.vue index 3a850df4..dfb6dade 100644 --- a/src/components/test/SiyuanTest.vue +++ b/src/components/test/SiyuanTest.vue @@ -335,26 +335,28 @@ const siyuanHandleApi = async () => { diff --git a/src/pages/ApiTest.vue b/src/pages/ApiTest.vue deleted file mode 100644 index b5d0fd32..00000000 --- a/src/pages/ApiTest.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - diff --git a/src/pages/Test.vue b/src/pages/Test.vue new file mode 100644 index 00000000..79ce9e2c --- /dev/null +++ b/src/pages/Test.vue @@ -0,0 +1,87 @@ + + + + + + + \ No newline at end of file