diff --git a/src/adaptors/web/juejin/juejinWebAdaptor.ts b/src/adaptors/web/juejin/juejinWebAdaptor.ts index d80ba0da..08fd48bd 100644 --- a/src/adaptors/web/juejin/juejinWebAdaptor.ts +++ b/src/adaptors/web/juejin/juejinWebAdaptor.ts @@ -190,6 +190,39 @@ class JuejinWebAdaptor extends BaseWebApi { return true } + public async getPost(postid: string, useSlug?: boolean): Promise { + const juejinPostKey = this.getJuejinPostidKey(postid) + const pageId = juejinPostKey.pageId + + const url = "https://api.juejin.cn/content_api/v1/article/detail" + const params = { + article_id: pageId, + } + const res = await this.webProxyFetch(url, [], params, "POST") + this.logger.debug("juejin get post res =>", res) + if (res.err_no !== 0) { + throw new Error("掘金文章获取失败 =>" + res.err_msg) + } + + const commonPost = new Post() + + // 掘金标签 + const tags = res.data.tags ?? [] + const tagSlugs = [] + tags.forEach((item: any) => { + tagSlugs.push(item.tag_id) + }) + commonPost.tags_slugs = tagSlugs.join(",") + + // 掘金分类 + const cate = res.data.category.category_id + const catSlugs = [] + catSlugs.push(cate) + commonPost.cate_slugs = catSlugs + + return commonPost + } + public async getCategories(): Promise { const cats = [] as CategoryInfo[] diff --git a/src/components/publish/SinglePublishDoPublish.vue b/src/components/publish/SinglePublishDoPublish.vue index 5655058d..946f5c85 100644 --- a/src/components/publish/SinglePublishDoPublish.vue +++ b/src/components/publish/SinglePublishDoPublish.vue @@ -255,7 +255,8 @@ const getBlogName = () => { if (formData.mergedPost?.categories?.length > 0) { cateName = formData.mergedPost?.categories[0] } else { - cateName = formData.mergedPost?.cate_slugs[0] + // cateName = formData.mergedPost?.cate_slugs[0] + cateName = "" } blogName = cateName ?? "" } diff --git a/src/components/publish/form/kwspace/SingleKnowledgeSpace.vue b/src/components/publish/form/kwspace/SingleKnowledgeSpace.vue index 9e918fa0..0ec34fc8 100644 --- a/src/components/publish/form/kwspace/SingleKnowledgeSpace.vue +++ b/src/components/publish/form/kwspace/SingleKnowledgeSpace.vue @@ -52,6 +52,8 @@ const formData = reactive({ categorySelected: "", categoryList: [], }, + + isInit: false }) // emits @@ -99,12 +101,19 @@ const initPage = async () => { } onMounted(async () => { - await initPage() + try { + await initPage() + } catch (e) { + logger.error("知识空间加载失败", e) + } finally { + formData.isInit = true + } })