From 4ca3ecddcd2b0eeb0378f633168d83afa6a408e6 Mon Sep 17 00:00:00 2001 From: terwer Date: Fri, 18 Aug 2023 21:23:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=88=86=E7=B1=BB-=E5=8D=95=E9=80=89=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 12 +- pnpm-lock.yaml | 128 ++++++------- src/adaptors/api/notion/notionApiAdaptor.ts | 11 ++ src/adaptors/api/yuque/useYuqueApi.ts | 6 + src/adaptors/api/yuque/yuqueApiAdaptor.ts | 2 +- src/components/publish/BatchPublishIndex.vue | 19 +- .../publish/SinglePublishDoPublish.vue | 40 +++- .../publish/form/PublishCategories.vue | 44 ++++- .../publish/form/category/MultiCategories.vue | 13 +- .../publish/form/category/SingleCategory.vue | 176 +++++++++++++++++- .../form/category/TreeMultiCategories.vue | 15 +- .../form/category/TreeSingleCategory.vue | 13 +- src/composables/usePublish.ts | 2 +- src/constants/siyuanAttr.ts | 44 +++++ src/locales/en_US.ts | 1 + src/locales/zh_CN.ts | 4 +- src/types/ICategoryConfig.ts | 108 +++++++++++ 17 files changed, 531 insertions(+), 107 deletions(-) create mode 100644 src/constants/siyuanAttr.ts create mode 100644 src/types/ICategoryConfig.ts diff --git a/package.json b/package.json index fc282cd5..a687c902 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "@terwer/eslint-config-custom": "^1.3.6", "@types/crypto-js": "^4.1.1", "@types/node": "^18.17.5", - "@vitejs/plugin-vue": "^4.2.3", - "@vitest/coverage-v8": "^0.34.1", + "@vitejs/plugin-vue": "^4.3.1", + "@vitest/coverage-v8": "^0.34.2", "@vue/test-utils": "^2.4.1", "esbuild-plugin-copy": "^2.1.1", "esbuild-style-plugin": "^1.6.2", @@ -44,11 +44,11 @@ "typescript": "^5.1.6", "unplugin-auto-import": "^0.16.6", "unplugin-vue-components": "^0.25.1", - "vercel": "^31.3.1", + "vercel": "^31.4.0", "vite": "^4.4.9", "vite-plugin-html": "^3.2.0", - "vite-plugin-node-polyfills": "^0.11.1", - "vitest": "^0.34.1", + "vite-plugin-node-polyfills": "^0.11.2", + "vitest": "^0.34.2", "vue-tsc": "^1.8.8" }, "dependencies": { @@ -77,7 +77,7 @@ "zhi-github-middleware": "^0.2.9", "zhi-lib-base": "^0.4.4", "zhi-notion-markdown": "^0.1.4", - "zhi-siyuan-api": "^2.2.3", + "zhi-siyuan-api": "^2.3.0", "zhi-xmlrpc-middleware": "^0.4.23" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eb6a5376..99b6e5bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,8 +81,8 @@ dependencies: specifier: ^0.1.4 version: 0.1.4 zhi-siyuan-api: - specifier: ^2.2.3 - version: 2.2.3 + specifier: ^2.3.0 + version: 2.3.0 zhi-xmlrpc-middleware: specifier: ^0.4.23 version: 0.4.23 @@ -101,11 +101,11 @@ devDependencies: specifier: ^18.17.5 version: 18.17.5 '@vitejs/plugin-vue': - specifier: ^4.2.3 - version: 4.2.3(vite@4.4.9)(vue@3.3.4) + specifier: ^4.3.1 + version: 4.3.1(vite@4.4.9)(vue@3.3.4) '@vitest/coverage-v8': - specifier: ^0.34.1 - version: 0.34.1(vitest@0.34.1) + specifier: ^0.34.2 + version: 0.34.2(vitest@0.34.2) '@vue/test-utils': specifier: ^2.4.1 version: 2.4.1(vue@3.3.4) @@ -140,8 +140,8 @@ devDependencies: specifier: ^0.25.1 version: 0.25.1(vue@3.3.4) vercel: - specifier: ^31.3.1 - version: 31.3.1 + specifier: ^31.4.0 + version: 31.4.0 vite: specifier: ^4.4.9 version: 4.4.9(@types/node@18.17.5)(stylus@0.59.0) @@ -149,11 +149,11 @@ devDependencies: specifier: ^3.2.0 version: 3.2.0(vite@4.4.9) vite-plugin-node-polyfills: - specifier: ^0.11.1 - version: 0.11.1(vite@4.4.9) + specifier: ^0.11.2 + version: 0.11.2(vite@4.4.9) vitest: - specifier: ^0.34.1 - version: 0.34.1(jsdom@22.1.0)(stylus@0.59.0) + specifier: ^0.34.2 + version: 0.34.2(jsdom@22.1.0)(stylus@0.59.0) vue-tsc: specifier: ^1.8.8 version: 1.8.8(typescript@5.1.6) @@ -1315,7 +1315,7 @@ packages: resolution: {integrity: sha512-jn7qwGFmJHwUSphV8zZneO3GmtlgLsmhs/LQyVvQbIIa+fzGMUiHI4HXJZL3FT8MJmgXWbLGiVVY7ElvHq6vDA==} deprecated: This is a stub types definition. sass provides its own type definitions, so you do not need this installed. dependencies: - sass: 1.65.1 + sass: 1.66.0 dev: true /@types/semver@7.5.0: @@ -1710,8 +1710,8 @@ packages: resolution: {integrity: sha512-J8I0B7wAn8piGoPhBroBfJWgMEJTMEL/2o8MCoCyWdaE7MRtpXhI10pj8IvcUvAECoGJ+SM1Pm+SvBqtbtZ5FQ==} dev: true - /@vercel/static-build@1.3.46: - resolution: {integrity: sha512-l0I2IvnUl5Ippn8SlsHPX3h+cTEvbolCMVVsMXP3OEZEkGxn/ffbDvEADux5hmbpEdnvKFNzsJEvTkv0Mm/WFA==} + /@vercel/static-build@1.4.0: + resolution: {integrity: sha512-rCFVBve9nFaXrqP0pGiPaDciTTJ8CHeage8blF8xOEYMYdFRCg5nzFAOPERwUvl80RNpZrnGC7eJKxTHxfY2Ew==} dependencies: '@vercel/gatsby-plugin-vercel-analytics': 1.0.10 '@vercel/gatsby-plugin-vercel-builder': 1.3.18 @@ -1729,8 +1729,8 @@ packages: ts-morph: 12.0.0 dev: true - /@vitejs/plugin-vue@4.2.3(vite@4.4.9)(vue@3.3.4): - resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==} + /@vitejs/plugin-vue@4.3.1(vite@4.4.9)(vue@3.3.4): + resolution: {integrity: sha512-tUBEtWcF7wFtII7ayNiLNDTCE1X1afySEo+XNVMNkFXaThENyCowIEX095QqbJZGTgoOcSVDJGlnde2NG4jtbQ==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: vite: ^4.0.0 @@ -1740,8 +1740,8 @@ packages: vue: 3.3.4 dev: true - /@vitest/coverage-v8@0.34.1(vitest@0.34.1): - resolution: {integrity: sha512-lRgUwjTMr8idXEbUPSNH4jjRZJXJCVY3BqUa+LDXyJVe3pldxYMn/r0HMqatKUGTp0Kyf1j5LfFoY6kRqRp7jw==} + /@vitest/coverage-v8@0.34.2(vitest@0.34.2): + resolution: {integrity: sha512-3VuDZPeGGd1zWtc0Tdj9cHSbFc8IQ0ffnWp9MlhItOkziN6HEf219meZ9cZheg/hJXrXb+Fi2bMu7GeCAfL4yA==} peerDependencies: vitest: '>=0.32.0 <1' dependencies: @@ -1756,65 +1756,65 @@ packages: std-env: 3.3.3 test-exclude: 6.0.0 v8-to-istanbul: 9.1.0 - vitest: 0.34.1(jsdom@22.1.0)(stylus@0.59.0) + vitest: 0.34.2(jsdom@22.1.0)(stylus@0.59.0) transitivePeerDependencies: - supports-color dev: true - /@vitest/expect@0.34.1: - resolution: {integrity: sha512-q2CD8+XIsQ+tHwypnoCk8Mnv5e6afLFvinVGCq3/BOT4kQdVQmY6rRfyKkwcg635lbliLPqbunXZr+L1ssUWiQ==} + /@vitest/expect@0.34.2: + resolution: {integrity: sha512-EZm2dMNlLyIfDMha17QHSQcg2KjeAZaXd65fpPzXY5bvnfx10Lcaz3N55uEe8PhF+w4pw+hmrlHLLlRn9vkBJg==} dependencies: - '@vitest/spy': 0.34.1 - '@vitest/utils': 0.34.1 + '@vitest/spy': 0.34.2 + '@vitest/utils': 0.34.2 chai: 4.3.7 dev: true - /@vitest/runner@0.34.1: - resolution: {integrity: sha512-YfQMpYzDsYB7yqgmlxZ06NI4LurHWfrH7Wy3Pvf/z/vwUSgq1zLAb1lWcItCzQG+NVox+VvzlKQrYEXb47645g==} + /@vitest/runner@0.34.2: + resolution: {integrity: sha512-8ydGPACVX5tK3Dl0SUwxfdg02h+togDNeQX3iXVFYgzF5odxvaou7HnquALFZkyVuYskoaHUOqOyOLpOEj5XTA==} dependencies: - '@vitest/utils': 0.34.1 + '@vitest/utils': 0.34.2 p-limit: 4.0.0 pathe: 1.1.1 dev: true - /@vitest/snapshot@0.34.1: - resolution: {integrity: sha512-0O9LfLU0114OqdF8lENlrLsnn024Tb1CsS9UwG0YMWY2oGTQfPtkW+B/7ieyv0X9R2Oijhi3caB1xgGgEgclSQ==} + /@vitest/snapshot@0.34.2: + resolution: {integrity: sha512-qhQ+xy3u4mwwLxltS4Pd4SR+XHv4EajiTPNY3jkIBLUApE6/ce72neJPSUQZ7bL3EBuKI+NhvzhGj3n5baRQUQ==} dependencies: magic-string: 0.30.2 pathe: 1.1.1 pretty-format: 29.6.2 dev: true - /@vitest/spy@0.34.1: - resolution: {integrity: sha512-UT4WcI3EAPUNO8n6y9QoEqynGGEPmmRxC+cLzneFFXpmacivjHZsNbiKD88KUScv5DCHVDgdBsLD7O7s1enFcQ==} + /@vitest/spy@0.34.2: + resolution: {integrity: sha512-yd4L9OhfH6l0Av7iK3sPb3MykhtcRN5c5K5vm1nTbuN7gYn+yvUVVsyvzpHrjqS7EWqn9WsPJb7+0c3iuY60tA==} dependencies: tinyspy: 2.1.1 dev: true - /@vitest/utils@0.34.1: - resolution: {integrity: sha512-/ql9dsFi4iuEbiNcjNHQWXBum7aL8pyhxvfnD9gNtbjR9fUKAjxhj4AA3yfLXg6gJpMGGecvtF8Au2G9y3q47Q==} + /@vitest/utils@0.34.2: + resolution: {integrity: sha512-Lzw+kAsTPubhoQDp1uVAOP6DhNia1GMDsI9jgB0yMn+/nDaPieYQ88lKqz/gGjSHL4zwOItvpehec9OY+rS73w==} dependencies: diff-sequences: 29.4.3 loupe: 2.3.6 pretty-format: 29.6.2 dev: true - /@volar/language-core@1.10.0: - resolution: {integrity: sha512-ddyWwSYqcbEZNFHm+Z3NZd6M7Ihjcwl/9B5cZd8kECdimVXUFdFi60XHWD27nrWtUQIsUYIG7Ca1WBwV2u2LSQ==} + /@volar/language-core@1.10.1: + resolution: {integrity: sha512-JnsM1mIPdfGPxmoOcK1c7HYAsL6YOv0TCJ4aW3AXPZN/Jb4R77epDyMZIVudSGjWMbvv/JfUa+rQ+dGKTmgwBA==} dependencies: - '@volar/source-map': 1.10.0 + '@volar/source-map': 1.10.1 dev: true - /@volar/source-map@1.10.0: - resolution: {integrity: sha512-/ibWdcOzDGiq/GM1JU2eX8fH1bvAhl66hfe8yEgLEzg9txgr6qb5sQ/DEz5PcDL75tF5H5sCRRwn8Eu8ezi9mw==} + /@volar/source-map@1.10.1: + resolution: {integrity: sha512-3/S6KQbqa7pGC8CxPrg69qHLpOvkiPHGJtWPkI/1AXCsktkJ6gIk/5z4hyuMp8Anvs6eS/Kvp/GZa3ut3votKA==} dependencies: muggle-string: 0.3.1 dev: true - /@volar/typescript@1.10.0: - resolution: {integrity: sha512-OtqGtFbUKYC0pLNIk3mHQp5xWnvL1CJIUc9VE39VdZ/oqpoBh5jKfb9uJ45Y4/oP/WYTrif/Uxl1k8VTPz66Gg==} + /@volar/typescript@1.10.1: + resolution: {integrity: sha512-+iiO9yUSRHIYjlteT+QcdRq8b44qH19/eiUZtjNtuh6D9ailYM7DVR0zO2sEgJlvCaunw/CF9Ov2KooQBpR4VQ==} dependencies: - '@volar/language-core': 1.10.0 + '@volar/language-core': 1.10.1 dev: true /@vue/compiler-core@3.3.4: @@ -1863,8 +1863,8 @@ packages: typescript: optional: true dependencies: - '@volar/language-core': 1.10.0 - '@volar/source-map': 1.10.0 + '@volar/language-core': 1.10.1 + '@volar/source-map': 1.10.1 '@vue/compiler-dom': 3.3.4 '@vue/reactivity': 3.3.4 '@vue/shared': 3.3.4 @@ -1930,7 +1930,7 @@ packages: /@vue/typescript@1.8.8(typescript@5.1.6): resolution: {integrity: sha512-jUnmMB6egu5wl342eaUH236v8tdcEPXXkPgj+eI/F6JwW/lb+yAU6U07ZbQ3MVabZRlupIlPESB7ajgAGixhow==} dependencies: - '@volar/typescript': 1.10.0 + '@volar/typescript': 1.10.1 '@vue/language-core': 1.8.8(typescript@5.1.6) transitivePeerDependencies: - typescript @@ -6020,8 +6020,8 @@ packages: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true - /sass@1.65.1: - resolution: {integrity: sha512-9DINwtHmA41SEd36eVPQ9BJKpn7eKDQmUHmpI0y5Zv2Rcorrh0zS+cFrt050hdNbmmCNKTW3hV5mWfuegNRsEA==} + /sass@1.66.0: + resolution: {integrity: sha512-C3U+RgpAAlTXULZkWwzfysgbbBBo8IZudNAOJAVBLslFbIaZv4MBPkTqhuvpK4lqgdoFiWhnOGMoV4L1FyOBag==} engines: {node: '>=14.0.0'} hasBin: true dependencies: @@ -6154,7 +6154,7 @@ packages: zhi-device: 2.3.1 zhi-fetch-middleware: 0.2.29 zhi-lib-base: 0.4.4 - zhi-siyuan-api: 2.2.3 + zhi-siyuan-api: 2.3.0 transitivePeerDependencies: - '@vue/composition-api' - typescript @@ -6842,8 +6842,8 @@ packages: convert-source-map: 1.9.0 dev: true - /vercel@31.3.1: - resolution: {integrity: sha512-p44vZUmcORejaGJgx2Fek2y63dCF3ni9rpvt6ffze0TT1Ucm5TxDZAr20qW3eKttXFBs8wB+TYC1/61F6JkXog==} + /vercel@31.4.0: + resolution: {integrity: sha512-jRzA3GyPiNckPN9aOiN63ulzgqEduTzALf4N8nh9UvCEzyEisCgtUxj2e+3xVWljdcGkj22VVij/DV4SnAXO6Q==} engines: {node: '>= 14'} hasBin: true dependencies: @@ -6856,7 +6856,7 @@ packages: '@vercel/redwood': 1.1.15 '@vercel/remix-builder': 1.10.1 '@vercel/ruby': 1.3.76 - '@vercel/static-build': 1.3.46 + '@vercel/static-build': 1.4.0 transitivePeerDependencies: - '@swc/core' - '@swc/wasm' @@ -6880,8 +6880,8 @@ packages: vfile-message: 2.0.4 dev: false - /vite-node@0.34.1(@types/node@18.17.5)(stylus@0.59.0): - resolution: {integrity: sha512-odAZAL9xFMuAg8aWd7nSPT+hU8u2r9gU3LRm9QKjxBEF2rRdWpMuqkrkjvyVQEdNFiBctqr2Gg4uJYizm5Le6w==} + /vite-node@0.34.2(@types/node@18.17.5)(stylus@0.59.0): + resolution: {integrity: sha512-JtW249Zm3FB+F7pQfH56uWSdlltCo1IOkZW5oHBzeQo0iX4jtC7o1t9aILMGd9kVekXBP2lfJBEQt9rBh07ebA==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -6922,8 +6922,8 @@ packages: vite: 4.4.9(@types/node@18.17.5)(stylus@0.59.0) dev: true - /vite-plugin-node-polyfills@0.11.1(vite@4.4.9): - resolution: {integrity: sha512-9bIZGzMhaGk2s/UC0fpDyIsPo5e33xAUAgZOav2GMgxC5KD48lgTecMmWgL326idrXmLGI12ef52CsKHSvSV6Q==} + /vite-plugin-node-polyfills@0.11.2(vite@4.4.9): + resolution: {integrity: sha512-KaMZ5Pgi5dT7Br21upTWNgkgyBPBBGHl9gQcv6fPfUa73v10mRgi88Rh7aLauvmdyqsLBmhJmRBbI9dmbVG9sA==} peerDependencies: vite: ^2.0.0 || ^3.0.0 || ^4.0.0 dependencies: @@ -6973,8 +6973,8 @@ packages: fsevents: 2.3.2 dev: true - /vitest@0.34.1(jsdom@22.1.0)(stylus@0.59.0): - resolution: {integrity: sha512-G1PzuBEq9A75XSU88yO5G4vPT20UovbC/2osB2KEuV/FisSIIsw7m5y2xMdB7RsAGHAfg2lPmp2qKr3KWliVlQ==} + /vitest@0.34.2(jsdom@22.1.0)(stylus@0.59.0): + resolution: {integrity: sha512-WgaIvBbjsSYMq/oiMlXUI7KflELmzM43BEvkdC/8b5CAod4ryAiY2z8uR6Crbi5Pjnu5oOmhKa9sy7uk6paBxQ==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -7007,11 +7007,11 @@ packages: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 '@types/node': 18.17.5 - '@vitest/expect': 0.34.1 - '@vitest/runner': 0.34.1 - '@vitest/snapshot': 0.34.1 - '@vitest/spy': 0.34.1 - '@vitest/utils': 0.34.1 + '@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 acorn: 8.10.0 acorn-walk: 8.2.0 cac: 6.7.14 @@ -7027,7 +7027,7 @@ packages: tinybench: 2.5.0 tinypool: 0.7.0 vite: 4.4.9(@types/node@18.17.5)(stylus@0.59.0) - vite-node: 0.34.1(@types/node@18.17.5)(stylus@0.59.0) + vite-node: 0.34.2(@types/node@18.17.5)(stylus@0.59.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -7408,8 +7408,8 @@ packages: - supports-color dev: false - /zhi-siyuan-api@2.2.3: - resolution: {integrity: sha512-Q2L5eG0mC1JYDwgA+rpexPUoRMMJBLhnSjWXR3ORXrNtVcB/s8eG2qAs9sGfJBkg3ohnlNPyTihBr/dC9NYNzQ==} + /zhi-siyuan-api@2.3.0: + resolution: {integrity: sha512-M6LccRXQ0wE0piQGBHIkgRIxOvkANSHNVTGmZha5WLnSdOSxeV10FIbMpEwRuK5BPBx7y0ZvHgWLs7L8GE7tTA==} dependencies: zhi-blog-api: 1.25.1 zhi-common: 1.20.0 diff --git a/src/adaptors/api/notion/notionApiAdaptor.ts b/src/adaptors/api/notion/notionApiAdaptor.ts index 135aa397..52c004de 100644 --- a/src/adaptors/api/notion/notionApiAdaptor.ts +++ b/src/adaptors/api/notion/notionApiAdaptor.ts @@ -79,6 +79,17 @@ class NotionApiAdaptor extends BaseBlogApi { const titles = notionPage?.properties?.title?.title ?? [] commonPost.title = titles.map((x: any) => x.plain_text).join("") commonPost.description = "暂不支持Notion正文" + + // const book = yuqueDoc.book + // const cats = [] + // const catSlugs = [] + // + // cats.push(book.name) + // commonPost.categories = cats + // + // catSlugs.push(book.namespace) + // commonPost.cate_slugs = catSlugs + return commonPost } diff --git a/src/adaptors/api/yuque/useYuqueApi.ts b/src/adaptors/api/yuque/useYuqueApi.ts index 1f5c6970..aaf3e6f2 100644 --- a/src/adaptors/api/yuque/useYuqueApi.ts +++ b/src/adaptors/api/yuque/useYuqueApi.ts @@ -31,6 +31,7 @@ import { useSettingStore } from "~/src/stores/useSettingStore.ts" import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common" import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts" import { YuqueApiAdaptor } from "~/src/adaptors/api/yuque/yuqueApiAdaptor.ts" +import { CategoryTypeEnum } from "zhi-blog-api" const useYuqueApi = async (key: string, newCfg?: YuqueConfig) => { // 创建应用日志记录器 @@ -73,6 +74,11 @@ const useYuqueApi = async (key: string, newCfg?: YuqueConfig) => { } } + // Yuque 使用单选分类 + cfg.categoryType = CategoryTypeEnum.CategoryType_Single + // 启用知识库作为分类 + cfg.enableKnowledgeSpace = true + // 创建 Yuque API 适配器 const blogApi = new YuqueApiAdaptor(appInstance, cfg) logger.info("Yuque API created successfully.", cfg) diff --git a/src/adaptors/api/yuque/yuqueApiAdaptor.ts b/src/adaptors/api/yuque/yuqueApiAdaptor.ts index 19281889..6421c84a 100644 --- a/src/adaptors/api/yuque/yuqueApiAdaptor.ts +++ b/src/adaptors/api/yuque/yuqueApiAdaptor.ts @@ -109,7 +109,7 @@ class YuqueApiAdaptor extends BaseBlogApi { // 只获取文档库 if (repo.type === "Book") { const cat = new CategoryInfo() - cat.categoryId = repo.slug + cat.categoryId = `${this.cfg.username}/${repo.slug}` cat.categoryName = repo.name cat.description = repo.name cat.categoryDescription = repo.name diff --git a/src/components/publish/BatchPublishIndex.vue b/src/components/publish/BatchPublishIndex.vue index 9ac38fea..d5921cf1 100644 --- a/src/components/publish/BatchPublishIndex.vue +++ b/src/components/publish/BatchPublishIndex.vue @@ -44,6 +44,7 @@ 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, ISingleCategoryConfig } from "~/src/types/ICategoryConfig.ts" const logger = createAppLogger("publisher-index") @@ -81,6 +82,9 @@ const formData = reactive({ siyuanPost: {} as Post, publishCfg: {} as IPublishCfg, + // 分类配置 + categoryConfig: {} as ICategoryConfig, + // ========================= // extra sync attrs start // ========================= @@ -253,6 +257,16 @@ onMounted(async () => { formData.siyuanPost = siyuanPost // 元数据初始化 formData.siyuanPost = await initPublishMethods.assignInitAttrs(formData.siyuanPost, id, formData.publishCfg) + + // 分类数据初始化 + formData.categoryConfig = { + cateEnabled: true, + readonlyMode: true, + pageId: id, + categories: formData.siyuanPost.categories, + cateSlugs: formData.siyuanPost.cate_slugs, + } as ISingleCategoryConfig + logger.debug("batch inited siyuanPost =>", toRaw(formData.siyuanPost)) // ================== // 初始化结束 @@ -346,7 +360,10 @@ onMounted(async () => { /> - + diff --git a/src/components/publish/SinglePublishDoPublish.vue b/src/components/publish/SinglePublishDoPublish.vue index da05237a..5b23dde2 100644 --- a/src/components/publish/SinglePublishDoPublish.vue +++ b/src/components/publish/SinglePublishDoPublish.vue @@ -29,7 +29,7 @@ import { useRoute, useRouter } from "vue-router" import BackPage from "~/src/components/common/BackPage.vue" import { usePublish } from "~/src/composables/usePublish.ts" import { MethodEnum } from "~/src/models/methodEnum.ts" -import { Post } from "zhi-blog-api" +import { BlogConfig, Post } from "zhi-blog-api" import { createAppLogger } from "~/src/utils/appLogger.ts" import { useVueI18n } from "~/src/composables/useVueI18n.ts" import { DynamicConfig } from "~/src/platforms/dynamicConfig.ts" @@ -46,6 +46,7 @@ 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" const logger = createAppLogger("single-publish-do-publish") @@ -74,17 +75,17 @@ const formData = reactive({ isPublishLoading: false, isDeleteLoading: false, - publishCfg: {} as IPublishCfg, - + // 单个平台信息 siyuanPost: {} as Post, platformPost: {} as Post, mergedPost: {} as Post, + publishCfg: {} as IPublishCfg, - postPreviewUrl: "", + // 分类配置 + categoryConfig: {} as ICategoryConfig, - changeTips: { - title: "", - }, + postPreviewUrl: "", + changeTips: { title: "" }, // ========================= // extra sync attrs start @@ -250,6 +251,12 @@ const syncTags = (val: string[]) => { logger.debug("syncTags in single publish") } +const syncCates = (cates: string[], cateSlugs: string[]) => { + formData.mergedPost.categories = cates + formData.mergedPost.cate_slugs = cateSlugs + logger.debug("syncCates in single publish") +} + const syncPublishTime = (val1: Date, val2: Date) => { formData.mergedPost.dateCreated = val1 formData.mergedPost.dateUpdated = val2 @@ -287,6 +294,7 @@ const initPage = async () => { formData.platformPost = platformPost formData.mergedPost = mergedPost + // 预览链接 formData.postPreviewUrl = postPreviewUrl // 刷新比对提示 @@ -314,6 +322,18 @@ onMounted(async () => { // 元数据初始化 formData.mergedPost = await initPublishMethods.assignInitAttrs(formData.mergedPost, id, formData.publishCfg) formData.isInit = true + + // 分类数据初始化 + const cfg = formData.publishCfg.cfg as BlogConfig + formData.categoryConfig = { + cateEnabled: true, + readonlyMode: formData.method === MethodEnum.METHOD_EDIT, + apiType: key, + cfg: cfg, + categories: formData.mergedPost.categories, + cateSlugs: formData.mergedPost.cate_slugs, + } + logger.debug("single publish inited mergedPost =>", toRaw(formData.mergedPost)) // ================== // 初始化结束 @@ -387,7 +407,11 @@ onMounted(async () => { /> - + diff --git a/src/components/publish/form/PublishCategories.vue b/src/components/publish/form/PublishCategories.vue index 9e2c9a30..1cadbbad 100644 --- a/src/components/publish/form/PublishCategories.vue +++ b/src/components/publish/form/PublishCategories.vue @@ -25,34 +25,62 @@ - - diff --git a/src/components/publish/form/category/MultiCategories.vue b/src/components/publish/form/category/MultiCategories.vue index 8e899ba3..75c05beb 100644 --- a/src/components/publish/form/category/MultiCategories.vue +++ b/src/components/publish/form/category/MultiCategories.vue @@ -24,13 +24,18 @@ --> - \ No newline at end of file + diff --git a/src/components/publish/form/category/SingleCategory.vue b/src/components/publish/form/category/SingleCategory.vue index b25244c5..46ecabdc 100644 --- a/src/components/publish/form/category/SingleCategory.vue +++ b/src/components/publish/form/category/SingleCategory.vue @@ -23,10 +23,180 @@ - questions. --> - + - + diff --git a/src/components/publish/form/category/TreeMultiCategories.vue b/src/components/publish/form/category/TreeMultiCategories.vue index 34114e42..2bd5e39e 100644 --- a/src/components/publish/form/category/TreeMultiCategories.vue +++ b/src/components/publish/form/category/TreeMultiCategories.vue @@ -24,15 +24,18 @@ --> - \ No newline at end of file + diff --git a/src/components/publish/form/category/TreeSingleCategory.vue b/src/components/publish/form/category/TreeSingleCategory.vue index 16867b68..9d185660 100644 --- a/src/components/publish/form/category/TreeSingleCategory.vue +++ b/src/components/publish/form/category/TreeSingleCategory.vue @@ -24,13 +24,18 @@ --> - \ No newline at end of file + diff --git a/src/composables/usePublish.ts b/src/composables/usePublish.ts index c9cf51ba..c9952c57 100644 --- a/src/composables/usePublish.ts +++ b/src/composables/usePublish.ts @@ -364,7 +364,6 @@ const usePublish = () => { if (method === MethodEnum.METHOD_ADD) { logger.info("Add, using siyuan post") - mergedPost = siyuanPost } else { logger.info("Reading post from remote platform") if (StrUtil.isEmptyString(postid)) { @@ -374,6 +373,7 @@ const usePublish = () => { // 查询平台文章 platformPost = await api.getPost(postid) // 更新属性 + mergedPost.cate_slugs = platformPost.cate_slugs // 更新预览链接 postPreviewUrl = await getPostPreviewUrl(api, postid, cfg) diff --git a/src/constants/siyuanAttr.ts b/src/constants/siyuanAttr.ts new file mode 100644 index 00000000..870938e2 --- /dev/null +++ b/src/constants/siyuanAttr.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * SiYuan属性枚举 + * + * @author terwer + * @since 1.9.0 + */ +enum SiyuanAttr { + /** + * 自定义slug属性 + */ + Custom_Slug = "custom-slug", + + /** + * 自定义categories属性 + */ + Custom_Categories = "custom-categories", +} + +export { SiyuanAttr } diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts index e818eefb..fc011bfe 100644 --- a/src/locales/en_US.ts +++ b/src/locales/en_US.ts @@ -556,4 +556,5 @@ 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", } diff --git a/src/locales/zh_CN.ts b/src/locales/zh_CN.ts index eff567a0..6cc6e3d1 100644 --- a/src/locales/zh_CN.ts +++ b/src/locales/zh_CN.ts @@ -282,7 +282,8 @@ export default { "yaml.show.type.html": "HTML正文", "main.read.mode": "只读模式", "main.edit.mode": "编辑模式", - "main.read.mode.tip1": "温馨提示:为了数据一致性,多平台分发或者未提供YAML适配器时无法处理平台属性,YAML将仅显示公共属性且只能只读。", + "main.read.mode.tip1": + "温馨提示:为了数据一致性,多平台分发或者未提供YAML适配器时无法处理平台属性,YAML将仅显示公共属性且只能只读。", "main.read.mode.tip2": "YAML如有修改,请务必点击保存按钮,否则修改内容将丢失!", "main.read.mode.tip3": "为了标识文章的唯一性,slug修改将忽略,其他属性可同步。", "main.read.mode.tip4": "此功能为高级功能,如果您不清楚YAML语法和用途,请勿修改!", @@ -544,4 +545,5 @@ export default { "setting.blog.siyuan.password": "思源Token", "setting.blog.siyuan.password.tip": "思源笔记鉴权Token,请从【设置->关于】复制,如果是本地笔记留空即可", "slogan.make.written.fun": "让创作回归乐趣", + "category.batch.not.supported": "注意:批量分发模式部分平台不支持公共分类,例如语雀、知乎等", } diff --git a/src/types/ICategoryConfig.ts b/src/types/ICategoryConfig.ts new file mode 100644 index 00000000..c9ceb773 --- /dev/null +++ b/src/types/ICategoryConfig.ts @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import { BlogConfig } from "zhi-blog-api" + +/** + * 类别接口配置 + * + * @author terwer + * @since 1.9.0 + */ +interface ICategoryConfig { + /** + * 是否启用类别 + */ + cateEnabled: boolean + + /** + * 是否只读模式 + */ + readonlyMode: boolean + + /** + * 思源笔记的文档ID + */ + pageId?: string + + /** + * API类型 + */ + apiType?: string + + /** + * 平台配置 + */ + cfg?: BlogConfig + + /** + * 类别列表 + */ + categories: string[] + + /** + * 类别链接列表 + */ + cateSlugs: string[] +} + +/** + * 类别配置接口 + * + * @author terwer + * @since 1.9.0 + */ +interface ISingleCategoryConfig extends ICategoryConfig {} + +/** + * 多个类别的配置 + * @author terwer + * @since 1.9.0 + */ +interface IMultiCategoriesConfig extends ICategoryConfig {} + +/** + * 树状结构中单个类别的配置 + * + * @author terwer + * @since 1.9.0 + */ +interface ITreeSingleCategoryConfig extends ICategoryConfig {} + +/** + * 树状结构中多个类别的配置 + * + * @author terwer + * @since 1.9.0 + */ +interface ITreeMultiCategoriesConfig extends ICategoryConfig {} + +export { + type ICategoryConfig, + type ISingleCategoryConfig, + type IMultiCategoriesConfig, + type ITreeSingleCategoryConfig, + type ITreeMultiCategoriesConfig, +}