Skip to content

Commit

Permalink
feat: 支持文章标签
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 16, 2023
1 parent d94f96a commit 37833d1
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 42 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.24.0",
"zhi-common": "^1.19.0",
"zhi-blog-api": "^1.24.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.0",
"zhi-siyuan-api": "^2.2.1",
"zhi-xmlrpc-middleware": "^0.4.23"
}
}
40 changes: 20 additions & 20 deletions pnpm-lock.yaml

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

13 changes: 11 additions & 2 deletions src/components/publish/BatchPublishIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ onMounted(async () => {

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

<!-- 别名 -->
<el-form-item :label="t('main.slug')">
Expand All @@ -332,7 +332,16 @@ onMounted(async () => {
/>

<!-- 标签 -->
<publish-tags />
<publish-tags
v-model:use-ai="formData.useAi"
v-model:page-id="id"
v-model:tags="formData.siyuanPost.mt_keywords"
v-model:content="formData.siyuanPost.html"
/>

<!-- 分类
<publish-categories />
-->

<!-- 发布时间 -->
<publish-time v-model="formData.siyuanPost" @emitSyncPublishTime="syncPublishTime" />
Expand Down
6 changes: 5 additions & 1 deletion src/components/publish/SinglePublishDoPublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-->

<script setup lang="ts">
import { markRaw, onMounted, reactive } from "vue"
import {markRaw, onMounted, reactive, toRaw} from "vue"
import { useRoute, useRouter } from "vue-router"
import BackPage from "~/src/components/common/BackPage.vue"
import { usePublish } from "~/src/composables/usePublish.ts"
Expand Down Expand Up @@ -309,6 +309,7 @@ onMounted(async () => {
// 元数据初始化
formData.mergedPost = await initPublishMethods.assignInitAttrs(formData.mergedPost, id, formData.publishCfg)
formData.isInit = true
logger.debug("single publish inited mergedPost =>", toRaw(formData.mergedPost))
// ==================
// 初始化结束
// ==================
Expand Down Expand Up @@ -374,6 +375,9 @@ onMounted(async () => {
<!-- 标签 -->
<publish-tags />

<!-- 分类 -->
<publish-categories />

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

Expand Down
12 changes: 11 additions & 1 deletion src/components/publish/form/AiSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ const onAiSwitchChange = (val: boolean) => {
emit("emitSyncAiSwitch", formData.useAi)
})
} else {
emit("emitSyncAiSwitch", formData.useAi)
ElMessageBox.confirm(`人工智能服务关闭之后将使用基础功能,是否继续?`, "温馨提示", {
type: "error",
icon: markRaw(Warning),
confirmButtonText: t("main.opt.ok"),
cancelButtonText: t("main.opt.cancel"),
})
.then(async () => {
emit("emitSyncAiSwitch", formData.useAi)
ElMessage.warning("人工智能服务[内测版]已关闭,将使用基础功能!")
})
.catch(() => {})
}
}
</script>
Expand Down
38 changes: 38 additions & 0 deletions src/components/publish/form/PublishCategories.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
- 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">

</script>

<template>
<div>
发布分类
</div>
</template>

<style scoped lang="stylus">

</style>
16 changes: 10 additions & 6 deletions src/components/publish/form/PublishDescription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ watch(
() => props.useAi,
(newValue) => {
formData.useAi = newValue
alert(111)
}
)

Expand All @@ -77,7 +76,6 @@ const handleMakeDesc = async () => {
formData.isDescLoading = true
try {
if (formData.useAi) {
ElMessage.warning("使用人工智能提取摘要")
if (StrUtil.isEmptyString(formData.html)) {
throw new Error("正文为空,无法生成摘要")
}
Expand All @@ -89,12 +87,12 @@ const handleMakeDesc = async () => {
} else {
formData.desc = result.result
}
ElMessage.warning("使用人工智能提取摘要成功")
} else {
formData.desc = HtmlUtil.parseHtml(formData.html, MAX_PREVIEW_LENGTH, true)
ElMessage.info(`未开启人工智能,直接截取文章前${MAX_PREVIEW_LENGTH}个字符作为摘要`)
ElMessage.success(`操作成功,未开启人工智能,直接截取文章前${MAX_PREVIEW_LENGTH}个字符作为摘要`)
}

ElMessage.success(t("main.opt.success"))
// ElMessage.success(t("main.opt.success"))
} catch (e) {
logger.error(t("main.opt.failure") + "=>", e)
ElMessage.error(t("main.opt.failure") + "=>", e)
Expand All @@ -112,7 +110,13 @@ const onDescChange = () => {
<template>
<div class="form-desc">
<el-form-item :label="t('main.desc')">
<el-input v-model="formData.desc" :autosize="{ minRows: 3, maxRows: 16 }" type="textarea" @input="onDescChange" />
<el-input
v-model="formData.desc"
:autosize="{ minRows: 3, maxRows: 16 }"
type="textarea"
placeholder="请输入文章摘要"
@input="onDescChange"
/>
</el-form-item>
<el-form-item>
<el-button size="small" :loading="formData.isDescLoading" type="primary" @click="handleMakeDesc">
Expand Down
Loading

0 comments on commit 37833d1

Please sign in to comment.