Skip to content

Commit

Permalink
feat: 支持文章分类-公共分类
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 19, 2023
1 parent 17538ca commit 66d3b54
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 49 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ Publish articles from siyuan-note to platforms such as Yuque, Notion, Cnblogs, W

Support features such as fast publishing, image bed management, platform expansion, smart labels, etc.

> **Front Announcement 1: `1.9.0` version of the Publish Tool, the first to support release view and AI beta early adopter version, is released!**
> **Front Announcement 1: The first version `1.9.0` for Publish Tools that supports release view and AI beta early adopter is released!**
>
> **Note: Due to cost relationships, AI features will be charged after the end of the Common Test.**
>
> **Front Announcement 2: The version `1.8.0` that fully supports image upload for all platforms and the forward agent using siyuan-note is released!**
> **Front Announcement 2: Version `1.8.0` released with full support for image upload in the Publish Tools!**
Tips: Zhihu uses the image upload of the Zhihu platform, Yuque, Notion, and Hexo need Picgo plugin support, and the Metaweblog series platform supports both Picgo plugin and self-contained image upload (install Picgo plugin to use Picgo plugin, otherwise use their own platform)

Expand Down Expand Up @@ -56,13 +54,13 @@ This plugin supports almost all devices and platforms of Siyuan Note, and the sp
Names not listed in order

- [X] Yuque
- [X] Notion
- [X] Github
- [X] Hexo
- [X] Metaweblog
- [X] Cnblogs
- [X] Typecho
- [X] WordPress
- [X] Github
- [X] Hexo
- [X] Notion
- [X] Zhihu

## Core Features
Expand Down Expand Up @@ -176,4 +174,4 @@ more useful tools~
|Svelte|3.57+|Rich Harris|
|TypeScript|5.0+|Microsoft|
|siyuan-note|2.9.0+|D,V|
- Thanks to [leolee9086](https://github.com/leolee9086) for the icon resource
- Thanks to [leolee9086](https://github.com/leolee9086) and [ciwoyipang]() for the icon resource
14 changes: 6 additions & 8 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

将思源笔记的文章发布到语雀、Notion、Cnblogs、WordPress、Typecho、Hexo、知乎 等平台,支持极速发布、图床管理、平台扩展、智能标签等特色功能。

> **前排公告1:发布工具首个支持发布视图以及AI公测尝鲜版的版本 `1.9.0` 发布!**
> **前排公告1:发布工具首个支持发布视图以及AI公测尝鲜的版本 `1.9.0` 发布!**
>
> **注意:鉴于成本关系,AI功能在公测结束后会收费。**
>
> **前排公告2:发布工具完整支持图片上传以及全平台使用思源笔记正向代理的版本 `1.8.0` 发布!**
> **前排公告2:发布工具完整支持图片上传的版本 `1.8.0` 发布!**
温馨提示:知乎使用知乎平台的图片上传,语雀、Notion、Hexo需要Picgo插件支持,Metaweblog系列平台同时支持Picgo插件和自带图片上传(安装了Picgo插件使用Picgo插件,否则使用自带)

Expand Down Expand Up @@ -55,13 +53,13 @@
排名不分先后

- [X] 语雀
- [X] 博客园
- [X] Notion
- [X] Github
- [X] Hexo
- [X] Metaweblog
- [X] 博客园
- [X] Typecho
- [X] WordPress
- [X] Github
- [X] Hexo
- [X] Notion
- [X] 知乎

## 核心特色
Expand Down
3 changes: 2 additions & 1 deletion src/adaptors/api/hexo/useHexoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const useHexoApi = async (key: string, newCfg?: HexoConfig) => {
}

// Hexo 使用树形单选分类
cfg.categoryType = CategoryTypeEnum.CategoryType_Tree_Single
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.knowledgeSpaceType = CategoryTypeEnum.CategoryType_Tree_Single

// 创建 Hexo 的 yamlAdaptor
const yamlAdaptor = new HexoYamlConverterAdaptor()
Expand Down
23 changes: 4 additions & 19 deletions src/components/publish/BatchPublishIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ const syncTags = (val: string[]) => {
logger.debug("syncTags in batch publish")
}
const syncCates = (cates: string[], cateSlugs: string[]) => {
const syncCates = (cates: string[]) => {
formData.siyuanPost.categories = cates
formData.siyuanPost.cate_slugs = cateSlugs
logger.debug("syncCates in batch publish")
}
Expand All @@ -264,16 +263,6 @@ onMounted(async () => {
// 元数据初始化
formData.siyuanPost = await initPublishMethods.assignInitAttrs(formData.siyuanPost, id, formData.publishCfg)
// 分类数据初始化
formData.categoryConfig = {
cateEnabled: true,
readonlyMode: false,
readonlyModeTip: t("category.batch.not.supported"),
pageId: id,
categories: formData.siyuanPost.categories,
cateSlugs: formData.siyuanPost.cate_slugs,
} as ISingleCategoryConfig
logger.debug("batch inited siyuanPost =>", toRaw(formData.siyuanPost))
// ==================
// 初始化结束
Expand Down Expand Up @@ -341,7 +330,7 @@ onMounted(async () => {

<div v-if="formData.editType === PageEditMode.EditMode_complex" class="complex-mode">
<!-- AI开关 -->
<ai-switch v-model:use-ai="formData.useAi" @emitSyncAiSwitch="syncAiSwitch" />
<ai-switch v-if="formData.useAi" v-model:use-ai="formData.useAi" @emitSyncAiSwitch="syncAiSwitch" />

<!-- 别名 -->
<el-form-item :label="t('main.slug')">
Expand All @@ -366,12 +355,8 @@ onMounted(async () => {
@emitSyncTags="syncTags"
/>

<!-- 分类 -->
<publish-categories
v-model:category-type="CategoryTypeEnum.CategoryType_Multi"
v-model:category-config="formData.categoryConfig"
@emitSyncCates="syncCates"
/>
<!-- 公共分类 -->
<common-categories v-model:cates="formData.siyuanPost.categories" @emitSyncCates="syncCates" />

<!-- 发布时间 -->
<publish-time v-model="formData.siyuanPost" @emitSyncPublishTime="syncPublishTime" />
Expand Down
28 changes: 25 additions & 3 deletions src/components/publish/SinglePublishDoPublish.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 AiSwitch from "~/src/components/publish/form/AiSwitch.vue"
import { pre } from "~/src/utils/import/pre.ts"
import { ICategoryConfig } from "~/src/types/ICategoryConfig.ts"
import PublishKnowledgeSpace from "~/src/components/publish/form/PublishKnowledgeSpace.vue";
const logger = createAppLogger("single-publish-do-publish")
Expand Down Expand Up @@ -83,6 +84,8 @@ const formData = reactive({
// 分类配置
categoryConfig: {} as ICategoryConfig,
// 知识空间配置
knowledgeSpaceConfig: {} as ICategoryConfig,
postPreviewUrl: "",
changeTips: { title: "" },
Expand Down Expand Up @@ -258,12 +261,16 @@ const syncTags = (val: string[]) => {
logger.debug("syncTags in single publish")
}
const syncCates = (cates: string[], cateSlugs: string[]) => {
const syncCates = (cates: string[]) => {
formData.mergedPost.categories = cates
formData.mergedPost.cate_slugs = cateSlugs
logger.debug("syncCates in single publish")
}
const syncCateSlugs = (cateSlugs: string[]) => {
formData.mergedPost.cate_slugs = cateSlugs
logger.debug("syncCateSlugs in single publish")
}
const syncPublishTime = (val1: Date, val2: Date) => {
formData.mergedPost.dateCreated = val1
formData.mergedPost.dateUpdated = val2
Expand Down Expand Up @@ -330,15 +337,23 @@ 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 && !cfg.allowCateChange,
readonlyModeTip: cfg.placeholder.cateReadonlyModeTip,
apiType: key,
cfg: cfg,
categories: formData.mergedPost.categories,
}
// 知识空间
formData.knowledgeSpaceConfig = {
cateEnabled: true,
readonlyMode: formData.method === MethodEnum.METHOD_EDIT && !cfg.allowCateChange,
readonlyModeTip: cfg.placeholder.cateReadonlyModeTip,
apiType: key,
cfg: cfg,
cateSlugs: formData.mergedPost.cate_slugs,
}
Expand Down Expand Up @@ -421,6 +436,13 @@ onMounted(async () => {
@emitSyncCates="syncCates"
/>

<!-- 知识空间 -->
<publish-knowledge-space
v-model:category-type="formData.publishCfg.cfg.knowledgeSpaceType"
v-model:category-config="formData.knowledgeSpaceConfig"
@emitSyncCates="syncCateSlugs"
/>

<!-- 发布时间 -->
<publish-time v-model="formData.mergedPost" @emitSyncPublishTime="syncPublishTime" />

Expand Down
127 changes: 127 additions & 0 deletions src/components/publish/form/CommonCategories.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<!--
- 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.
-->

<script setup lang="ts">
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { useVueI18n } from "~/src/composables/useVueI18n.ts"
import { nextTick, reactive, ref } from "vue"
import { StrUtil } from "zhi-common"
const logger = createAppLogger("common-categories")
const { t } = useVueI18n()
const props = defineProps({
cates: {
type: Array,
default: [],
},
})
// datas
const tagRefInput = ref()
const formData = reactive({
cate: {
inputValue: "",
dynamicCates: <string[]>(props.cates.length == 0 ? [] : props.cates),
inputVisible: false,
},
})
const emit = defineEmits(["emitSyncCates"])
const cateMethods = {
handleTagClose: (tag: any) => {
formData.cate.dynamicCates.splice(formData.cate.dynamicCates.indexOf(tag), 1)
emit("emitSyncCates", formData.cate.dynamicCates)
},
tagShowInput: () => {
formData.cate.inputVisible = true
nextTick(() => {
tagRefInput.value!.input!.focus()
})
},
handleTagInputConfirm: () => {
if (formData.cate.inputValue) {
formData.cate.dynamicCates.push(formData.cate.inputValue)
emit("emitSyncCates", formData.cate.dynamicCates)
}
formData.cate.inputVisible = false
formData.cate.inputValue = ""
},
}
</script>

<template>
<div class="form-tag-cates">
<el-form-item :label="t('main.commonn.cate.title')">
<el-tag
v-for="tag in formData.cate.dynamicCates"
:key="tag"
:disable-transitions="false"
class="mx-1 pub-tag"
closable
@close="cateMethods.handleTagClose(tag)"
>
{{ tag }}
</el-tag>
<el-input
v-if="formData.cate.inputVisible"
ref="tagRefInput"
v-model="formData.cate.inputValue"
class="ml-1 w-20 pub-tag-input"
size="small"
@blur="cateMethods.handleTagInputConfirm"
@keyup.enter="cateMethods.handleTagInputConfirm"
/>
<el-button v-else class="button-new-tag ml-1 el-tag" size="small" @click="cateMethods.tagShowInput">
{{ t("main.cate.new") }}
</el-button>
</el-form-item>
<el-form-item>
<el-alert :closable="false" :title="t('category.batch.not.supported')" class="form-item-tip form-item-bottom" type="warning" />
</el-form-item>
</div>
</template>

<style lang="stylus" scoped>
.form-item-tip
padding 2px 4px
margin 0 10px 0 0
.form-item-bottom
margin-bottom 16px
.form-tag-cates
:deep(.el-form-item)
margin-bottom 0
:deep(.pub-tag)
margin-right 10px
:deep(.pub-tag-input)
max-width 120px
</style>
Loading

0 comments on commit 66d3b54

Please sign in to comment.