feat(training-workspace): 优化员工培训工作区与角色化常见问题交互
This commit is contained in:
1 parent
61acbe50a7
commit
f1b9b7c3a9
15 files changed
+199
-26
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
type AgentRegistryFields,
|
||||
} from '@/shared/utils/agent-registry.utils';
|
||||
import { matchesTrainingAgent } from '../training/trainingWorkspace.utils';
|
||||
import { resolveTrainingRoleChatQuestions } from '../training/trainingChatQuestions';
|
||||
import type { ChatDeps } from './chat.deps';
|
||||
import type { UseChatGuidesReturn } from './useChatGuides';
|
||||
|
||||
@@ -26,13 +27,6 @@ const ERP_KB = 'ERP知识库';
|
||||
const TRAINING_AGENT_DESCRIPTION =
|
||||
'我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。';
|
||||
|
||||
const TRAINING_AGENT_QUESTIONS: AgentSuggestedQuestionItem[] = [
|
||||
{ question: '这次员工培训主要学习什么内容?', group: '培训问答' },
|
||||
{ question: '员工培训的通过规则是什么?', group: '培训问答' },
|
||||
{ question: '这次培训的试题范围有哪些?', group: '培训问答' },
|
||||
{ question: '培训记录会如何统计?', group: '培训问答' },
|
||||
];
|
||||
|
||||
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value
|
||||
@@ -53,11 +47,12 @@ const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestio
|
||||
export interface UseChatAgentOptions {
|
||||
deps: ChatDeps;
|
||||
currentAgentId: ComputedRef<number>;
|
||||
currentUser: ComputedRef<Record<string, unknown> | null>;
|
||||
chatGuides: Pick<UseChatGuidesReturn, 'loadGuides' | 'clearGuides'>;
|
||||
}
|
||||
|
||||
export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const { deps, currentAgentId, chatGuides } = options;
|
||||
const { deps, currentAgentId, currentUser, chatGuides } = options;
|
||||
const { t, msg, router } = deps;
|
||||
|
||||
const currentAgent = ref<AgentRegistryFields | null>(null);
|
||||
@@ -88,6 +83,10 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
: kbOptions.filter((option) => option !== ERP_KB)
|
||||
));
|
||||
const kbDropdownDisabled = computed(() => availableKbOptions.value.length <= 1);
|
||||
const isTrainingAdminViewer = computed(() => Boolean(
|
||||
(currentUser.value as { feature_permissions?: { training_hr_manage?: boolean } } | null)
|
||||
?.feature_permissions?.training_hr_manage,
|
||||
));
|
||||
|
||||
watch(canSelectErpKnowledgeBase, (allowed) => {
|
||||
if (allowed) {
|
||||
@@ -119,8 +118,18 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const configured = normalizeAgentSuggestedQuestions(
|
||||
currentAgent.value?.suggested_questions,
|
||||
);
|
||||
if (matchesTrainingAgent(currentAgent.value)) {
|
||||
const roleQuestions = resolveTrainingRoleChatQuestions(
|
||||
currentAgent.value?.extra_config,
|
||||
isTrainingAdminViewer.value ? 'hr' : 'employee',
|
||||
);
|
||||
if (roleQuestions.configured) {
|
||||
return roleQuestions.questions.map((question) => ({ question, group: '' }));
|
||||
}
|
||||
if (configured.length > 0) return configured;
|
||||
return roleQuestions.questions.map((question) => ({ question, group: '' }));
|
||||
}
|
||||
if (configured.length > 0) return configured;
|
||||
if (matchesTrainingAgent(currentAgent.value)) return TRAINING_AGENT_QUESTIONS;
|
||||
return [];
|
||||
});
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ export function useChatPage() {
|
||||
};
|
||||
|
||||
const chatGuides = useChatGuides({ currentAgentId });
|
||||
const agent = useChatAgent({ deps, currentAgentId, chatGuides });
|
||||
const agent = useChatAgent({ deps, currentAgentId, currentUser: computed(() => currentUser.value), chatGuides });
|
||||
const attachmentApi = useChatAttachments({
|
||||
deps,
|
||||
currentAgentId,
|
||||
|
||||
Reference in new issue
Block a user