|
@@ -7,140 +7,145 @@ const KEY_PROJECT_SELECTED = 'global_project_selected'
|
|
|
const KEY_PAGE_BRANDCRUMB = 'page_brandcrumb'
|
|
|
|
|
|
export default {
|
|
|
- namespaced: true,
|
|
|
+ namespaced: true,
|
|
|
state: {
|
|
|
- sidebarClosed: false,
|
|
|
- sidebarSelected: '', // sidebar选中的选项
|
|
|
- userInfo: null, //{ username: 'admin' },
|
|
|
- permissions: { "system:role:delete": true, "system:role:create": true, "system:role:query": true, "system:role:setOpts": true },
|
|
|
- projectId: '',
|
|
|
- projects: [],
|
|
|
- breadcrumb: [],
|
|
|
- uploaderList: [], //当前上传文件列表
|
|
|
- secret: "", //项目密码
|
|
|
- userId: "", //用户id
|
|
|
- rowEdit: false,//表格数据变化
|
|
|
+ sidebarClosed: false,
|
|
|
+ sidebarSelected: '', // sidebar选中的选项
|
|
|
+ userInfo: null, //{ username: 'admin' },
|
|
|
+ permissions: {
|
|
|
+ "system:role:delete": true,
|
|
|
+ "system:role:create": true,
|
|
|
+ "system:role:query": true,
|
|
|
+ "system:role:setOpts": true
|
|
|
+ },
|
|
|
+ projectId: '',
|
|
|
+ projects: [],
|
|
|
+ breadcrumb: [],
|
|
|
+ uploaderList: [], //当前上传文件列表
|
|
|
+ secret: "", //项目密码
|
|
|
+ userId: "", //用户id
|
|
|
+ rowEdit: false,//表格数据变化
|
|
|
},
|
|
|
getters: {
|
|
|
- sidebarClosed: state => state.sidebarClosed,
|
|
|
- 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
|
|
|
- },
|
|
|
- breadcrumb: state => {
|
|
|
- if (!state.breadcrumb) {
|
|
|
- let arr = storage.get(KEY_PAGE_BRANDCRUMB)
|
|
|
- if (arr) {
|
|
|
- state.breadcrumb = arr
|
|
|
- }
|
|
|
- }
|
|
|
- return state.breadcrumb
|
|
|
+ sidebarClosed: state => state.sidebarClosed,
|
|
|
+ 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
|
|
|
+ },
|
|
|
+ breadcrumb: state => {
|
|
|
+ if (!state.breadcrumb) {
|
|
|
+ let arr = storage.get(KEY_PAGE_BRANDCRUMB)
|
|
|
+ if (arr) {
|
|
|
+ state.breadcrumb = arr
|
|
|
+ }
|
|
|
}
|
|
|
+ return state.breadcrumb
|
|
|
+ }
|
|
|
},
|
|
|
mutations: {
|
|
|
- setRowEdit: (state, val) => (state.rowEdit = val),
|
|
|
- setSidebarClosed: (state, val) => (state.sidebarClosed = val),
|
|
|
- setSidebarSelected: (state, val) => {
|
|
|
- state.sidebarSelected = val
|
|
|
- storage.set(KEY_MENU_SELECTED, val)
|
|
|
- lStorage.set('screen_data', { path: val, data: {} })
|
|
|
- },
|
|
|
- setprojectId: (state, val) => {
|
|
|
- let cacheInfo = lStorage.get('cacheInfo') ? lStorage.get('cacheInfo') : {}
|
|
|
- state.projectId = val
|
|
|
- localStorage.setItem('projectId', val)
|
|
|
- if (cacheInfo[state.userInfo.userName]) {
|
|
|
- cacheInfo[state.userInfo.userName].projectId = val
|
|
|
- lStorage.set('cacheInfo', cacheInfo)
|
|
|
- } else {
|
|
|
- cacheInfo[state.userInfo.userName] = { projectId: val }
|
|
|
- lStorage.set('cacheInfo', 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:[]
|
|
|
- },
|
|
|
+ setRowEdit: (state, val) => (state.rowEdit = val),
|
|
|
+ setSidebarClosed: (state, val) => (state.sidebarClosed = val),
|
|
|
+ setSidebarSelected: (state, val) => {
|
|
|
+ state.sidebarSelected = val
|
|
|
+ storage.set(KEY_MENU_SELECTED, val)
|
|
|
+ lStorage.set('screen_data', {path: val, data: {}})
|
|
|
+ },
|
|
|
+ setprojectId: (state, val) => {
|
|
|
+ let cacheInfo = lStorage.get('cacheInfo') ? lStorage.get('cacheInfo') : {}
|
|
|
+ state.projectId = val
|
|
|
+ localStorage.setItem('projectId', val)
|
|
|
+ if (cacheInfo[state.userInfo.userName]) {
|
|
|
+ cacheInfo[state.userInfo.userName].projectId = val
|
|
|
+ lStorage.set('cacheInfo', cacheInfo)
|
|
|
+ } else {
|
|
|
+ cacheInfo[state.userInfo.userName] = {projectId: val}
|
|
|
+ lStorage.set('cacheInfo', 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: {
|
|
|
- setRowEdit(contentx, value) {
|
|
|
- contentx.commit('setRowEdit', value)
|
|
|
- },
|
|
|
- loadUserInfo({ state }) {
|
|
|
- console.log(state)
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- frameworkApi.loadUserInfo().then(resp => {
|
|
|
- console.log(resp)
|
|
|
- if (resp.Result == 'success') {
|
|
|
- state.userInfo = { userName: resp.Username, userId: resp.UserId }
|
|
|
- state.userId = resp.UserId
|
|
|
- storage.set('user_name', resp.Username)
|
|
|
- storage.set('user_id', resp.UserId)
|
|
|
- state.permissions = {}
|
|
|
- if (resp.Permissions) {
|
|
|
- resp.Permissions.forEach(p => (state.permissions[p] = true))
|
|
|
- }
|
|
|
- state.projects = []
|
|
|
- if (resp.Projects) {
|
|
|
- if (resp.Projects[0] && resp.Projects[0].ProjId) {
|
|
|
- state.projectId = resp.Projects[0].ProjId
|
|
|
- state.secret = resp.Projects[0].Secret ? resp.Projects[0].Secret : ""
|
|
|
- }
|
|
|
- resp.Projects.forEach(proj =>
|
|
|
- state.projects.push({
|
|
|
- id: proj.ProjId,
|
|
|
- name: proj.ProjLocalName,
|
|
|
- pwd: proj.Secret ? proj.Secret : ""
|
|
|
- })
|
|
|
- )
|
|
|
- }
|
|
|
- } else {
|
|
|
- state.userInfo = null
|
|
|
-
|
|
|
- }
|
|
|
- resolve(resp)
|
|
|
+ actions: {
|
|
|
+ setRowEdit(contentx, value) {
|
|
|
+ contentx.commit('setRowEdit', value)
|
|
|
+ },
|
|
|
+ loadUserInfo({state}) {
|
|
|
+ console.log(state)
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ frameworkApi.loadUserInfo().then(resp => {
|
|
|
+ console.log(resp)
|
|
|
+ if (resp.Result == 'success') {
|
|
|
+ state.userInfo = {userName: resp.Username, userId: resp.UserId}
|
|
|
+ state.userId = resp.UserId
|
|
|
+ storage.set('user_name', resp.Username)
|
|
|
+ storage.set('user_id', resp.UserId)
|
|
|
+ state.permissions = {}
|
|
|
+ if (resp.Permissions) {
|
|
|
+ resp.Permissions.forEach(p => (state.permissions[p] = true))
|
|
|
+ }
|
|
|
+ state.projects = []
|
|
|
+ if (resp.Projects) {
|
|
|
+ if (resp.Projects[0] && resp.Projects[0].ProjId) {
|
|
|
+ state.projectId = resp.Projects[0].ProjId
|
|
|
+ state.secret = resp.Projects[0].Secret ? resp.Projects[0].Secret : ""
|
|
|
+ }
|
|
|
+ resp.Projects.forEach(proj =>
|
|
|
+ state.projects.push({
|
|
|
+ id: proj.ProjId,
|
|
|
+ name: proj.ProjLocalName,
|
|
|
+ pwd: proj.Secret ? proj.Secret : ""
|
|
|
})
|
|
|
- })
|
|
|
- },
|
|
|
- setBreadcrumb: {
|
|
|
- root: true,
|
|
|
- handler({ state, commit }, val) {
|
|
|
- let label = val[0].label;
|
|
|
- if (label === "消息中心") {
|
|
|
- commit("setSidebarSelected", "message"); // 当进入消息中心页面的时候不选中导航栏
|
|
|
- }
|
|
|
- state.breadcrumb = []
|
|
|
- state.breadcrumb = val
|
|
|
- storage.set(KEY_PAGE_BRANDCRUMB, val)
|
|
|
+ )
|
|
|
}
|
|
|
+ } else {
|
|
|
+ state.userInfo = null
|
|
|
+
|
|
|
+ }
|
|
|
+ resolve(resp)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setBreadcrumb: {
|
|
|
+ root: true,
|
|
|
+ handler({state, commit}, val) {
|
|
|
+ let label = val[0].label;
|
|
|
+ if (label === "消息中心") {
|
|
|
+ commit("setSidebarSelected", "message"); // 当进入消息中心页面的时候不选中导航栏
|
|
|
}
|
|
|
+ state.breadcrumb = []
|
|
|
+ state.breadcrumb = val
|
|
|
+ storage.set(KEY_PAGE_BRANDCRUMB, val)
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
}
|