Files
syops/frontend/src/features/sso/components/ExternalSystemLinks.vue
T

64 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
features/sso/components/ExternalSystemLinks.vue
用途:在 HXOPS 已登录页面展示关联服务与产品内 SSO 平级服务入口。
依赖:linked-nav.store、lucide-vue-next。
逻辑:读 Pinia 缓存即时渲染;未缓存时触发一次预取。工作台可通过 buttonClass/iconClass 对齐 ws-nav-btn。
-->
<script setup lang="ts">
import { computed, onMounted } from 'vue';
import { storeToRefs } from 'pinia';
import { ExternalLink } from 'lucide-vue-next';
import { useLinkedNavStore } from '../stores/linked-nav.store';
const props = withDefaults(defineProps<{
compact?: boolean;
showLabel?: boolean;
/** 覆盖按钮样式(如工作台 ws-nav-btn),未传时用紧凑/默认样式 */
buttonClass?: string;
/** 覆盖图标尺寸类,未传时随 compact 变化 */
iconClass?: string;
}>(), {
compact: false,
showLabel: true,
buttonClass: '',
iconClass: '',
});
const linkedNav = useLinkedNavStore();
const { items } = storeToRefs(linkedNav);
/**
* 解析按钮 class。
* 核心逻辑:外部传入优先;compact 默认与 Chat 底栏图标按钮一致(无额外 36px 盒子,避免错位)。
*/
const resolvedButtonClass = computed(() => {
if (props.buttonClass) return props.buttonClass;
if (props.compact) {
return 'inline-flex items-center justify-center transition-colors hover:text-secondary';
}
return 'inline-flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm text-muted transition-colors hover:bg-surface-soft hover:text-secondary min-h-9';
});
/** 解析图标 class:默认 16px,与 Chat 底栏 Moon/Briefcase 一致。 */
const resolvedIconClass = computed(() => props.iconClass || 'h-4 w-4 shrink-0');
onMounted(() => {
// 已缓存则立即展示;未缓存时补一次预取(登录后 App 通常已预取)。
void linkedNav.ensureLoaded();
});
</script>
<template>
<template v-for="entry in items" :key="entry.key">
<button
type="button"
:class="resolvedButtonClass"
:title="entry.display_name"
@click="linkedNav.openItem(entry)"
>
<ExternalLink :class="resolvedIconClass" />
<span v-if="showLabel && !compact" class="truncate">{{ entry.display_name }}</span>
</button>
</template>
</template>