Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Bug 终结者
vue-vben-admin
提交
8fb03961
V
vue-vben-admin
项目概览
Bug 终结者
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8fb03961
编写于
3月 23, 2021
作者:
V
Vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: ensure permissionMode exists close #409
上级
fedd9cae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
16 deletion
+18
-16
src/settings/projectSetting.ts
src/settings/projectSetting.ts
+1
-1
src/store/modules/permission.ts
src/store/modules/permission.ts
+15
-13
src/utils/helper/vuexHelper.ts
src/utils/helper/vuexHelper.ts
+2
-2
未找到文件。
src/settings/projectSetting.ts
浏览文件 @
8fb03961
...
@@ -20,7 +20,7 @@ const setting: ProjectConfig = {
...
@@ -20,7 +20,7 @@ const setting: ProjectConfig = {
settingButtonPosition
:
SettingButtonPositionEnum
.
AUTO
,
settingButtonPosition
:
SettingButtonPositionEnum
.
AUTO
,
// Permission mode
// Permission mode
permissionMode
:
PermissionModeEnum
.
ROLE
,
permissionMode
:
PermissionModeEnum
.
BACK
,
// Permission-related cache is stored in sessionStorage or localStorage
// Permission-related cache is stored in sessionStorage or localStorage
permissionCacheType
:
CacheTypeEnum
.
LOCAL
,
permissionCacheType
:
CacheTypeEnum
.
LOCAL
,
...
...
src/store/modules/permission.ts
浏览文件 @
8fb03961
import
type
{
AppRouteRecordRaw
,
Menu
}
from
'
/@/router/types
'
;
import
type
{
AppRouteRecordRaw
,
Menu
}
from
'
/@/router/types
'
;
import
store
from
'
/@/store/index
'
;
import
{
hotModuleUnregisterModule
}
from
'
/@/utils/helper/vuexHelper
'
;
import
store
from
'
/@/store
'
;
import
{
toRaw
}
from
'
vue
'
;
import
{
VuexModule
,
Mutation
,
Module
,
getModule
,
Action
}
from
'
vuex-module-decorators
'
;
import
{
VuexModule
,
Mutation
,
Module
,
getModule
,
Action
}
from
'
vuex-module-decorators
'
;
import
{
hotModuleUnregisterModule
}
from
'
/@/utils/helper/vuexHelper
'
;
import
{
PermissionModeEnum
}
from
'
/@/enums/appEnum
'
;
import
{
PermissionModeEnum
}
from
'
/@/enums/appEnum
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
{
userStore
}
from
'
/@/store/modules/user
'
;
import
{
userStore
}
from
'
/@/store/modules/user
'
;
import
projectSetting
from
'
/@/settings/projectSetting
'
;
import
{
asyncRoutes
}
from
'
/@/router/routes
'
;
import
{
asyncRoutes
}
from
'
/@/router/routes
'
;
import
{
ERROR_LOG_ROUTE
,
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/routes/basic
'
;
import
{
transformObjToRoute
,
flatMultiLevelRoutes
}
from
'
/@/router/helper/routeHelper
'
;
import
{
transformRouteToMenu
}
from
'
/@/router/helper/menuHelper
'
;
import
{
filter
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
filter
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
toRaw
}
from
'
vue
'
;
import
{
getMenuListById
}
from
'
/@/api/sys/menu
'
;
import
{
getMenuListById
}
from
'
/@/api/sys/menu
'
;
import
{
getPermCodeByUserId
}
from
'
/@/api/sys/user
'
;
import
{
getPermCodeByUserId
}
from
'
/@/api/sys/user
'
;
import
{
transformObjToRoute
,
flatMultiLevelRoutes
}
from
'
/@/router/helper/routeHelper
'
;
import
{
transformRouteToMenu
}
from
'
/@/router/helper/menuHelper
'
;
import
{
useMessage
}
from
'
/@/hooks/web/useMessage
'
;
import
{
useMessage
}
from
'
/@/hooks/web/useMessage
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
ERROR_LOG_ROUTE
,
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/routes/basic
'
;
const
{
createMessage
}
=
useMessage
();
const
NAME
=
'
app-permission
'
;
const
NAME
=
'
app-permission
'
;
hotModuleUnregisterModule
(
NAME
);
hotModuleUnregisterModule
(
NAME
);
@
Module
({
dynamic
:
true
,
namespaced
:
true
,
store
,
name
:
NAME
})
@
Module
({
dynamic
:
true
,
namespaced
:
true
,
store
,
name
:
NAME
})
...
@@ -94,13 +96,11 @@ class Permission extends VuexModule {
...
@@ -94,13 +96,11 @@ class Permission extends VuexModule {
const
{
t
}
=
useI18n
();
const
{
t
}
=
useI18n
();
let
routes
:
AppRouteRecordRaw
[]
=
[];
let
routes
:
AppRouteRecordRaw
[]
=
[];
const
roleList
=
toRaw
(
userStore
.
getRoleListState
);
const
roleList
=
toRaw
(
userStore
.
getRoleListState
);
const
{
permissionMode
=
projectSetting
.
permissionMode
}
=
appStore
.
getProjectConfig
;
const
{
permissionMode
=
PermissionModeEnum
.
ROLE
}
=
appStore
.
getProjectConfig
;
// role permissions
// role permissions
if
(
permissionMode
===
PermissionModeEnum
.
ROLE
)
{
if
(
permissionMode
===
PermissionModeEnum
.
ROLE
)
{
const
routeFilter
=
(
route
)
=>
{
const
routeFilter
=
(
route
:
AppRouteRecordRaw
)
=>
{
const
{
meta
}
=
route
as
AppRouteRecordRaw
;
const
{
meta
}
=
route
;
const
{
roles
}
=
meta
||
{};
const
{
roles
}
=
meta
||
{};
if
(
!
roles
)
return
true
;
if
(
!
roles
)
return
true
;
return
roleList
.
some
((
role
)
=>
roles
.
includes
(
role
));
return
roleList
.
some
((
role
)
=>
roles
.
includes
(
role
));
...
@@ -111,6 +111,8 @@ class Permission extends VuexModule {
...
@@ -111,6 +111,8 @@ class Permission extends VuexModule {
routes
=
flatMultiLevelRoutes
(
routes
);
routes
=
flatMultiLevelRoutes
(
routes
);
// If you are sure that you do not need to do background dynamic permissions, please comment the entire judgment below
// If you are sure that you do not need to do background dynamic permissions, please comment the entire judgment below
}
else
if
(
permissionMode
===
PermissionModeEnum
.
BACK
)
{
}
else
if
(
permissionMode
===
PermissionModeEnum
.
BACK
)
{
const
{
createMessage
}
=
useMessage
();
createMessage
.
loading
({
createMessage
.
loading
({
content
:
t
(
'
sys.app.menuLoading
'
),
content
:
t
(
'
sys.app.menuLoading
'
),
duration
:
1
,
duration
:
1
,
...
...
src/utils/helper/vuexHelper.ts
浏览文件 @
8fb03961
import
store
from
'
/@/store
'
;
import
store
from
'
/@/store
'
;
export
function
hotModuleUnregisterModule
(
name
:
string
)
{
export
function
hotModuleUnregisterModule
(
name
:
string
)
{
if
(
!
name
)
return
;
if
(
!
name
||
!
import
.
meta
.
hot
)
return
;
if
((
store
.
state
as
any
)[
name
])
{
if
((
store
.
state
as
Recordable
)[
name
])
{
store
.
unregisterModule
(
name
);
store
.
unregisterModule
(
name
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录