From acc6dc91ff3c3dfdc6ce6b04c0c9b52f0ac9de7d Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 11 Oct 2023 13:52:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20#765=20=E4=BF=AE=E5=A4=8DHalo=20?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=97=A0=E6=B3=95=E8=AE=BE=E7=BD=AE=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=B6=E9=97=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/adaptors/api/halo/HaloApiAdaptor.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/adaptors/api/halo/HaloApiAdaptor.ts b/src/adaptors/api/halo/HaloApiAdaptor.ts index 6c29e151..075e5650 100644 --- a/src/adaptors/api/halo/HaloApiAdaptor.ts +++ b/src/adaptors/api/halo/HaloApiAdaptor.ts @@ -30,18 +30,8 @@ import { Attachment, CategoryInfo, MediaObject, Post, UserBlog } from "zhi-blog- import { AliasTranslator, JsonUtil, ObjectUtil, StrUtil } from "zhi-common" import { Base64 } from "js-base64" import sypIdUtil from "~/src/utils/sypIdUtil.ts" -import { - Category, - CategoryList, - ListedPost, - ListedPostList, - Policy, - PostRequest, - Tag, - TagList, -} from "@halo-dev/api-client" +import { PostRequest } from "@halo-dev/api-client" import { HaloPostMeta } from "~/src/adaptors/api/halo/HaloPostMeta.ts" -import HaloUtils from "~/src/adaptors/api/halo/haloUtils.ts" /** * Halo API 适配器 @@ -137,6 +127,9 @@ class HaloApiAdaptor extends BaseBlogApi { throw e } + // 发布时间 + params.post.spec.publishTime = post.dateCreated.toISOString() + // 草稿 const res = await this.haloRequest("/apis/api.console.halo.run/v1alpha1/posts", params, "POST") this.logger.debug("halo newPost res =>", res) @@ -197,12 +190,19 @@ class HaloApiAdaptor extends BaseBlogApi { params.post.spec.tags = tagNames } + // 发布时间 + params.post.spec.publishTime = post.dateCreated.toISOString() + // 更新文章信息 await this.haloRequest(`/apis/content.halo.run/v1alpha1/posts/${name}`, params.post, "PUT") await this.haloRequest(`/apis/api.console.halo.run/v1alpha1/posts/${name}/content`, params.content, "PUT") // 重新发布 - await this.haloRequest(`/apis/api.console.halo.run/v1alpha1/posts/${params.post.metadata.name}/publish`, {}, "PUT") + await this.haloRequest( + `/apis/api.console.halo.run/v1alpha1/posts/${params.post.metadata.name}/publish`, + {}, + "PUT" + ) this.logger.debug("halo 文章发布完成") } catch (e) { this.logger.error("Halo文章更新失败", e) From 50d440cfc15b96a3a0cf2b68cfc11f6931b7eac2 Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 11 Oct 2023 14:02:03 +0800 Subject: [PATCH 2/4] docs: prepare for release docs --- README.md | 15 +++++++++------ README_zh_CN.md | 13 ++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 06811c85..0181fce4 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,16 @@ 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. -🎉 Exciting News: New tool version `1.16.0` is out! +> Latest Feature Release: 🎉 New Publish Tool version `1.17.0` is out! 🚀 -- `1.16.0` focuses on enhancing support for **formulas** and **tables** on Zhihu. Additionally, GitHub now allows custom author homepage configuration. -- `1.15.1` addresses minor issues like fixing publishing errors on Juejin, handling anomalies during article deletion, and resolving tag duplication during article editing. -- Introducing support for the Halo platform! After upgrading to `1.15.0+`, you can seamlessly publish content to Halo2 sites. -- In `1.15.0`, fixes were made for misinterpretation of YAML in certain scenarios and publishing errors on platforms when tags were empty. -- Oh, by the way, starting from version `1.14.0`, the author secretly developed an import feature. You can swiftly import built-in platforms using the `Settings` -> `Publish Settings` -> `Import Predefined Platforms` feature 😄. +**This might be the most worthwhile update since the National Day. 😄** + +- In `1.17.0`, the following significant changes have been made: + - Optimization and support for AI effects. + - Persistence of preference settings, eliminating concerns about preference configuration being invalidated due to restarts or other situations. + - Resolved the issue where Halo publication times were not taking effect. + - Fixed the problem of articles previously published with old widgets not being updatable. +- Ah, by the way, since version `1.14.0`, the author secretly developed an import feature. You can swiftly import built-in platforms using the `Settings` -> `Publish Settings` -> `Import Predefined Platforms` feature. 😄 > Platform Limitations: - **WeChat Official Accounts**: Publishing Tool now supports posting articles to the WeChat Official Accounts draft box in version `1.13.0` and beyond. However, due to limitations on the WeChat platform in Electron, normal login operations are not possible. Therefore, you will need to visit `https://mp.weixin.qq.com/` yourself, complete the login, copy the cookie, and then paste it into the configuration options. diff --git a/README_zh_CN.md b/README_zh_CN.md index fb13a09d..65c1114d 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -6,12 +6,15 @@ 将思源笔记的文章发布到语雀、Notion、Cnblogs、WordPress、Typecho、Hexo、知乎 等平台,支持极速发布、图床管理、平台扩展、智能标签等特色功能。 -> 最近的新特性版本:🎉 发布工具新版本 `1.16.0` 发布 +> 最近的新特性版本:🎉 发布工具新版本 `1.17.0` 发布 + + **这可能是国庆之后您最值得升级的一个版本。😄** - - `1.16.0` 主要对知乎平台进行**公式**和**表格**支持。另外,对于GitHub,也支持配置自定义作者主页了。 - - `1.15.1` 小版本修复掘金平台发布错误的问题,部分场景下文章删除异常问题,以及文章编辑时候标签重复问题。 - - 新增 Halo 平台,升级到 `1.15.0+` 之后可发布到 Halo2 站点。 - - `1.15.0` 修复了 yaml 部分场景误解析、标签为空的时候部分平台发布错误的问题。 + - `1.17.0` 主要有以下重要变更: + - 对AI效果进行了优化支持。 + - 偏好设置进行持久化,再也不用担心重启或者其他情况导致的偏好配置失效的问题了。 + - 修复了 Halo 发布时间未生效问题。 + - 修复了旧挂件发布过的文章无法更新的问题。 - 咳咳,另外,在 `1.14.0` 版本之后,作者还悄悄开发了导入功能。您可以使用 `设置` -> `发布设置` -> `导入预定义平台` 功能快速导入内置平台😄 > 平台限制说明 From de10a343f376caab005427bb03d68c908c7978fd Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 11 Oct 2023 14:05:17 +0800 Subject: [PATCH 3/4] docs: prepare for release docs --- src/stores/common/jsonStorage.ts | 4 ++-- src/stores/common/useCommonLocalStorage.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/stores/common/jsonStorage.ts b/src/stores/common/jsonStorage.ts index ad6ae43b..56b67e84 100644 --- a/src/stores/common/jsonStorage.ts +++ b/src/stores/common/jsonStorage.ts @@ -33,8 +33,8 @@ import { JsonUtil } from "zhi-common" * https://github.com/vueuse/vueuse/blob/main/packages/core/ssr-handlers.ts#L11 * * @author terwer - * @version 1.7.0 - * @since 1.7.0 + * @version 1.17.0 + * @since 1.17.0 */ class JsonStorage implements StorageLike { private readonly logger: any diff --git a/src/stores/common/useCommonLocalStorage.ts b/src/stores/common/useCommonLocalStorage.ts index 16f799e2..46d2efa2 100644 --- a/src/stores/common/useCommonLocalStorage.ts +++ b/src/stores/common/useCommonLocalStorage.ts @@ -22,19 +22,19 @@ * or visit www.terwer.space if you need additional information or have any * questions. */ -import type {MaybeRefOrGetter, RemovableRef} from "@vueuse/shared" -import type {StorageLike, UseStorageOptions} from "@vueuse/core" -import {defaultWindow, useStorage} from "@vueuse/core" +import type { MaybeRefOrGetter, RemovableRef } from "@vueuse/shared" +import type { StorageLike, UseStorageOptions } from "@vueuse/core" +import { defaultWindow, useStorage } from "@vueuse/core" import JsonStorage from "~/src/stores/common/jsonStorage.ts" -import {createAppLogger} from "~/src/utils/appLogger.ts" -import {useSiyuanDevice} from "~/src/composables/useSiyuanDevice.ts" +import { createAppLogger } from "~/src/utils/appLogger.ts" +import { useSiyuanDevice } from "~/src/composables/useSiyuanDevice.ts" const logger = createAppLogger("use-common-local-storage") /** - * 通用响应式的 LocalStorage. + * 通用响应式的 LocalStorage * - * @see https://vueuse.org/useCommonLocalStorage + * @see https://vueuse.org/useLocalStorage * @param filePath json文件存储位置,可选,浏览器环境忽略此参数 * @param key key * @param initialValue 初始值 From 3b12563c37caa2a0c54e6ca6b0cef2c0283a8ec4 Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 11 Oct 2023 14:27:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20#754=20=E4=BF=AE=E5=A4=8D=E6=97=A7?= =?UTF-8?q?=E6=8C=82=E4=BB=B6=E5=8F=91=E5=B8=83=E8=BF=87=E7=9A=84=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=97=A0=E6=B3=95=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/base/github/commonGithubApiAdaptor.ts | 29 ++++++++++++++---- .../api/base/gitlab/commonGitlabApiAdaptor.ts | 30 +++++++++++++++---- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/adaptors/api/base/github/commonGithubApiAdaptor.ts b/src/adaptors/api/base/github/commonGithubApiAdaptor.ts index abd3caef..a0739593 100644 --- a/src/adaptors/api/base/github/commonGithubApiAdaptor.ts +++ b/src/adaptors/api/base/github/commonGithubApiAdaptor.ts @@ -32,7 +32,7 @@ import { DateUtil, HtmlUtil, StrUtil, YamlUtil } from "zhi-common" import { toRaw } from "vue" import { Base64 } from "js-base64" import { CommonGitlabConfig } from "~/src/adaptors/api/base/gitlab/commonGitlabConfig.ts" -import sypIdUtil from "~/src/utils/sypIdUtil.ts"; +import sypIdUtil from "~/src/utils/sypIdUtil.ts" /** * Github API 适配器 @@ -93,12 +93,31 @@ class CommonGithubApiAdaptor extends BaseBlogApi { this.logger.info("将要最终发送到以下目录 =>", docPath) // 开始发布 - const res = await this.githubClient.publishGithubPage(docPath, post.description) + let finalRes: any + try { + const res = await this.githubClient.publishGithubPage(docPath, post.description) - if (!res?.content?.path) { - throw new Error("Github 调用API异常") + if (!res?.content?.path) { + throw new Error("Github 调用API异常") + } + + finalRes = res + } catch (e) { + // 失败之后尝试删除旧数据再发一次 + try { + await this.deletePost(docPath) + } catch (e) { + this.logger.warn("尝试删除失败,忽略", e) + } + const res2 = await this.githubClient.publishGithubPage(docPath, post.description) + if (!res2?.content?.path) { + throw new Error("重发依旧失败,Github 调用API异常") + } + + finalRes = res2 } - return res.content.path + + return finalRes.content.path } public async getPost(postid: string, useSlug?: boolean): Promise { diff --git a/src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts b/src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts index ebb2a579..f547c71b 100644 --- a/src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts +++ b/src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts @@ -33,7 +33,7 @@ import { StrUtil, YamlUtil } from "zhi-common" import { toRaw } from "vue" import { Base64 } from "js-base64" import { isDev } from "~/src/utils/constants.ts" -import sypIdUtil from "~/src/utils/sypIdUtil.ts"; +import sypIdUtil from "~/src/utils/sypIdUtil.ts" /** * Gitlab API 适配器 @@ -95,13 +95,31 @@ class CommonGitlabApiAdaptor extends BaseBlogApi { this.logger.info("将要最终发送到以下目录 =>", docPath) // 开始发布 - const res = await this.gitlabClient.createRepositoryFile(docPath, post.description) - this.logger.debug("gitlab newPost finished =>", res) + let finalRes: any + try { + const res = await this.gitlabClient.createRepositoryFile(docPath, post.description) + this.logger.debug("gitlab newPost finished =>", res) + if (!res?.file_path) { + throw new Error("Gitlab 调用API异常 =>" + res?.message) + } - if (!res?.file_path) { - throw new Error("Gitlab 调用API异常 =>" + res?.message) + finalRes = res + } catch (e) { + // 失败之后尝试删除旧数据再发一次 + try { + await this.deletePost(docPath) + } catch (e) { + this.logger.warn("尝试删除失败,忽略", e) + } + const res2 = await this.gitlabClient.createRepositoryFile(docPath, post.description) + if (!res2?.file_path) { + throw new Error("重发依旧失败,Gitlab 调用API异常 =>" + res2?.message) + } + + finalRes = res2 } - return res.file_path + + return finalRes.file_path } public async getPost(postid: string, useSlug?: boolean): Promise {