mirror of
https://gitee.com/chu1204505056/vue-admin-beautiful.git
synced 2025-04-06 03:58:00 +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,
|
||||
role: [],
|
||||
ability: [],
|
||||
}
|
||||
})
|
||||
const getters = {
|
||||
admin: (state) => state.admin,
|
||||
role: (state) => state.role,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -3,9 +3,9 @@
|
||||
* @description tagsBar多标签页逻辑,前期借鉴了很多开源项目发现都有个共同的特点很繁琐并不符合框架设计的初衷,后来在github用户cyea的启发下完成了重构,请勿修改
|
||||
*/
|
||||
|
||||
const state = {
|
||||
const state = () => ({
|
||||
visitedRoutes: [],
|
||||
}
|
||||
})
|
||||
const getters = {
|
||||
visitedRoutes: (state) => state.visitedRoutes,
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user