单点登录的登出功能
This commit is contained in:
parent
96890c095e
commit
8c3d81bf63
2
.env
2
.env
@ -2,7 +2,7 @@
|
|||||||
VITE_APP_TITLE=智慧轮渡大数据平台
|
VITE_APP_TITLE=智慧轮渡大数据平台
|
||||||
|
|
||||||
# 项目本地运行端口号
|
# 项目本地运行端口号
|
||||||
VITE_PORT=82
|
VITE_PORT=80
|
||||||
|
|
||||||
|
|
||||||
# open 运行 npm run dev 时自动打开浏览器
|
# open 运行 npm run dev 时自动打开浏览器
|
||||||
|
@ -151,6 +151,7 @@ export default {
|
|||||||
},
|
},
|
||||||
router: {
|
router: {
|
||||||
login: '登录',
|
login: '登录',
|
||||||
|
logout: '登出',
|
||||||
socialLogin: '社交登录',
|
socialLogin: '社交登录',
|
||||||
home: '首页',
|
home: '首页',
|
||||||
analysis: '分析页',
|
analysis: '分析页',
|
||||||
|
@ -53,7 +53,8 @@ const whiteList = [
|
|||||||
'/auth-redirect',
|
'/auth-redirect',
|
||||||
'/bind',
|
'/bind',
|
||||||
'/register',
|
'/register',
|
||||||
'/oauthLogin/gitee'
|
'/oauthLogin/gitee',
|
||||||
|
'/logout'
|
||||||
]
|
]
|
||||||
|
|
||||||
// 路由加载前
|
// 路由加载前
|
||||||
|
@ -184,6 +184,16 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
noTagsView: true
|
noTagsView: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/logout',
|
||||||
|
component: () => import('@/views/Login/Logout.vue'),
|
||||||
|
name: 'Logout',
|
||||||
|
meta: {
|
||||||
|
hidden: true,
|
||||||
|
title: t('router.logout'),
|
||||||
|
noTagsView: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/sso',
|
path: '/sso',
|
||||||
component: () => import('@/views/Login/components/SSOLoginCustom.vue'),
|
component: () => import('@/views/Login/components/SSOLoginCustom.vue'),
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div :class="prefixCls" class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px">
|
||||||
:class="prefixCls"
|
|
||||||
class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px"
|
|
||||||
>
|
|
||||||
<div class="relative mx-auto h-full flex">
|
<div class="relative mx-auto h-full flex">
|
||||||
<div
|
<div :class="`${prefixCls}__left flex-1 bg-gray-500 bg-opacity-20 relative p-30px lt-xl:hidden`">
|
||||||
:class="`${prefixCls}__left flex-1 bg-gray-500 bg-opacity-20 relative p-30px lt-xl:hidden`"
|
|
||||||
>
|
|
||||||
<!-- 左上角的 logo + 系统标题 -->
|
<!-- 左上角的 logo + 系统标题 -->
|
||||||
<div class="relative flex items-center text-white">
|
<div class="relative flex items-center text-white">
|
||||||
<!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" /> -->
|
<!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" /> -->
|
||||||
@ -14,11 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 左边的背景图 + 欢迎语 -->
|
<!-- 左边的背景图 + 欢迎语 -->
|
||||||
<div class="h-[calc(100%-60px)] flex items-center justify-center">
|
<div class="h-[calc(100%-60px)] flex items-center justify-center">
|
||||||
<TransitionGroup
|
<TransitionGroup appear enter-active-class="animate__animated animate__bounceInLeft" tag="div">
|
||||||
appear
|
|
||||||
enter-active-class="animate__animated animate__bounceInLeft"
|
|
||||||
tag="div"
|
|
||||||
>
|
|
||||||
<img key="1" alt="" class="w-350px" src="@/assets/svgs/login-box-bg.svg" />
|
<img key="1" alt="" class="w-350px" src="@/assets/svgs/login-box-bg.svg" />
|
||||||
<div key="2" class="text-3xl text-white" style="text-align: center;">{{ t('login.welcome') }}</div>
|
<div key="2" class="text-3xl text-white" style="text-align: center;">{{ t('login.welcome') }}</div>
|
||||||
<!-- <div key="3" class="mt-5 text-14px font-normal text-white">
|
<!-- <div key="3" class="mt-5 text-14px font-normal text-white">
|
||||||
@ -29,9 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="relative flex-1 p-30px dark:bg-[var(--login-bg-color)] lt-sm:p-10px">
|
<div class="relative flex-1 p-30px dark:bg-[var(--login-bg-color)] lt-sm:p-10px">
|
||||||
<!-- 右上角的主题、语言选择 -->
|
<!-- 右上角的主题、语言选择 -->
|
||||||
<div
|
<div class="flex items-center justify-between text-white at-2xl:justify-end at-xl:justify-end">
|
||||||
class="flex items-center justify-between text-white at-2xl:justify-end at-xl:justify-end"
|
|
||||||
>
|
|
||||||
<div class="flex items-center at-2xl:hidden at-xl:hidden">
|
<div class="flex items-center at-2xl:hidden at-xl:hidden">
|
||||||
<!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" /> -->
|
<!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" /> -->
|
||||||
<span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
|
<span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
|
||||||
@ -44,8 +33,7 @@
|
|||||||
<!-- 右边的登录界面 -->
|
<!-- 右边的登录界面 -->
|
||||||
<Transition appear enter-active-class="animate__animated animate__bounceInRight">
|
<Transition appear enter-active-class="animate__animated animate__bounceInRight">
|
||||||
<div
|
<div
|
||||||
class="m-auto h-full w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px"
|
class="m-auto h-full w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px">
|
||||||
>
|
|
||||||
<!-- 账号登录 -->
|
<!-- 账号登录 -->
|
||||||
<LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
|
<LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
|
||||||
<!-- 手机登录 -->
|
<!-- 手机登录 -->
|
||||||
@ -63,42 +51,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { underlineToHump } from '@/utils'
|
import { underlineToHump } from '@/utils'
|
||||||
|
|
||||||
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 { ThemeSwitch } from '@/layout/components/ThemeSwitch'
|
import { ThemeSwitch } from '@/layout/components/ThemeSwitch'
|
||||||
import { LocaleDropdown } from '@/layout/components/LocaleDropdown'
|
import { LocaleDropdown } from '@/layout/components/LocaleDropdown'
|
||||||
|
|
||||||
import { LoginForm, MobileForm, QrCodeForm, RegisterForm, SSOLoginVue } from './components'
|
import { LoginForm, MobileForm, QrCodeForm, RegisterForm, SSOLoginVue } from './components'
|
||||||
|
|
||||||
defineOptions({ name: 'Login' })
|
defineOptions({ name: 'Login' })
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const { getPrefixCls } = useDesign()
|
const { getPrefixCls } = useDesign()
|
||||||
const prefixCls = getPrefixCls('login')
|
const prefixCls = getPrefixCls('login')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$prefix-cls: #{$namespace}-login;
|
$prefix-cls: #{$namespace}-login;
|
||||||
|
|
||||||
.#{$prefix-cls} {
|
.#{$prefix-cls} {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
&__left {
|
&__left {
|
||||||
&::before {
|
&::before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-image: url('@/assets/svgs/login-bg.svg');
|
background-image: url('@/assets/svgs/login-bg.svg');
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
content: '';
|
content: '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
26
src/views/Login/Logout.vue
Normal file
26
src/views/Login/Logout.vue
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="false">正在退出登录......</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ElLoading } from 'element-plus'
|
||||||
|
|
||||||
|
import { useUserStore } from '@/store/modules/user'
|
||||||
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
||||||
|
const { replace } = useRouter()
|
||||||
|
const loading = ElLoading.service({
|
||||||
|
lock: true,
|
||||||
|
text: '',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)',
|
||||||
|
})
|
||||||
|
const loginOut = async () => {
|
||||||
|
try {
|
||||||
|
await useUserStore().loginOut()
|
||||||
|
useTagsViewStore().delAllViews()
|
||||||
|
replace('/login?redirect=/index')
|
||||||
|
loading.close()
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
loginOut()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped></style>
|
Loading…
Reference in New Issue
Block a user