提交 efb12ebe 编写于 作者: zcdtk's avatar zcdtk

对象处理

上级 220f81ae
......@@ -62,28 +62,26 @@ export class AuthGuard {
}
/**
* post请求
* 权限认证
*
* @param {string} url
* @param {*} [params={}]
* @param {Store<any>} store
* @returns {Promise<boolean>}
* @returns {Promise<any>}
* @memberof AuthGuard
*/
public async authGuard(url: string, params: any = {}, store: Store<any>): Promise<any> {
this.loadDictionaryDatas(store);
try{
let response = await Http.getInstance().get(url);
const response: any = await Http.getInstance().get(url);
if (response && response.status === 200) {
let { data }: { data: any } = response;
if (data) {
// token认证把用户信息放入应用级数据
if(localStorage.getItem('user')){
let user:any = JSON.parse(localStorage.getItem('user') as string);
let localAppData:any = {};
if(user.sessionParams){
localAppData = {context:user.sessionParams};
Object.assign(localAppData,data);
if (localStorage.getItem('user')) {
let user: any = JSON.parse(localStorage.getItem('user') as string);
let localAppData: any = {};
if (user.sessionParams) {
localAppData = { context: user.sessionParams };
Object.assign(localAppData, data);
}
data = JSON.parse(JSON.stringify(localAppData));
}
......@@ -91,11 +89,8 @@ export class AuthGuard {
// 提交统一资源数据
store.dispatch('authresource/commitAuthData', data);
}
return true;
}
}catch (error) {
console.error("获取应用数据出现异常");
}
return await this.loadDictionaryDatas(store);
}
/**
......@@ -115,7 +110,7 @@ export class AuthGuard {
if (response && response.status === 200 && response.data && Array.isArray(response.data)) {
const datas: any[] = [...response.data];
datas.forEach((item: any) => {
if (!item.items) {
if (item && !item.items) {
item.items = [];
}
});
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册