mirror of
https://gitee.com/chu1204505056/vue-admin-beautiful.git
synced 2025-05-04 13:26:34 +08:00
✨ feat: module state declaration as function, 详见vuex官方github:eb33ed6fbe
This commit is contained in:
parent
fd0effe803
commit
8bea3fbe1c
@ -1,8 +1,8 @@
|
|||||||
const state = {
|
const state = () => ({
|
||||||
admin: false,
|
admin: false,
|
||||||
role: [],
|
role: [],
|
||||||
ability: [],
|
ability: [],
|
||||||
}
|
})
|
||||||
const getters = {
|
const getters = {
|
||||||
admin: (state) => state.admin,
|
admin: (state) => state.admin,
|
||||||
role: (state) => state.role,
|
role: (state) => state.role,
|
||||||
|
@ -6,7 +6,10 @@ import { asyncRoutes, constantRoutes } from '@/router'
|
|||||||
import { getRouterList } from '@/api/router'
|
import { getRouterList } from '@/api/router'
|
||||||
import { convertRouter, filterRoutes } from '@/utils/routes'
|
import { convertRouter, filterRoutes } from '@/utils/routes'
|
||||||
|
|
||||||
const state = { routes: [], partialRoutes: [] }
|
const state = () => ({
|
||||||
|
routes: [],
|
||||||
|
partialRoutes: [],
|
||||||
|
})
|
||||||
const getters = {
|
const getters = {
|
||||||
routes: (state) => state.routes,
|
routes: (state) => state.routes,
|
||||||
partialRoutes: (state) => state.partialRoutes,
|
partialRoutes: (state) => state.partialRoutes,
|
||||||
|
@ -38,7 +38,7 @@ const toggleBoolean = (key) => {
|
|||||||
return typeof theme[key] !== 'undefined' ? theme[key] : key
|
return typeof theme[key] !== 'undefined' ? theme[key] : key
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = {
|
const state = () => ({
|
||||||
logo,
|
logo,
|
||||||
title,
|
title,
|
||||||
collapse,
|
collapse,
|
||||||
@ -55,7 +55,7 @@ const state = {
|
|||||||
showTagsBar: toggleBoolean(showTagsBar),
|
showTagsBar: toggleBoolean(showTagsBar),
|
||||||
showNotice: toggleBoolean(showNotice),
|
showNotice: toggleBoolean(showNotice),
|
||||||
showFullScreen: toggleBoolean(showFullScreen),
|
showFullScreen: toggleBoolean(showFullScreen),
|
||||||
}
|
})
|
||||||
const getters = {
|
const getters = {
|
||||||
collapse: (state) => state.collapse,
|
collapse: (state) => state.collapse,
|
||||||
device: (state) => state.device,
|
device: (state) => state.device,
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
* @description tagsBar多标签页逻辑,前期借鉴了很多开源项目发现都有个共同的特点很繁琐并不符合框架设计的初衷,后来在github用户cyea的启发下完成了重构,请勿修改
|
* @description tagsBar多标签页逻辑,前期借鉴了很多开源项目发现都有个共同的特点很繁琐并不符合框架设计的初衷,后来在github用户cyea的启发下完成了重构,请勿修改
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const state = {
|
const state = () => ({
|
||||||
visitedRoutes: [],
|
visitedRoutes: [],
|
||||||
}
|
})
|
||||||
const getters = {
|
const getters = {
|
||||||
visitedRoutes: (state) => state.visitedRoutes,
|
visitedRoutes: (state) => state.visitedRoutes,
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ import {
|
|||||||
import { title, tokenName } from '@/config'
|
import { title, tokenName } from '@/config'
|
||||||
import { message, notification } from 'ant-design-vue'
|
import { message, notification } from 'ant-design-vue'
|
||||||
|
|
||||||
const state = {
|
const state = () => ({
|
||||||
accessToken: getAccessToken(),
|
accessToken: getAccessToken(),
|
||||||
username: '',
|
username: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
}
|
})
|
||||||
const getters = {
|
const getters = {
|
||||||
accessToken: (state) => state.accessToken,
|
accessToken: (state) => state.accessToken,
|
||||||
username: (state) => state.username,
|
username: (state) => state.username,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user