109 lines
4.3 KiB
Vue
109 lines
4.3 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[];
|
|
hideTitle?: boolean;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
'select-question': [question: string];
|
|
}>();
|
|
|
|
const { t } = useI18n();
|
|
|
|
const displayAgentName = computed(() => props.agentName || t('chat.assistantLabel'));
|
|
const shouldShowTitle = computed(() => !props.hideTitle);
|
|
</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">
|
|
<h2 v-if="shouldShowTitle" class="mb-8 mt-12 shrink-0 text-center text-2xl font-bold text-primary md:mt-16 md:text-3xl">
|
|
<span>{{ $t('chat.welcomeAgentTitlePrefix') }}</span>
|
|
<span class="mx-1 text-brand-600">{{ displayAgentName }}</span>
|
|
<span>{{ $t('chat.welcomeAgentTitleSuffix') }}</span>
|
|
</h2>
|
|
|
|
<div class="min-h-0 w-full flex-1 overflow-y-auto pb-2" :class="shouldShowTitle ? '' : 'pt-4 md:pt-8'">
|
|
<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">
|
|
<h2 v-if="shouldShowTitle" class="mb-8 mt-12 shrink-0 text-center text-2xl font-bold text-primary md:mt-16 md:text-3xl">
|
|
<span>{{ $t('chat.welcomeAgentTitlePrefix') }}</span>
|
|
<span class="mx-1 text-brand-600">{{ displayAgentName }}</span>
|
|
<span>{{ $t('chat.welcomeAgentTitleSuffix') }}</span>
|
|
</h2>
|
|
|
|
<div class="min-h-0 w-full flex-1 overflow-y-auto pb-2" :class="shouldShowTitle ? '' : 'pt-6 md:pt-10'">
|
|
<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>
|
|
<h2 v-if="shouldShowTitle" class="mt-12 text-center text-2xl font-bold text-primary md:mt-16 md:text-3xl">
|
|
<span>{{ $t('chat.welcomeAgentTitlePrefix') }}</span>
|
|
<span class="mx-1 text-brand-600">{{ displayAgentName }}</span>
|
|
<span>{{ $t('chat.welcomeAgentTitleSuffix') }}</span>
|
|
</h2>
|
|
</template>
|
|
</div>
|
|
</template>
|