fix: 修复二次登录后标签页会多出登录标签问题

This commit is contained in:
张传龙 2022-04-14 15:30:34 +08:00
parent db5089d92e
commit 094a9dcb3b
2 changed files with 4 additions and 2 deletions

View File

@ -3,3 +3,5 @@ import { createSessionStorage } from '@/utils/cache'
export const tagsSS = createSessionStorage({ prefixKey: 'tag_' }) export const tagsSS = createSessionStorage({ prefixKey: 'tag_' })
export const activeTag = tagsSS.get('activeTag') export const activeTag = tagsSS.get('activeTag')
export const tags = tagsSS.get('tags') export const tags = tagsSS.get('tags')
export const WITHOUT_TAG_PATHS = ['/404', '/login', '/redirect']

View File

@ -1,5 +1,5 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { tagsSS, activeTag, tags } from './helpers' import { tagsSS, activeTag, tags, WITHOUT_TAG_PATHS } from './helpers'
export const useTagsStore = defineStore('tag', { export const useTagsStore = defineStore('tag', {
state() { state() {
@ -14,7 +14,7 @@ export const useTagsStore = defineStore('tag', {
tagsSS.set('activeTag', path) tagsSS.set('activeTag', path)
}, },
addTag(tag = {}) { addTag(tag = {}) {
if (this.tags.some((item) => item.path === tag.path)) return if (WITHOUT_TAG_PATHS.includes(tag.path) || this.tags.some((item) => item.path === tag.path)) return
this.tags.push(tag) this.tags.push(tag)
tagsSS.set('tags', this.tags) tagsSS.set('tags', this.tags)
}, },