refactor(品牌工具页): 抽取 formatDateTime 与 uploadPathsToJava 公共工具
- 新增 shared/utils/datetime.ts:13 个品牌页逐字重复的 formatDateTime 收敛为一处; 语义不同的 3 个变体(toLocaleString / 字符串切片 / 支持时间戳)保留不动 - 新增 shared/utils/upload-to-java.ts:10 个品牌页的上传循环收敛,api 依赖注入便于单测; 保留 uploadOss(品牌Tab)与 returnEmptyWhenUnavailable(跟价)两处行为差异 - 补 datetime / upload-to-java 单测 10 例 净减约 327 行;vue-tsc 构建与 690 个前端单测全通过
This commit is contained in:
@@ -272,6 +272,7 @@ import {
|
||||
countryLabel,
|
||||
sanitizeCountryCodes,
|
||||
} from "@/shared/country-options";
|
||||
import { formatDateTime } from '@/shared/utils/datetime'
|
||||
|
||||
const MAX_TRANSIENT_ERRORS = 30;
|
||||
/** 任务终态后等待结果文件(Java 侧异步生成)的最大轮次,12 × 10s ≈ 2 分钟 */
|
||||
@@ -447,19 +448,6 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
||||
return `patrol-delete:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
||||
}
|
||||
|
||||
function formatDateTime(value?: string) {
|
||||
if (!value) return "-";
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
const hours = String(date.getHours()).padStart(2, "0");
|
||||
const minutes = String(date.getMinutes()).padStart(2, "0");
|
||||
const seconds = String(date.getSeconds()).padStart(2, "0");
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
function formatMatchStatus(status?: string) {
|
||||
const value = (status || "").trim();
|
||||
const map: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user