Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
x-learn
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
x-learn
Commits
20df7690
提交
20df7690
authored
10月 21, 2021
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增权限控制
上级
ddc37847
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
73 行增加
和
21 行删除
+73
-21
account.js
src/api/account.js
+5
-0
aside.vue
src/components/layout/aside.vue
+51
-18
index.js
src/store/index.js
+17
-3
没有找到文件。
src/api/account.js
浏览文件 @
20df7690
...
...
@@ -53,3 +53,8 @@ export function checkCode(params) {
export
function
chooseRole
(
data
)
{
return
httpRequest
.
post
(
'/api/zy/user/choose-role'
,
data
)
}
// 获取所有权限
export
function
getPermissions
()
{
return
httpRequest
.
get
(
'/api/zy/user/get-permissions'
)
}
src/components/layout/aside.vue
浏览文件 @
20df7690
...
...
@@ -10,7 +10,7 @@
</div>
<el-menu
class=
"nav"
:unique-opened=
"true"
:default-active=
"activeLink"
>
<template
v-for=
"item in currentMenus"
>
<el-submenu
:index=
"item.title"
:key=
"item.title"
v-if=
"item.children"
>
<el-submenu
:index=
"item.title"
:key=
"item.title"
v-
show=
"menuVisible(item.tag)"
v-
if=
"item.children"
>
<template
#
title
>
<i
class=
"iconfont"
:class=
"item.icon"
></i><span>
{{
item
.
title
}}
</span>
</
template
>
...
...
@@ -19,6 +19,7 @@
:key=
"item.title"
v-for=
"item in item.children"
@
click=
"handleClick(item.path, item)"
v-show=
"menuVisible(item.tag)"
>
<
template
#
title
>
<template
v-if=
"item.href"
>
...
...
@@ -29,7 +30,13 @@
</el-menu-item>
</el-submenu>
<el-menu-item
:index=
"item.path"
:key=
"item.title"
@
click=
"handleClick(item.path)"
v-else
>
<el-menu-item
:index=
"item.path"
:key=
"item.title"
@
click=
"handleClick(item.path)"
v-show=
"menuVisible(item.tag)"
v-else
>
<i
class=
"iconfont"
:class=
"item.icon"
></i>
<span
slot=
"title"
>
{{ item.title }}
</span>
</el-menu-item>
...
...
@@ -54,23 +61,26 @@ export default {
activeLink
:
'/course/learn'
,
studentMenus
:
[
{
tag
:
'menu_course'
,
title
:
'我的课程'
,
icon
:
'icon-bianzu6-hong'
,
children
:
[{
title
:
'课程学习'
,
path
:
'/course/learn'
}]
children
:
[{
t
ag
:
'menu_course_learn'
,
t
itle
:
'课程学习'
,
path
:
'/course/learn'
}]
},
{
tag
:
'menu_exam'
,
title
:
'模拟考试'
,
icon
:
'icon-bianzuhong'
,
children
:
[
{
title
:
'模拟考试'
,
path
:
'/testExam'
},
{
title
:
'错题集合'
,
path
:
'/my/questions/wrong'
},
{
title
:
'收藏试题'
,
path
:
'/my/questions/collection'
}
{
t
ag
:
'menu_exam_index'
,
t
itle
:
'模拟考试'
,
path
:
'/testExam'
},
{
t
ag
:
'menu_exam_wq'
,
t
itle
:
'错题集合'
,
path
:
'/my/questions/wrong'
},
{
t
ag
:
'menu_exam_cq'
,
t
itle
:
'收藏试题'
,
path
:
'/my/questions/collection'
}
]
},
{
tag
:
'menu_training'
,
title
:
'实训练习'
,
icon
:
'icon-kaoshihong'
,
children
:
[{
title
:
'实训案例练习'
,
path
:
xtrainingUrl
,
href
:
xtrainingUrl
}]
children
:
[{
t
ag
:
'menu_tranining_test'
,
t
itle
:
'实训案例练习'
,
path
:
xtrainingUrl
,
href
:
xtrainingUrl
}]
}
],
techerMenus
:
[
...
...
@@ -83,24 +93,27 @@ export default {
// ]
// },
{
tag
:
'menu_course'
,
title
:
'课程中心'
,
icon
:
'icon-bianzu6-hong'
,
children
:
[{
title
:
'课程库'
,
path
:
'/course/learn'
}]
children
:
[{
t
ag
:
'menu_course_learn'
,
t
itle
:
'课程库'
,
path
:
'/course/learn'
}]
},
{
tag
:
'menu_exam'
,
title
:
'模拟考试'
,
icon
:
'icon-bianzuhong'
,
children
:
[
{
title
:
'考卷批阅'
,
path
:
'/teacher/exam'
},
{
title
:
'习题批阅'
,
path
:
'/teacher/test'
}
{
t
ag
:
'menu_exam_paper_review'
,
t
itle
:
'考卷批阅'
,
path
:
'/teacher/exam'
},
{
t
ag
:
'menu_exam_exercise_review'
,
t
itle
:
'习题批阅'
,
path
:
'/teacher/test'
}
]
},
{
tag
:
'menu_training'
,
title
:
'实训资源'
,
icon
:
'icon-kaoshihong'
,
children
:
[
// { title: '实训课程库', path: '/teacher/practicalCourse' },
{
title
:
'实训课程库'
,
path
:
xtrainingUrl
,
href
:
xtrainingUrl
}
{
t
ag
:
'menu_tranining_test'
,
t
itle
:
'实训课程库'
,
path
:
xtrainingUrl
,
href
:
xtrainingUrl
}
]
}
// {
...
...
@@ -115,21 +128,23 @@ export default {
],
defaultMenus
:
[
{
tag
:
'menu_my'
,
title
:
'个人中心'
,
icon
:
'icon-guanlizhongxinbeifen-hong'
,
children
:
[
{
title
:
'个人信息'
,
path
:
'/account'
},
{
title
:
'修改密码'
,
path
:
'/account/password'
},
{
title
:
'安全设置'
,
path
:
'/account/safe'
}
{
t
ag
:
'menu_my_info'
,
t
itle
:
'个人信息'
,
path
:
'/account'
},
{
t
ag
:
'menu_my_password'
,
t
itle
:
'修改密码'
,
path
:
'/account/password'
},
{
t
ag
:
'menu_my_safe'
,
t
itle
:
'安全设置'
,
path
:
'/account/safe'
}
]
},
{
tag
:
'menu_help'
,
title
:
'帮助与反馈'
,
icon
:
'icon-bianzu8-hong'
,
children
:
[
{
title
:
'服务专区'
,
path
:
'/contact'
},
{
title
:
'系统说明'
,
path
:
'/doc'
},
{
title
:
'常见问题'
,
path
:
'/help'
}
{
t
ag
:
'menu_help_services'
,
t
itle
:
'服务专区'
,
path
:
'/contact'
},
{
t
ag
:
'menu_help_system'
,
t
itle
:
'系统说明'
,
path
:
'/doc'
},
{
t
ag
:
'menu_help_qa'
,
t
itle
:
'常见问题'
,
path
:
'/help'
}
]
}
]
...
...
@@ -145,10 +160,22 @@ export default {
:
this
.
studentMenus
.
concat
(
this
.
defaultMenus
)
},
user
()
{
return
this
.
$store
.
state
.
user
return
this
.
$store
.
state
.
user
||
{}
},
avatar
()
{
return
this
.
user
.
avatar
||
defaultAvatar
},
// 菜单权限
menuPermissions
()
{
// role: 1学生,2老师
// system_tag: 2教师,3学生
return
this
.
$store
.
state
.
permissions
.
filter
(
item
=>
{
if
(
this
.
user
.
role
===
2
)
{
return
item
.
system_tag
===
2
}
else
{
return
item
.
system_tag
===
3
}
})
}
},
watch
:
{
...
...
@@ -160,6 +187,12 @@ export default {
}
},
methods
:
{
menuVisible
(
tag
)
{
if
(
!
tag
)
{
return
true
}
return
!!
this
.
menuPermissions
.
find
(
item
=>
item
.
tag
===
tag
)
},
genClasses
(
data
)
{
const
isActive
=
this
.
$route
.
fullPath
.
includes
(
data
.
path
)
return
{
'is-active'
:
isActive
}
...
...
src/store/index.js
浏览文件 @
20df7690
import
Vue
from
'vue'
import
Vuex
from
'vuex'
import
{
getUser
,
logout
,
getIsVip
,
createGuestUser
}
from
'@/api/account'
import
{
getUser
,
logout
,
getIsVip
,
createGuestUser
,
getPermissions
}
from
'@/api/account'
Vue
.
use
(
Vuex
)
const
store
=
new
Vuex
.
Store
({
...
...
@@ -12,7 +12,8 @@ const store = new Vuex.Store({
isIos
:
/iphone|ipad|ipod/i
.
test
(
navigator
.
userAgent
),
isAndroid
:
/android/i
.
test
(
navigator
.
userAgent
),
isWeapp
:
/miniProgram/
.
test
(
navigator
.
userAgent
),
guestUser
:
{
user_id
:
''
,
student_id
:
''
}
guestUser
:
{
user_id
:
''
,
student_id
:
''
},
permissions
:
[]
},
mutations
:
{
setUser
(
state
,
user
)
{
...
...
@@ -30,6 +31,9 @@ const store = new Vuex.Store({
setGuestUser
(
state
,
user
)
{
state
.
guestUser
=
user
window
.
localStorage
.
setItem
(
'guestUser'
,
JSON
.
stringify
(
user
))
},
setPermissions
(
state
,
permissions
)
{
state
.
permissions
=
permissions
}
},
actions
:
{
...
...
@@ -87,13 +91,23 @@ const store = new Vuex.Store({
}
}
commit
(
'setGuestUser'
,
guestUser
)
},
// 获取所有权限列表
getPermissions
({
commit
})
{
getPermissions
({
type
:
1
}).
then
(
res
=>
{
if
(
res
.
data
&&
res
.
data
.
items
)
{
commit
(
'setPermissions'
,
res
.
data
.
items
)
}
})
}
}
})
export
default
store
store
.
dispatch
(
'getPermissions'
)
// 加载本地游客用户
// store.dispatch('loadGuestUser')
// 检测是否付费
// store.dispatch('checkIsVip')
export
default
store
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论