diff --git a/src/store/modules/acl.js b/src/store/modules/acl.js index 3c06f31..80b9c81 100644 --- a/src/store/modules/acl.js +++ b/src/store/modules/acl.js @@ -1,8 +1,8 @@ -const state = { +const state = () => ({ admin: false, role: [], ability: [], -} +}) const getters = { admin: (state) => state.admin, role: (state) => state.role, diff --git a/src/store/modules/routes.js b/src/store/modules/routes.js index ec2c017..153d824 100644 --- a/src/store/modules/routes.js +++ b/src/store/modules/routes.js @@ -6,7 +6,10 @@ import { asyncRoutes, constantRoutes } from '@/router' import { getRouterList } from '@/api/router' import { convertRouter, filterRoutes } from '@/utils/routes' -const state = { routes: [], partialRoutes: [] } +const state = () => ({ + routes: [], + partialRoutes: [], +}) const getters = { routes: (state) => state.routes, partialRoutes: (state) => state.partialRoutes, diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index ac85632..2352608 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -38,7 +38,7 @@ const toggleBoolean = (key) => { return typeof theme[key] !== 'undefined' ? theme[key] : key } -const state = { +const state = () => ({ logo, title, collapse, @@ -55,7 +55,7 @@ const state = { showTagsBar: toggleBoolean(showTagsBar), showNotice: toggleBoolean(showNotice), showFullScreen: toggleBoolean(showFullScreen), -} +}) const getters = { collapse: (state) => state.collapse, device: (state) => state.device, diff --git a/src/store/modules/tagsBar.js b/src/store/modules/tagsBar.js index 298bbb1..1a23568 100644 --- a/src/store/modules/tagsBar.js +++ b/src/store/modules/tagsBar.js @@ -3,9 +3,9 @@ * @description tagsBar多标签页逻辑,前期借鉴了很多开源项目发现都有个共同的特点很繁琐并不符合框架设计的初衷,后来在github用户cyea的启发下完成了重构,请勿修改 */ -const state = { +const state = () => ({ visitedRoutes: [], -} +}) const getters = { visitedRoutes: (state) => state.visitedRoutes, } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 06e0c63..d1bbda6 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -11,11 +11,11 @@ import { import { title, tokenName } from '@/config' import { message, notification } from 'ant-design-vue' -const state = { +const state = () => ({ accessToken: getAccessToken(), username: '', avatar: '', -} +}) const getters = { accessToken: (state) => state.accessToken, username: (state) => state.username,