Merge branch 'dev' into hugo
# Conflicts: # .env.dev # .env.shared # backend/app/api/chat.py
This commit is contained in:
commit
ee90b66ff7
63 files changed
+4786
-1422
No files matched your search
+217
-65
@@ -88,13 +88,17 @@ const currentUser = ref(getStoredAuthUser());
|
||||
const showUserDropdown = ref(false);
|
||||
const userMenuRef = ref<HTMLElement | null>(null);
|
||||
|
||||
const selectedKb = ref('企业知识库');
|
||||
const DEFAULT_KB = '企业知识库';
|
||||
const ERP_KB = 'ERP知识库';
|
||||
const ERP_KB_ENABLED_AGENT_NAMES = new Set(['固资管理']);
|
||||
|
||||
const selectedKb = ref(DEFAULT_KB);
|
||||
const showKbDropdown = ref(false);
|
||||
const kbMenuRef = ref<HTMLElement | null>(null);
|
||||
const kbOptions = ['企业知识库', 'ERP知识库'];
|
||||
const kbOptions = [DEFAULT_KB, ERP_KB];
|
||||
const getKbLabel = (kb: string) => {
|
||||
if (kb === '企业知识库') return t('chat.kb.enterprise');
|
||||
if (kb === 'ERP知识库') return t('chat.kb.erp');
|
||||
if (kb === DEFAULT_KB) return t('chat.kb.enterprise');
|
||||
if (kb === ERP_KB) return t('chat.kb.erp');
|
||||
return kb;
|
||||
};
|
||||
const chatScrollContainer = ref<HTMLElement | null>(null);
|
||||
@@ -682,6 +686,27 @@ const shouldShowThinkingBubble = computed(() => {
|
||||
const filePreviewVisible = ref(false);
|
||||
const previewFile = ref<{ name: string; url: string; actualExt?: string } | null>(null);
|
||||
|
||||
const getSourcePreviewExt = (file: { name?: string; url?: string; actualExt?: string }) => {
|
||||
const actual = String(file?.actualExt || '').trim().toLowerCase();
|
||||
if (actual) return actual;
|
||||
const byName = getUrlExt(file?.name || '');
|
||||
if (byName) return byName;
|
||||
return getUrlExt(file?.url || '');
|
||||
};
|
||||
|
||||
const isWeComMobileWebView = () => {
|
||||
if (typeof navigator === 'undefined') return false;
|
||||
const ua = navigator.userAgent || '';
|
||||
return /wxwork/i.test(ua) && /mobile/i.test(ua);
|
||||
};
|
||||
|
||||
const shouldBypassEmbeddedPreview = (file: { name?: string; url?: string; actualExt?: string }) => {
|
||||
const ext = getSourcePreviewExt(file);
|
||||
if (!isMobile.value || !isWeComMobileWebView()) return false;
|
||||
if (!/^https?:\/\//i.test(file?.url || '')) return false;
|
||||
return ['pdf', 'xls', 'xlsx'].includes(ext);
|
||||
};
|
||||
|
||||
const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; url: string; actualExt?: string }> => {
|
||||
if (file.datasetId && file.remoteDocumentId) {
|
||||
const data = await resolveChatSourceFile({
|
||||
@@ -715,6 +740,10 @@ const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string;
|
||||
const openPreview = async (file: SourceFileLink) => {
|
||||
try {
|
||||
const resolvedFile = await resolveSourceLink(file);
|
||||
if (shouldBypassEmbeddedPreview(resolvedFile)) {
|
||||
window.location.href = resolvedFile.url;
|
||||
return;
|
||||
}
|
||||
previewFile.value = resolvedFile;
|
||||
filePreviewVisible.value = true;
|
||||
} catch (error: any) {
|
||||
@@ -784,6 +813,125 @@ watch(isThinking, (thinking) => {
|
||||
const currentAgent = ref<any>(null);
|
||||
const userAgents = ref<Array<{ id: number; name: string; description: string; icon_url?: string; dify_app_type?: 'chatflow' | 'workflow' }>>([]);
|
||||
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 canSelectErpKnowledgeBase = computed(() => ERP_KB_ENABLED_AGENT_NAMES.has(currentAgentName.value));
|
||||
const availableKbOptions = computed(() => (
|
||||
canSelectErpKnowledgeBase.value
|
||||
? kbOptions
|
||||
: kbOptions.filter((option) => option !== ERP_KB)
|
||||
));
|
||||
const kbDropdownDisabled = computed(() => availableKbOptions.value.length <= 1);
|
||||
|
||||
const toggleKbDropdown = () => {
|
||||
if (kbDropdownDisabled.value) {
|
||||
showKbDropdown.value = false;
|
||||
return;
|
||||
}
|
||||
showKbDropdown.value = !showKbDropdown.value;
|
||||
};
|
||||
|
||||
const selectKb = (option: string) => {
|
||||
if (!availableKbOptions.value.includes(option)) return;
|
||||
selectedKb.value = option;
|
||||
showKbDropdown.value = false;
|
||||
};
|
||||
|
||||
watch(canSelectErpKnowledgeBase, (allowed) => {
|
||||
if (!allowed && selectedKb.value === ERP_KB) {
|
||||
selectedKb.value = DEFAULT_KB;
|
||||
}
|
||||
if (!allowed) {
|
||||
showKbDropdown.value = false;
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
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);
|
||||
@@ -800,13 +948,13 @@ const loadAgentGuides = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const showGuideSidebar = ref(false);
|
||||
const showGuideSidebar = ref(true);
|
||||
|
||||
const openGuideModal = () => {
|
||||
if (agentGuides.value.length > 0) {
|
||||
activeGuideId.value = agentGuides.value[0].id;
|
||||
showGuideModal.value = true;
|
||||
showGuideSidebar.value = false; // 默认收起
|
||||
showGuideSidebar.value = true; // 默认展开
|
||||
}
|
||||
};
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
@@ -1918,6 +2066,10 @@ const handleChatMarkdownClick = (event: MouseEvent) => {
|
||||
const action = actionElement.getAttribute('data-leave-action');
|
||||
if (action !== 'start-leave-flow' || isThinking.value) return;
|
||||
event.preventDefault();
|
||||
if (!canUseLeaveFeature.value) {
|
||||
msg.warning('请在“通用入口”或“人事规章”入口使用请假功能');
|
||||
return;
|
||||
}
|
||||
startLocalLeaveFlow('我要请假');
|
||||
};
|
||||
|
||||
@@ -3356,7 +3508,7 @@ const handleSend = async (textOrEvent?: string | Event) => {
|
||||
}
|
||||
if (!trimmed || isThinking.value || isUploadingAttachments.value) return;
|
||||
|
||||
if (isStrongLeaveIntent(content)) {
|
||||
if (canUseLeaveFeature.value && isStrongLeaveIntent(content)) {
|
||||
startLocalLeaveFlow(content);
|
||||
return;
|
||||
}
|
||||
@@ -4056,20 +4208,17 @@ const showChatRating = ref(false);
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-brand-700 bg-brand-100 border border-brand-300 rounded-lg hover:bg-brand-200 hover:border-brand-400 transition-all shadow-sm"
|
||||
>
|
||||
<BookOpen class="w-4 h-4" />
|
||||
新手指南
|
||||
学习之窗
|
||||
</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>
|
||||
@@ -4143,8 +4292,8 @@ const showChatRating = ref(false);
|
||||
|
||||
<!-- Bottom Icons -->
|
||||
<div class="flex items-center justify-between text-muted relative" ref="userMenuRef">
|
||||
<button @click="showUserDropdown = !showUserDropdown" class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20 hover:bg-brand-700 transition-colors">
|
||||
{{ (currentUser?.username || 'I').charAt(0).toUpperCase() }}
|
||||
<button @click="showUserDropdown = !showUserDropdown" class="flex h-10 min-w-[2.5rem] items-center justify-center rounded-full bg-brand-600 px-3 text-sm font-bold text-white shadow-sm shadow-brand-500/20 transition-colors hover:bg-brand-700">
|
||||
退出
|
||||
</button>
|
||||
|
||||
<!-- User Dropdown Menu -->
|
||||
@@ -4194,7 +4343,7 @@ const showChatRating = ref(false);
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-brand-700 bg-brand-100 border border-brand-300 rounded-lg hover:bg-brand-200 hover:border-brand-400 transition-all shadow-sm ml-1"
|
||||
>
|
||||
<BookOpen class="w-4 h-4" />
|
||||
新手指南
|
||||
学习之窗
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
@@ -4248,61 +4397,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>
|
||||
@@ -4943,20 +5095,21 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
<div class="relative" ref="kbMenuRef">
|
||||
<button
|
||||
@click="showKbDropdown = !showKbDropdown"
|
||||
class="flex items-center gap-1 rounded-lg border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="toggleKbDropdown"
|
||||
:disabled="kbDropdownDisabled"
|
||||
class="flex items-center gap-1 rounded-lg border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<Database class="h-3.5 w-3.5 text-brand-500" />
|
||||
{{ getKbLabel(selectedKb) }} <ChevronDown class="h-3 w-3" />
|
||||
</button>
|
||||
<div
|
||||
v-if="showKbDropdown"
|
||||
v-if="showKbDropdown && !kbDropdownDisabled"
|
||||
class="absolute bottom-full left-0 mb-2 w-36 overflow-hidden rounded-xl border border-subtle bg-surface py-1 shadow-xl animate-fade-in"
|
||||
>
|
||||
<button
|
||||
v-for="option in kbOptions"
|
||||
v-for="option in availableKbOptions"
|
||||
:key="option"
|
||||
@click="selectedKb = option; showKbDropdown = false"
|
||||
@click="selectKb(option)"
|
||||
class="flex w-full items-center justify-between px-3 py-2 text-xs text-secondary transition-colors hover:bg-surface-soft"
|
||||
:class="{ 'font-bold text-brand-700': selectedKb === option }"
|
||||
>
|
||||
@@ -5231,13 +5384,13 @@ const showChatRating = ref(false);
|
||||
/>
|
||||
|
||||
<Teleport to="body">
|
||||
<!-- 新手指南 Modal -->
|
||||
<!-- 学习之窗 Modal -->
|
||||
<div v-if="showGuideModal" class="fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm">
|
||||
<div class="bg-surface rounded-2xl shadow-xl w-full max-w-4xl overflow-hidden flex flex-col h-[85vh]">
|
||||
<div class="px-6 py-4 border-b border-default flex justify-between items-center bg-surface shrink-0">
|
||||
<h3 class="text-lg font-bold text-primary flex items-center gap-2">
|
||||
<BookOpen class="w-5 h-5 text-brand-600" />
|
||||
{{ currentAgent?.name }} - 新手指南
|
||||
{{ currentAgent?.name }} - 学习之窗
|
||||
</h3>
|
||||
<div class="flex items-center gap-3">
|
||||
<button @click="showGuideSidebar = !showGuideSidebar" class="flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-brand-600 hover:text-brand-700 hover:bg-brand-50 rounded-lg transition-colors border border-transparent hover:border-brand-100">
|
||||
@@ -5279,7 +5432,6 @@ const showChatRating = ref(false);
|
||||
:key="'video-' + activeGuide.id"
|
||||
:src="activeGuide.file_url || activeGuide.file_path"
|
||||
controls
|
||||
autoplay
|
||||
class="w-full h-full object-contain bg-black"
|
||||
></video>
|
||||
<iframe
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -242,6 +242,8 @@ const draggedSectionIndex = ref<number | null>(null);
|
||||
|
||||
// Computed
|
||||
const isLoggedIn = computed(() => !!currentUser.value && currentUser.value.role !== 'guest');
|
||||
const hasKnowledgeBaseAccess = computed(() => String(currentUser.value?.username || '').trim().toLowerCase() === 'admin');
|
||||
const KB_ACCESS_DENIED_MESSAGE = '暂无权限,请登录admin账号操作知识库!';
|
||||
|
||||
const favoriteAgents = computed(() => {
|
||||
return agents.value.filter(a => favoriteAgentIds.value.includes(a.id));
|
||||
@@ -751,8 +753,9 @@ const isProfileLoading = ref(false);
|
||||
const isProfileSaving = ref(false);
|
||||
const isProfileEditing = ref(false);
|
||||
const showPasswordModal = ref(false);
|
||||
|
||||
// TODO(casdoor): set true when Casdoor change-password is ready
|
||||
const CHANGE_PASSWORD_ENABLED = false;
|
||||
const CHANGE_PASSWORD_ENABLED = true;
|
||||
|
||||
const handleChangePasswordClick = () => {
|
||||
if (!CHANGE_PASSWORD_ENABLED) {
|
||||
@@ -979,7 +982,15 @@ const navigateToApplications = () => openWorkspaceSection('favorites', 'applicat
|
||||
|
||||
const navigateToUpdates = () => openWorkspaceSection('announcements', 'updates');
|
||||
|
||||
const showKnowledgeBaseAccessDenied = () => {
|
||||
msg.warning(KB_ACCESS_DENIED_MESSAGE);
|
||||
};
|
||||
|
||||
const navigateToKnowledgeBase = () => {
|
||||
if (!hasKnowledgeBaseAccess.value) {
|
||||
showKnowledgeBaseAccessDenied();
|
||||
return;
|
||||
}
|
||||
activeSidebarItem.value = 'knowledge_base';
|
||||
};
|
||||
|
||||
@@ -1347,7 +1358,12 @@ onMounted(async () => {
|
||||
const viewParam = route.query.view as string;
|
||||
const validViews: string[] = ['profile', 'applications', 'feedback', 'updates', 'knowledge_base', 'schedule_runs', 'shipping_notice', 'history'];
|
||||
if (viewParam && validViews.includes(viewParam)) {
|
||||
activeSidebarItem.value = viewParam as typeof activeSidebarItem.value;
|
||||
if (viewParam === 'knowledge_base' && !hasKnowledgeBaseAccess.value) {
|
||||
showKnowledgeBaseAccessDenied();
|
||||
activeSidebarItem.value = 'applications';
|
||||
} else {
|
||||
activeSidebarItem.value = viewParam as typeof activeSidebarItem.value;
|
||||
}
|
||||
if (viewParam === 'profile' && !profileUser.value.id) {
|
||||
await fetchProfile();
|
||||
}
|
||||
@@ -1361,6 +1377,12 @@ onMounted(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
watch(hasKnowledgeBaseAccess, (allowed) => {
|
||||
if (!allowed && activeSidebarItem.value === 'knowledge_base') {
|
||||
activeSidebarItem.value = 'applications';
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('hxops:logout', onAuthLogout);
|
||||
});
|
||||
@@ -1524,7 +1546,7 @@ onBeforeUnmount(() => {
|
||||
<div v-else>
|
||||
<header v-if="isMobile" class="sticky top-0 z-30 flex items-center justify-between border-b border-default bg-surface px-4 py-2.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<button @click="navigateToGeneralChat" class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20" :title="$t('workspace.nav.backToChat')">AI</button>
|
||||
<button @click="navigateToGeneralChat" class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20" :title="$t('workspace.nav.backToChat')">返</button>
|
||||
<span class="text-sm font-semibold text-primary">{{ mobileTabTitle }}</span>
|
||||
</div>
|
||||
</header>
|
||||
@@ -2323,7 +2345,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Change password modal: re-enable via CHANGE_PASSWORD_ENABLED when Casdoor is ready -->
|
||||
<!-- Change password modal -->
|
||||
<div
|
||||
v-if="CHANGE_PASSWORD_ENABLED && showPasswordModal"
|
||||
class="dialog-overlay z-50 items-center"
|
||||
|
||||
Reference in new issue
Block a user