feat: 集成tags多标签功能

This commit is contained in:
张传龙
2022-04-10 21:41:06 +08:00
parent c180cf54a8
commit 0d240f083a
4 changed files with 139 additions and 7 deletions

22
src/store/modules/tag.js Normal file
View File

@@ -0,0 +1,22 @@
import { defineStore } from 'pinia'
export const useTagStore = defineStore('tag', {
state() {
return {
tags: [],
activeTag: '',
}
},
actions: {
setActiveTag(path) {
this.activeTag = path
},
addTag(tag = {}) {
if (this.tags.some((item) => item.path === tag.path)) return
this.tags.push(tag)
},
removeTag(path) {
this.tags = this.tags.filter((tag) => tag.path !== path)
},
},
})

View File

@@ -0,0 +1,17 @@
import { defineStore } from 'pinia'
export const useThemeStore = defineStore('theme', {
state() {
return {
tag: {
visible: true,
height: 50,
},
}
},
actions: {
setTabVisible(visible) {
this.tag.visible = visible
},
},
})