提交 7e90360d 编写于 作者: tony001's avatar tony001

zpc --- 统一资源中心

上级 4e1f2360
...@@ -7,6 +7,7 @@ import * as mutations from './mutations'; ...@@ -7,6 +7,7 @@ import * as mutations from './mutations';
import * as getters from './getters'; import * as getters from './getters';
import viewaction from './modules/view-action' import viewaction from './modules/view-action'
import unifiedresource from './modules/unified-resource'
const state = { const state = {
...rootstate ...rootstate
...@@ -20,7 +21,8 @@ const store = new Vuex.Store({ ...@@ -20,7 +21,8 @@ const store = new Vuex.Store({
mutations, mutations,
getters, getters,
modules: { modules: {
viewaction viewaction,
unifiedresource
}, },
}); });
......
/**
* 提交统一资源数据
*
* @param param0
* @param data
*/
export const commitResourceData = ({ commit, state }: { commit: any, state: any }, { unires, enablePermissionValid }: { unires: Array<any>, enablePermissionValid: boolean }) => {
if(unires && unires.length > 0){
commit('setResourceData', unires);
}
if(enablePermissionValid){
commit('setEnablePermissionValid', enablePermissionValid);
}
}
\ No newline at end of file
/**
* 判断指定统一资源是否存在
*
* @param state
*/
export const getResourceData = (state: any) => (resourcetag: string) => {
let itemIndex: any = state.resourceData.findIndex((obj: any, objIndex: any, objs: any) => {
return Object.is(obj.unirescode, resourcetag);
})
return itemIndex === -1 ? false : true;
}
/**
* 获取是否开启权限认证
*
* @param state
*/
export const getEnablePermissionValid = (state: any) => {
return state.enablePermissionValid;
}
\ No newline at end of file
import { resourcestate } from './state';
import * as actions from './actions';
import * as mutations from './mutations';
import * as getters from './getters';
const state = {
...resourcestate
}
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
\ No newline at end of file
/**
* 设置统一资源数据
*
* @param state
* @param resourceArray
*/
export const setResourceData = (state: any, resourceArray:Array<any>) => {
if(resourceArray && resourceArray.length === 0){
return;
}
state.resourceData = resourceArray;
}
/**
* 设置是否开启权限认证
*
* @param state
* @param resourceArray
*/
export const setEnablePermissionValid = (state: any, enablePermissionValid:boolean) => {
state.enablePermissionValid = enablePermissionValid;
}
/**
* 所有资源状态
*/
export const resourcestate: any = {
// 统一资源数据
resourceData: [],
// 是否开启权限认证
enablePermissionValid: true
}
\ No newline at end of file
...@@ -56,6 +56,8 @@ export class AuthGuard { ...@@ -56,6 +56,8 @@ export class AuthGuard {
const { data }: { data: any } = response; const { data }: { data: any } = response;
if (data) { if (data) {
router.app.$store.commit('addAppData', data); router.app.$store.commit('addAppData', data);
// 提交统一资源数据
router.app.$store.dispatch('unifiedresource/commitResourceData', data);
} }
} }
resolve(true); resolve(true);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册