Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-resource
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-resource
Commits
be59d92a
提交
be59d92a
authored
6月 14, 2022
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 新增权限方法和指令;优化store数据;新增401页面;
上级
b39cd786
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
122 行增加
和
34 行删除
+122
-34
base.ts
src/api/base.ts
+3
-4
Header.vue
src/components/layout/Header.vue
+1
-1
main.ts
src/main.ts
+4
-0
index.ts
src/modules/error/index.ts
+8
-0
401.vue
src/modules/error/views/401.vue
+0
-0
List.vue
src/modules/system/dictionary/views/List.vue
+1
-1
index.ts
src/router/index.ts
+3
-2
map.ts
src/stores/map.ts
+12
-4
user.ts
src/stores/user.ts
+22
-20
types.ts
src/types.ts
+45
-0
axios.ts
src/utils/axios.ts
+1
-2
permission.ts
src/utils/permission.ts
+22
-0
没有找到文件。
src/api/base.ts
浏览文件 @
be59d92a
...
...
@@ -2,7 +2,7 @@ import httpRequest from '@/utils/axios'
// 获取用户信息
export
function
getUser
()
{
return
httpRequest
.
get
(
'/api/
passport/account/get-user-
info'
)
return
httpRequest
.
get
(
'/api/
resource/v1/util/
info'
)
}
// 退出登录
...
...
@@ -40,7 +40,7 @@ export function getMapList() {
}
// 上传视频
export
function
getCreateAuth
(
data
:
{
title
:
string
,
file_name
:
string
})
{
export
function
getCreateAuth
(
data
:
{
title
:
string
;
file_name
:
string
})
{
return
httpRequest
.
post
(
'/api/resource/v1/resource/video/create-auth'
,
data
)
}
...
...
@@ -57,4 +57,4 @@ export function getCategoryList(params: { type: string; category_name?: string }
// 获取项目列表
export
function
getProjectList
(
params
:
{
organization_id
:
string
})
{
return
httpRequest
.
get
(
'/api/resource/v1/util/members'
,
{
params
})
}
\ No newline at end of file
}
src/components/layout/Header.vue
浏览文件 @
be59d92a
...
...
@@ -51,7 +51,7 @@ function genNavClassName(data: IMenuItem) {
<img
:src=
"userInfo.avatar || 'https://webapp-pub.ezijing.com/website/base/images/avatar.svg'"
/>
</div>
<div
class=
"app-header-user-main"
>
<h3>
{{
user
Store
.
userN
ame
}}
</h3>
<h3>
{{
user
Info
.
n
ame
}}
</h3>
<p>
{{
userInfo
.
email
||
userInfo
.
mobile
}}
</p>
</div>
<div
class=
"app-header-user-buttons"
>
...
...
src/main.ts
浏览文件 @
be59d92a
...
...
@@ -14,9 +14,13 @@ import AppList from '@/components/base/AppList.vue'
import
AppUpload
from
'@/components/base/AppUpload.vue'
import
modules
from
'./modules'
import
{
permissionDirective
}
from
'@/utils/permission'
const
app
=
createApp
(
App
)
// 注册公共组件
app
.
component
(
'AppCard'
,
AppCard
).
component
(
'AppList'
,
AppList
).
component
(
'AppUpload'
,
AppUpload
)
app
.
directive
(
'permission'
,
permissionDirective
)
// 注册模块
modules
({
router
})
...
...
src/modules/error/index.ts
0 → 100644
浏览文件 @
be59d92a
const
routes
=
[
{
path
:
'/401'
,
component
:
()
=>
import
(
'./views/401.vue'
)
}
]
export
{
routes
}
src/modules/error/views/401.vue
0 → 100644
浏览文件 @
be59d92a
差异被折叠。
点击展开。
src/modules/system/dictionary/views/List.vue
浏览文件 @
be59d92a
...
...
@@ -100,7 +100,7 @@ const handleUpdate = () => {
<AppCard
title=
"数据字典"
>
<AppList
v-bind=
"listOptions"
ref=
"appList"
border
stripe
>
<el-row>
<el-button
type=
"primary"
@
click=
"handleAdd"
style=
"margin-bottom: 20px"
>
新增字典
</el-button>
<el-button
type=
"primary"
@
click=
"handleAdd"
style=
"margin-bottom: 20px"
v-permission=
"'test1'"
>
新增字典
</el-button>
</el-row>
<template
v-slot:created_time_start=
"
{ params }">
<el-date-picker
v-model=
"params.created_time_start"
type=
"date"
placeholder=
"开始时间"
>
</el-date-picker>
...
...
src/router/index.ts
浏览文件 @
be59d92a
...
...
@@ -7,14 +7,15 @@ const router = createRouter({
})
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
const
whiteList
=
[
'/401'
]
const
user
=
useUserStore
()
if
(
!
user
.
isLogin
)
{
if
(
!
user
.
isLogin
&&
!
whiteList
.
includes
(
to
.
path
)
)
{
try
{
await
user
.
getUser
()
}
catch
(
e
)
{
console
.
error
(
e
)
}
user
.
isLogin
?
next
()
:
(
location
.
href
=
`
${
import
.
meta
.
env
.
VITE_LOGIN_URL
}
?rd=
${
encodeURIComponent
(
location
.
href
)}
`
)
user
.
isLogin
?
next
()
:
next
(
'/401'
)
return
}
next
()
...
...
src/stores/map.ts
浏览文件 @
be59d92a
import
{
defineStore
}
from
'pinia'
import
{
getMapList
}
from
'@/api/base'
interface
State
{
mapList
:
IMapState
[]
}
interface
IMapState
{
id
:
string
key
:
string
...
...
@@ -17,18 +20,23 @@ interface IValuesList {
sort
:
string
value
:
string
}
export
const
useMapStore
=
defineStore
({
id
:
'map'
,
state
:
()
=>
{
state
:
()
:
State
=>
{
return
{
mapList
:
[]
as
IMapState
|
any
mapList
:
[]
}
},
getters
:
{
getMapValuesByKey
:
state
=>
{
return
(
key
:
string
)
=>
state
.
mapList
.
find
(
map
=>
map
.
key
===
key
)?.
values
||
[]
}
},
getters
:
{},
actions
:
{
async
getMapList
()
{
const
res
=
await
getMapList
()
this
.
mapList
=
res
.
data
this
.
mapList
=
res
.
data
||
[]
}
}
})
...
...
src/stores/user.ts
浏览文件 @
be59d92a
import
{
defineStore
}
from
'pinia'
import
{
getUser
,
logout
}
from
'@/api/base'
import
type
{
UserType
,
ProjectType
,
OrganizationType
,
RoleType
,
PermissionType
}
from
'@/types'
interface
IUserState
{
id
:
string
avatar
:
string
mobile
:
string
realname
:
string
nickname
:
string
username
:
string
email
:
string
interface
State
{
user
:
UserType
|
null
project
:
ProjectType
|
null
organization
:
OrganizationType
|
null
roles
:
RoleType
[]
permissions
:
PermissionType
[]
}
export
const
useUserStore
=
defineStore
({
id
:
'user'
,
state
:
()
=>
{
return
{
user
:
null
as
IUserState
|
null
}
},
state
:
():
State
=>
({
user
:
null
,
organization
:
null
,
project
:
null
,
roles
:
[],
permissions
:
[]
}),
getters
:
{
isLogin
:
state
=>
!!
state
.
user
,
userName
:
({
user
})
=>
{
if
(
!
user
)
return
''
return
user
.
realname
||
user
.
nickname
||
user
.
username
||
''
}
isLogin
:
state
=>
!!
state
.
user
},
actions
:
{
async
getUser
()
{
const
res
=
await
getUser
()
this
.
user
=
res
.
data
console
.
log
(
res
.
data
,
'res.data'
)
const
{
info
}
=
res
.
data
const
{
organization
,
project
,
roles
,
permissions
}
=
res
.
data
.
permissions
this
.
user
=
info
this
.
organization
=
organization
this
.
project
=
project
this
.
roles
=
roles
this
.
permissions
=
permissions
},
async
logout
()
{
await
logout
()
...
...
src/types.ts
浏览文件 @
be59d92a
...
...
@@ -6,3 +6,48 @@ export interface IMenuItem {
icon
?:
Component
children
?:
IMenuItem
[]
}
// 用户信息
export
interface
UserType
{
id
:
string
mobile
:
string
name
:
string
email
:
string
username
:
string
avatar
:
string
}
// 项目信息
export
interface
ProjectType
{
id
:
string
tab
:
string
name
:
string
}
// 机构信息
export
interface
OrganizationType
{
id
:
string
name
:
string
contact_name
:
string
contact_information
:
string
validity_date
:
string
is_valid
:
1
|
2
}
// 角色信息
export
interface
RoleType
{
id
:
string
name
:
string
desc
:
string
}
// 权限信息
export
interface
PermissionType
{
desc
:
string
effect_uris
:
string
id
:
string
name
:
string
parent_id
:
string
system_tag
:
number
type
:
number
tag
:
string
}
src/utils/axios.ts
浏览文件 @
be59d92a
...
...
@@ -4,7 +4,6 @@ import { ElMessage } from 'element-plus'
import
router
from
'@/router'
const
httpRequest
=
axios
.
create
({
// baseURL: 'https://project-api.ezijing.com',
timeout
:
60000
,
withCredentials
:
true
,
headers
:
{
...
...
@@ -52,7 +51,7 @@ httpRequest.interceptors.response.use(
// 未登录
if
(
status
===
403
)
{
location
.
href
=
`
${
import
.
meta
.
env
.
VITE_LOGIN_URL
}
?rd=
${
encodeURIComponent
(
location
.
href
)}
`
}
else
if
(
status
===
400
)
{
}
else
if
(
status
===
400
||
status
===
402
)
{
// 未授权
router
.
push
(
'/401'
)
}
else
{
...
...
src/utils/permission.ts
0 → 100644
浏览文件 @
be59d92a
import
{
useUserStore
}
from
'@/stores/user'
import
type
{
DirectiveBinding
}
from
'vue'
// 判断是否有权限
export
function
checkPermission
(
value
:
string
|
string
[]):
boolean
{
const
userStore
=
useUserStore
()
const
permissions
=
userStore
.
permissions
if
(
Array
.
isArray
(
value
))
{
return
permissions
.
some
(
item
=>
value
.
includes
(
item
.
tag
))
}
else
{
return
!!
permissions
.
find
(
item
=>
item
.
tag
===
value
)
}
}
// 权限指令
export
function
permissionDirective
(
el
:
HTMLElement
,
binding
:
DirectiveBinding
)
{
const
{
value
}
=
binding
if
(
!
value
)
return
if
(
!
checkPermission
(
value
))
{
el
.
parentNode
&&
el
.
parentNode
.
removeChild
(
el
)
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论