Compare commits
2 Commits
5044db830b
...
b8d08b40bb
Author | SHA1 | Date | |
---|---|---|---|
|
b8d08b40bb | ||
|
2676d4d1d8 |
@ -55,13 +55,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { ApiError } from 'src/boot/axios';
|
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 { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useUserStore } from 'src/stores/user-store';
|
||||||
|
import { handleRefreshToken } from 'src/utils/refreshToken';
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const loginInfo = reactive({
|
const loginInfo = reactive({
|
||||||
account: '',
|
account: '',
|
||||||
@ -74,6 +77,14 @@ async function doLogin() {
|
|||||||
clearJwtToken();
|
clearJwtToken();
|
||||||
const token = await login(loginInfo);
|
const token = await login(loginInfo);
|
||||||
saveJwtToken(token);
|
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' });
|
router.push({ name: 'home' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user