Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yongxinda-admin
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
yongxinda-admin
Commits
c0fd1eb4
提交
c0fd1eb4
authored
12月 14, 2022
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化
上级
0aa8f812
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
20 行增加
和
13 行删除
+20
-13
main.ts
src/main.ts
+3
-1
index.ts
src/router/index.ts
+1
-1
config.ts
src/services/api/config.ts
+3
-1
basehttp.ts
src/services/basehttp.ts
+12
-8
importLic.vue
src/views/login/importLic.vue
+1
-2
没有找到文件。
src/main.ts
浏览文件 @
c0fd1eb4
...
...
@@ -43,18 +43,20 @@ router.beforeEach(async (to, from, next) => {
let
token
=
getToken
();
if
(
token
)
{
if
(
to
.
path
===
'/login'
||
to
.
path
===
'/'
)
{
// console.log('/import/lic', to.path);
next
({
path
:
'/'
})
}
else
{
// if (to.path === '/import/lic') return window.location.href = '/#/import/lic'
if
(
store
.
state
.
menu
.
menuList
.
length
==
1
)
{
try
{
await
store
.
dispatch
(
'user/getInfo'
)
await
store
.
dispatch
(
'menu/getMenuList'
,
router
)
next
({
...
to
,
replace
:
true
})
}
catch
(
error
)
{
// if (to.path === '/import/lic') return next({ path: '/import/lic' })
cleanSession
();
next
({
path
:
'/login'
})
}
}
else
{
next
()
}
...
...
src/router/index.ts
浏览文件 @
c0fd1eb4
...
...
@@ -40,7 +40,7 @@ const routes: Array<RouteRecordRaw> = [
{
path
:
"/import/lic"
,
name
:
"importLic"
,
component
:
()
=>
import
(
"@/views/
importLic/index
.vue"
),
component
:
()
=>
import
(
"@/views/
login/importLic
.vue"
),
},
{
path
:
"/404"
,
...
...
src/services/api/config.ts
浏览文件 @
c0fd1eb4
import
router
from
'@/router'
import
axios
,
{
AxiosInstance
}
from
'axios'
import
{
ElMessage
}
from
'element-plus'
...
...
@@ -32,6 +33,7 @@ service.interceptors.response.use(
error
=>
{
// 数据请求失败后的相应操作
const
response
=
error
.
response
;
// 根据返回的code值来做不同的处理(和后端约定)
switch
(
response
.
status
)
{
case
401
:
...
...
@@ -40,7 +42,7 @@ service.interceptors.response.use(
sessionStorage
.
clear
()
return
ElMessage
.
error
(
'请重新登录'
)
}
else
if
(
response
.
data
.
code
===
913
)
{
window
.
location
.
href
=
'/#/import/lic'
router
.
push
({
path
:
'/import/lic'
})
return
ElMessage
.
error
(
'请重新导入lic文件'
)
}
ElMessage
.
error
(
'错误请求'
)
...
...
src/services/basehttp.ts
浏览文件 @
c0fd1eb4
...
...
@@ -4,7 +4,7 @@ import { AxiosRequest, ResponseType, CustomResponse } from './types';
import
{
LoginParm
}
from
'./types/user/userModel'
;
// import storage from '@/utils/storage';
import
{
ElLoading
,
ElMessage
}
from
'element-plus'
import
{
store
}
from
'@/store'
import
{
store
}
from
'@/store'
// import { ILoadingInstance } from 'element-plus/lib/components/loading'
import
qs
from
'qs'
;
import
axios
,
{
AxiosRequestHeaders
,
AxiosInstance
,
AxiosResponse
,
AxiosRequestConfig
,
Method
}
from
'axios'
;
...
...
@@ -19,8 +19,8 @@ interface PendingType {
cancel
:
Function
;
}
interface
listParms
{
pageNo
:
number
;
pageSize
:
number
;
pageNo
:
number
;
pageSize
:
number
;
}
//加载效果
// let loading: ILoadingInstance;
...
...
@@ -87,7 +87,7 @@ class BaseHttp {
(
response
:
AxiosResponse
)
=>
{
// loading.close();//关闭loading动画
removePending
(
response
.
config
);
switch
(
response
.
data
.
code
)
{
switch
(
response
.
data
.
code
)
{
case
401
:
ElMessage
.
error
(
response
.
data
.
msg
)
break
;
...
...
@@ -109,6 +109,10 @@ class BaseHttp {
// 根据返回的code值来做不同的处理(和后端约定)
switch
(
response
.
status
)
{
case
401
:
if
(
response
.
data
.
code
===
913
)
{
router
.
push
({
path
:
'/import/lic'
})
return
ElMessage
.
error
(
'请重新导入lic文件'
)
}
ElMessage
.
error
(
'错误请求'
)
break
;
case
403
:
...
...
@@ -168,7 +172,7 @@ class BaseHttp {
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
sericeAPI
.
get
<
T
>
(
url
,
{
params
:
parms
,
headers
:{
headers
:
{
},
paramsSerializer
:
(
parms
)
=>
{
return
qs
.
stringify
(
parms
)
...
...
@@ -201,7 +205,7 @@ class BaseHttp {
delete
<
T
=
any
>
(
url
:
string
,
parms
:
any
):
Promise
<
CustomResponse
<
T
>>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
sericeAPI
.
delete
(
url
,
{
params
:
parms
params
:
parms
}).
then
((
res
)
=>
{
resolve
(
res
.
data
as
any
)
}).
catch
((
error
)
=>
{
...
...
@@ -212,7 +216,7 @@ class BaseHttp {
put
<
T
=
any
>
(
url
:
string
,
parm
:
any
):
Promise
<
CustomResponse
<
T
>>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
sericeAPI
.
put
(
url
,
parm
).
then
((
res
)
=>
{
this
.
sericeAPI
.
put
(
url
,
parm
).
then
((
res
)
=>
{
resolve
(
res
.
data
as
any
)
}).
catch
((
error
)
=>
{
reject
(
error
)
...
...
@@ -250,7 +254,7 @@ class BaseHttp {
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
sericeAPI
.
get
<
T
>
(
url
,
{
params
:
parms
,
headers
:{
headers
:
{
},
paramsSerializer
:
(
parms
)
=>
{
return
qs
.
stringify
(
parms
)
...
...
src/views/
importLic/index
.vue
→
src/views/
login/importLic
.vue
浏览文件 @
c0fd1eb4
...
...
@@ -21,7 +21,6 @@ const handleSelected = () => uploadInput.value.click()
const
submitUpload
=
(
e
:
any
)
=>
{
const
files
=
e
.
target
.
files
const
rawFile
=
files
[
0
]
console
.
log
(
rawFile
);
if
(
!
rawFile
)
return
upload
(
rawFile
)
}
...
...
@@ -33,7 +32,6 @@ const upload = (rawFile: any) => {
}
const
uploadSectionFile
=
(
file
:
any
,
params
?:
any
)
=>
{
// let data = params
let
fromData
=
new
FormData
()
// FormData 对象
let
fileObj
=
file
// 相当于input里取得的files
fromData
.
append
(
'file'
,
fileObj
)
// 文件对象
...
...
@@ -41,6 +39,7 @@ const uploadSectionFile = (file: any, params?: any) => {
importFile
(
fromData
).
then
((
res
:
any
)
=>
{
//调用上传接口
if
(
res
.
code
===
200
)
{
window
.
location
.
href
=
'/#/login'
sessionStorage
.
clear
()
ElMessage
({
type
:
'success'
,
message
:
'导入成功!'
})
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论