From 8c1191ece2e75577a1d648c6f5e306900cb7d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Mon, 11 Apr 2022 22:12:00 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E6=96=87=E4=BB=B6=E5=90=8D=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/tags/index.vue | 26 ++++++++++----------- src/store/modules/{tag.js => tags/index.js} | 10 +++++--- src/utils/http/{help.js => helpers.js} | 0 src/utils/http/interceptors.js | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) rename src/store/modules/{tag.js => tags/index.js} (58%) rename src/utils/http/{help.js => helpers.js} (100%) diff --git a/src/layout/components/tags/index.vue b/src/layout/components/tags/index.vue index 81e2392..df13f1b 100644 --- a/src/layout/components/tags/index.vue +++ b/src/layout/components/tags/index.vue @@ -2,10 +2,10 @@
@@ -18,12 +18,12 @@ diff --git a/src/store/modules/tag.js b/src/store/modules/tags/index.js similarity index 58% rename from src/store/modules/tag.js rename to src/store/modules/tags/index.js index a16ce0c..ef8aa52 100644 --- a/src/store/modules/tag.js +++ b/src/store/modules/tags/index.js @@ -1,22 +1,26 @@ import { defineStore } from 'pinia' +import { tagsSS, activeTag, tags } from './helpers' -export const useTagStore = defineStore('tag', { +export const useTagsStore = defineStore('tag', { state() { return { - tags: [], - activeTag: '', + tags: tags || [], + activeTag: activeTag || '', } }, actions: { setActiveTag(path) { this.activeTag = path + tagsSS.set('activeTag', path) }, addTag(tag = {}) { if (this.tags.some((item) => item.path === tag.path)) return this.tags.push(tag) + tagsSS.set('tags', this.tags) }, removeTag(path) { this.tags = this.tags.filter((tag) => tag.path !== path) + tagsSS.set('tags', this.tags) }, }, }) diff --git a/src/utils/http/help.js b/src/utils/http/helpers.js similarity index 100% rename from src/utils/http/help.js rename to src/utils/http/helpers.js diff --git a/src/utils/http/interceptors.js b/src/utils/http/interceptors.js index 0d1a538..6ef2ef6 100644 --- a/src/utils/http/interceptors.js +++ b/src/utils/http/interceptors.js @@ -1,6 +1,6 @@ import { router } from '@/router' import { getToken, removeToken } from '@/utils/token' -import { isWithoutToken } from './help' +import { isWithoutToken } from './helpers' export function setupInterceptor(service) { service.interceptors.request.use(