mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 13:07:58 +08:00
37 lines
987 B
JavaScript
37 lines
987 B
JavaScript
const useKeepAliveStore = defineStore(
|
|
// 唯一ID
|
|
'keepAlive',
|
|
{
|
|
state: () => ({
|
|
list: []
|
|
}),
|
|
actions: {
|
|
add(name) {
|
|
if (typeof name === 'string') {
|
|
!this.list.includes(name) && this.list.push(name)
|
|
} else {
|
|
name.map(v => {
|
|
v && !this.list.includes(v) && this.list.push(v)
|
|
})
|
|
}
|
|
},
|
|
remove(name) {
|
|
if (typeof name === 'string') {
|
|
this.list = this.list.filter(v => {
|
|
return v !== name
|
|
})
|
|
} else {
|
|
this.list = this.list.filter(v => {
|
|
return !name.includes(v)
|
|
})
|
|
}
|
|
},
|
|
clean() {
|
|
this.list = []
|
|
}
|
|
}
|
|
}
|
|
)
|
|
|
|
export default useKeepAliveStore
|