From 782f4fb05cb8494be91f64b06028be6e5e2225a9 Mon Sep 17 00:00:00 2001 From: terwer Date: Wed, 16 Aug 2023 23:12:54 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- pnpm-lock.yaml | 20 +++++----- src/adaptors/api/hexo/useHexoApi.ts | 4 ++ src/adaptors/index.ts | 22 ++++++----- src/components/publish/BatchPublishIndex.vue | 7 ++-- .../publish/SinglePublishDoPublish.vue | 5 +-- .../publish/form/PublishCategories.vue | 32 +++++++++++++--- .../publish/form/category/MultiCategories.vue | 2 +- .../publish/form/category/SingleCategory.vue | 10 ++--- .../form/category/TreeMultiCategories.vue | 38 +++++++++++++++++++ ...eCategories.vue => TreeSingleCategory.vue} | 2 +- src/composables/usePublishConfig.ts | 3 +- 12 files changed, 104 insertions(+), 45 deletions(-) create mode 100644 src/components/publish/form/category/TreeMultiCategories.vue rename src/components/publish/form/category/{TreeCategories.vue => TreeSingleCategory.vue} (97%) diff --git a/package.json b/package.json index f0c305e7..fc282cd5 100644 --- a/package.json +++ b/package.json @@ -70,14 +70,14 @@ "vue-i18n": "^9.2.2", "vue-router": "^4.2.4", "xmlbuilder2": "^3.1.1", - "zhi-blog-api": "^1.24.1", + "zhi-blog-api": "^1.25.1", "zhi-common": "^1.20.0", "zhi-device": "^2.3.1", "zhi-fetch-middleware": "^0.2.29", "zhi-github-middleware": "^0.2.9", "zhi-lib-base": "^0.4.4", "zhi-notion-markdown": "^0.1.4", - "zhi-siyuan-api": "^2.2.1", + "zhi-siyuan-api": "^2.2.3", "zhi-xmlrpc-middleware": "^0.4.23" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f3cb3fa..eb6a5376 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ dependencies: specifier: ^3.1.1 version: 3.1.1 zhi-blog-api: - specifier: ^1.24.1 - version: 1.24.1 + specifier: ^1.25.1 + version: 1.25.1 zhi-common: specifier: ^1.20.0 version: 1.20.0 @@ -81,8 +81,8 @@ dependencies: specifier: ^0.1.4 version: 0.1.4 zhi-siyuan-api: - specifier: ^2.2.1 - version: 2.2.1 + specifier: ^2.2.3 + version: 2.2.3 zhi-xmlrpc-middleware: specifier: ^0.4.23 version: 0.4.23 @@ -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.1 + zhi-siyuan-api: 2.2.3 transitivePeerDependencies: - '@vue/composition-api' - typescript @@ -7346,8 +7346,8 @@ packages: engines: {node: '>=12.20'} dev: true - /zhi-blog-api@1.24.1: - resolution: {integrity: sha512-eTYC4unGn02DPDiZOfdTgFZmws0aEojdoEavJxyrpii4Uaw/9ABdOaV6FP4+7pGVIZZpoogMXNyvEn25nVv3VQ==} + /zhi-blog-api@1.25.1: + resolution: {integrity: sha512-7Nog6oSyS/5hs0AzAVyURerUvfX3eSca44ppLloYHgOcGMeMHPhNzJIdaGSBYOW4Em3IqxNYwYm4qufpYwHT9g==} dependencies: zhi-common: 1.20.0 zhi-lib-base: 0.4.4 @@ -7408,10 +7408,10 @@ packages: - supports-color dev: false - /zhi-siyuan-api@2.2.1: - resolution: {integrity: sha512-mGSfbm4CHd7RcJ4hOHtIFCgvBl+0u1hTB6qv5NOCbod6+g9pF3XfOlxc45jok1AM/9OOZ9a20pANTYZ3Zpa+TA==} + /zhi-siyuan-api@2.2.3: + resolution: {integrity: sha512-Q2L5eG0mC1JYDwgA+rpexPUoRMMJBLhnSjWXR3ORXrNtVcB/s8eG2qAs9sGfJBkg3ohnlNPyTihBr/dC9NYNzQ==} dependencies: - zhi-blog-api: 1.24.1 + zhi-blog-api: 1.25.1 zhi-common: 1.20.0 zhi-lib-base: 0.4.4 dev: false diff --git a/src/adaptors/api/hexo/useHexoApi.ts b/src/adaptors/api/hexo/useHexoApi.ts index d1edd9d4..f9b93ab9 100644 --- a/src/adaptors/api/hexo/useHexoApi.ts +++ b/src/adaptors/api/hexo/useHexoApi.ts @@ -32,6 +32,7 @@ import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts" import { HexoConfig } from "~/src/adaptors/api/hexo/hexoConfig.ts" import { HexoApiAdaptor } from "~/src/adaptors/api/hexo/hexoApiAdaptor.ts" import { HexoYamlConverterAdaptor } from "~/src/adaptors/api/hexo/hexoYamlConverterAdaptor.ts" +import { CategoryTypeEnum } from "zhi-blog-api" const useHexoApi = async (key: string, newCfg?: HexoConfig) => { // 创建应用日志记录器 @@ -76,6 +77,9 @@ const useHexoApi = async (key: string, newCfg?: HexoConfig) => { } } + // Hexo 使用树形单选分类 + cfg.categoryType = CategoryTypeEnum.CategoryType_Tree_Single + // 创建 Hexo 的 yamlAdaptor const yamlAdaptor = new HexoYamlConverterAdaptor() diff --git a/src/adaptors/index.ts b/src/adaptors/index.ts index 191f74a3..a491ca48 100644 --- a/src/adaptors/index.ts +++ b/src/adaptors/index.ts @@ -23,7 +23,7 @@ * questions. */ -import { BlogAdaptor, BlogConfig, WebAdaptor } from "zhi-blog-api" +import { BlogAdaptor, WebAdaptor } from "zhi-blog-api" import { getSubPlatformTypeByKey, SubPlatformType } from "~/src/platforms/dynamicConfig.ts" import { useCnblogsApi } from "~/src/adaptors/api/cnblogs/useCnblogsApi.ts" import { createAppLogger } from "~/src/utils/appLogger.ts" @@ -36,6 +36,7 @@ import { useMetaweblogApi } from "~/src/adaptors/api/metaweblog/useMetaweblogApi import { useNotionApi } from "~/src/adaptors/api/notion/useNotionApi.ts" import { useHexoApi } from "~/src/adaptors/api/hexo/useHexoApi.ts" import { YamlConvertAdaptor } from "~/src/platforms/yamlConvertAdaptor.ts" +import { CommonBlogConfig } from "~/src/adaptors/api/base/commonBlogConfig.ts" /** * 适配器统一入口 @@ -50,49 +51,50 @@ class Adaptors { * 根据平台key查找配置 * * @param key + * @param newCfg */ - public static async getCfg(key: string): Promise { + public static async getCfg(key: string, newCfg?: any): Promise { let conf = null const type: SubPlatformType = getSubPlatformTypeByKey(key) switch (type) { case SubPlatformType.Common_Yuque: { - const { cfg } = await useYuqueApi(key) + const { cfg } = await useYuqueApi(key, newCfg) conf = cfg break } case SubPlatformType.Common_Notion: { - const { cfg } = await useNotionApi(key) + const { cfg } = await useNotionApi(key, newCfg) conf = cfg break } case SubPlatformType.Github_Hexo: { - const { cfg } = await useHexoApi(key) + const { cfg } = await useHexoApi(key, newCfg) conf = cfg break } case SubPlatformType.Metaweblog_Metaweblog: { - const { cfg } = await useMetaweblogApi(key) + const { cfg } = await useMetaweblogApi(key, newCfg) conf = cfg break } case SubPlatformType.Metaweblog_Cnblogs: { - const { cfg } = await useCnblogsApi(key) + const { cfg } = await useCnblogsApi(key, newCfg) conf = cfg break } case SubPlatformType.Metaweblog_Typecho: { - const { cfg } = await useTypechoApi(key) + const { cfg } = await useTypechoApi(key, newCfg) conf = cfg break } case SubPlatformType.Wordpress_Wordpress: { - const { cfg } = await useWordpressApi(key) + const { cfg } = await useWordpressApi(key, newCfg) conf = cfg break } case SubPlatformType.Custom_Zhihu: { - const { cfg } = await useZhihuWeb(key) + const { cfg } = await useZhihuWeb(key, newCfg) conf = cfg break } diff --git a/src/components/publish/BatchPublishIndex.vue b/src/components/publish/BatchPublishIndex.vue index ef1d5aec..9ac38fea 100644 --- a/src/components/publish/BatchPublishIndex.vue +++ b/src/components/publish/BatchPublishIndex.vue @@ -37,7 +37,7 @@ import { pre } from "~/src/utils/import/pre.ts" import { Delete } from "@element-plus/icons-vue" import { BrowserUtil } from "zhi-device" import { usePublishConfig } from "~/src/composables/usePublishConfig.ts" -import { Post } from "zhi-blog-api" +import { CategoryTypeEnum, Post } from "zhi-blog-api" import { IPublishCfg } from "~/src/types/IPublishCfg.ts" import { PageEditMode } from "~/src/models/pageEditMode.ts" import EditModeSelect from "~/src/components/publish/form/EditModeSelect.vue" @@ -345,9 +345,8 @@ onMounted(async () => { @emitSyncTags="syncTags" /> - + + diff --git a/src/components/publish/SinglePublishDoPublish.vue b/src/components/publish/SinglePublishDoPublish.vue index dae381f6..da05237a 100644 --- a/src/components/publish/SinglePublishDoPublish.vue +++ b/src/components/publish/SinglePublishDoPublish.vue @@ -386,9 +386,8 @@ onMounted(async () => { @emitSyncTags="syncTags" /> - + + diff --git a/src/components/publish/form/PublishCategories.vue b/src/components/publish/form/PublishCategories.vue index 4769b115..9e2c9a30 100644 --- a/src/components/publish/form/PublishCategories.vue +++ b/src/components/publish/form/PublishCategories.vue @@ -24,15 +24,35 @@ --> - \ No newline at end of file + diff --git a/src/components/publish/form/category/MultiCategories.vue b/src/components/publish/form/category/MultiCategories.vue index 1577176b..8e899ba3 100644 --- a/src/components/publish/form/category/MultiCategories.vue +++ b/src/components/publish/form/category/MultiCategories.vue @@ -28,7 +28,7 @@ \ No newline at end of file + diff --git a/src/components/publish/form/category/TreeMultiCategories.vue b/src/components/publish/form/category/TreeMultiCategories.vue new file mode 100644 index 00000000..34114e42 --- /dev/null +++ b/src/components/publish/form/category/TreeMultiCategories.vue @@ -0,0 +1,38 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/publish/form/category/TreeCategories.vue b/src/components/publish/form/category/TreeSingleCategory.vue similarity index 97% rename from src/components/publish/form/category/TreeCategories.vue rename to src/components/publish/form/category/TreeSingleCategory.vue index 1577176b..16867b68 100644 --- a/src/components/publish/form/category/TreeCategories.vue +++ b/src/components/publish/form/category/TreeSingleCategory.vue @@ -28,7 +28,7 @@