Merge branch 'singleLogin-gaoang' into 'dev'
feat: 单点登录 See merge request itc-framework/ma/2024/front!2
This commit is contained in:
@ -33,7 +33,7 @@ export function createPermissionGuard(router: Router) {
|
|||||||
|
|
||||||
// Whitelist can be directly entered
|
// Whitelist can be directly entered
|
||||||
if (whitePathList.includes(to.path as PageEnum)) {
|
if (whitePathList.includes(to.path as PageEnum)) {
|
||||||
if (to.path === LOGIN_PATH && token) {
|
if (to.path === LOGIN_PATH && token && !to.query?.ltpasToken) {
|
||||||
const isSessionTimeout = userStore.getSessionTimeout;
|
const isSessionTimeout = userStore.getSessionTimeout;
|
||||||
try {
|
try {
|
||||||
await userStore.afterLoginAction();
|
await userStore.afterLoginAction();
|
||||||
|
|||||||
@ -131,11 +131,12 @@ export const useUserStore = defineStore({
|
|||||||
): Promise<GetUserInfoModel | null> {
|
): Promise<GetUserInfoModel | null> {
|
||||||
try {
|
try {
|
||||||
const data = await singleLoginApi(params, params.mode);
|
const data = await singleLoginApi(params, params.mode);
|
||||||
|
const userInfo = await this.getUserInfoAction();
|
||||||
|
|
||||||
const { token } = data;
|
const { token } = data;
|
||||||
// save token
|
// save token
|
||||||
this.setToken(token);
|
this.setToken(token);
|
||||||
router.replace(params.targetURL)
|
router.replace(params.targetURL || params.redirect || userInfo?.homePath || PageEnum.BASE_HOME)
|
||||||
|
|
||||||
return await this.afterLoginAction(false);
|
return await this.afterLoginAction(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -82,7 +82,9 @@ const transform: AxiosTransform = {
|
|||||||
timeoutMsg = t('登录超时,请重新登录!');
|
timeoutMsg = t('登录超时,请重新登录!');
|
||||||
const userStore = useUserStoreWithOut();
|
const userStore = useUserStoreWithOut();
|
||||||
userStore.setToken(undefined);
|
userStore.setToken(undefined);
|
||||||
userStore.logout(true);
|
if (!window.location.hash.includes('login')) {
|
||||||
|
userStore.logout(true);
|
||||||
|
}
|
||||||
const go = useGo();
|
const go = useGo();
|
||||||
go('/login');
|
go('/login');
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="prefixCls" class="login-box relative w-full h-full">
|
<div :class="prefixCls" class="login-box relative w-full h-full" v-if="!isSingleLogin">
|
||||||
<div class="center-box">
|
<div class="center-box">
|
||||||
<div class="login-left-title">
|
<div class="login-left-title">
|
||||||
<div class="sub-title">{{ sysName }}</div>
|
<div class="sub-title">{{ sysName }}</div>
|
||||||
@ -9,14 +9,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="width: 100%; height: 300px; display: flex;justify-content: center;align-items: center;" v-else>
|
||||||
|
<a-spin />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import LoginForm from './LoginForm.vue';
|
import LoginForm from './LoginForm.vue';
|
||||||
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useAppStore } from '/@/store/modules/app';
|
import { useAppStore } from '/@/store/modules/app';
|
||||||
import { getLogoInfo } from '/@/api/system/login';
|
import { getLogoInfo } from '/@/api/system/login';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { LogoConfig } from '/#/config';
|
import { LogoConfig } from '/#/config';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
const { currentRoute } = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const isSingleLogin = ref(false)
|
||||||
|
onMounted(async () => {
|
||||||
|
const fullPath = currentRoute.value.fullPath;
|
||||||
|
if (currentRoute.value.query?.ltpasToken) {
|
||||||
|
isSingleLogin.value = true
|
||||||
|
let targetURL = ''
|
||||||
|
let redirect = ''
|
||||||
|
if (fullPath.includes('targetURL')) {
|
||||||
|
const list = fullPath.split('targetURL=');
|
||||||
|
targetURL = list[1];
|
||||||
|
} else {
|
||||||
|
const list = fullPath.split('redirect=');
|
||||||
|
redirect = list[1];
|
||||||
|
}
|
||||||
|
let params = {...currentRoute.value.query, targetURL: targetURL,redirect: redirect, mode: 'none' }; //不要默认的错误提示
|
||||||
|
await userStore.singleLogin(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|||||||
Reference in New Issue
Block a user