Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
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,
|
||||
|
||||
@@ -16,6 +16,15 @@ export interface UsageReport {
|
||||
by_agent: { agent: string; count: number }[];
|
||||
/** 当前范围内按自然日聚合的对话趋势,用于使用分析柱状图。 */
|
||||
by_day?: { date: string; count: number }[];
|
||||
/**
|
||||
* 运营提醒:启用应用中范围内对话次数 ≤ low_agent_max_chats 的列表(含零使用)。
|
||||
* 由后端以 Agent 主表左连接统计,与应用运营「零使用」口径对齐。
|
||||
*/
|
||||
low_agents?: { agent: string; count: number }[];
|
||||
/** 低使用对话次数上限(后端常量) */
|
||||
low_agent_max_chats?: number;
|
||||
/** 低使用列表条数上限(后端常量) */
|
||||
low_agent_list_limit?: number;
|
||||
user_total: number;
|
||||
user_page: number;
|
||||
user_page_size: number;
|
||||
|
||||
@@ -27,12 +27,16 @@ function normalizeAssetImageErrorMessage(message: string): string {
|
||||
if (lowerCaseMessage.includes('固定资产图片文档库未配置')) {
|
||||
return '当前系统暂未配置固定资产图片文档库,暂时无法查看图片,请联系管理员处理。';
|
||||
}
|
||||
if (lowerCaseMessage.includes('请求的资源不存在')) {
|
||||
return '设备管理员还未上传照片~';
|
||||
}
|
||||
if (lowerCaseMessage.includes('未找到资产')) {
|
||||
return normalizedMessage;
|
||||
}
|
||||
return normalizedMessage || '检索固定资产图片失败';
|
||||
}
|
||||
|
||||
|
||||
export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
const loading = ref(false);
|
||||
|
||||
@@ -76,7 +80,11 @@ export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
} catch (err: unknown) {
|
||||
const rawMessage = err instanceof Error ? err.message : '检索固定资产图片失败';
|
||||
const message = normalizeAssetImageErrorMessage(rawMessage);
|
||||
options.warn(`图片查询失败:${message}`);
|
||||
if (message === '设备管理员还未上传照片~') {
|
||||
options.warn(message);
|
||||
} else {
|
||||
options.warn(`图片查询失败:${message}`);
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@
|
||||
"usageTrendEmpty": "No trend data yet",
|
||||
"usageInsights": "Operational alerts",
|
||||
"usageLowAgents": "Low-usage apps",
|
||||
"usageLowAgentsHint": "Apps with ≤ {max} chats in the selected range, sorted ascending, showing up to {limit}.",
|
||||
"usageLowAgentsHint": "Enabled apps with ≤ {max} chats in the selected range (including zero), sorted ascending, up to {limit}.",
|
||||
"usageLowAgentsHintAria": "Show low-usage app selection rule",
|
||||
"usageLowAgentsEmpty": "No low-usage apps in this range",
|
||||
"usageSpikeDays": "Spike days",
|
||||
|
||||
@@ -893,7 +893,7 @@
|
||||
"usageTrendEmpty": "ยังไม่มีข้อมูลแนวโน้ม",
|
||||
"usageInsights": "การแจ้งเตือนการดำเนินงาน",
|
||||
"usageLowAgents": "แอปที่ใช้น้อย",
|
||||
"usageLowAgentsHint": "แอปที่มีแชท ≤ {max} ครั้งในช่วงที่เลือก เรียงจากน้อยไปมาก แสดงสูงสุด {limit} รายการ",
|
||||
"usageLowAgentsHint": "แอปที่เปิดใช้และมีแชท ≤ {max} ครั้งในช่วงที่เลือก (รวมศูนย์ครั้ง) เรียงจากน้อยไปมาก แสดงสูงสุด {limit} รายการ",
|
||||
"usageLowAgentsHintAria": "ดูเกณฑ์การคัดเลือกแอปที่ใช้น้อย",
|
||||
"usageLowAgentsEmpty": "ไม่มีแอปที่ใช้น้อยในช่วงนี้",
|
||||
"usageSpikeDays": "วันที่มีการใช้งานพุ่งสูง",
|
||||
|
||||
@@ -889,7 +889,7 @@
|
||||
"usageTrendEmpty": "暂无趋势数据",
|
||||
"usageInsights": "运营提醒",
|
||||
"usageLowAgents": "低使用应用",
|
||||
"usageLowAgentsHint": "统计范围内对话次数 ≤ {max} 的应用,按对话量升序最多展示 {limit} 个。",
|
||||
"usageLowAgentsHint": "启用应用中,统计范围内对话次数 ≤ {max}(含零使用),按对话量升序最多展示 {limit} 个。",
|
||||
"usageLowAgentsHintAria": "查看低使用应用选取规则",
|
||||
"usageLowAgentsEmpty": "当前范围内暂无低使用应用",
|
||||
"usageSpikeDays": "异常高峰日期",
|
||||
|
||||
@@ -893,7 +893,7 @@
|
||||
"usageTrendEmpty": "暫無趨勢資料",
|
||||
"usageInsights": "營運提醒",
|
||||
"usageLowAgents": "低使用應用",
|
||||
"usageLowAgentsHint": "統計範圍內對話次數 ≤ {max} 的應用,按對話量升序最多展示 {limit} 個。",
|
||||
"usageLowAgentsHint": "啟用應用中,統計範圍內對話次數 ≤ {max}(含零使用),按對話量升序最多展示 {limit} 個。",
|
||||
"usageLowAgentsHintAria": "查看低使用應用選取規則",
|
||||
"usageLowAgentsEmpty": "目前範圍內暫無低使用應用",
|
||||
"usageSpikeDays": "異常高峰日期",
|
||||
|
||||
Reference in new issue
Block a user