Skip to content

Commit

Permalink
fix: 重构批量分发初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 22, 2023
1 parent 758d891 commit e0f7538
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 107 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@terwer/eslint-config-custom": "^1.3.6",
"@types/crypto-js": "^4.1.1",
"@types/node": "^18.17.6",
"@vitejs/plugin-vue": "^4.3.2",
"@vitejs/plugin-vue": "^4.3.3",
"@vitest/coverage-v8": "^0.34.2",
"@vue/test-utils": "^2.4.1",
"esbuild-plugin-copy": "^2.1.1",
Expand All @@ -47,7 +47,7 @@
"vercel": "^31.4.0",
"vite": "^4.4.9",
"vite-plugin-html": "^3.2.0",
"vite-plugin-node-polyfills": "^0.11.2",
"vite-plugin-node-polyfills": "^0.11.3",
"vitest": "^0.34.2",
"vue-tsc": "^1.8.8"
},
Expand All @@ -60,24 +60,25 @@
"crypto-js": "^4.1.1",
"element-plus": "^2.3.9",
"js-base64": "^3.7.5",
"lodash": "^4.17.21",
"pinia": "^2.1.6",
"shorthash2": "^1.0.3",
"simple-xmlrpc": "^1.4.2",
"siyuan": "^0.8.0",
"siyuan": "^0.8.1",
"siyuan-plugin-picgo": "^1.4.4",
"uuid": "^9.0.0",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.32.2",
"zhi-blog-api": "^1.33.1",
"zhi-common": "^1.23.1",
"zhi-device": "^2.3.1",
"zhi-fetch-middleware": "^0.3.5",
"zhi-github-middleware": "^0.3.5",
"zhi-lib-base": "^0.4.4",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.4.4",
"zhi-siyuan-api": "^2.5.1",
"zhi-xmlrpc-middleware": "^0.5.5"
}
}
87 changes: 45 additions & 42 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/components/publish/BatchPublishIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { isDev } from "~/src/utils/constants.ts"
import { ICategoryConfig } from "~/src/types/ICategoryConfig.ts"
import { SiyuanAttr } from "zhi-siyuan-api"
import { DistributionPattern } from "~/src/models/distributionPattern.ts"
import _ from "lodash"
const logger = createAppLogger("publisher-index")
Expand Down Expand Up @@ -118,34 +119,33 @@ const handlePublish = async () => {
formData.failBatchResults = []
formData.successBatchResults = []
// 思源笔记原始文章数据
const siyuanPost = _.cloneDeep(formData.siyuanPost) as Post
for (const key of formData.dynList) {
let batchItemPost: Post
if (sysKeys.includes(key)) {
logger.info(`开始发布 [${key}] 系统内置平台`)
batchItemPost = siyuanPost
} else {
logger.info(`开始发布 [${key}] 自定义平台`)
// 平台相关的配置,需要各自重新获取
const publishCfg = await getPublishCfg(key)
formData.publishCfg = publishCfg
// 思源笔记原始文章数据
const siyuanPost = await blogApi.getPost(id)
// 元数据初始化
formData.siyuanPost = await initPublishMethods.assignInitSlug(siyuanPost, id, formData.publishCfg)
// 平台相关的元数据初始化
batchItemPost = await initPublishMethods.assignInitAttrs(siyuanPost, id, formData.publishCfg)
// 合并模式需要重新获取
// 合并属性
if (formData.distriPattern === DistributionPattern.Merge) {
// 元数据初始化
const platformPost = await initPublishMethods.assignInitAttrs(siyuanPost, id, formData.publishCfg)
const mergedPost = initPublishMethods.doMergeBatchPost(formData.siyuanPost, platformPost)
batchItemPost = initPublishMethods.doMergeBatchPost(siyuanPost, batchItemPost)
logger.debug("批量分发模式文章已合并", {
siyuanPost: toRaw(siyuanPost),
platformPost: toRaw(platformPost),
mergedPost: toRaw(mergedPost),
mergedPost: toRaw(batchItemPost),
})
}
}
const batchResult = await doSinglePublish(key, id, formData.publishCfg, formData.siyuanPost)
const batchResult = await doSinglePublish(key, id, formData.publishCfg, batchItemPost)
if (batchResult.status) {
formData.successBatchResults.push(batchResult)
} else {
Expand Down
Loading

0 comments on commit e0f7538

Please sign in to comment.