From 0f01c674673f4580d0c73d9db645d6f83c8818d2 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Sat, 9 Sep 2023 16:30:17 +0800 Subject: [PATCH] fix: category BUG --- src/language/en.ts | 14 ++++++------ .../content/article/components/TopicPart.vue | 6 ++--- src/views/edit/components/Button.vue | 22 ++++++++++++------- src/views/edit/components/category.ts | 6 ++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/language/en.ts b/src/language/en.ts index 0fc46785..2020105e 100644 --- a/src/language/en.ts +++ b/src/language/en.ts @@ -129,21 +129,21 @@ export default { default: 'Default', essential: 'Essential', full: 'Full', - tagsHint: 'Hot Keywords', + tagsHint: 'Hot Tags', refresh: 'Refresh the page', help1: "The topic's title length should be between 1 and 40 characters.", help2: "You can click on the left settings to adjust the editor's mode.", help3: "The website's code is handwritten, and errors are inevitable.", help4: 'If you encounter any errors, please', contact: ' Contact Us.', - tags: 'Please input topic keywords', - hint: `Hint: (A single keyword should be within 14 characters, choose at least one and up to 7 keywords). You can enter text and press \`Enter\` to create a keyword.`, - hot: 'Popular Keywords (Click to Select) : ', + tags: 'Please input topic tags', + hint: `Hint: (A single tag should be within 14 characters, choose at least one and up to 7 tags). You can enter text and press \`Enter\` to create a tag.`, + hot: 'Popular Tags (Click to Select) : ', categories: 'Click to select topic categories (multiple selections allowed) : ', - btnGalgame: 'Visual Novel', - btnTechnique: 'Technique', - btnOthers: 'Others', + Galgame: 'Visual Novel', + Technique: 'Technique', + Others: 'Others', publish: 'Confirm Publish', draft: 'Save Draft', }, diff --git a/src/views/Home/content/article/components/TopicPart.vue b/src/views/Home/content/article/components/TopicPart.vue index 754da221..dc653aec 100644 --- a/src/views/Home/content/article/components/TopicPart.vue +++ b/src/views/Home/content/article/components/TopicPart.vue @@ -25,7 +25,7 @@ const plainText = getPlainText(props.data.content)
{{ props.data.title }}
- +
- +
{{ formatTimeDifference( @@ -115,7 +115,7 @@ const plainText = getPlainText(props.data.content) } /* 发帖日期 */ .time { - width: 60px; + width: 77px; font-size: x-small; color: var(--kungalgame-font-color-0); /* 居中 */ diff --git a/src/views/edit/components/Button.vue b/src/views/edit/components/Button.vue index 55f5eaad..e969c675 100644 --- a/src/views/edit/components/Button.vue +++ b/src/views/edit/components/Button.vue @@ -12,8 +12,6 @@ import { useKUNGalgamerStore } from '@/store/modules/kungalgamer' import { storeToRefs } from 'pinia' // 导入路由 import { useRouter } from 'vue-router' -// 导入将富文本变成纯文本的函数 -import { getPlainText } from '@/utils/getPlainText' // 导入请求数据格式 import { EditCreateTopicRequestData, @@ -22,7 +20,7 @@ import { const router = useRouter() -const topicData = storeToRefs(useKUNGalgameEditStore()) +const { content, isSave } = storeToRefs(useKUNGalgameEditStore()) const messageStore = useKUNGalgameMessageStore() @@ -31,10 +29,18 @@ const checkPublish = (topicData: EditCreateTopicRequestData) => { // 标题为空的话,警告 message('Title cannot be empty!', '标题不可为空!', 'warn') return false - } else if (topicData.content.trim()) { - // TODO: - console.log(getPlainText(topicData.content.trim()).length) - return true + } else if (!content.value.trim()) { + // 内容为空的话,警告 + message('Content cannot be empty!', '内容不可为空!', 'warn') + return false + } else if (topicData.tags.length === 0) { + message('Please use at least one tag!', '请至少使用一个标签!', 'warn') + } else if (topicData.category.length === 0) { + message( + 'Please select at least one category!', + '请至少选择一个分类!', + 'warn' + ) } else { return true } @@ -85,7 +91,7 @@ const handlePublish = async () => { const handleSave = () => { // 这个值为 true 的时候每次页面加载的时候都会预加载上一次的话题数据 - topicData.isSave.value = true + isSave.value = true messageStore.info('AlertInfo.edit.draft') } diff --git a/src/views/edit/components/category.ts b/src/views/edit/components/category.ts index 8f8af1cc..1c44abe9 100644 --- a/src/views/edit/components/category.ts +++ b/src/views/edit/components/category.ts @@ -8,14 +8,14 @@ export interface Category { export const category: Category[] = [ { index: 1, - name: 'btnGalgame', + name: 'Galgame', }, { index: 2, - name: 'btnTechnique', + name: 'Technique', }, { index: 3, - name: 'btnOthers', + name: 'Others', }, ]