登录流程调整
This commit is contained in:
parent
31ae2f378d
commit
2676d4d1d8
@ -55,13 +55,16 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuasar } from 'quasar';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { login } from 'src/api/UserApi';
|
||||
import { getUserInfo, login } from 'src/api/UserApi';
|
||||
import { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { handleRefreshToken } from 'src/utils/refreshToken';
|
||||
|
||||
const $q = useQuasar();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const loginInfo = reactive({
|
||||
account: '',
|
||||
@ -74,6 +77,14 @@ async function doLogin() {
|
||||
clearJwtToken();
|
||||
const token = await login(loginInfo);
|
||||
saveJwtToken(token);
|
||||
const userInfo = await getUserInfo();
|
||||
userStore.roles = userInfo.roles;
|
||||
userStore.defaultRole = userInfo.defaultRole;
|
||||
userStore.remainingSecond = userInfo.remainingSecond;
|
||||
setTimeout(
|
||||
() => handleRefreshToken(),
|
||||
userInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
router.push({ name: 'home' });
|
||||
} catch (err) {
|
||||
visible.value = false;
|
||||
|
Loading…
Reference in New Issue
Block a user