116 lines
4.4 KiB
Vue
116 lines
4.4 KiB
Vue
/**
|
|
* features/chat/components/ChatWelcomePanel.vue
|
|
* 无消息时的欢迎区:Agent 头像、标题与预设问题快捷入口。
|
|
*/
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { Building, CalendarDays } from 'lucide-vue-next';
|
|
|
|
export interface WelcomeQuestionItem {
|
|
question: string;
|
|
group: string;
|
|
}
|
|
|
|
export interface WelcomeQuestionSection {
|
|
title: string;
|
|
questions: WelcomeQuestionItem[];
|
|
iconType: 'calendar' | 'building';
|
|
}
|
|
|
|
const props = defineProps<{
|
|
agentName: string;
|
|
suggestedQuestionsStyle: 'plain' | 'styled';
|
|
styledSections: WelcomeQuestionSection[];
|
|
suggestedQuestions: WelcomeQuestionItem[];
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
'select-question': [question: string];
|
|
}>();
|
|
|
|
const { t } = useI18n();
|
|
|
|
const avatarLabel = computed(() => (props.agentName === '人事规章' ? 'HR' : 'AI'));
|
|
|
|
const welcomeTitle = computed(() => (
|
|
props.agentName === '人事规章'
|
|
? '你好,我是人事规章 AI 助手'
|
|
: t('chat.welcomeTitle')
|
|
));
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex h-full min-h-0 w-full flex-col items-center px-4 pb-2 pt-2 md:pb-3">
|
|
<template v-if="suggestedQuestionsStyle === 'styled' && styledSections.length > 0">
|
|
<div class="mb-6 mt-2 flex h-16 w-16 shrink-0 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-2xl font-bold text-white shadow-lg shadow-brand-500/20">
|
|
{{ avatarLabel }}
|
|
</div>
|
|
<h2 class="mb-6 shrink-0 text-center text-xl font-bold text-primary md:text-2xl">
|
|
{{ welcomeTitle }}
|
|
</h2>
|
|
|
|
<div class="min-h-0 w-full flex-1 overflow-y-auto pb-2">
|
|
<div class="mx-auto grid w-full max-w-4xl grid-cols-1 gap-4 md:grid-cols-2">
|
|
<div
|
|
v-for="(section, sectionIndex) in styledSections"
|
|
:key="`${section.title}-${sectionIndex}`"
|
|
class="w-full rounded-2xl border border-default bg-surface p-5 shadow-sm transition-colors hover:border-brand-300"
|
|
>
|
|
<div class="mb-3 flex items-center gap-2">
|
|
<div class="rounded-lg bg-brand-50 p-1.5 text-brand-600">
|
|
<CalendarDays v-if="section.iconType === 'calendar'" class="h-4 w-4" />
|
|
<Building v-else class="h-4 w-4" />
|
|
</div>
|
|
<h3 class="font-semibold text-secondary">{{ section.title }}</h3>
|
|
</div>
|
|
<div class="space-y-2">
|
|
<button
|
|
v-for="(item, questionIndex) in section.questions"
|
|
:key="`${section.title}-${questionIndex}`"
|
|
type="button"
|
|
class="w-full truncate rounded-lg bg-surface-soft px-3 py-2 text-left text-xs text-secondary transition-colors hover:bg-brand-50 hover:text-brand-600 md:text-sm"
|
|
@click="emit('select-question', item.question)"
|
|
>
|
|
"{{ item.question }}"
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<template v-else-if="suggestedQuestions.length > 0">
|
|
<div class="mb-6 mt-2 flex h-16 w-16 shrink-0 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-2xl font-bold text-white shadow-lg shadow-brand-500/20">
|
|
AI
|
|
</div>
|
|
<h2 class="mb-6 shrink-0 text-center text-xl font-medium text-primary md:text-2xl">
|
|
{{ $t('chat.welcomeTitle') }}
|
|
</h2>
|
|
|
|
<div class="min-h-0 w-full flex-1 overflow-y-auto pb-2">
|
|
<div class="mx-auto mt-2 flex w-full max-w-3xl flex-wrap justify-center gap-3">
|
|
<button
|
|
v-for="(item, index) in suggestedQuestions"
|
|
:key="`${item.question}-${index}`"
|
|
type="button"
|
|
class="rounded-full border border-default bg-surface px-4 py-2 text-sm text-secondary shadow-sm transition-all hover:border-brand-300 hover:bg-brand-50 hover:text-brand-600"
|
|
@click="emit('select-question', item.question)"
|
|
>
|
|
"{{ item.question }}"
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<template v-else>
|
|
<div class="mb-6 mt-2 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-2xl font-bold text-white shadow-lg shadow-brand-500/20">
|
|
AI
|
|
</div>
|
|
<h2 class="text-center text-xl font-medium text-primary md:text-2xl">
|
|
{{ $t('chat.welcomeTitle') }}
|
|
</h2>
|
|
</template>
|
|
</div>
|
|
</template>
|