feat: pc端单点登录,隐藏上边栏左边栏
This commit is contained in:
@ -47,6 +47,17 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export function singleLoginApi(params, mode) {
|
||||||
|
return defHttp.post(
|
||||||
|
{
|
||||||
|
url: Api.Login + '/' + params.ltpasToken,
|
||||||
|
params:{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorMessageMode: mode,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: getUserInfo
|
* @description: getUserInfo
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { ref } from 'vue';
|
|||||||
|
|
||||||
const isEditorOpen = ref(false);
|
const isEditorOpen = ref(false);
|
||||||
const hasAjaxError = ref(false);
|
const hasAjaxError = ref(false);
|
||||||
|
const isSingleLogin = ref(false);
|
||||||
|
|
||||||
function ajaxError() {
|
function ajaxError() {
|
||||||
hasAjaxError.value = true;
|
hasAjaxError.value = true;
|
||||||
@ -14,7 +15,8 @@ export default function() {
|
|||||||
return {
|
return {
|
||||||
isEditorOpen,
|
isEditorOpen,
|
||||||
hasAjaxError,
|
hasAjaxError,
|
||||||
ajaxError
|
ajaxError,
|
||||||
|
isSingleLogin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<Layout :class="prefixCls" v-bind="lockEvents">
|
<Layout :class="prefixCls" v-bind="lockEvents">z
|
||||||
<LayoutFeatures />
|
<LayoutFeatures v-if="showSide"/>
|
||||||
<LayoutHeader fixed v-if="getShowFullHeaderRef" />
|
<LayoutHeader fixed v-if="getShowFullHeaderRef && showSide"/>
|
||||||
<Layout :class="[layoutClass]">
|
<Layout :class="[layoutClass]">
|
||||||
<LayoutSideBar v-if="getShowSidebar || getIsMobile" />
|
<LayoutSideBar v-if="(getShowSidebar || getIsMobile) && showSide"/>
|
||||||
<Layout :class="`${prefixCls}-main`">
|
<Layout :class="`${prefixCls}-main`">
|
||||||
<LayoutMultipleHeader />
|
<LayoutMultipleHeader v-if="showSide"/>
|
||||||
<LayoutContent />
|
<LayoutContent />
|
||||||
<LayoutFooter />
|
<LayoutFooter />
|
||||||
</Layout>
|
</Layout>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, computed, unref } from 'vue';
|
import { defineComponent, computed, unref, ref } from 'vue';
|
||||||
import { Layout } from 'ant-design-vue';
|
import { Layout } from 'ant-design-vue';
|
||||||
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
|
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
|
||||||
|
|
||||||
@ -29,6 +29,8 @@
|
|||||||
import { useLockPage } from '/@/hooks/web/useLockPage';
|
import { useLockPage } from '/@/hooks/web/useLockPage';
|
||||||
|
|
||||||
import { useAppInject } from '/@/hooks/web/useAppInject';
|
import { useAppInject } from '/@/hooks/web/useAppInject';
|
||||||
|
import useGlobalFlag from '/@/hooks/core/useGlobalFlag';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'DefaultLayout',
|
name: 'DefaultLayout',
|
||||||
@ -46,6 +48,16 @@
|
|||||||
const { getIsMobile } = useAppInject();
|
const { getIsMobile } = useAppInject();
|
||||||
const { getShowFullHeaderRef } = useHeaderSetting();
|
const { getShowFullHeaderRef } = useHeaderSetting();
|
||||||
const { getShowSidebar, getIsMixSidebar, getShowMenu } = useMenuSetting();
|
const { getShowSidebar, getIsMixSidebar, getShowMenu } = useMenuSetting();
|
||||||
|
const globalFlag = useGlobalFlag();
|
||||||
|
const route = useRoute();
|
||||||
|
let showSide = ref(true)
|
||||||
|
const { isSingleLogin } = globalFlag;
|
||||||
|
if (route.query.isSingleLogin) {
|
||||||
|
isSingleLogin.value = true
|
||||||
|
}
|
||||||
|
if (isSingleLogin.value) {
|
||||||
|
showSide.value = false
|
||||||
|
}
|
||||||
|
|
||||||
// Create a lock screen monitor
|
// Create a lock screen monitor
|
||||||
const lockEvents = useLockPage();
|
const lockEvents = useLockPage();
|
||||||
@ -66,6 +78,7 @@
|
|||||||
getIsMixSidebar,
|
getIsMixSidebar,
|
||||||
layoutClass,
|
layoutClass,
|
||||||
lockEvents,
|
lockEvents,
|
||||||
|
showSide
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { PageEnum } from '/@/enums/pageEnum';
|
|||||||
import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum';
|
import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum';
|
||||||
import { getAuthCache, setAuthCache } from '/@/utils/auth';
|
import { getAuthCache, setAuthCache } from '/@/utils/auth';
|
||||||
import { GetUserInfoModel, LoginParams, RoleInfo } from '/@/api/system/login/model';
|
import { GetUserInfoModel, LoginParams, RoleInfo } from '/@/api/system/login/model';
|
||||||
import { doLogout, getUserInfo, loginApi } from '/@/api/system/login';
|
import { doLogout, getUserInfo, loginApi, singleLoginApi } from '/@/api/system/login';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { router } from '/@/router';
|
import { router } from '/@/router';
|
||||||
@ -123,6 +123,25 @@ export const useUserStore = defineStore({
|
|||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @description: singleLogin
|
||||||
|
*/
|
||||||
|
async singleLogin(
|
||||||
|
params: any
|
||||||
|
): Promise<GetUserInfoModel | null> {
|
||||||
|
try {
|
||||||
|
const data = await singleLoginApi(params, params.mode);
|
||||||
|
|
||||||
|
const { token } = data;
|
||||||
|
// save token
|
||||||
|
this.setToken(token);
|
||||||
|
router.replace(params.targetURL)
|
||||||
|
|
||||||
|
return await this.afterLoginAction(false);
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
async afterLoginAction(goHome?: boolean): Promise<GetUserInfoModel | null> {
|
async afterLoginAction(goHome?: boolean): Promise<GetUserInfoModel | null> {
|
||||||
if (!this.getToken) return null;
|
if (!this.getToken) return null;
|
||||||
|
|
||||||
|
|||||||
24
src/views/secondDev/SingleLogin.vue
Normal file
24
src/views/secondDev/SingleLogin.vue
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<div style="width: 100%; height: 300px; display: flex;justify-content: center;align-items: center;">
|
||||||
|
<a-spin />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const { currentRoute } = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
onMounted(async () => {
|
||||||
|
const fullPath = currentRoute.value.fullPath;
|
||||||
|
const list = fullPath.split('targetURL=');
|
||||||
|
const targetURL = list[1];
|
||||||
|
let params = {...currentRoute.value.query, targetURL: targetURL, mode: 'none' }; //不要默认的错误提示
|
||||||
|
await userStore.singleLogin(params);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style lang="less">
|
||||||
|
</style>
|
||||||
|
|
||||||
Reference in New Issue
Block a user