|
@@ -3,53 +3,34 @@ import storage from '@/utils/storage'
|
|
|
import lStorage from '@/utils/localStorage'
|
|
|
|
|
|
const KEY_MENU_SELECTED = 'menu_selected'
|
|
|
-const KEY_PROJECT_SELECTED = 'global_project_selected'
|
|
|
const KEY_PAGE_BRANDCRUMB = 'page_brandcrumb'
|
|
|
|
|
|
export default {
|
|
|
namespaced: true,
|
|
|
state: {
|
|
|
- sidebarSelected: '', // sidebar选中的选项
|
|
|
userInfo: { username: 'admin' }, //null,
|
|
|
+ userId: "", //用户id
|
|
|
permissions: {
|
|
|
"system:role:delete": true,
|
|
|
"system:role:create": true,
|
|
|
"system:role:query": true,
|
|
|
"system:role:setOpts": true
|
|
|
},
|
|
|
- projectId: '',
|
|
|
- projects: [],
|
|
|
+ dictionary: {
|
|
|
+ dictionaryValue: 'common',
|
|
|
+ dictionaryType: 'common',
|
|
|
+ groupId: '0',
|
|
|
+ projectId: '0',
|
|
|
+ },
|
|
|
+ sidebarSelected: '', // sidebar选中的选项
|
|
|
breadcrumb: [],
|
|
|
- uploaderList: [], //当前上传文件列表
|
|
|
- secret: "", //项目密码
|
|
|
- userId: "", //用户id
|
|
|
},
|
|
|
getters: {
|
|
|
- secret: state => state.secret,
|
|
|
userId: state => state.userId,
|
|
|
- sidebarSelected: state => {
|
|
|
- // if (!state.pageSidebarSelected) {
|
|
|
- // let menu = storage.get(KEY_MENU_SELECTED)
|
|
|
- // if (menu) {
|
|
|
- // state.pageSidebarSelected = menu
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return state.pageSidebarSelected
|
|
|
- return state.sidebarSelected
|
|
|
- },
|
|
|
userInfo: state => state.userInfo,
|
|
|
permissions: state => state.permissions,
|
|
|
- projects: state => state.projects,
|
|
|
- uploaderList: state => state.uploaderList,
|
|
|
- projectId: state => {
|
|
|
- if (!state.projectId) {
|
|
|
- let pid = storage.get(KEY_PROJECT_SELECTED)
|
|
|
- if (pid) {
|
|
|
- state.projectId = pid
|
|
|
- }
|
|
|
- }
|
|
|
- return state.projectId
|
|
|
- },
|
|
|
+ dictionary: state => state.dictionary,
|
|
|
+ sidebarSelected: state => state.sidebarSelected,
|
|
|
breadcrumb: state => {
|
|
|
if (!state.breadcrumb) {
|
|
|
let arr = storage.get(KEY_PAGE_BRANDCRUMB)
|
|
@@ -61,36 +42,14 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mutations: {
|
|
|
+ setDictionary: (state, val) => {
|
|
|
+ state.dictionary = val
|
|
|
+ },
|
|
|
setSidebarSelected: (state, val) => {
|
|
|
state.sidebarSelected = val
|
|
|
storage.set(KEY_MENU_SELECTED, val)
|
|
|
lStorage.set('screen_data', {path: val, data: {}})
|
|
|
},
|
|
|
- setprojectId: (state, val) => {
|
|
|
- lStorage.remove('cacheInfo') //待删除(删除用户浏览器无用缓存)
|
|
|
- let cacheInfo = lStorage.get('historyInfo') ? lStorage.get('historyInfo') : {}
|
|
|
- state.projectId = val
|
|
|
- localStorage.setItem('projectId', val)
|
|
|
- if (cacheInfo[state.userInfo.userName]) {
|
|
|
- // cacheInfo[state.userInfo.userName].projectId = val
|
|
|
- cacheInfo[state.userInfo.userName] = [...new Set([val, ...cacheInfo[state.userInfo.userName]])].slice(0,3)
|
|
|
- lStorage.set('historyInfo', cacheInfo)
|
|
|
- } else {
|
|
|
- cacheInfo[state.userInfo.userName] = [val]
|
|
|
- lStorage.set('historyInfo', cacheInfo)
|
|
|
- }
|
|
|
- storage.set(KEY_PROJECT_SELECTED, val)
|
|
|
- state.projects.map((item) => {
|
|
|
- if (item.id == val) {
|
|
|
- state.secret = item.pwd
|
|
|
- localStorage.setItem('secret', item.pwd)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- setUploaderList: (state, val) => {
|
|
|
- state.uploaderList = val ? val : []
|
|
|
- },
|
|
|
-
|
|
|
},
|
|
|
actions: {
|
|
|
loadUserInfo({state}) {
|