feat: commit
This commit is contained in:
parent
f805f6dce1
commit
a91d8016f8
@ -2,14 +2,13 @@ import { Result } from '@/request/Result'
|
|||||||
import { get, post } from '@/request/index'
|
import { get, post } from '@/request/index'
|
||||||
import type { LoginRequest } from '@/api/type/login'
|
import type { LoginRequest } from '@/api/type/login'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
* @param request 登录接口请求表单
|
* @param request 登录接口请求表单
|
||||||
* @param loading 接口加载器
|
* @param loading 接口加载器
|
||||||
* @returns 认证数据
|
* @returns 认证数据
|
||||||
*/
|
*/
|
||||||
const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<string>> = (
|
const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||||
request,
|
request,
|
||||||
loading,
|
loading,
|
||||||
) => {
|
) => {
|
||||||
@ -20,7 +19,7 @@ const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<s
|
|||||||
* 获取验证码
|
* 获取验证码
|
||||||
* @param loading 接口加载器
|
* @param loading 接口加载器
|
||||||
*/
|
*/
|
||||||
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<string>> = (loading) => {
|
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
|
||||||
return get('/user/captcha', undefined, loading)
|
return get('/user/captcha', undefined, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ instance.interceptors.request.use(
|
|||||||
const language = user.getLanguage()
|
const language = user.getLanguage()
|
||||||
config.headers['Accept-Language'] = `${language}`
|
config.headers['Accept-Language'] = `${language}`
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers['AUTHORIZATION'] = `${token}`
|
config.headers['AUTHORIZATION'] = `Bearer ${token}`
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
@ -43,14 +43,14 @@ instance.interceptors.response.use(
|
|||||||
if (response.data) {
|
if (response.data) {
|
||||||
if (response.data.code !== 200 && !(response.data instanceof Blob)) {
|
if (response.data.code !== 200 && !(response.data instanceof Blob)) {
|
||||||
if (response.config.url.includes('/application/authentication')) {
|
if (response.config.url.includes('/application/authentication')) {
|
||||||
return Promise.reject(response.data)
|
return Promise.reject(response.data.data)
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!response.config.url.includes('/valid') &&
|
!response.config.url.includes('/valid') &&
|
||||||
!response.config.url.includes('/function_lib/debug')
|
!response.config.url.includes('/function_lib/debug')
|
||||||
) {
|
) {
|
||||||
MsgError(response.data.message)
|
MsgError(response.data.message)
|
||||||
return Promise.reject(response.data)
|
return Promise.reject(response.data.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,11 +99,12 @@ const promise: (
|
|||||||
}
|
}
|
||||||
request
|
request
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
console.log(response)
|
||||||
// blob类型的返回状态是response.status
|
// blob类型的返回状态是response.status
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
resolve(response?.data || response)
|
resolve(response?.data?.data || response)
|
||||||
} else {
|
} else {
|
||||||
reject(response?.data || response)
|
reject(response?.data?.data || response)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -30,9 +30,9 @@ const useLoginStore = defineStore('login', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async asyncLogin(data: LoginRequest, loading?: Ref<boolean>) {
|
async asyncLogin(data: LoginRequest, loading?: Ref<boolean>) {
|
||||||
return loginApi.login(data).then((ok) => {
|
return loginApi.login(data).then((ok: any) => {
|
||||||
this.token = ok.data
|
this.token = ok.token
|
||||||
localStorage.setItem('token', ok.data)
|
localStorage.setItem('token', ok.token)
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
return user.profile()
|
return user.profile()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
@click="loginHandle"
|
@click="loginHandle"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
>
|
>
|
||||||
>{{ $t('views.login.buttons.login') }}
|
{{ $t('views.login.buttons.login') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<div class="operate-container flex-between mt-12">
|
<div class="operate-container flex-between mt-12">
|
||||||
<el-button
|
<el-button
|
||||||
@ -135,7 +135,7 @@ const loginHandle = () => {
|
|||||||
}
|
}
|
||||||
function makeCode() {
|
function makeCode() {
|
||||||
loginApi.getCaptcha().then((res: any) => {
|
loginApi.getCaptcha().then((res: any) => {
|
||||||
identifyCode.value = res.data.captcha
|
identifyCode.value = res.captcha
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user