feat(frontend): add sso signout action

This commit is contained in:
mac
2026-07-15 15:52:27 +08:00
parent 2154839915
commit 8390c9c677
2 changed files with 21 additions and 1 deletions
@@ -17,6 +17,7 @@
<div>{{ user?.display_name || '未登录' }}</div> <div>{{ user?.display_name || '未登录' }}</div>
<div class="ldap-tag">LDAP · {{ user?.business_line || '' }}业务线</div> <div class="ldap-tag">LDAP · {{ user?.business_line || '' }}业务线</div>
</div> </div>
<el-button class="logout-button" text @click="handleLogout">退出</el-button>
</div> </div>
</header> </header>
</template> </template>
@@ -24,12 +25,18 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { useAuthStore } from '@/stores/auth' import { useAuthStore } from '@/stores/auth'
import { useAuth } from '@/composables/useAuth'
const authStore = useAuthStore() const authStore = useAuthStore()
const { logout } = useAuth()
const user = computed(() => authStore.user) const user = computed(() => authStore.user)
const userInitial = computed(() => { const userInitial = computed(() => {
return user.value?.display_name?.charAt(0) || 'U' return user.value?.display_name?.charAt(0) || 'U'
}) })
const handleLogout = () => {
logout()
}
</script> </script>
<style scoped> <style scoped>
@@ -137,4 +144,15 @@ const userInitial = computed(() => {
font-size: 10px; font-size: 10px;
color: var(--text-dim); color: var(--text-dim);
} }
.logout-button {
color: var(--text-dim);
font-size: 12px;
padding: 4px 6px;
}
.logout-button:hover {
color: var(--text-hi);
background: var(--bg-panel-2);
}
</style> </style>
+3 -1
View File
@@ -2,6 +2,8 @@ import { useAuthStore } from '@/stores/auth'
import { authApi } from '@/api/auth' import { authApi } from '@/api/auth'
import { redirectToSSO } from '@/utils/sso' import { redirectToSSO } from '@/utils/sso'
const SSO_SIGNOUT_URL = 'https://bo-staging-sso-internal.jfcs-k8s-qa1.qiniu.io/signout'
export function useAuth() { export function useAuth() {
const authStore = useAuthStore() const authStore = useAuthStore()
@@ -15,7 +17,7 @@ export function useAuth() {
const logout = async () => { const logout = async () => {
await authApi.logout() await authApi.logout()
authStore.clearAuth() authStore.clearAuth()
redirectToSSO() window.location.assign(SSO_SIGNOUT_URL)
} }
const checkAuth = () => { const checkAuth = () => {