Merge branch 'dev' into hugo-shipping-notice

This commit is contained in:
hugo committed 2026-07-16 13:13:34 +08:00
commit dde25344ca
9 files changed
+110 -19

No files matched your search

@@ -2,7 +2,8 @@
* features/admin/modules/reports/composables/useReportsAdmin.ts
* 用途:管理后台报表(多表浏览、筛选、排序、chat_logs 批量删除、使用分析与应用运营看板)。
* 依赖:admin.api、useReportLayoutStorage、useOffsetPagination、useMessage、dateTime、vue-router。
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,均复用 PaginationBar。
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,均复用 PaginationBar;
* 低使用应用优先消费后端 low_agents(含零使用启用应用),与应用运营口径对齐。
*/
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
@@ -252,9 +253,9 @@ export function useReportsAdmin() {
const usageUserTopLimit = computed(() => usageReport.value?.user_top_limit ?? 50);
const usageActiveAgentCount = computed(() => usageReport.value?.by_agent.length ?? 0);
const usageTrendMax = computed(() => Math.max(1, ...(usageReport.value?.by_day || []).map((item) => item.count)));
/** 低使用应用:范围内对话次数 ≤ 该阈值 */
/** 低使用应用:范围内对话次数 ≤ 该阈值(兜底;优先用后端返回值) */
const USAGE_LOW_AGENT_MAX_CHATS = 2;
/** 低使用应用提醒最多展示条数 */
/** 低使用应用提醒最多展示条数(兜底;优先用后端返回值) */
const USAGE_LOW_AGENT_LIST_LIMIT = 5;
/** 异常高峰:单日对话量下限(与日均倍数取较大者) */
const USAGE_SPIKE_DAY_MIN_CHATS = 5;
@@ -262,12 +263,26 @@ export function useReportsAdmin() {
const USAGE_SPIKE_DAY_AVG_MULTIPLIER = 2;
/** 异常高峰日期最多展示条数 */
const USAGE_SPIKE_DAY_LIST_LIMIT = 3;
const usageLowAgentItems = computed(() =>
[...(usageReport.value?.by_agent || [])]
.filter((item) => item.count <= USAGE_LOW_AGENT_MAX_CHATS)
.sort((a, b) => a.count - b.count || a.agent.localeCompare(b.agent))
.slice(0, USAGE_LOW_AGENT_LIST_LIMIT),
const usageLowAgentMaxChats = computed(
() => usageReport.value?.low_agent_max_chats ?? USAGE_LOW_AGENT_MAX_CHATS,
);
const usageLowAgentListLimit = computed(
() => usageReport.value?.low_agent_list_limit ?? USAGE_LOW_AGENT_LIST_LIMIT,
);
/**
* 低使用应用列表:优先用后端 low_agents(含零使用启用应用);
* 旧接口无该字段时回退到 by_agent 过滤(不含零使用)。
*/
const usageLowAgentItems = computed(() => {
const fromApi = usageReport.value?.low_agents;
if (Array.isArray(fromApi)) {
return fromApi;
}
return [...(usageReport.value?.by_agent || [])]
.filter((item) => item.count <= usageLowAgentMaxChats.value)
.sort((a, b) => a.count - b.count || a.agent.localeCompare(b.agent))
.slice(0, usageLowAgentListLimit.value);
});
const usageSpikeDayItems = computed(() => {
const days = usageReport.value?.by_day || [];
if (days.length === 0) return [];
@@ -1162,8 +1177,8 @@ watch([reportPageSize, sortedTableData], () => {
usageUserTopLimit,
usageActiveAgentCount,
usageTrendMax,
usageLowAgentMaxChats: USAGE_LOW_AGENT_MAX_CHATS,
usageLowAgentListLimit: USAGE_LOW_AGENT_LIST_LIMIT,
usageLowAgentMaxChats,
usageLowAgentListLimit,
usageSpikeDayMinChats: USAGE_SPIKE_DAY_MIN_CHATS,
usageSpikeDayAvgMultiplier: USAGE_SPIKE_DAY_AVG_MULTIPLIER,
usageSpikeDayListLimit: USAGE_SPIKE_DAY_LIST_LIMIT,