Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
220f81ae
提交
220f81ae
编写于
6月 09, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
权限菜单
上级
89dafd4d
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
160 行增加
和
17 行删除
+160
-17
index.ts
src/store/index.ts
+3
-1
actions.ts
src/store/modules/auth-resource/actions.ts
+17
-0
getters.ts
src/store/modules/auth-resource/getters.ts
+52
-0
index.ts
src/store/modules/auth-resource/index.ts
+16
-0
mutations.ts
src/store/modules/auth-resource/mutations.ts
+35
-0
state.ts
src/store/modules/auth-resource/state.ts
+11
-0
auth-guard.ts
src/utils/auth-guard/auth-guard.ts
+26
-16
未找到文件。
src/store/index.ts
浏览文件 @
220f81ae
...
@@ -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
authresource
from
'./modules/auth-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
,
authresource
},
},
});
});
...
...
src/store/modules/auth-resource/actions.ts
0 → 100644
浏览文件 @
220f81ae
/**
* 提交统一资源数据
*
* @param param0
* @param data
*/
export
const
commitAuthData
=
({
commit
,
state
}:
{
commit
:
any
,
state
:
any
},
{
unires
,
appmenu
,
enablepermissionvalid
}:
{
unires
:
Array
<
any
>
,
appmenu
:
Array
<
any
>
,
enablepermissionvalid
:
boolean
})
=>
{
if
(
unires
&&
unires
.
length
>
0
){
commit
(
'setResourceData'
,
unires
);
}
if
(
appmenu
&&
appmenu
.
length
>
0
){
commit
(
'setMenuData'
,
appmenu
);
}
if
(
enablepermissionvalid
){
commit
(
'setEnablePermissionValid'
,
enablepermissionvalid
);
}
}
\ No newline at end of file
src/store/modules/auth-resource/getters.ts
0 → 100644
浏览文件 @
220f81ae
/**
* 判断指定统一资源是否存在
*
* @param state
*/
export
const
getResourceData
=
(
state
:
any
)
=>
(
resourcetag
:
string
)
=>
{
let
itemIndex
:
any
=
state
.
resourceData
.
findIndex
((
unirescode
:
any
,
objIndex
:
any
,
objs
:
any
)
=>
{
return
Object
.
is
(
unirescode
,
resourcetag
);
})
return
itemIndex
===
-
1
?
false
:
true
;
}
/**
* 判断指定菜单权限是否存在
*
* @param state
*/
export
const
getMenuData
=
(
state
:
any
)
=>
(
menutag
:
string
)
=>
{
let
itemIndex
:
any
=
state
.
menuData
.
findIndex
((
menucode
:
any
,
objIndex
:
any
,
objs
:
any
)
=>
{
return
Object
.
is
(
menucode
,
menutag
);
})
return
itemIndex
===
-
1
?
false
:
true
;
}
/**
* 获取是否开启权限认证
*
* @param state
*/
export
const
getEnablePermissionValid
=
(
state
:
any
)
=>
{
return
state
.
enablePermissionValid
;
}
/**
* 判断指定菜单是否显示
*
* @param state
*/
export
const
getAuthMenu
=
(
state
:
any
)
=>
(
menu
:
any
)
=>
{
// 存在权限
let
resourceIndex
:
any
;
let
menuIndex
:
any
;
if
(
state
.
enablePermissionValid
){
resourceIndex
=
state
.
resourceData
.
findIndex
((
resourcetag
:
any
,
objIndex
:
any
,
objs
:
any
)
=>
{
return
Object
.
is
(
menu
.
resourcetag
,
resourcetag
);
})
}
menuIndex
=
state
.
menuData
.
findIndex
((
menutag
:
any
,
objIndex
:
any
,
objs
:
any
)
=>
{
return
Object
.
is
(
menu
.
authtag
,
menutag
);
})
return
(
resourceIndex
!==
-
1
||
menuIndex
!==
-
1
)?
true
:
false
;
}
\ No newline at end of file
src/store/modules/auth-resource/index.ts
0 → 100644
浏览文件 @
220f81ae
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
src/store/modules/auth-resource/mutations.ts
0 → 100644
浏览文件 @
220f81ae
/**
* 设置统一资源数据
*
* @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
setMenuData
=
(
state
:
any
,
menuArray
:
Array
<
any
>
)
=>
{
if
(
menuArray
&&
menuArray
.
length
===
0
){
return
;
}
state
.
menuData
=
menuArray
;
}
/**
* 设置是否开启权限认证
*
* @param state
* @param resourceArray
*/
export
const
setEnablePermissionValid
=
(
state
:
any
,
enablepermissionvalid
:
boolean
)
=>
{
state
.
enablePermissionValid
=
enablepermissionvalid
;
}
src/store/modules/auth-resource/state.ts
0 → 100644
浏览文件 @
220f81ae
/**
* 所有资源状态
*/
export
const
resourcestate
:
any
=
{
// 统一资源数据
resourceData
:
[],
// 菜单数据
menuData
:[],
// 是否开启权限认证
enablePermissionValid
:
false
}
\ No newline at end of file
src/utils/auth-guard/auth-guard.ts
浏览文件 @
220f81ae
...
@@ -70,22 +70,32 @@ export class AuthGuard {
...
@@ -70,22 +70,32 @@ export class AuthGuard {
* @returns {Promise<boolean>}
* @returns {Promise<boolean>}
* @memberof AuthGuard
* @memberof AuthGuard
*/
*/
public
async
authGuard
(
url
:
string
,
params
:
any
=
{},
store
:
Store
<
any
>
):
Promise
<
boolean
>
{
public
async
authGuard
(
url
:
string
,
params
:
any
=
{},
store
:
Store
<
any
>
):
Promise
<
any
>
{
// const get: Promise<any> = Http.getInstance().get(url);
this
.
loadDictionaryDatas
(
store
);
// get.then((response: any) => {
try
{
// if (response && response.status === 200) {
let
response
=
await
Http
.
getInstance
().
get
(
url
);
// const { data }: { data: any } = response;
if
(
response
&&
response
.
status
===
200
)
{
// const { remotetag, localdata }: { remotetag: string, localdata: {} } = data;
let
{
data
}:
{
data
:
any
}
=
response
;
// if (remotetag) {
if
(
data
)
{
// store.commit('addAppData', remotetag);
// token认证把用户信息放入应用级数据
// }
if
(
localStorage
.
getItem
(
'user'
)){
// if (localdata) {
let
user
:
any
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
as
string
);
// store.commit('addLocalData', localdata);
let
localAppData
:
any
=
{};
// }
if
(
user
.
sessionParams
){
// }
localAppData
=
{
context
:
user
.
sessionParams
};
// }).catch((error: any) => {
Object
.
assign
(
localAppData
,
data
);
// });
}
return
await
this
.
loadDictionaryDatas
(
store
)
data
=
JSON
.
parse
(
JSON
.
stringify
(
localAppData
));
}
store
.
commit
(
'addAppData'
,
data
);
// 提交统一资源数据
store
.
dispatch
(
'authresource/commitAuthData'
,
data
);
}
return
true
;
}
}
catch
(
error
)
{
console
.
error
(
"获取应用数据出现异常"
);
}
}
}
/**
/**
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录