From 3dd67a1e1ca476ba0590232ae358f9bdb3e20a08 Mon Sep 17 00:00:00 2001 From: jmal Date: Thu, 22 May 2025 16:23:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(store):=20=E9=87=8D=E6=9E=84=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 app 和 user 模块的状态持久化从 sessionStorage 改为 localStorage - 移除 auth.js 中的 Cookie 操作,改为使用 Vuex store - 更新 getters、actions 和 mutations 以适应新的状态管理方式 -调整 logo、path 等工具类中的数据存储逻辑 - 修改请求拦截器中的 token 设置方式 --- src/components/HistoryPopover/index.vue | 3 ++ src/layout/index.vue | 3 +- src/main.js | 4 +- src/permission.js | 3 +- src/store/getters.js | 1 + src/store/modules/app.js | 5 +-- src/store/modules/user.js | 47 +++++++-------------- src/utils/auth.js | 55 ------------------------- src/utils/logo.js | 13 +++--- src/utils/path.js | 29 ------------- src/utils/request.js | 11 +++-- src/views/login/index.vue | 6 --- src/views/public/share/shareList.vue | 1 - 13 files changed, 38 insertions(+), 143 deletions(-) delete mode 100644 src/utils/auth.js diff --git a/src/components/HistoryPopover/index.vue b/src/components/HistoryPopover/index.vue index 691270a..1e3a95a 100644 --- a/src/components/HistoryPopover/index.vue +++ b/src/components/HistoryPopover/index.vue @@ -143,6 +143,9 @@ export default { }) }, loadHistoryPathList(pathname) { + if (!this.$store.getters.token) { + return + } historyApi.fileHistoryPathList({path: encodeURI(pathname), username: this.$store.state.user.name, pageIndex: this.historyPageIndex, pageSize: this.historyPageSize}).then((res) => { this.fileHistoryList = res.data this.$emit('loadHistoryPathListSuccess', {res: res, pathname: pathname}) diff --git a/src/layout/index.vue b/src/layout/index.vue index c5d6818..5a08d8c 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -18,7 +18,6 @@