feat: edit page category store

This commit is contained in:
KUN1007 2023-08-21 19:38:23 +08:00
parent eee460ade3
commit 991fd8e8a1
5 changed files with 48 additions and 11 deletions

View file

@ -10,6 +10,7 @@
"fontawesome", "fontawesome",
"galgame", "galgame",
"Galgame", "Galgame",
"gsap",
"iconify", "iconify",
"INTLIFY", "INTLIFY",
"kungal", "kungal",

View file

@ -5,12 +5,13 @@
import '@wangeditor/editor/dist/css/style.css' import '@wangeditor/editor/dist/css/style.css'
import '@/styles/editor/editor.scss' import '@/styles/editor/editor.scss'
import { IDomEditor } from '@wangeditor/editor' import { IDomEditor } from '@wangeditor/editor'
import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue' import { onBeforeUnmount, ref, shallowRef } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
// store // store
import { useKUNGalgameEditStore } from '@/store/modules/edit' import { useKUNGalgameEditStore } from '@/store/modules/edit'
// xss // xss
import DOMPurify from 'dompurify' import DOMPurify from 'dompurify'
// store // store
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
const topicData = storeToRefs(useKUNGalgameEditStore()) const topicData = storeToRefs(useKUNGalgameEditStore())
@ -107,9 +108,10 @@ const handleChange = (editor: IDomEditor) => {
} }
.count { .count {
right: 50px; padding: 3px 7px;
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center;
justify-content: end; justify-content: end;
color: var(--kungalgame-font-color-0); color: var(--kungalgame-font-color-0);
background-color: var(--kungalgame-white); background-color: var(--kungalgame-white);

View file

@ -3,8 +3,6 @@ import { useKUNGalgameMessageStore } from '@/store/modules/message'
const info = useKUNGalgameMessageStore() const info = useKUNGalgameMessageStore()
import { button } from './button'
const handlePublish = async () => { const handlePublish = async () => {
const res = await info.alert('AlertInfo.edit.publish', true) const res = await info.alert('AlertInfo.edit.publish', true)
// TODO: // TODO:
@ -83,3 +81,4 @@ const handleSave = () => {
transform: scale(0.8); transform: scale(0.8);
} }
</style> </style>
./Category

View file

@ -1,12 +1,47 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'
// //
import Button from './Button.vue' import Button from './Button.vue'
// store
import { useKUNGalgameEditStore } from '@/store/modules/edit'
//
import { Category, category } from './category'
// store
import { storeToRefs } from 'pinia'
import { button } from './button' const topicData = storeToRefs(useKUNGalgameEditStore())
import { ref } from 'vue'
//
const buttonStatus = ref(false) const buttonStatus = ref(false)
//
const selectedCategories = ref<string[]>([])
//
const handleClickCategory = (kun: Category) => {
// 1 3 1
if (kun.index === 1 && selectedCategories.value.includes('其它')) {
return
}
// 3 1 3
if (kun.index === 3 && selectedCategories.value.includes('galgame')) {
return
}
//
kun.isActive.value = !kun.isActive.value
//
if (kun.isActive.value) {
selectedCategories.value.push(kun.name)
} else {
const index = selectedCategories.value.indexOf(kun.name)
if (index !== -1) {
selectedCategories.value.splice(index, 1)
}
}
// category pinia store
topicData.category.value = selectedCategories.value
}
</script> </script>
<template> <template>
@ -17,9 +52,9 @@ const buttonStatus = ref(false)
<div class="group-btn" :class="buttonStatus ? 'selected-btn' : ''"> <div class="group-btn" :class="buttonStatus ? 'selected-btn' : ''">
<span <span
class="btn" class="btn"
v-for="kun in button" v-for="kun in category"
:key="kun.index" :key="kun.index"
@click="kun.isActive.value = !kun.isActive.value" @click="handleClickCategory(kun)"
:class="{ active: kun.isActive.value }" :class="{ active: kun.isActive.value }"
> >
{{ kun.name }} {{ kun.name }}

View file

@ -1,12 +1,12 @@
import { type Ref, ref } from 'vue' import { type Ref, ref } from 'vue'
interface Button { export interface Category {
index: number index: number
name: string name: string
isActive: Ref<boolean> isActive: Ref<boolean>
} }
export const button: Button[] = [ export const category: Category[] = [
{ {
index: 1, index: 1,
name: 'galgame', name: 'galgame',