fix(admin): 优化数据报表
This commit is contained in:
1 parent
49c149eb3e
commit
cd81911514
10 files changed
+327
-178
No files matched your search
@@ -1,16 +1,23 @@
|
||||
/**
|
||||
* features/kb/utils/kb-display.utils.ts
|
||||
* 文档标题、时间、文件大小与状态徽标等纯展示工具。
|
||||
* 用途:文档标题、时间、文件大小与状态徽标等纯展示工具。
|
||||
* 依赖:kb.api 类型、kb-i18n.types、shared/utils/dateTime(UTC 时间戳本地化)。
|
||||
* 逻辑:KbWorkspace / KbAdminPanel 等调用;时间统一走 formatLocalDateTime,避免无时区后缀被当成本地时间导致差 8 小时。
|
||||
*/
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import type { KbDocumentItem } from '../api/kb.api';
|
||||
import type { KbTranslateFn } from './kb-i18n.types';
|
||||
|
||||
/**
|
||||
* 格式化知识库时间戳为本地时区 `YYYY-MM-DD HH:mm:ss`。
|
||||
* 核心逻辑:委托 formatLocalDateTime;后端 isoformat() 常无 Z,按 UTC 解析后再转浏览器本地时区。
|
||||
* @param value - API 返回的时间字符串
|
||||
* @returns 本地展示文案;空值返回 `--`
|
||||
*/
|
||||
export const formatDateTime = (value?: string | null) => {
|
||||
if (!value) return '--';
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
const formatted = formatLocalDateTime(value);
|
||||
return formatted === '-' ? '--' : formatted;
|
||||
};
|
||||
|
||||
export const formatFileSize = (value?: number | null) => {
|
||||
|
||||
Reference in new issue
Block a user