fix: 优化一些配置
This commit is contained in:
1 parent
ac7b53a523
commit
eb21af5949
17 files changed
+117
-208
No files matched your search
@@ -2,10 +2,12 @@
|
||||
backend/app/api/user/handlers.py
|
||||
|
||||
用途:当前用户域 API(Casdoor 登录、企微 OAuth、首页、FAQ、反馈等)。
|
||||
依赖:app.core.auth.jwt、app.core.errors、models、wecom/dify 相关 services。
|
||||
依赖:sqlalchemy(and_/or_、exc)、app.core.errors、models、wecom/dify 相关 services。
|
||||
逻辑:薄路由层鉴权与参数校验;Casdoor/企微 OAuth 委托 services/auth/*。
|
||||
"""
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from sqlalchemy import and_, or_
|
||||
from sqlalchemy.exc import DatabaseError, OperationalError
|
||||
from app import db
|
||||
from app.models import User, Agent, QuickQuestion, UserFavoriteAgent, UserDefaultAgent, UserHomepageConfig, GeneralFeedback, ChatLog
|
||||
from app.services.feedback_notify import send_feedback_group_notification
|
||||
@@ -18,6 +20,7 @@ from app.core.errors import (
|
||||
AppError,
|
||||
ForbiddenError,
|
||||
NotFoundError,
|
||||
ServiceUnavailableError,
|
||||
UnauthorizedError,
|
||||
ValidationError,
|
||||
)
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@
|
||||
| 功能项 | 说明 | 状态 | 优先级 |
|
||||
| --- | --- | --- | --- |
|
||||
| 管理端使用分析 | 管理控制台「数据报表」首项由原始用户表替换为「使用分析」,展示对话总量、活跃用户/应用、按日趋势、应用/用户排行、低使用应用与异常高峰提醒,并保留聊天明细追溯与导出 | 已实现 | P1 |
|
||||
| 管理端应用运营报表 | 「数据报表 > 应用」由 agents 配置表替换为应用运营看板:按应用聚合对话/用户/最近活跃/授权/待审/均分,支持时间范围与状态筛选、Excel 导出,并可下钻聊天日志与权限申请 | 已实现 | P1 |
|
||||
| 管理端应用运营报表 | 「数据报表 > 应用」由 agents 配置表替换为应用运营看板:按应用聚合对话/用户/最近活跃/授权/均分,支持时间范围与状态筛选、Excel 导出,并可下钻聊天日志 | 已实现 | P1 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* features/admin/modules/agents/components/AgentFormModal.vue
|
||||
*
|
||||
* 用途:应用管理新增/编辑弹窗,集中承载 Agent 基础信息、Dify/Iframe 配置和常见问题表单。
|
||||
* 用途:应用管理新增/编辑弹窗,集中承载 Agent 基础信息(含启用状态)、Dify/Iframe 配置和常见问题表单。
|
||||
* 依赖:agent.types AgentFormState、schedule.types ScheduleTask、AgentToolRunProgressConfig、vue-i18n。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;本组件直接编辑传入的 form,并通过事件通知关闭、保存、增删常见问题。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;本组件直接编辑传入的 form(含 is_active),并通过事件通知关闭、保存、增删常见问题。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -340,6 +340,23 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.isActive') }}</label>
|
||||
<div class="flex flex-col gap-2 rounded-xl border border-default bg-surface-soft/40 px-4 py-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<p class="text-sm leading-6 text-secondary">
|
||||
{{ form.is_active ? t('admin.agent.fields.isActiveHintOn') : t('admin.agent.fields.isActiveHintOff') }}
|
||||
</p>
|
||||
<label class="inline-flex shrink-0 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-sm text-secondary">
|
||||
<input
|
||||
v-model="form.is_active"
|
||||
type="checkbox"
|
||||
class="accent-brand-600"
|
||||
/>
|
||||
<span>{{ t('admin.agent.fields.isActiveEnable') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.description') }}</label>
|
||||
<input
|
||||
|
||||
@@ -74,7 +74,6 @@ const {
|
||||
getApplicationSortMark,
|
||||
handleApplicationSearchChange,
|
||||
openApplicationChatLogs,
|
||||
openApplicationPermissionRequests,
|
||||
isLoading,
|
||||
currentTable,
|
||||
tableData,
|
||||
@@ -139,7 +138,6 @@ const applicationSortableKeys: ApplicationSortKey[] = [
|
||||
'unique_users',
|
||||
'last_active_at',
|
||||
'authorized_users',
|
||||
'pending_requests',
|
||||
'avg_score',
|
||||
];
|
||||
|
||||
@@ -531,7 +529,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="applicationSummary" class="grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<div v-if="applicationSummary" class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
||||
<button type="button" class="rounded-xl border border-default bg-surface p-4 text-left" @click="setApplicationUsageFilter('all')">
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryActive') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.active_agents }}</div>
|
||||
@@ -545,25 +543,20 @@ onBeforeUnmount(() => {
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryUnused') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.unused_agents }}</div>
|
||||
</button>
|
||||
<div class="rounded-xl border border-default bg-surface p-4">
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryPending') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.pending_permission_total }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-report-table-wrap">
|
||||
<table class="admin-report-table admin-report-table--app-ops w-full table-fixed border-collapse">
|
||||
<colgroup>
|
||||
<col class="w-[14%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[16%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[18%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[12%]" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -588,7 +581,7 @@ onBeforeUnmount(() => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="applicationItems.length === 0">
|
||||
<td colspan="10" class="text-center text-muted py-12">
|
||||
<td colspan="9" class="text-center text-muted py-12">
|
||||
{{ t('admin.report.appOps.empty') }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -600,7 +593,6 @@ onBeforeUnmount(() => {
|
||||
{{ row.last_active_at ? formatLocalDateTime(row.last_active_at) : '-' }}
|
||||
</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums">{{ row.authorized_users }}</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums">{{ row.pending_requests }}</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums whitespace-nowrap">
|
||||
{{ row.avg_score == null ? '-' : row.avg_score }}
|
||||
<span v-if="row.feedback_count" class="text-xs text-muted">({{ row.feedback_count }})</span>
|
||||
@@ -612,14 +604,9 @@ onBeforeUnmount(() => {
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-3 text-left align-middle">
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationChatLogs(row)">
|
||||
{{ t('admin.report.appOps.actionLogs') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationPermissionRequests(row)">
|
||||
{{ t('admin.report.appOps.actionRequests') }}
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationChatLogs(row)">
|
||||
{{ t('admin.report.appOps.actionLogs') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -207,18 +207,6 @@ export function useReportsAdmin() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 下钻到权限申请列表,按 agent_id 精确过滤。
|
||||
* @param row - 应用运营行
|
||||
*/
|
||||
const openApplicationPermissionRequests = (row: ApplicationReportItem): void => {
|
||||
void router.push({
|
||||
name: 'AdminReports',
|
||||
params: { table: 'permission_requests' },
|
||||
query: { agent_id: String(row.agent_id) },
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出应用运营报表 Excel(仅运营字段)。
|
||||
*/
|
||||
@@ -237,7 +225,6 @@ export function useReportsAdmin() {
|
||||
? formatLocalDateTime(row.last_active_at)
|
||||
: '-',
|
||||
[t('admin.report.appOps.columns.authorized_users')]: row.authorized_users,
|
||||
[t('admin.report.appOps.columns.pending_requests')]: row.pending_requests,
|
||||
[t('admin.report.appOps.columns.avg_score')]: row.avg_score ?? '-',
|
||||
[t('admin.report.appOps.columns.feedback_count')]: row.feedback_count,
|
||||
[t('admin.report.appOps.columns.tokens_used')]: row.tokens_used,
|
||||
@@ -405,7 +392,7 @@ const dataSourceTable = computed<Exclude<AdminReportTableId, 'usage_analysis'>>(
|
||||
});
|
||||
|
||||
/**
|
||||
* 从路由 query 灌入列筛选(用于应用运营下钻到聊天日志 / 权限申请)。
|
||||
* 从路由 query 灌入列筛选(用于应用运营下钻到聊天日志)。
|
||||
*/
|
||||
const applyRouteQueryFilters = (): void => {
|
||||
const next: Record<string, string> = {};
|
||||
@@ -1218,7 +1205,6 @@ watch([reportPageSize, sortedTableData], () => {
|
||||
getApplicationSortMark,
|
||||
handleApplicationSearchChange,
|
||||
openApplicationChatLogs,
|
||||
openApplicationPermissionRequests,
|
||||
isLoading,
|
||||
currentTable,
|
||||
tableData,
|
||||
|
||||
@@ -45,7 +45,6 @@ export type ApplicationSortKey =
|
||||
| 'unique_users'
|
||||
| 'last_active_at'
|
||||
| 'authorized_users'
|
||||
| 'pending_requests'
|
||||
| 'avg_score'
|
||||
| 'tokens_used';
|
||||
|
||||
@@ -58,7 +57,8 @@ export interface ApplicationReportItem {
|
||||
unique_users: number;
|
||||
last_active_at: string | null;
|
||||
authorized_users: number;
|
||||
pending_requests: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审列 */
|
||||
pending_requests?: number;
|
||||
avg_score: number | null;
|
||||
feedback_count: number;
|
||||
tokens_used: number;
|
||||
@@ -70,7 +70,8 @@ export interface ApplicationReportSummary {
|
||||
active_agents: number;
|
||||
used_agents: number;
|
||||
unused_agents: number;
|
||||
pending_permission_total: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审摘要卡 */
|
||||
pending_permission_total?: number;
|
||||
}
|
||||
|
||||
export interface ApplicationReport {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/chat/components/ChatInputBar.vue
|
||||
* 聊天输入栏:文本框、附件、语音、知识库与采购合同双文件输入控件。
|
||||
* 逻辑:附件卡片和快捷操作显示在文字输入区上方;采购合同审查隐藏企业知识库,模板比对明确上传双方合同。
|
||||
* 聊天输入栏:文本框、附件、语音与采购合同双文件输入控件。
|
||||
* 逻辑:底部左区放附件/合同等工具;右区语音与发送并排。采购合同审查用专用上传按钮,不展示通用回形针附件入口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -9,8 +9,6 @@ import { useI18n } from 'vue-i18n';
|
||||
import type { Ref } from 'vue';
|
||||
import {
|
||||
Check,
|
||||
ChevronDown,
|
||||
Database,
|
||||
FileText,
|
||||
Link2,
|
||||
Loader2,
|
||||
@@ -37,14 +35,11 @@ export interface ChatInputAttachmentPolicy {
|
||||
}
|
||||
|
||||
const inputValue = defineModel<string>({ required: true });
|
||||
const selectedKb = defineModel<string>('selectedKb', { required: true });
|
||||
const procurementReviewMode = defineModel<ContractReviewMode>('procurementReviewMode', { default: 'compare' });
|
||||
|
||||
const props = defineProps<{
|
||||
attachments: PendingAttachment[];
|
||||
attachmentPolicy: ChatInputAttachmentPolicy;
|
||||
availableKbOptions: string[];
|
||||
kbDropdownDisabled: boolean;
|
||||
isThinking: boolean;
|
||||
isVoiceRecording: boolean;
|
||||
isVoiceTranscribing: boolean;
|
||||
@@ -61,7 +56,6 @@ const props = defineProps<{
|
||||
/** 用对象包裹 Ref,避免 template 自动解包 */
|
||||
shippingPickerRefHolder: { pickerRef: Ref<HTMLInputElement | null> };
|
||||
shippingNoticePickerRefHolder: { pickerRef: Ref<HTMLInputElement | null> };
|
||||
getKbLabel: (kb: string) => string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -87,11 +81,9 @@ const originalContractPickerRef = ref<HTMLInputElement | null>(null);
|
||||
const { t } = useI18n();
|
||||
const textareaRef = ref<HTMLTextAreaElement | null>(null);
|
||||
const attachmentMenuRef = ref<HTMLElement | null>(null);
|
||||
const kbMenuRef = ref<HTMLElement | null>(null);
|
||||
const attachmentUrlInputRef = ref<HTMLInputElement | null>(null);
|
||||
const showAttachmentMenu = ref(false);
|
||||
const showAttachmentUrlPanel = ref(false);
|
||||
const showKbDropdown = ref(false);
|
||||
const attachmentUrlInput = ref('');
|
||||
|
||||
const hasProcurementContractAttachment = computed(() =>
|
||||
@@ -227,20 +219,6 @@ const selectAttachmentUrl = async () => {
|
||||
attachmentUrlInputRef.value?.focus();
|
||||
};
|
||||
|
||||
const toggleKbDropdown = () => {
|
||||
if (props.kbDropdownDisabled) {
|
||||
showKbDropdown.value = false;
|
||||
return;
|
||||
}
|
||||
showKbDropdown.value = !showKbDropdown.value;
|
||||
};
|
||||
|
||||
const selectKb = (option: string) => {
|
||||
if (!props.availableKbOptions.includes(option)) return;
|
||||
selectedKb.value = option;
|
||||
showKbDropdown.value = false;
|
||||
};
|
||||
|
||||
const submitRemoteUrl = () => {
|
||||
const raw = attachmentUrlInput.value.trim();
|
||||
if (!raw) return;
|
||||
@@ -271,12 +249,12 @@ const bindAttachmentPickerRef = (el: unknown) => {
|
||||
bindShippingNoticePickerRef(el);
|
||||
};
|
||||
|
||||
/**
|
||||
* 点击输入栏外部时收起附件菜单。
|
||||
*/
|
||||
const handleDocumentPointerDown = (event: MouseEvent | TouchEvent) => {
|
||||
const target = event.target as Node | null;
|
||||
if (!target) return;
|
||||
if (showKbDropdown.value && kbMenuRef.value && !kbMenuRef.value.contains(target)) {
|
||||
showKbDropdown.value = false;
|
||||
}
|
||||
if (showAttachmentMenu.value && attachmentMenuRef.value && !attachmentMenuRef.value.contains(target)) {
|
||||
closeAttachmentMenu();
|
||||
}
|
||||
@@ -539,21 +517,13 @@ watch(
|
||||
@keydown.enter.prevent="emit('send')"
|
||||
/>
|
||||
|
||||
<div class="mt-1.5 flex items-center justify-between px-1.5 pb-0.5">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isVoiceTranscribing"
|
||||
:title="isVoiceRecording ? $t('chat.voiceStop') : isVoiceTranscribing ? $t('chat.voiceTranscribing') : $t('chat.voiceFeature')"
|
||||
class="transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="isVoiceRecording ? 'animate-pulse text-red-500' : isVoiceTranscribing ? 'text-brand-500' : 'text-muted hover:text-brand-600'"
|
||||
@click="emit('voice-click')"
|
||||
<div class="mt-1.5 flex items-center justify-between gap-2 px-1.5 pb-0.5">
|
||||
<div class="flex min-w-0 flex-1 flex-wrap items-center gap-2">
|
||||
<div
|
||||
v-if="attachmentPolicy.anyEnabled && !isProcurementContractAgent"
|
||||
ref="attachmentMenuRef"
|
||||
class="relative"
|
||||
>
|
||||
<Loader2 v-if="isVoiceTranscribing" class="h-5 w-5 animate-spin" />
|
||||
<Mic v-else class="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
<div v-if="attachmentPolicy.anyEnabled" ref="attachmentMenuRef" class="relative">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
@@ -658,34 +628,6 @@ watch(
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!isMaintenanceAgent" ref="kbMenuRef" class="relative">
|
||||
<button
|
||||
type="button"
|
||||
: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"
|
||||
@click="toggleKbDropdown"
|
||||
>
|
||||
<Database class="h-3.5 w-3.5 text-brand-500" />
|
||||
{{ getKbLabel(selectedKb) }} <ChevronDown class="h-3 w-3" />
|
||||
</button>
|
||||
<div
|
||||
v-if="showKbDropdown && !kbDropdownDisabled"
|
||||
class="absolute bottom-full left-0 mb-2 w-36 animate-fade-in overflow-hidden rounded-xl border border-subtle bg-surface py-1 shadow-xl"
|
||||
>
|
||||
<button
|
||||
v-for="option in availableKbOptions"
|
||||
:key="option"
|
||||
type="button"
|
||||
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 }"
|
||||
@click="selectKb(option)"
|
||||
>
|
||||
{{ getKbLabel(option) }}
|
||||
<Check v-if="selectedKb === option" class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isMaintenanceAgent && canManageMaintenance"
|
||||
class="flex flex-wrap items-center gap-2"
|
||||
@@ -708,29 +650,47 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="isThinking && !isUploadingAttachments"
|
||||
type="button"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition-all duration-200 hover:scale-105 hover:bg-rose-100 active:scale-95"
|
||||
:title="$t('chat.stopGenerating')"
|
||||
:aria-label="$t('chat.stopGenerating')"
|
||||
@click="emit('stop')"
|
||||
>
|
||||
<Square class="h-4 w-4 fill-current" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
:disabled="!canSendMessage"
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full border shadow-sm transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="!canSendMessage
|
||||
? 'border-default bg-slate-100 text-muted'
|
||||
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
|
||||
@click="emit('send')"
|
||||
>
|
||||
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
|
||||
<Send v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<div class="flex shrink-0 items-center gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isVoiceTranscribing"
|
||||
:title="isVoiceRecording ? $t('chat.voiceStop') : isVoiceTranscribing ? $t('chat.voiceTranscribing') : $t('chat.voiceFeature')"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="isVoiceRecording
|
||||
? 'animate-pulse bg-rose-50 text-red-500'
|
||||
: isVoiceTranscribing
|
||||
? 'bg-brand-50 text-brand-500'
|
||||
: 'text-muted hover:bg-surface-soft hover:text-brand-600'"
|
||||
@click="emit('voice-click')"
|
||||
>
|
||||
<Loader2 v-if="isVoiceTranscribing" class="h-5 w-5 animate-spin" />
|
||||
<Mic v-else class="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="isThinking && !isUploadingAttachments"
|
||||
type="button"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition-all duration-200 hover:scale-105 hover:bg-rose-100 active:scale-95"
|
||||
:title="$t('chat.stopGenerating')"
|
||||
:aria-label="$t('chat.stopGenerating')"
|
||||
@click="emit('stop')"
|
||||
>
|
||||
<Square class="h-4 w-4 fill-current" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
:disabled="!canSendMessage"
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full border shadow-sm transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="!canSendMessage
|
||||
? 'border-default bg-slate-100 text-muted'
|
||||
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
|
||||
@click="emit('send')"
|
||||
>
|
||||
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
|
||||
<Send v-else class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 text-center text-[11px] text-muted">
|
||||
|
||||
@@ -263,12 +263,9 @@ watch(() => page.currentAgentId, () => {
|
||||
v-show="!isTrainingWorkspaceExpanded"
|
||||
:key="`${page.currentAgentId}-${page.conversationId || 'draft'}-${page.messages.length}`"
|
||||
v-model="page.input"
|
||||
v-model:selected-kb="page.selectedKb"
|
||||
v-model:procurement-review-mode="page.procurementReviewMode"
|
||||
:attachments="page.attachments"
|
||||
:attachment-policy="page.attachmentPolicy"
|
||||
:available-kb-options="page.availableKbOptions"
|
||||
:kb-dropdown-disabled="page.kbDropdownDisabled"
|
||||
:is-thinking="page.isThinking"
|
||||
:is-voice-recording="page.isVoiceRecording"
|
||||
:is-voice-transcribing="page.isVoiceTranscribing"
|
||||
@@ -284,7 +281,6 @@ watch(() => page.currentAgentId, () => {
|
||||
:shipping-focus-reason="page.shippingFocusReason"
|
||||
:shipping-picker-ref-holder="page.shippingPickerRefHolder"
|
||||
:shipping-notice-picker-ref-holder="page.shippingNoticePickerRefHolder"
|
||||
:get-kb-label="page.getKbLabel"
|
||||
@send="page.handleSend()"
|
||||
@stop="page.stopActiveGeneration()"
|
||||
@voice-click="page.handleVoiceFeatureClick"
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
/**
|
||||
* features/chat/composables/useChatAgent.ts
|
||||
* 当前 Agent 元数据、知识库选项、推荐问题与用户可切换 Agent 列表。
|
||||
* 当前 Agent 元数据、发送时默认知识库类型、推荐问题与用户可切换 Agent 列表。
|
||||
* 依赖:user API、agent-registry / agent-category utils、training 题库工具、ChatDeps。
|
||||
* 逻辑:Chat 页面通过 useChatPage 调用;selectedKb 固定为企业知识库供发消息透传,输入栏不再展示知识库下拉。
|
||||
*/
|
||||
import { computed, ref, watch, type ComputedRef } from 'vue';
|
||||
import { computed, ref, type ComputedRef } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { getUserAgent, listUserAgents } from '@/features/user';
|
||||
import { setLastChatAgentId } from '@/shared/utils/lastChatAgent';
|
||||
import { sortAgentsByCategory } from '@/shared/utils/agent-category.utils';
|
||||
import {
|
||||
agentHasErpKb,
|
||||
type AgentRegistryFields,
|
||||
} from '@/shared/utils/agent-registry.utils';
|
||||
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';
|
||||
@@ -21,8 +20,8 @@ export type AgentSuggestedQuestionItem = {
|
||||
group: string;
|
||||
};
|
||||
|
||||
/** 发消息时透传给后端的默认 kb_type;聊天输入栏已不再提供切换入口 */
|
||||
const DEFAULT_KB = '企业知识库';
|
||||
const ERP_KB = 'ERP知识库';
|
||||
|
||||
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
|
||||
if (!Array.isArray(value)) return [];
|
||||
@@ -77,36 +76,11 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const userAgents = ref<ChatAgentOption[]>([]);
|
||||
const showAgentPanel = ref(true);
|
||||
const selectedKb = ref(DEFAULT_KB);
|
||||
const kbOptions = [DEFAULT_KB, ERP_KB];
|
||||
|
||||
const getKbLabel = (kb: string) => {
|
||||
if (kb === DEFAULT_KB) return t('chat.kb.enterprise');
|
||||
if (kb === ERP_KB) return t('chat.kb.erp');
|
||||
return kb;
|
||||
};
|
||||
|
||||
const canSelectErpKnowledgeBase = computed(() => agentHasErpKb(currentAgent.value));
|
||||
const availableKbOptions = computed(() => (
|
||||
canSelectErpKnowledgeBase.value
|
||||
? kbOptions
|
||||
: 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) {
|
||||
selectedKb.value = DEFAULT_KB;
|
||||
return;
|
||||
}
|
||||
if (selectedKb.value === ERP_KB) {
|
||||
selectedKb.value = DEFAULT_KB;
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
const agentDescription = computed(() => {
|
||||
const welcome = String(currentAgent.value?.welcome_message || '').trim();
|
||||
if (welcome) return welcome;
|
||||
@@ -200,9 +174,6 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
userAgents,
|
||||
showAgentPanel,
|
||||
selectedKb,
|
||||
getKbLabel,
|
||||
availableKbOptions,
|
||||
kbDropdownDisabled,
|
||||
agentDescription,
|
||||
suggestedQuestionsStyle,
|
||||
agentSuggestedQuestions,
|
||||
|
||||
@@ -267,6 +267,10 @@
|
||||
"conversationMode": "Conversation mode",
|
||||
"welcomeMessage": "Welcome message",
|
||||
"welcomeMessagePlaceholder": "Welcome text shown in chat (optional; overrides description)",
|
||||
"isActive": "Availability",
|
||||
"isActiveEnable": "Enable this app",
|
||||
"isActiveHintOn": "Enabled: shown in the workspace and chat sidebar; authorized users can open conversations.",
|
||||
"isActiveHintOff": "Disabled: hidden from the workspace and chat sidebar. Settings are kept and can be re-enabled anytime.",
|
||||
"runtimeProviders": {
|
||||
"dify": "Dify",
|
||||
"builtin": "Built-in",
|
||||
@@ -1009,7 +1013,7 @@
|
||||
"usageActiveUserHint": "Top 50 users by chat volume, with pagination",
|
||||
"appOps": {
|
||||
"title": "App Operations",
|
||||
"intro": "Per-app usage, authorization, pending requests, and ratings — with drill-down to chat logs and permission requests.",
|
||||
"intro": "Per-app usage, authorization, and ratings — with drill-down to chat logs.",
|
||||
"statusLabel": "Status",
|
||||
"statusAll": "All",
|
||||
"statusActive": "Active",
|
||||
@@ -1023,10 +1027,8 @@
|
||||
"summaryTotal": "{total} total",
|
||||
"summaryUsed": "Used",
|
||||
"summaryUnused": "Unused",
|
||||
"summaryPending": "Pending permissions",
|
||||
"empty": "No application ops data. Try adjusting filters.",
|
||||
"actionLogs": "Logs",
|
||||
"actionRequests": "Requests",
|
||||
"columns": {
|
||||
"name": "App",
|
||||
"is_active": "Status",
|
||||
@@ -1035,7 +1037,6 @@
|
||||
"unique_users": "Users",
|
||||
"last_active_at": "Last active",
|
||||
"authorized_users": "Authorized",
|
||||
"pending_requests": "Pending",
|
||||
"avg_score": "Avg score",
|
||||
"feedback_count": "Ratings",
|
||||
"tokens_used": "Tokens",
|
||||
|
||||
@@ -403,10 +403,6 @@
|
||||
"voiceTranscriptionFailed": "Speech recognition failed. Please try again",
|
||||
"collapseBrowser": "Collapse Browser",
|
||||
"openBrowser": "Open Browser",
|
||||
"kb": {
|
||||
"enterprise": "Enterprise Knowledge Base",
|
||||
"erp": "ERP Knowledge Base"
|
||||
},
|
||||
"browser": "Browser",
|
||||
"closeBrowser": "Close Browser",
|
||||
"browserInputPlaceholder": "Enter URL, e.g. https://example.com",
|
||||
|
||||
@@ -267,6 +267,10 @@
|
||||
"conversationMode": "โหมดการสนทนา",
|
||||
"welcomeMessage": "ข้อความต้อนรับ",
|
||||
"welcomeMessagePlaceholder": "ข้อความต้อนรับในหน้าแชท (ไม่บังคับ ใช้แทนคำอธิบาย)",
|
||||
"isActive": "สถานะการเปิดใช้",
|
||||
"isActiveEnable": "เปิดใช้แอปนี้",
|
||||
"isActiveHintOn": "เปิดใช้อยู่: จะแสดงในพื้นที่ทำงานและแถบแชท ผู้ใช้ที่ได้รับสิทธิ์สามารถสนทนาได้",
|
||||
"isActiveHintOff": "ปิดใช้อยู่: จะไม่แสดงในพื้นที่ทำงานและแถบแชท การตั้งค่ายังคงอยู่และเปิดใช้ใหม่ได้ตลอดเวลา",
|
||||
"runtimeProviders": {
|
||||
"dify": "Dify",
|
||||
"builtin": "Built-in",
|
||||
@@ -993,7 +997,7 @@
|
||||
"usageActiveUserHint": "ผู้ใช้ 50 อันดับแรกตามปริมาณแชท พร้อมแบ่งหน้า",
|
||||
"appOps": {
|
||||
"title": "แอปปฏิบัติการ",
|
||||
"intro": "ดูปริมาณการใช้ สิทธิ์ คำขอที่รอ และคะแนนรายแอป พร้อมเจาะลงบันทึกแชทและคำขอสิทธิ์",
|
||||
"intro": "ดูปริมาณการใช้ สิทธิ์ และคะแนนรายแอป พร้อมเจาะลงบันทึกแชท",
|
||||
"statusLabel": "สถานะ",
|
||||
"statusAll": "ทั้งหมด",
|
||||
"statusActive": "เปิดใช้",
|
||||
@@ -1007,10 +1011,8 @@
|
||||
"summaryTotal": "ทั้งหมด {total}",
|
||||
"summaryUsed": "มีการใช้",
|
||||
"summaryUnused": "ไม่มีการใช้",
|
||||
"summaryPending": "สิทธิ์รอดำเนินการ",
|
||||
"empty": "ไม่มีข้อมูลแอปปฏิบัติการ ลองปรับตัวกรอง",
|
||||
"actionLogs": "บันทึก",
|
||||
"actionRequests": "คำขอ",
|
||||
"columns": {
|
||||
"name": "แอป",
|
||||
"is_active": "สถานะ",
|
||||
@@ -1019,7 +1021,6 @@
|
||||
"unique_users": "ผู้ใช้",
|
||||
"last_active_at": "ใช้งานล่าสุด",
|
||||
"authorized_users": "ได้รับสิทธิ์",
|
||||
"pending_requests": "รอดำเนินการ",
|
||||
"avg_score": "คะแนนเฉลี่ย",
|
||||
"feedback_count": "จำนวนคะแนน",
|
||||
"tokens_used": "Token",
|
||||
|
||||
@@ -403,10 +403,6 @@
|
||||
"voiceTranscriptionFailed": "การรู้จำเสียงล้มเหลว โปรดลองอีกครั้ง",
|
||||
"collapseBrowser": "ย่อเบราว์เซอร์",
|
||||
"openBrowser": "เปิดเบราว์เซอร์",
|
||||
"kb": {
|
||||
"enterprise": "คลังความรู้ขององค์กร",
|
||||
"erp": "คลังความรู้ ERP"
|
||||
},
|
||||
"browser": "เบราว์เซอร์",
|
||||
"closeBrowser": "ปิดเบราว์เซอร์",
|
||||
"browserInputPlaceholder": "ใส่ URL เช่น https://example.com",
|
||||
|
||||
@@ -267,6 +267,10 @@
|
||||
"conversationMode": "对话形态",
|
||||
"welcomeMessage": "欢迎语",
|
||||
"welcomeMessagePlaceholder": "聊天页展示的欢迎文案(选填,优先于描述)",
|
||||
"isActive": "启用状态",
|
||||
"isActiveEnable": "启用此应用",
|
||||
"isActiveHintOn": "当前已启用:会出现在工作台与聊天侧栏,授权用户可进入对话。",
|
||||
"isActiveHintOff": "当前已禁用:不会出现在工作台与聊天侧栏,配置仍保留,可随时重新启用。",
|
||||
"runtimeProviders": {
|
||||
"dify": "Dify",
|
||||
"builtin": "内置",
|
||||
@@ -988,7 +992,7 @@
|
||||
"usageActiveUserHint": "对话量前 50 名用户,支持翻页",
|
||||
"appOps": {
|
||||
"title": "应用运营",
|
||||
"intro": "按应用查看使用量、授权、待审与评分,支持下钻聊天日志与权限申请。",
|
||||
"intro": "按应用查看使用量、授权与评分,支持下钻聊天日志。",
|
||||
"statusLabel": "状态",
|
||||
"statusAll": "全部",
|
||||
"statusActive": "启用",
|
||||
@@ -1002,10 +1006,8 @@
|
||||
"summaryTotal": "共 {total} 个",
|
||||
"summaryUsed": "有使用",
|
||||
"summaryUnused": "零使用",
|
||||
"summaryPending": "待审权限",
|
||||
"empty": "暂无应用运营数据,请调整筛选条件",
|
||||
"actionLogs": "日志",
|
||||
"actionRequests": "申请",
|
||||
"columns": {
|
||||
"name": "应用",
|
||||
"is_active": "状态",
|
||||
@@ -1014,7 +1016,6 @@
|
||||
"unique_users": "用户",
|
||||
"last_active_at": "最近活跃",
|
||||
"authorized_users": "授权",
|
||||
"pending_requests": "待审",
|
||||
"avg_score": "均分",
|
||||
"feedback_count": "评价数",
|
||||
"tokens_used": "Token",
|
||||
|
||||
@@ -403,10 +403,6 @@
|
||||
"voiceTranscriptionFailed": "语音识别失败,请重试",
|
||||
"collapseBrowser": "收起浏览器",
|
||||
"openBrowser": "打开浏览器",
|
||||
"kb": {
|
||||
"enterprise": "企业知识库",
|
||||
"erp": "ERP知识库"
|
||||
},
|
||||
"browser": "浏览器",
|
||||
"closeBrowser": "关闭浏览器",
|
||||
"browserInputPlaceholder": "输入网址,例如 https://example.com",
|
||||
|
||||
@@ -267,6 +267,10 @@
|
||||
"conversationMode": "對話形態",
|
||||
"welcomeMessage": "歡迎語",
|
||||
"welcomeMessagePlaceholder": "聊天頁展示的歡迎文案(選填,優先於描述)",
|
||||
"isActive": "啟用狀態",
|
||||
"isActiveEnable": "啟用此應用",
|
||||
"isActiveHintOn": "目前已啟用:會出現在工作台與聊天側欄,授權使用者可進入對話。",
|
||||
"isActiveHintOff": "目前已停用:不會出現在工作台與聊天側欄,設定仍保留,可隨時重新啟用。",
|
||||
"runtimeProviders": {
|
||||
"dify": "Dify",
|
||||
"builtin": "內建",
|
||||
@@ -993,7 +997,7 @@
|
||||
"usageActiveUserHint": "對話量前 50 名使用者,支援翻頁",
|
||||
"appOps": {
|
||||
"title": "應用運營",
|
||||
"intro": "按應用查看使用量、授權、待審與評分,支援下鑽聊天日誌與權限申請。",
|
||||
"intro": "按應用查看使用量、授權與評分,支援下鑽聊天日誌。",
|
||||
"statusLabel": "狀態",
|
||||
"statusAll": "全部",
|
||||
"statusActive": "啟用",
|
||||
@@ -1007,10 +1011,8 @@
|
||||
"summaryTotal": "共 {total} 個",
|
||||
"summaryUsed": "有使用",
|
||||
"summaryUnused": "零使用",
|
||||
"summaryPending": "待審權限",
|
||||
"empty": "暫無應用運營資料,請調整篩選條件",
|
||||
"actionLogs": "日誌",
|
||||
"actionRequests": "申請",
|
||||
"columns": {
|
||||
"name": "應用",
|
||||
"is_active": "狀態",
|
||||
@@ -1019,7 +1021,6 @@
|
||||
"unique_users": "使用者",
|
||||
"last_active_at": "最近活躍",
|
||||
"authorized_users": "授權",
|
||||
"pending_requests": "待審",
|
||||
"avg_score": "均分",
|
||||
"feedback_count": "評價數",
|
||||
"tokens_used": "Token",
|
||||
|
||||
@@ -403,10 +403,6 @@
|
||||
"voiceTranscriptionFailed": "語音辨識失敗,請重試",
|
||||
"collapseBrowser": "收起瀏覽器",
|
||||
"openBrowser": "打開瀏覽器",
|
||||
"kb": {
|
||||
"enterprise": "企業知識庫",
|
||||
"erp": "ERP知識庫"
|
||||
},
|
||||
"browser": "瀏覽器",
|
||||
"closeBrowser": "關閉瀏覽器",
|
||||
"browserInputPlaceholder": "輸入網址,例如 https://example.com",
|
||||
|
||||
Reference in new issue
Block a user