feat(auth): 重构统一认证并支持平级服务无感登录

This commit is contained in:
sophie committed 2026-07-28 09:15:41 +08:00
1 parent d79def5519
commit ca312ea751
64 files changed
+3713 -449

No files matched your search

@@ -0,0 +1,54 @@
<!--
features/sso/components/ExternalSystemLinks.vue
用途:在 HXOPS 已登录页面展示已配置产品内平级服务入口。
依赖:SSO 应用目录 API、lucide-vue-next。
逻辑:点击后先打开 HXOPS 同源 launch 页以继承当前登录态,再由 launch 页跳平级服务生成签名 state。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { ExternalLink } from 'lucide-vue-next';
import { listSsoApplications, type SsoApplication } from '../api/sso.api';
withDefaults(defineProps<{
compact?: boolean;
showLabel?: boolean;
}>(), {
compact: false,
showLabel: true,
});
const applications = ref<SsoApplication[]>([]);
/** 加载已启用应用;目录不可用时隐藏入口,不阻断 HXOPS 主业务。 */
async function loadApplications(): Promise<void> {
try {
applications.value = await listSsoApplications();
} catch (error) {
console.warn('[sso] failed to load peer services', error);
}
}
/** 在新标签先打开同源中转页,确保非 remember 登录态也可继承到新标签。 */
function openApplication(application: SsoApplication): void {
window.open(`/sso/launch?app=${encodeURIComponent(application.key)}`, '_blank');
}
onMounted(() => {
void loadApplications();
});
</script>
<template>
<template v-for="application in applications" :key="application.key">
<button
type="button"
class="inline-flex items-center justify-center gap-2 rounded-xl text-muted transition-colors hover:bg-surface-soft hover:text-secondary"
:class="compact ? 'h-9 w-9' : 'min-h-9 px-3 py-2 text-sm'"
:title="application.display_name"
@click="openApplication(application)"
>
<ExternalLink class="h-4 w-4 shrink-0" />
<span v-if="showLabel && !compact" class="truncate">{{ application.display_name }}</span>
</button>
</template>
</template>