Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
mall-admin
提交
de3d0ef8
M
mall-admin
项目概览
有来技术
/
mall-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mall-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
de3d0ef8
编写于
3月 22, 2022
作者:
郝
郝先瑞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 代码优化
上级
88ee9c7d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
18 deletion
+15
-18
src/router/index.ts
src/router/index.ts
+2
-2
src/store/modules/permission.ts
src/store/modules/permission.ts
+8
-10
src/store/modules/user.ts
src/store/modules/user.ts
+2
-3
src/types/api/system/user.d.ts
src/types/api/system/user.d.ts
+1
-1
src/views/system/user/index.vue
src/views/system/user/index.vue
+2
-2
未找到文件。
src/router/index.ts
浏览文件 @
de3d0ef8
...
...
@@ -42,7 +42,8 @@ export const constantRoutes: Array<RouteRecordRaw> = [
name
:
'
Dashboard
'
,
meta
:
{
title
:
'
dashboard
'
,
icon
:
'
dashboard
'
,
affix
:
true
}
}
]
]
}
// 外部链接
/*{
...
...
@@ -95,7 +96,6 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
]
}*/
}
]
// 创建路由
...
...
src/store/modules/permission.ts
浏览文件 @
de3d0ef8
import
{
PermissionState
}
from
"
@/types
"
;
import
{
RouteRecordRaw
}
from
'
vue-router
'
import
{
constantRoutes
}
from
'
@/router
'
import
{
listRoutes
}
from
"
@/api/system/menu
"
;
import
{
defineStore
}
from
"
pinia
"
;
import
{
PermissionState
}
from
"
@/types
"
;
import
{
RouteRecordRaw
}
from
'
vue-router
'
import
{
defineStore
}
from
"
pinia
"
;
import
{
constantRoutes
}
from
'
@/router
'
import
{
listRoutes
}
from
"
@/api/system/menu
"
;
const
modules
=
import
.
meta
.
glob
(
"
../../views/**/**.vue
"
);
export
const
Layout
=
()
=>
import
(
'
@/layout/index.vue
'
)
export
const
Layout
=
()
=>
import
(
'
@/layout/index.vue
'
)
const
hasPermission
=
(
roles
:
string
[],
route
:
RouteRecordRaw
)
=>
{
if
(
route
.
meta
&&
route
.
meta
.
roles
)
{
...
...
@@ -24,7 +24,7 @@ const hasPermission = (roles: string[], route: RouteRecordRaw) => {
export
const
filterAsyncRoutes
=
(
routes
:
RouteRecordRaw
[],
roles
:
string
[])
=>
{
const
res
:
RouteRecordRaw
[]
=
[]
routes
.
forEach
(
route
=>
{
const
tmp
=
{
...
route
}
as
any
const
tmp
=
{
...
route
}
as
any
if
(
hasPermission
(
roles
,
tmp
))
{
if
(
tmp
.
component
==
'
Layout
'
)
{
tmp
.
component
=
Layout
...
...
@@ -47,7 +47,7 @@ export const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) =>
}
const
usePermissionStore
=
defineStore
({
const
usePermissionStore
=
defineStore
({
id
:
"
permission
"
,
state
:
():
PermissionState
=>
({
routes
:
[],
...
...
@@ -73,6 +73,4 @@ export const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) =>
}
})
export
default
usePermissionStore
;
src/store/modules/user.ts
浏览文件 @
de3d0ef8
import
{
defineStore
}
from
"
pinia
"
;
import
{
LoginFormData
,
UserState
}
from
"
@/types
"
;
import
{
localStorage
}
from
"
@/utils/storage
"
;
import
{
resetRouter
}
from
"
@/router
"
;
import
{
login
,
logout
}
from
"
@/api/login
"
;
import
{
getUserInfo
}
from
"
@/api/system/user
"
;
import
{
resetRouter
}
from
"
@/router
"
;
const
useUserStore
=
defineStore
({
id
:
"
user
"
,
...
...
@@ -53,8 +53,7 @@ const useUserStore = defineStore({
*/
getUserInfo
()
{
return
new
Promise
(((
resolve
,
reject
)
=>
{
getUserInfo
().
then
(
response
=>
{
const
{
data
}
=
response
getUserInfo
().
then
(({
data
})
=>
{
if
(
!
data
)
{
return
reject
(
'
Verification failed, please Login again.
'
)
}
...
...
src/types/api/system/user.d.ts
浏览文件 @
de3d0ef8
import
{
PageQueryParam
,
PageResult
}
from
"
../base
"
/**
*
用户信息
类型声明
*
登录用户
类型声明
*/
export
interface
UserInfo
{
nickname
:
string
,
...
...
src/views/system/user/index.vue
浏览文件 @
de3d0ef8
...
...
@@ -276,7 +276,7 @@ import {
// API依赖
import
{
listUser
Pages
,
listUser
sPage
,
getUserFormDetail
,
deleteUsers
,
addUser
,
...
...
@@ -451,7 +451,7 @@ function handleStatusChange(row: { [key: string]: any }) {
**/
function
handleQuery
()
{
state
.
loading
=
true
;
listUser
Pages
(
state
.
queryParams
).
then
(({
data
})
=>
{
listUser
sPage
(
state
.
queryParams
).
then
(({
data
})
=>
{
state
.
userList
=
data
.
list
;
state
.
total
=
data
.
total
;
state
.
loading
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录