feat(应用管理):增加应用管理介绍描述及自定义常见问题
refactor(chat):chat页面接口获取应用管理中的应用介绍及常见问题
This commit is contained in:
1 parent
01173e0a0e
commit
a3123cd602
4 files changed
+241
-47
No files matched your search
+132
-46
@@ -705,6 +705,92 @@ const showGeneralFeedbackDialog = ref(false);
|
||||
const LEAVE_FEATURE_AGENT_NAMES = new Set(['通用入口', '人事规章']);
|
||||
const canUseLeaveFeature = computed(() => LEAVE_FEATURE_AGENT_NAMES.has(String(currentAgent.value?.name || '').trim()));
|
||||
|
||||
type AgentSuggestedQuestionItem = {
|
||||
question: string;
|
||||
group: string;
|
||||
};
|
||||
|
||||
const DEFAULT_AGENT_DESCRIPTIONS: Record<string, string> = {
|
||||
人事规章: '我是你的7x24小时专属HR政策助手。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的规章制度中,为你精准提取并总结答案。',
|
||||
通用入口: '我是你的7x24小时专属AI数字人。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的人事规章制度中,为你精准提取并总结答案。',
|
||||
};
|
||||
|
||||
const DEFAULT_AGENT_SUGGESTED_QUESTIONS: Record<string, { style: 'plain' | 'styled'; questions: AgentSuggestedQuestionItem[] }> = {
|
||||
人事规章: {
|
||||
style: 'styled',
|
||||
questions: [
|
||||
{ question: '查询我有多少假期?', group: '考勤与休假' },
|
||||
{ question: '如何进行请假?', group: '考勤与休假' },
|
||||
{ question: '查公司法定节假日?', group: '考勤与休假' },
|
||||
{ question: '新员工入职须知', group: '规章与日常' },
|
||||
{ question: '怎么开具在职证明?', group: '规章与日常' },
|
||||
{ question: '查公司薪酬及福利待遇怎么样?', group: '规章与日常' },
|
||||
],
|
||||
},
|
||||
通用入口: {
|
||||
style: 'plain',
|
||||
questions: [
|
||||
{ question: '新员工入职须知', group: '' },
|
||||
{ question: '查询我有多少假期?', group: '' },
|
||||
{ question: '如何进行请假?', group: '' },
|
||||
{ question: '查公司法定节假日?', group: '' },
|
||||
{ question: '查公司薪酬及福利待遇怎么样?', group: '' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value
|
||||
.map((item) => {
|
||||
if (typeof item === 'string') {
|
||||
const question = item.trim();
|
||||
return question ? { question, group: '' } : null;
|
||||
}
|
||||
if (!item || typeof item !== 'object') return null;
|
||||
const record = item as Record<string, unknown>;
|
||||
const question = String(record.question || record.text || '').trim();
|
||||
const group = String(record.group || '').trim();
|
||||
return question ? { question, group } : null;
|
||||
})
|
||||
.filter((item): item is AgentSuggestedQuestionItem => !!item);
|
||||
};
|
||||
|
||||
const currentAgentName = computed(() => String(currentAgent.value?.name || '').trim());
|
||||
const agentDescription = computed(() => {
|
||||
const text = String(currentAgent.value?.description || '').trim();
|
||||
return text || DEFAULT_AGENT_DESCRIPTIONS[currentAgentName.value] || '';
|
||||
});
|
||||
const suggestedQuestionsStyle = computed<'plain' | 'styled'>(() => {
|
||||
const style = String(currentAgent.value?.extra_config?.suggested_questions_style || '').trim().toLowerCase();
|
||||
if (style === 'styled') return 'styled';
|
||||
if (style === 'plain') return 'plain';
|
||||
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.style || 'plain';
|
||||
});
|
||||
const agentSuggestedQuestions = computed<AgentSuggestedQuestionItem[]>(() => {
|
||||
const configured = normalizeAgentSuggestedQuestions(
|
||||
currentAgent.value?.suggested_questions ?? currentAgent.value?.extra_config?.suggested_questions,
|
||||
);
|
||||
if (configured.length > 0) return configured;
|
||||
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.questions || [];
|
||||
});
|
||||
const styledSuggestedQuestionSections = computed(() => {
|
||||
const groups = new Map<string, AgentSuggestedQuestionItem[]>();
|
||||
for (const item of agentSuggestedQuestions.value) {
|
||||
const groupName = String(item.group || '').trim() || '常见问题';
|
||||
if (!groups.has(groupName)) {
|
||||
groups.set(groupName, []);
|
||||
}
|
||||
groups.get(groupName)?.push(item);
|
||||
}
|
||||
const iconTypes: Array<'calendar' | 'building'> = ['calendar', 'building'];
|
||||
return Array.from(groups.entries()).map(([title, questions], index) => ({
|
||||
title,
|
||||
questions,
|
||||
iconType: iconTypes[index % iconTypes.length],
|
||||
}));
|
||||
});
|
||||
|
||||
const agentGuides = ref<any[]>([]);
|
||||
const showGuideModal = ref(false);
|
||||
const activeGuideId = ref<number | null>(null);
|
||||
@@ -2698,17 +2784,14 @@ const showChatRating = ref(false);
|
||||
学习之窗
|
||||
</button>
|
||||
</div>
|
||||
<span v-if="currentAgent?.name === '人事规章'" class="block text-[11px] text-muted mt-1 truncate cursor-help">
|
||||
我是你的7x24小时专属HR政策助手。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的规章制度中,为你精准提取并总结答案。
|
||||
</span>
|
||||
<span v-else-if="currentAgent?.name === '通用入口'" class="block text-[11px] text-muted mt-1 truncate cursor-help">
|
||||
我是你的7x24小时专属AI数字人。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的人事规章制度中,为你精准提取并总结答案。
|
||||
<span v-if="agentDescription" class="block text-[11px] text-muted mt-1 truncate cursor-help">
|
||||
{{ agentDescription }}
|
||||
</span>
|
||||
|
||||
<!-- 气泡提示 -->
|
||||
<div v-if="currentAgent?.name === '人事规章' || currentAgent?.name === '通用入口'" class="absolute left-0 top-[calc(100%+0.25rem)] w-[20rem] p-3 bg-surface border border-default rounded-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-[100] shadow-xl pointer-events-none">
|
||||
<div v-if="agentDescription" class="absolute left-0 top-[calc(100%+0.25rem)] w-[20rem] p-3 bg-surface border border-default rounded-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-[100] shadow-xl pointer-events-none">
|
||||
<div class="leading-relaxed text-[11px] text-secondary">
|
||||
{{ currentAgent?.name === '人事规章' ? '我是你的7x24小时专属HR政策助手。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的规章制度中,为你精准提取并总结答案。' : '我是你的7x24小时专属AI数字人。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的人事规章制度中,为你精准提取并总结答案。' }}
|
||||
{{ agentDescription }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2887,61 +2970,64 @@ const showChatRating = ref(false);
|
||||
<div
|
||||
:class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'"
|
||||
>
|
||||
<div v-if="messages.length === 0" class="flex h-full flex-col items-center justify-center py-2 md:pb-16 w-full px-4">
|
||||
<template v-if="currentAgent?.name === '人事规章'">
|
||||
<div class="mb-6 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">
|
||||
HR
|
||||
<div v-if="messages.length === 0" class="flex h-full min-h-0 w-full flex-col items-center px-4 pt-2 pb-2 md:pb-3">
|
||||
<template v-if="suggestedQuestionsStyle === 'styled' && styledSuggestedQuestionSections.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">
|
||||
{{ currentAgent?.name === '人事规章' ? 'HR' : 'AI' }}
|
||||
</div>
|
||||
<h2 class="text-center text-xl font-bold text-primary md:text-2xl mb-8">你好,我是人事规章 AI 助手</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-4xl mx-auto">
|
||||
<!-- 考勤与休假 -->
|
||||
<div class="bg-surface border border-default rounded-2xl p-5 hover:border-brand-300 transition-colors shadow-sm">
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<div class="p-1.5 bg-brand-50 rounded-lg text-brand-600">
|
||||
<CalendarDays class="h-4 w-4" />
|
||||
</div>
|
||||
<h3 class="font-semibold text-secondary">考勤与休假</h3>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<button @click="handleSend('查询我有多少假期?')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"查询我有多少假期?"</button>
|
||||
<button @click="handleSend('如何进行请假?')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"如何进行请假?"</button>
|
||||
<button @click="handleSend('查公司法定节假日?')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"查公司法定节假日?"</button>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="mb-6 shrink-0 text-center text-xl font-bold text-primary md:text-2xl">
|
||||
{{ currentAgent?.name === '人事规章' ? '你好,我是人事规章 AI 助手' : t('chat.welcomeTitle') }}
|
||||
</h2>
|
||||
|
||||
<!-- 规章与日常 -->
|
||||
<div class="bg-surface border border-default rounded-2xl p-5 hover:border-brand-300 transition-colors shadow-sm">
|
||||
<div class="w-full flex-1 min-h-0 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 styledSuggestedQuestionSections"
|
||||
:key="`${section.title}-${sectionIndex}`"
|
||||
class="w-full bg-surface border border-default rounded-2xl p-5 hover:border-brand-300 transition-colors shadow-sm"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<div class="p-1.5 bg-brand-50 rounded-lg text-brand-600">
|
||||
<Building class="h-4 w-4" />
|
||||
<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">规章与日常</h3>
|
||||
<h3 class="font-semibold text-secondary">{{ section.title }}</h3>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<button @click="handleSend('新员工入职须知')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"新员工入职须知"</button>
|
||||
<button @click="handleSend('怎么开具在职证明?')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"怎么开具在职证明?"</button>
|
||||
<button @click="handleSend('查公司薪酬及福利待遇怎么样?')" class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate">"查公司薪酬及福利待遇怎么样?"</button>
|
||||
<button
|
||||
v-for="(item, questionIndex) in section.questions"
|
||||
:key="`${section.title}-${questionIndex}`"
|
||||
@click="handleSend(item.question)"
|
||||
class="w-full text-left text-xs md:text-sm text-secondary hover:text-brand-600 bg-surface-soft hover:bg-brand-50 px-3 py-2 rounded-lg transition-colors truncate"
|
||||
>
|
||||
"{{ item.question }}"
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="currentAgent?.name === '通用入口'">
|
||||
<div class="mb-6 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">
|
||||
<template v-else-if="agentSuggestedQuestions.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="text-center text-xl font-medium text-primary md:text-2xl mb-8">{{ $t('chat.welcomeTitle') }}</h2>
|
||||
|
||||
<div class="flex flex-wrap justify-center gap-3 w-full max-w-3xl mx-auto mt-2">
|
||||
<button @click="handleSend('新员工入职须知')" class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm">"新员工入职须知"</button>
|
||||
<button @click="handleSend('查询我有多少假期?')" class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm">"查询我有多少假期?"</button>
|
||||
<button @click="handleSend('如何进行请假?')" class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm">"如何进行请假?"</button>
|
||||
<button @click="handleSend('查公司法定节假日?')" class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm">"查公司法定节假日?"</button>
|
||||
<button @click="handleSend('查公司薪酬及福利待遇怎么样?')" class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm">"查公司薪酬及福利待遇怎么样?"</button>
|
||||
<h2 class="mb-6 shrink-0 text-center text-xl font-medium text-primary md:text-2xl">{{ $t('chat.welcomeTitle') }}</h2>
|
||||
|
||||
<div class="w-full flex-1 min-h-0 overflow-y-auto pb-2">
|
||||
<div class="flex flex-wrap justify-center gap-3 w-full max-w-3xl mx-auto mt-2">
|
||||
<button
|
||||
v-for="(item, index) in agentSuggestedQuestions"
|
||||
:key="`${item.question}-${index}`"
|
||||
@click="handleSend(item.question)"
|
||||
class="px-4 py-2 text-sm text-secondary bg-surface border border-default rounded-full hover:border-brand-300 hover:text-brand-600 hover:bg-brand-50 transition-all shadow-sm"
|
||||
>
|
||||
"{{ item.question }}"
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="mb-6 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">
|
||||
<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>
|
||||
|
||||
Reference in new issue
Block a user