Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
integrate-admin
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
integrate-admin
Commits
236895c0
提交
236895c0
authored
12月 12, 2022
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化登录功能
上级
30b5a032
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
18 行删除
+24
-18
config.ts
src/services/api/config.ts
+8
-2
useLogin.ts
src/services/business/login/useLogin.ts
+14
-14
vite.config.ts
vite.config.ts
+2
-2
没有找到文件。
src/services/api/config.ts
浏览文件 @
236895c0
...
...
@@ -13,7 +13,7 @@ service.interceptors.request.use(
config
=>
{
const
token
=
sessionStorage
.
getItem
(
'token'
)
if
(
token
)
{
config
.
headers
=
{
'Authorization'
:
`
${
token
}
`
,
...
config
.
headers
}
config
.
headers
=
{
'Authorization'
:
`
${
token
}
`
,
...
config
.
headers
}
}
return
config
}
...
...
@@ -25,7 +25,8 @@ service.interceptors.response.use(
// 数据请求成功后 相应操作
const
responseData
=
res
.
data
if
(
responseData
.
code
!==
200
)
{
ElMessage
.
error
(
responseData
.
message
)
if
(
responseData
.
hasOwnProperty
(
'msg'
))
ElMessage
.
error
(
responseData
.
msg
)
else
ElMessage
.
error
(
responseData
.
message
)
}
return
responseData
},
...
...
@@ -35,6 +36,11 @@ service.interceptors.response.use(
// 根据返回的code值来做不同的处理(和后端约定)
switch
(
response
.
status
)
{
case
401
:
if
(
response
.
data
.
code
===
911
)
{
window
.
location
.
href
=
"/#/login"
;
sessionStorage
.
clear
()
return
ElMessage
.
error
(
'请重新登录'
)
}
ElMessage
.
error
(
'错误请求'
)
break
;
case
403
:
...
...
src/services/business/login/useLogin.ts
浏览文件 @
236895c0
import
{
ref
,
getCurrentInstance
}
from
"vue"
;
import
{
ref
,
getCurrentInstance
}
from
"vue"
;
import
{
LoginParm
}
from
"@/services/types/user/userModel"
;
import
{
store
}
from
"@/store"
;
import
{
ElNotification
}
from
'element-plus'
;
...
...
@@ -15,27 +15,27 @@ export default function useLogin(loginModel: LoginParm) {
loginState
.
value
=
false
if
(
res
.
code
==
200
)
{
ElNotification
({
title
:
'登录成功'
,
message
:
'欢迎回来'
,
type
:
'success'
,
title
:
'登录成功'
,
message
:
'欢迎回来'
,
type
:
'success'
,
})
//跳转到首页
setTimeout
(()
=>
{
setTimeout
(()
=>
{
router
.
push
({
path
:
'/'
})
},
1500
)
},
1500
)
}
else
{
ElNotification
({
title
:
'登陆失败'
,
message
:
res
.
msg
,
type
:
'error'
,
})
//
ElNotification({
//
title:'登陆失败',
//
message:res.msg,
//
type:'error',
//
})
}
}).
catch
((
err
)
=>
{
loginState
.
value
=
false
ElNotification
({
title
:
'登录失败'
,
message
:
err
.
message
,
type
:
'error'
,
title
:
'登录失败'
,
message
:
err
.
message
,
type
:
'error'
,
})
})
}
...
...
vite.config.ts
浏览文件 @
236895c0
...
...
@@ -27,7 +27,7 @@ export default ({ command, mode }) => {
iconDirs
:
[
path
.
resolve
(
process
.
cwd
(),
"src/assets/icons"
),
path
.
resolve
(
process
.
cwd
(),
"src/vueFormCreate/icons/svg"
)
],
],
// 指定symbolId格式
symbolId
:
"icon-[dir]-[name]"
,
}),
...
...
@@ -89,7 +89,7 @@ export default ({ command, mode }) => {
// '/foo': '',
// 选项写法
"/integrate"
:
{
target
:
"http://192.168.0.
39:809
0/"
,
target
:
"http://192.168.0.
60:8
0/"
,
// rewrite: (path) => path.replace(/^\/api/, '')
},
// 正则表达式写法
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论