From d43f6b4cd9f223584fa2195b7bb1148bf61eea57 Mon Sep 17 00:00:00 2001 From: terwer Date: Fri, 25 Aug 2023 16:30:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96token=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 +-- README_zh_CN.md | 15 +-- package.json | 8 +- pnpm-lock.yaml | 99 +++++++++---------- src/components/publish/BatchPublishIndex.vue | 19 ++-- .../publish/SinglePublishDoPublish.vue | 17 +++- .../set/preference/PreferenceSetting.vue | 5 +- src/composables/usePublish.ts | 1 - src/composables/useSiyuanApi.ts | 1 + src/locales/en_US.ts | 1 + src/locales/zh_CN.ts | 1 + 11 files changed, 87 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 34a0a5da..2a2c8869 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,9 @@ Support features such as fast publishing, image bed management, platform expansi **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 +## Update history -- 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. +Please check [CHANGELOG](./CHANGELOG.MD) ## Platform List @@ -78,10 +71,6 @@ the [Siyuan Note Publishing Tool Plugin Platform Adaptation Tracking Form](https For platform adaptation, please refer to [Latest Adaptation](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGIz1r94z9qvqUghDzd) -## Update history - -Please check [CHANGELOG](./CHANGELOG.MD) - ## FAQ * Q1:How to install the publishing tool plugin? Where can I find his entrance after installation? diff --git a/README_zh_CN.md b/README_zh_CN.md index 0261f6ea..3e89f73a 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -8,16 +8,9 @@ > **前排公告:发布工具首个AI集成版本 `1.10.0` 发布!** -我们建议您使用 `卸载->安装` 方法进行更新。如果配置异常,请备份 `[workspace]/data/storage/syp/sy-p-plus-cfg.json` ,然后删除,这个配置文件会在第一次使用时自动初始化。 - -## 最近的关键更新与 Bug 修复 +## 更新历史 -- 支持手动通过AI生成标题、摘要、标签、分类 -- AI集成 -- 支持多种发布视图,简单模式、详细模式和源码模式 -- 支持摘要、标签、分类、知识空间 -- 不支持图片链接替换的平台支持使用平台自带的图片上传接口 -- 支持使用Picgo插件的情况下替换图床图片链接 +请直接查看 [CHANGELOG](./CHANGELOG.md) ## 平台列表 @@ -74,10 +67,6 @@ 平台适配情况请查看请参考 [最新适配情况](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGIz1r94z9qvqUghDzd) -## 更新历史 - -请直接查看 [CHANGELOG](./CHANGELOG.md) - ## FAQ * Q1:发布工具插件怎么安装?安装之后在哪里找到他的入口? diff --git a/package.json b/package.json index fdd2555c..68218f57 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@types/crypto-js": "^4.1.1", "@types/node": "^18.17.11", "@vitejs/plugin-vue": "^4.3.3", - "@vitest/coverage-v8": "^0.34.2", + "@vitest/coverage-v8": "^0.34.3", "@vue/test-utils": "^2.4.1", "esbuild-plugin-copy": "^2.1.1", "esbuild-style-plugin": "^1.6.2", @@ -48,7 +48,7 @@ "vite": "^4.4.9", "vite-plugin-html": "^3.2.0", "vite-plugin-node-polyfills": "^0.11.3", - "vitest": "^0.34.2", + "vitest": "^0.34.3", "vue-tsc": "^1.8.8" }, "dependencies": { @@ -72,14 +72,14 @@ "vue-i18n": "^9.2.2", "vue-router": "^4.2.4", "xmlbuilder2": "^3.1.1", - "zhi-blog-api": "^1.34.10", + "zhi-blog-api": "^1.34.12", "zhi-common": "^1.23.5", "zhi-device": "^2.3.1", "zhi-fetch-middleware": "^0.3.9", "zhi-github-middleware": "^0.3.9", "zhi-lib-base": "^0.4.4", "zhi-notion-markdown": "^0.1.4", - "zhi-siyuan-api": "^2.5.13", + "zhi-siyuan-api": "^2.5.15", "zhi-xmlrpc-middleware": "^0.5.9" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35f7ed08..f576c940 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,8 +66,8 @@ dependencies: specifier: ^3.1.1 version: 3.1.1 zhi-blog-api: - specifier: ^1.34.10 - version: 1.34.10 + specifier: ^1.34.12 + version: 1.34.12 zhi-common: specifier: ^1.23.5 version: 1.23.5 @@ -87,8 +87,8 @@ dependencies: specifier: ^0.1.4 version: 0.1.4 zhi-siyuan-api: - specifier: ^2.5.13 - version: 2.5.13 + specifier: ^2.5.15 + version: 2.5.15 zhi-xmlrpc-middleware: specifier: ^0.5.9 version: 0.5.9 @@ -110,8 +110,8 @@ devDependencies: specifier: ^4.3.3 version: 4.3.3(vite@4.4.9)(vue@3.3.4) '@vitest/coverage-v8': - specifier: ^0.34.2 - version: 0.34.2(vitest@0.34.2) + specifier: ^0.34.3 + version: 0.34.3(vitest@0.34.3) '@vue/test-utils': specifier: ^2.4.1 version: 2.4.1(vue@3.3.4) @@ -158,8 +158,8 @@ devDependencies: specifier: ^0.11.3 version: 0.11.3(vite@4.4.9) vitest: - specifier: ^0.34.2 - version: 0.34.2(jsdom@22.1.0)(stylus@0.59.0) + specifier: ^0.34.3 + version: 0.34.3(jsdom@22.1.0)(stylus@0.59.0) vue-tsc: specifier: ^1.8.8 version: 1.8.8(typescript@5.2.2) @@ -705,8 +705,8 @@ packages: eslint-visitor-keys: 3.4.3 dev: true - /@eslint-community/regexpp@4.7.0: - resolution: {integrity: sha512-+HencqxU7CFJnQb7IKtuNBqS6Yx3Tz4kOL8BJXo+JyeiBm5MEX6pO8onXDkjrkCRlfYXS1Axro15ZjVFe9YgsA==} + /@eslint-community/regexpp@4.8.0: + resolution: {integrity: sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true @@ -925,7 +925,7 @@ packages: nopt: 5.0.0 npmlog: 5.0.1 rimraf: 3.0.2 - semver: 7.3.8 + semver: 7.5.4 tar: 6.1.15 transitivePeerDependencies: - encoding @@ -1360,7 +1360,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.7.0 + '@eslint-community/regexpp': 4.8.0 '@typescript-eslint/parser': 5.62.0(eslint@8.47.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.47.0)(typescript@4.9.5) @@ -1388,7 +1388,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.7.0 + '@eslint-community/regexpp': 4.8.0 '@typescript-eslint/parser': 5.62.0(eslint@8.47.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.47.0)(typescript@5.2.2) @@ -1750,8 +1750,8 @@ packages: vue: 3.3.4 dev: true - /@vitest/coverage-v8@0.34.2(vitest@0.34.2): - resolution: {integrity: sha512-3VuDZPeGGd1zWtc0Tdj9cHSbFc8IQ0ffnWp9MlhItOkziN6HEf219meZ9cZheg/hJXrXb+Fi2bMu7GeCAfL4yA==} + /@vitest/coverage-v8@0.34.3(vitest@0.34.3): + resolution: {integrity: sha512-bNjP0RHe8UxdklCigZlk6FVCNbOiqVjWnpZJ1zKixpvb7YHSaZiN/w+mzpvXIoqyxyePzKC+L+G1oj7SB20PJw==} peerDependencies: vitest: '>=0.32.0 <1' dependencies: @@ -1766,43 +1766,43 @@ packages: std-env: 3.4.3 test-exclude: 6.0.0 v8-to-istanbul: 9.1.0 - vitest: 0.34.2(jsdom@22.1.0)(stylus@0.59.0) + vitest: 0.34.3(jsdom@22.1.0)(stylus@0.59.0) transitivePeerDependencies: - supports-color dev: true - /@vitest/expect@0.34.2: - resolution: {integrity: sha512-EZm2dMNlLyIfDMha17QHSQcg2KjeAZaXd65fpPzXY5bvnfx10Lcaz3N55uEe8PhF+w4pw+hmrlHLLlRn9vkBJg==} + /@vitest/expect@0.34.3: + resolution: {integrity: sha512-F8MTXZUYRBVsYL1uoIft1HHWhwDbSzwAU9Zgh8S6WFC3YgVb4AnFV2GXO3P5Em8FjEYaZtTnQYoNwwBrlOMXgg==} dependencies: - '@vitest/spy': 0.34.2 - '@vitest/utils': 0.34.2 + '@vitest/spy': 0.34.3 + '@vitest/utils': 0.34.3 chai: 4.3.8 dev: true - /@vitest/runner@0.34.2: - resolution: {integrity: sha512-8ydGPACVX5tK3Dl0SUwxfdg02h+togDNeQX3iXVFYgzF5odxvaou7HnquALFZkyVuYskoaHUOqOyOLpOEj5XTA==} + /@vitest/runner@0.34.3: + resolution: {integrity: sha512-lYNq7N3vR57VMKMPLVvmJoiN4bqwzZ1euTW+XXYH5kzr3W/+xQG3b41xJn9ChJ3AhYOSoweu974S1V3qDcFESA==} dependencies: - '@vitest/utils': 0.34.2 + '@vitest/utils': 0.34.3 p-limit: 4.0.0 pathe: 1.1.1 dev: true - /@vitest/snapshot@0.34.2: - resolution: {integrity: sha512-qhQ+xy3u4mwwLxltS4Pd4SR+XHv4EajiTPNY3jkIBLUApE6/ce72neJPSUQZ7bL3EBuKI+NhvzhGj3n5baRQUQ==} + /@vitest/snapshot@0.34.3: + resolution: {integrity: sha512-QyPaE15DQwbnIBp/yNJ8lbvXTZxS00kRly0kfFgAD5EYmCbYcA+1EEyRalc93M0gosL/xHeg3lKAClIXYpmUiQ==} dependencies: magic-string: 0.30.3 pathe: 1.1.1 pretty-format: 29.6.3 dev: true - /@vitest/spy@0.34.2: - resolution: {integrity: sha512-yd4L9OhfH6l0Av7iK3sPb3MykhtcRN5c5K5vm1nTbuN7gYn+yvUVVsyvzpHrjqS7EWqn9WsPJb7+0c3iuY60tA==} + /@vitest/spy@0.34.3: + resolution: {integrity: sha512-N1V0RFQ6AI7CPgzBq9kzjRdPIgThC340DGjdKdPSE8r86aUSmeliTUgkTqLSgtEwWWsGfBQ+UetZWhK0BgJmkQ==} dependencies: tinyspy: 2.1.1 dev: true - /@vitest/utils@0.34.2: - resolution: {integrity: sha512-Lzw+kAsTPubhoQDp1uVAOP6DhNia1GMDsI9jgB0yMn+/nDaPieYQ88lKqz/gGjSHL4zwOItvpehec9OY+rS73w==} + /@vitest/utils@0.34.3: + resolution: {integrity: sha512-kiSnzLG6m/tiT0XEl4U2H8JDBjFtwVlaE8I3QfGiMFR0QvnRDfYfdP3YvTBWM/6iJDAyaPY6yVQiCTUc7ZzTHA==} dependencies: diff-sequences: 29.6.3 loupe: 2.3.6 @@ -3866,7 +3866,7 @@ packages: hasBin: true dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.47.0) - '@eslint-community/regexpp': 4.7.0 + '@eslint-community/regexpp': 4.8.0 '@eslint/eslintrc': 2.1.2 '@eslint/js': 8.47.0 '@humanwhocodes/config-array': 0.11.10 @@ -5035,7 +5035,7 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} dependencies: - semver: 6.3.1 + semver: 6.1.1 dev: true /make-dir@4.0.0: @@ -6297,11 +6297,6 @@ packages: hasBin: true dev: true - /semver@6.3.1: - resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} - hasBin: true - dev: true - /semver@7.3.8: resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} engines: {node: '>=10'} @@ -6406,7 +6401,7 @@ packages: zhi-device: 2.3.1 zhi-fetch-middleware: 0.2.29 zhi-lib-base: 0.4.4 - zhi-siyuan-api: 2.5.13 + zhi-siyuan-api: 2.5.15 transitivePeerDependencies: - '@vue/composition-api' - typescript @@ -7192,8 +7187,8 @@ packages: vfile-message: 2.0.4 dev: false - /vite-node@0.34.2(@types/node@18.17.11)(stylus@0.59.0): - resolution: {integrity: sha512-JtW249Zm3FB+F7pQfH56uWSdlltCo1IOkZW5oHBzeQo0iX4jtC7o1t9aILMGd9kVekXBP2lfJBEQt9rBh07ebA==} + /vite-node@0.34.3(@types/node@18.17.11)(stylus@0.59.0): + resolution: {integrity: sha512-+0TzJf1g0tYXj6tR2vEyiA42OPq68QkRZCu/ERSo2PtsDJfBpDyEfuKbRvLmZqi/CgC7SCBtyC+WjTGNMRIaig==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -7285,8 +7280,8 @@ packages: fsevents: 2.3.3 dev: true - /vitest@0.34.2(jsdom@22.1.0)(stylus@0.59.0): - resolution: {integrity: sha512-WgaIvBbjsSYMq/oiMlXUI7KflELmzM43BEvkdC/8b5CAod4ryAiY2z8uR6Crbi5Pjnu5oOmhKa9sy7uk6paBxQ==} + /vitest@0.34.3(jsdom@22.1.0)(stylus@0.59.0): + resolution: {integrity: sha512-7+VA5Iw4S3USYk+qwPxHl8plCMhA5rtfwMjgoQXMT7rO5ldWcdsdo3U1QD289JgglGK4WeOzgoLTsGFu6VISyQ==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -7319,11 +7314,11 @@ packages: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 '@types/node': 18.17.11 - '@vitest/expect': 0.34.2 - '@vitest/runner': 0.34.2 - '@vitest/snapshot': 0.34.2 - '@vitest/spy': 0.34.2 - '@vitest/utils': 0.34.2 + '@vitest/expect': 0.34.3 + '@vitest/runner': 0.34.3 + '@vitest/snapshot': 0.34.3 + '@vitest/spy': 0.34.3 + '@vitest/utils': 0.34.3 acorn: 8.10.0 acorn-walk: 8.2.0 cac: 6.7.14 @@ -7339,7 +7334,7 @@ packages: tinybench: 2.5.0 tinypool: 0.7.0 vite: 4.4.9(@types/node@18.17.11)(stylus@0.59.0) - vite-node: 0.34.2(@types/node@18.17.11)(stylus@0.59.0) + vite-node: 0.34.3(@types/node@18.17.11)(stylus@0.59.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -7660,8 +7655,8 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} - /zhi-blog-api@1.34.10: - resolution: {integrity: sha512-EcAY2YvBbfUdmFvRZonE5PasISQ033N2C5CCJysBjv4eXMprigi2yzBET/R0nbC35jcsudFWW5PwTU0e3O+cCg==} + /zhi-blog-api@1.34.12: + resolution: {integrity: sha512-HgKtb7ujPI/VDfxo/VHZWGIrZvsUGDATIrnAiknNBxAyIM1i22g/wsX9W3golv2D9pz16vtYK92L3bZgPf5bqg==} dependencies: zhi-common: 1.23.5 zhi-lib-base: 0.5.0 @@ -7734,10 +7729,10 @@ packages: - supports-color dev: false - /zhi-siyuan-api@2.5.13: - resolution: {integrity: sha512-dB5dwa85qPtT+/kPMwGI/wDHREvsBsZya5qI5ugOtZRYtfO3GcfA+paQc8PkQ04y+Qxci8IIa4uvPlEoJ89+mA==} + /zhi-siyuan-api@2.5.15: + resolution: {integrity: sha512-Hc82jlzx2h6v3Ze+w51aPsExW1eSRrtoOdSqw0pq7MG3ZxWtxNdBJ42lEIKA67VkMm5RxcBQTtHf9kVAO9Nt9A==} dependencies: - zhi-blog-api: 1.34.10 + zhi-blog-api: 1.34.12 zhi-common: 1.23.5 zhi-lib-base: 0.5.0 dev: false diff --git a/src/components/publish/BatchPublishIndex.vue b/src/components/publish/BatchPublishIndex.vue index 9b2c1db3..6e98a0ce 100644 --- a/src/components/publish/BatchPublishIndex.vue +++ b/src/components/publish/BatchPublishIndex.vue @@ -312,12 +312,19 @@ const handleRefresh = () => { const checkChatGPTEnabled = () => { let flag = false - try { - useChatGPT() - flag = true - } catch (e) { - logger.error(t("main.opt.failure") + "=>", e) + let attempts = 0 + + while (!flag && attempts < 3) { + try { + useChatGPT() + flag = true + } catch (e) { + logger.error(`${t("main.opt.failure")} => ${e}`) + attempts++ + } } + + logger.info(`第${attempts}次尝试就检测AI状态: ${flag}`) return flag } @@ -558,4 +565,4 @@ onMounted(async () => { .distri-tip-alert margin 10px 0 padding: 2px 0 - \ No newline at end of file + diff --git a/src/components/publish/SinglePublishDoPublish.vue b/src/components/publish/SinglePublishDoPublish.vue index 00267d04..99868ef1 100644 --- a/src/components/publish/SinglePublishDoPublish.vue +++ b/src/components/publish/SinglePublishDoPublish.vue @@ -361,12 +361,19 @@ const initPage = async () => { const checkChatGPTEnabled = () => { let flag = false - try { - useChatGPT() - flag = true - } catch (e) { - logger.error(t("main.opt.failure") + "=>", e) + let attempts = 0 + + while (!flag && attempts < 3) { + try { + useChatGPT() + flag = true + } catch (e) { + logger.error(`${t("main.opt.failure")} => ${e}`) + attempts++ + } } + + logger.info(`第${attempts}次尝试就检测AI状态: ${flag}`) return flag } diff --git a/src/components/set/preference/PreferenceSetting.vue b/src/components/set/preference/PreferenceSetting.vue index cabf334c..dcd56c9b 100644 --- a/src/components/set/preference/PreferenceSetting.vue +++ b/src/components/set/preference/PreferenceSetting.vue @@ -34,10 +34,13 @@ const publishPreferenceSettingForm = getPublishPreferenceSetting()