登录调整1
This commit is contained in:
parent
a47a0730ea
commit
b7d16ed501
@ -42,18 +42,12 @@ interface LoginInfo {
|
|||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoginRes {
|
|
||||||
code: number;
|
|
||||||
expire: string;
|
|
||||||
token: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
* @param loginInfo
|
* @param loginInfo
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function login(loginInfo: LoginInfo): Promise<LoginRes> {
|
export async function login(loginInfo: LoginInfo): Promise<string> {
|
||||||
const info = { ...loginInfo, password: encryptPassword(loginInfo.password) };
|
const info = { ...loginInfo, password: encryptPassword(loginInfo.password) };
|
||||||
const response = await api.post(`${UserUriBase}/login`, info);
|
const response = await api.post(`${UserUriBase}/login`, info);
|
||||||
return response.data.token;
|
return response.data.token;
|
||||||
|
@ -70,7 +70,7 @@ const loginInfo = reactive({
|
|||||||
async function doLogin() {
|
async function doLogin() {
|
||||||
try {
|
try {
|
||||||
clearJwtToken();
|
clearJwtToken();
|
||||||
const { token } = await login(loginInfo);
|
const token = await login(loginInfo);
|
||||||
saveJwtToken(token);
|
saveJwtToken(token);
|
||||||
router.push({ name: 'home' });
|
router.push({ name: 'home' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user