Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
02230d5e
提交
02230d5e
authored
3月 04, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 增加全局loading
上级
2b104fa0
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
104 行增加
和
13 行删除
+104
-13
user.js
frontend/src/api/system/user.js
+2
-1
AppMain.vue
frontend/src/layout/components/AppMain.vue
+7
-7
Topbar.vue
frontend/src/layout/components/Topbar.vue
+2
-0
permission.js
frontend/src/permission.js
+1
-0
getters.js
frontend/src/store/getters.js
+3
-1
index.js
frontend/src/store/index.js
+3
-2
permission.js
frontend/src/store/modules/permission.js
+7
-0
request.js
frontend/src/store/modules/request.js
+46
-0
loading.js
frontend/src/utils/loading.js
+20
-0
request.js
frontend/src/utils/request.js
+8
-0
index.vue
frontend/src/views/system/menu/index.vue
+1
-1
index.vue
frontend/src/views/system/user/index.vue
+4
-1
没有找到文件。
frontend/src/api/system/user.js
浏览文件 @
02230d5e
...
@@ -11,7 +11,8 @@ export function userLists(page, size, data) {
...
@@ -11,7 +11,8 @@ export function userLists(page, size, data) {
return
request
({
return
request
({
url
:
pathMap
.
queryPath
+
page
+
'/'
+
size
,
url
:
pathMap
.
queryPath
+
page
+
'/'
+
size
,
method
:
'post'
,
method
:
'post'
,
data
data
,
loading
:
true
})
})
}
}
...
...
frontend/src/layout/components/AppMain.vue
浏览文件 @
02230d5e
<
template
>
<
template
>
<section
class=
"app-main"
>
<section
class=
"app-main"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
<el-main
class=
"ms-main-container"
>
<el-main
class=
"ms-main-container"
>
<keep-alive>
<keep-alive>
<router-view
:key=
"key"
/>
<router-view
:key=
"key"
/>
</keep-alive>
</keep-alive>
</el-main>
</el-main>
</transition>
</transition>
</section>
</section>
</
template
>
</
template
>
<
script
>
<
script
>
...
...
frontend/src/layout/components/Topbar.vue
浏览文件 @
02230d5e
...
@@ -106,6 +106,7 @@ export default {
...
@@ -106,6 +106,7 @@ export default {
'permission_routes'
'permission_routes'
])
])
},
},
mounted
()
{
mounted
()
{
this
.
initCurrentRoutes
()
this
.
initCurrentRoutes
()
},
},
...
@@ -190,6 +191,7 @@ export default {
...
@@ -190,6 +191,7 @@ export default {
await
this
.
$store
.
dispatch
(
'user/logout'
)
await
this
.
$store
.
dispatch
(
'user/logout'
)
this
.
$router
.
push
(
`/login?redirect=
${
this
.
$route
.
fullPath
}
`
)
this
.
$router
.
push
(
`/login?redirect=
${
this
.
$route
.
fullPath
}
`
)
}
}
}
}
}
}
</
script
>
</
script
>
...
...
frontend/src/permission.js
浏览文件 @
02230d5e
...
@@ -31,6 +31,7 @@ router.beforeEach(async(to, from, next) => {
...
@@ -31,6 +31,7 @@ router.beforeEach(async(to, from, next) => {
const
hasGetUserInfo
=
store
.
getters
.
name
const
hasGetUserInfo
=
store
.
getters
.
name
if
(
hasGetUserInfo
)
{
if
(
hasGetUserInfo
)
{
next
()
next
()
store
.
dispatch
(
'permission/setCurrentPath'
,
to
.
path
)
}
else
{
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
// get user info
// get user info
...
...
frontend/src/store/getters.js
浏览文件 @
02230d5e
...
@@ -14,6 +14,8 @@ const getters = {
...
@@ -14,6 +14,8 @@ const getters = {
addRouters
:
state
=>
state
.
permission
.
addRouters
,
addRouters
:
state
=>
state
.
permission
.
addRouters
,
errorLogs
:
state
=>
state
.
errorLog
.
logs
,
errorLogs
:
state
=>
state
.
errorLog
.
logs
,
sceneData
:
state
=>
state
.
dataset
.
sceneData
,
sceneData
:
state
=>
state
.
dataset
.
sceneData
,
table
:
state
=>
state
.
dataset
.
table
table
:
state
=>
state
.
dataset
.
table
,
loadingMap
:
state
=>
state
.
request
.
loadingMap
,
currentPath
:
state
=>
state
.
permission
.
currentPath
}
}
export
default
getters
export
default
getters
frontend/src/store/index.js
浏览文件 @
02230d5e
...
@@ -7,7 +7,7 @@ import user from './modules/user'
...
@@ -7,7 +7,7 @@ import user from './modules/user'
import
permission
from
'./modules/permission'
import
permission
from
'./modules/permission'
import
dataset
from
'./modules/dataset'
import
dataset
from
'./modules/dataset'
import
chart
from
'./modules/chart'
import
chart
from
'./modules/chart'
import
request
from
'./modules/request'
Vue
.
use
(
Vuex
)
Vue
.
use
(
Vuex
)
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
...
@@ -17,7 +17,8 @@ const store = new Vuex.Store({
...
@@ -17,7 +17,8 @@ const store = new Vuex.Store({
user
,
user
,
permission
,
permission
,
dataset
,
dataset
,
chart
chart
,
request
},
},
getters
getters
})
})
...
...
frontend/src/store/modules/permission.js
浏览文件 @
02230d5e
...
@@ -2,6 +2,7 @@ import { constantRoutes } from '@/router'
...
@@ -2,6 +2,7 @@ import { constantRoutes } from '@/router'
import
Layout
from
'@/layout/index'
import
Layout
from
'@/layout/index'
const
state
=
{
const
state
=
{
currentPath
:
null
,
routes
:
[],
routes
:
[],
addRoutes
:
[],
addRoutes
:
[],
currentRoutes
:
{}
currentRoutes
:
{}
...
@@ -14,12 +15,18 @@ const mutations = {
...
@@ -14,12 +15,18 @@ const mutations = {
},
},
SET_CURRENT_ROUTES
:
(
state
,
routes
)
=>
{
SET_CURRENT_ROUTES
:
(
state
,
routes
)
=>
{
state
.
currentRoutes
=
routes
state
.
currentRoutes
=
routes
},
SET_CURRENT_PATH
:
(
state
,
path
)
=>
{
state
.
currentPath
=
path
}
}
}
}
const
actions
=
{
const
actions
=
{
GenerateRoutes
({
commit
},
asyncRouter
)
{
GenerateRoutes
({
commit
},
asyncRouter
)
{
commit
(
'SET_ROUTERS'
,
asyncRouter
)
commit
(
'SET_ROUTERS'
,
asyncRouter
)
},
setCurrentPath
({
commit
},
path
)
{
commit
(
'SET_CURRENT_PATH'
,
path
)
}
}
}
}
...
...
frontend/src/store/modules/request.js
0 → 100644
浏览文件 @
02230d5e
const
state
=
{
loadingMap
:
{}
}
const
mutations
=
{
SET_LOADING_MAP
:
(
state
,
value
)
=>
{
state
.
loadingMap
=
value
},
ADD_LOADING
:
(
state
,
key
)
=>
{
if
(
state
.
loadingMap
.
hasOwnProperty
(
key
))
{
const
map
=
state
.
loadingMap
map
[
key
]
+=
1
state
.
loadingMap
=
map
}
else
{
const
nMap
=
{}
nMap
[
key
]
=
1
state
.
loadingMap
=
nMap
}
},
REDUCE_LOADING
:
(
state
,
key
)
=>
{
if
(
state
.
loadingMap
)
{
const
map
=
state
.
loadingMap
map
[
key
]
-=
1
state
.
loadingMap
=
map
}
}
}
const
actions
=
{
addLoading
({
commit
},
data
)
{
commit
(
'ADD_LOADING'
,
data
)
},
reduceLoading
({
commit
},
data
)
{
commit
(
'REDUCE_LOADING'
,
data
)
}
}
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
}
frontend/src/utils/loading.js
0 → 100644
浏览文件 @
02230d5e
import
store
from
'@/store'
export
const
tryShowLoading
=
identification
=>
{
if
(
!
identification
)
return
// const count = store.getters.loadingMap[identification]
store
.
dispatch
(
'request/addLoading'
,
identification
)
}
export
const
tryHideLoading
=
identification
=>
{
if
(
!
identification
)
return
const
count
=
store
.
getters
.
loadingMap
[
identification
]
if
(
count
>
0
)
{
// setTimeout(() => {
// store.dispatch('request/reduceLoading', identification)
// }, 1000)
store
.
dispatch
(
'request/reduceLoading'
,
identification
)
}
}
frontend/src/utils/request.js
浏览文件 @
02230d5e
...
@@ -5,6 +5,9 @@ import { $alert, $error } from './message'
...
@@ -5,6 +5,9 @@ import { $alert, $error } from './message'
import
{
getToken
}
from
'@/utils/auth'
import
{
getToken
}
from
'@/utils/auth'
import
Config
from
'@/settings'
import
Config
from
'@/settings'
import
{
tryShowLoading
,
tryHideLoading
}
from
'./loading'
// import router from '@/router'
const
TokenKey
=
Config
.
TokenKey
const
TokenKey
=
Config
.
TokenKey
// create an axios instance
// create an axios instance
const
service
=
axios
.
create
({
const
service
=
axios
.
create
({
...
@@ -24,6 +27,10 @@ service.interceptors.request.use(
...
@@ -24,6 +27,10 @@ service.interceptors.request.use(
// please modify it according to the actual situation
// please modify it according to the actual situation
config
.
headers
[
TokenKey
]
=
getToken
()
config
.
headers
[
TokenKey
]
=
getToken
()
}
}
// 增加loading
config
.
loading
&&
tryShowLoading
(
store
.
getters
.
currentPath
)
return
config
return
config
},
},
error
=>
{
error
=>
{
...
@@ -97,6 +104,7 @@ service.interceptors.response.use(
...
@@ -97,6 +104,7 @@ service.interceptors.response.use(
*/
*/
// 请根据实际需求修改
// 请根据实际需求修改
service
.
interceptors
.
response
.
use
(
response
=>
{
service
.
interceptors
.
response
.
use
(
response
=>
{
response
.
config
.
loading
&&
tryHideLoading
(
store
.
getters
.
currentPath
)
checkAuth
(
response
)
checkAuth
(
response
)
return
response
.
data
return
response
.
data
},
error
=>
{
},
error
=>
{
...
...
frontend/src/views/system/menu/index.vue
浏览文件 @
02230d5e
<
template
>
<
template
>
<div
v-loading=
"
result.loading
"
>
<div
v-loading=
"
$store.getters.loadingMap[$store.getters.currentPath]
"
>
<el-card
class=
"table-card"
>
<el-card
class=
"table-card"
>
<template
v-slot:header
>
<template
v-slot:header
>
...
...
frontend/src/views/system/user/index.vue
浏览文件 @
02230d5e
<
template
>
<
template
>
<div
v-loading=
"
result.loading
"
>
<div
v-loading=
"
$store.getters.loadingMap[$store.getters.currentPath]
"
>
<el-card
class=
"table-card"
>
<el-card
class=
"table-card"
>
<template
v-slot:header
>
<template
v-slot:header
>
...
@@ -181,6 +181,7 @@ import { allRoles } from '@/api/system/role'
...
@@ -181,6 +181,7 @@ import { allRoles } from '@/api/system/role'
import
{
getDeptTree
}
from
'@/api/system/dept'
import
{
getDeptTree
}
from
'@/api/system/dept'
export
default
{
export
default
{
name
:
'MsUser'
,
name
:
'MsUser'
,
components
:
{
components
:
{
// MsCreateBox,
// MsCreateBox,
MsTablePagination
,
MsTablePagination
,
...
@@ -276,11 +277,13 @@ export default {
...
@@ -276,11 +277,13 @@ export default {
formType
:
'add'
formType
:
'add'
}
}
},
},
activated
()
{
activated
()
{
// this.form = Object.assign({}, this.defaultForm);
// this.form = Object.assign({}, this.defaultForm);
this
.
allRoles
()
this
.
allRoles
()
this
.
search
()
this
.
search
()
},
},
methods
:
{
methods
:
{
create
()
{
create
()
{
this
.
formType
=
'add'
this
.
formType
=
'add'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论