Skip to content

Commit a91d801

Browse files
feat: commit
1 parent f805f6d commit a91d801

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

ui/src/api/user/login.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { Result } from '@/request/Result'
22
import { get, post } from '@/request/index'
33
import type { LoginRequest } from '@/api/type/login'
44
import type { Ref } from 'vue'
5-
65
/**
76
* 登录
87
* @param request 登录接口请求表单
98
* @param loading 接口加载器
109
* @returns 认证数据
1110
*/
12-
const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<string>> = (
11+
const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<any>> = (
1312
request,
1413
loading,
1514
) => {
@@ -20,7 +19,7 @@ const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<s
2019
* 获取验证码
2120
* @param loading 接口加载器
2221
*/
23-
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<string>> = (loading) => {
22+
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
2423
return get('/user/captcha', undefined, loading)
2524
}
2625

ui/src/request/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ instance.interceptors.request.use(
2828
const language = user.getLanguage()
2929
config.headers['Accept-Language'] = `${language}`
3030
if (token) {
31-
config.headers['AUTHORIZATION'] = `${token}`
31+
config.headers['AUTHORIZATION'] = `Bearer ${token}`
3232
}
3333
return config
3434
},
@@ -43,14 +43,14 @@ instance.interceptors.response.use(
4343
if (response.data) {
4444
if (response.data.code !== 200 && !(response.data instanceof Blob)) {
4545
if (response.config.url.includes('/application/authentication')) {
46-
return Promise.reject(response.data)
46+
return Promise.reject(response.data.data)
4747
}
4848
if (
4949
!response.config.url.includes('/valid') &&
5050
!response.config.url.includes('/function_lib/debug')
5151
) {
5252
MsgError(response.data.message)
53-
return Promise.reject(response.data)
53+
return Promise.reject(response.data.data)
5454
}
5555
}
5656
}
@@ -99,11 +99,12 @@ const promise: (
9999
}
100100
request
101101
.then((response) => {
102+
console.log(response)
102103
// blob类型的返回状态是response.status
103104
if (response.status === 200) {
104-
resolve(response?.data || response)
105+
resolve(response?.data?.data || response)
105106
} else {
106-
reject(response?.data || response)
107+
reject(response?.data?.data || response)
107108
}
108109
})
109110
.catch((error) => {

ui/src/stores/modules/login.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ const useLoginStore = defineStore('login', {
3030
},
3131

3232
async asyncLogin(data: LoginRequest, loading?: Ref<boolean>) {
33-
return loginApi.login(data).then((ok) => {
34-
this.token = ok.data
35-
localStorage.setItem('token', ok.data)
33+
return loginApi.login(data).then((ok: any) => {
34+
this.token = ok.token
35+
localStorage.setItem('token', ok.token)
3636
const user = useUserStore()
3737
return user.profile()
3838
})

ui/src/views/login/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
@click="loginHandle"
5959
:loading="loading"
6060
>
61-
>{{ $t('views.login.buttons.login') }}
61+
{{ $t('views.login.buttons.login') }}
6262
</el-button>
6363
<div class="operate-container flex-between mt-12">
6464
<el-button
@@ -135,7 +135,7 @@ const loginHandle = () => {
135135
}
136136
function makeCode() {
137137
loginApi.getCaptcha().then((res: any) => {
138-
identifyCode.value = res.data.captcha
138+
identifyCode.value = res.captcha
139139
})
140140
}
141141
onBeforeMount(() => {

0 commit comments

Comments
 (0)