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",
"galgame",
"Galgame",
"gsap",
"iconify",
"INTLIFY",
"kungal",

View file

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

View file

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

View file

@ -1,12 +1,47 @@
<script setup lang="ts">
import { ref } from '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'
import { ref } from 'vue'
const topicData = storeToRefs(useKUNGalgameEditStore())
//
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>
<template>
@ -17,9 +52,9 @@ const buttonStatus = ref(false)
<div class="group-btn" :class="buttonStatus ? 'selected-btn' : ''">
<span
class="btn"
v-for="kun in button"
v-for="kun in category"
:key="kun.index"
@click="kun.isActive.value = !kun.isActive.value"
@click="handleClickCategory(kun)"
:class="{ active: kun.isActive.value }"
>
{{ kun.name }}

View file

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