Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
074386c8
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
332
Star
18154
Fork
5505
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
074386c8
编写于
12月 27, 2019
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
超时遮罩封装
上级
8fac89ad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
4 deletion
+35
-4
QMPlusVuePage/src/utils/request.js
QMPlusVuePage/src/utils/request.js
+27
-3
QMPlusVuePage/src/view/example/upload/upload.vue
QMPlusVuePage/src/view/example/upload/upload.vue
+8
-1
未找到文件。
QMPlusVuePage/src/utils/request.js
浏览文件 @
074386c8
import
axios
from
'
axios
'
;
// 引入axios
import
{
Message
}
from
'
element-ui
'
;
import
{
Message
,
Loading
}
from
'
element-ui
'
;
import
{
store
}
from
'
@/store/index
'
const
service
=
axios
.
create
({
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
timeout
:
99999
})
let
acitveAxios
=
0
let
loadingInstance
let
timer
const
showLoading
=
()
=>
{
acitveAxios
++
if
(
timer
)
{
clearTimeout
(
timer
)
}
timer
=
setTimeout
(()
=>
{
if
(
acitveAxios
>
0
)
{
loadingInstance
=
Loading
.
service
({
fullscreen
:
true
})
}
},
400
);
}
//http request 拦截器
const
closeLoading
=
()
=>
{
acitveAxios
--
if
(
acitveAxios
<=
0
)
{
clearTimeout
(
timer
)
loadingInstance
&&
loadingInstance
.
close
()
}
}
//http request 拦截器
service
.
interceptors
.
request
.
use
(
config
=>
{
showLoading
()
const
token
=
store
.
getters
[
'
user/token
'
]
config
.
data
=
JSON
.
stringify
(
config
.
data
);
config
.
headers
=
{
...
...
@@ -19,6 +40,7 @@ service.interceptors.request.use(
return
config
;
},
error
=>
{
closeLoading
()
Message
({
showClose
:
true
,
message
:
error
,
...
...
@@ -32,6 +54,7 @@ service.interceptors.request.use(
//http response 拦截器
service
.
interceptors
.
response
.
use
(
response
=>
{
closeLoading
()
if
(
response
.
data
.
success
)
{
return
response
.
data
}
else
{
...
...
@@ -47,6 +70,7 @@ service.interceptors.response.use(
}
},
error
=>
{
closeLoading
()
Message
({
showClose
:
true
,
message
:
error
,
...
...
QMPlusVuePage/src/view/example/upload/upload.vue
浏览文件 @
074386c8
<
template
>
<div>
<div
v-loading.fullscreen.lock=
"fullscreenLoading"
>
<el-upload
:action=
"`$
{path}/fileUploadAndDownload/upload`"
:before-upload="checkFile"
...
...
@@ -64,6 +64,7 @@ export default {
mixins
:
[
infoList
],
data
()
{
return
{
fullscreenLoading
:
false
,
listApi
:
getFileList
,
listKey
:
'
list
'
,
path
:
path
,
...
...
@@ -121,14 +122,17 @@ export default {
})
},
checkFile
(
file
)
{
this
.
fullscreenLoading
=
true
const
isJPG
=
file
.
type
===
'
image/jpeg
'
const
isPng
=
file
.
type
===
'
image/png
'
const
isLt2M
=
file
.
size
/
1024
/
1024
<
2
if
(
!
isJPG
&&
!
isPng
)
{
this
.
$message
.
error
(
'
上传头像图片只能是 JPG或png 格式!
'
)
this
.
fullscreenLoading
=
false
}
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
'
上传头像图片大小不能超过 2MB!
'
)
this
.
fullscreenLoading
=
false
}
return
(
isPng
||
isJPG
)
&&
isLt2M
},
...
...
@@ -140,12 +144,15 @@ export default {
if
(
res
.
success
)
{
this
.
getTableData
()
}
this
.
fullscreenLoading
=
false
},
uploadError
()
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
上传失败
'
})
this
.
fullscreenLoading
=
false
},
downloadFile
(
row
)
{
downloadImage
(
row
.
url
,
row
.
name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录