diff --git a/src/components/WangEditor.vue b/src/components/WangEditor.vue index f5a6f954..5bd8711b 100644 --- a/src/components/WangEditor.vue +++ b/src/components/WangEditor.vue @@ -6,6 +6,7 @@ import '@wangeditor/editor/dist/css/style.css' // 引入 css import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue' import { Editor, Toolbar } from '@wangeditor/editor-for-vue' +const props = defineProps(['html', 'text']) // 覆盖编辑器原生样式 import '@/styles/editor/editor.scss' @@ -13,7 +14,8 @@ import '@/styles/editor/editor.scss' const editorRef = shallowRef() // 内容 HTML -const valueHtml = ref('') +const valueHtml = ref(props.html) +const valueText = ref(props.text) // 模拟 ajax 异步获取内容 onMounted(() => { diff --git a/src/language/en.ts b/src/language/en.ts index faa9a229..954e4008 100644 --- a/src/language/en.ts +++ b/src/language/en.ts @@ -106,6 +106,19 @@ export default { contact: { title: 'Join / Contact Us', }, + edit: { + title: 'Please input title, limit is 40 characters', + 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): ', + categories: + 'Click to select post categories (multiple selections allowed): ', + btnGalgame: 'Visual Novel', + btnTechnique: 'Technical Discussions', + others: 'Others', + publish: 'Confirm Publish', + draft: 'Save Draft', + }, // 非页面组件这里统一用大驼峰 ComponentAlert: { confirm: 'OK', @@ -113,6 +126,8 @@ export default { }, AlertInfo: { publish: 'Confirm to publish?', + publishSuccess: 'Publish Successfully', + publishCancel: 'Cancel Publish', draft: 'The draft has been saved successfully!', }, } diff --git a/src/language/zh.ts b/src/language/zh.ts index 0dc56323..257cc643 100644 --- a/src/language/zh.ts +++ b/src/language/zh.ts @@ -106,6 +106,18 @@ export default { contact: { title: '加入 / 联系我们', }, + edit: { + title: '请输入帖子的标题(40字以内)', + tags: '请输入帖子的关键词', + hint: `提示:(单个关键词 14 个字符以内,至少选择一个、最多 7 个), 您可以输入文字按下 ' Enter ' 创建关键词`, + hot: '热门关键词(点击选择):', + categories: '点击选择帖子的分区(可多选):', + btnGalgame: 'Galgame', + btnTechnique: '技术交流', + others: '其它', + publish: '确认发布', + draft: '保存草稿', + }, // 非页面组件这里统一用大驼峰 ComponentAlert: { confirm: '确定', @@ -113,6 +125,8 @@ export default { }, AlertInfo: { publish: '确认发布吗?', + publishSuccess: '发布成功', + publishCancel: '取消发布', draft: '草稿已经保存成功!', }, } diff --git a/src/store/modules/edit.ts b/src/store/modules/edit.ts new file mode 100644 index 00000000..737a549f --- /dev/null +++ b/src/store/modules/edit.ts @@ -0,0 +1,28 @@ +/* 编辑区的 store */ +import { defineStore } from 'pinia' +interface Tag { + index: number + name: string +} + +interface Topic { + // 帖子标题 + title: string + // 帖子内容 + article: string + // 帖子标签 + tags: Tag[] + // 帖子分区 + partition: string[] +} + +export const useKUNGalgameEditStore = defineStore({ + id: 'edit', + persist: true, + state: (): Topic => ({ + title: '', + article: '', + tags: [], + partition: [], + }), +}) diff --git a/src/views/edit/Edit.vue b/src/views/edit/Edit.vue index 409d5e5d..58918f34 100644 --- a/src/views/edit/Edit.vue +++ b/src/views/edit/Edit.vue @@ -1,8 +1,29 @@ diff --git a/src/views/edit/components/Button.vue b/src/views/edit/components/Button.vue index f9260111..b260a539 100644 --- a/src/views/edit/components/Button.vue +++ b/src/views/edit/components/Button.vue @@ -13,7 +13,11 @@ const handlePublish = async () => { const res = await info.alert('AlertInfo.publish', true) // TODO: // 这里实现用户的点击确认取消逻辑 - console.log(res) + if (res) { + info.info('AlertInfo.publishSuccess') + } else { + info.info('AlertInfo.publishCancel') + } } const handleSave = () => { @@ -29,7 +33,7 @@ const handleSave = () => {
点击选择帖子的分区(可多选):
- +
@@ -73,6 +77,9 @@ const handleSave = () => { border: 1px solid var(--kungalgame-blue-1); background-color: var(--kungalgame-trans-blue-0); color: var(--kungalgame-blue-4); + display: flex; + justify-content: center; + align-items: center; } /* 按钮的容器 */ .btn-container { diff --git a/src/views/edit/components/Footer.vue b/src/views/edit/components/Footer.vue deleted file mode 100644 index 1b0fe3d0..00000000 --- a/src/views/edit/components/Footer.vue +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/src/views/edit/components/Tags.vue b/src/views/edit/components/Tags.vue index e2357aba..388242bb 100644 --- a/src/views/edit/components/Tags.vue +++ b/src/views/edit/components/Tags.vue @@ -94,7 +94,7 @@ const validateTagName = (tagName: string) => {