fix: 修复登录成功之后查询登录用户信息
This commit is contained in:
parent
0bb5991231
commit
4b2b8c1728
|
@ -163,14 +163,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getImage } from '@/utils/comm';
|
import { getImage } from '@/utils/comm';
|
||||||
import {
|
import {
|
||||||
config,
|
config,
|
||||||
code,
|
code,
|
||||||
authLogin,
|
authLogin,
|
||||||
getInitSet,
|
getInitSet,
|
||||||
systemVersion,
|
systemVersion,
|
||||||
bindInfo,
|
bindInfo,
|
||||||
settingDetail,
|
settingDetail, userDetail
|
||||||
} from '@/api/login';
|
} from '@/api/login'
|
||||||
import { useUserInfo } from '@/store/userInfo';
|
import { useUserInfo } from '@/store/userInfo';
|
||||||
import { LocalStore } from '@/utils/comm';
|
import { LocalStore } from '@/utils/comm';
|
||||||
import { BASE_API_PATH, TOKEN_KEY, Version_Code } from '@/utils/variable';
|
import { BASE_API_PATH, TOKEN_KEY, Version_Code } from '@/utils/variable';
|
||||||
|
@ -250,18 +250,29 @@ const onFinish = async () => {
|
||||||
const res: any = await authLogin(form);
|
const res: any = await authLogin(form);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
LocalStore.set(TOKEN_KEY, res?.result.token);
|
||||||
|
const userResp = await userDetail()
|
||||||
|
if (userResp.success) {
|
||||||
store.$patch({
|
store.$patch({
|
||||||
...res.result,
|
userInfos: {
|
||||||
username: form.username,
|
...userResp.result,
|
||||||
|
token: res?.result.token,
|
||||||
|
},
|
||||||
|
isAdmin: userResp.username === "admin",
|
||||||
});
|
});
|
||||||
LocalStore.set(TOKEN_KEY, res?.result.token);
|
|
||||||
if (res.result.user?.username === 'admin') {
|
if (userResp.result?.username === 'admin') {
|
||||||
const resp: any = await getInitSet();
|
const resp: any = await getInitSet();
|
||||||
if (resp.status === 200 && !resp.result.length) {
|
if (resp.status === 200 && !resp.result.length) {
|
||||||
window.location.href = '/#/init-home';
|
window.location.href = '/#/init-home';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
store.$patch({
|
||||||
|
...res.result
|
||||||
|
});
|
||||||
|
}
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue