增加转账时间

This commit is contained in:
zhx 2026-06-04 11:58:20 +08:00
parent 91d355b7f1
commit cd9dfb4bfb
2 changed files with 37 additions and 7 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>Withdraw/Exchange</title>
<link rel="stylesheet" href="./style.css?v=20260601-0110" />
<link rel="stylesheet" href="./style.css?v=20260604-0100" />
</head>
<body>
<div class="wallet-page" aria-label="Withdraw and exchange" data-i18n-aria="page_label">
@ -165,6 +165,6 @@
</div>
<div class="home-indicator" aria-hidden="true"></div>
</div>
<script src="./script.js?v=20260601-0110" defer></script>
<script src="./script.js?v=20260604-0100" defer></script>
</body>
</html>

View File

@ -69,6 +69,8 @@
income: "Income",
expense: "Expense",
balance: "Balance",
receive_time: "Receive time",
transfer_time: "Transfer time",
period: "Period",
days: "Days",
target: "Target",
@ -675,12 +677,40 @@
document.body.classList.toggle("salary-history-open", open);
}
function formatHistoryDateParts(date) {
const pad = (item) => String(item).padStart(2, "0");
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
function formatHistoryDate(value) {
if (!value) return "";
const text = String(value).replace("T", " ");
if (value === null || value === undefined || value === "") return "";
const raw = String(value).trim();
if (/^\d{10,13}$/.test(raw)) {
const number = Number(raw);
const date = new Date(raw.length === 10 ? number * 1000 : number);
if (!Number.isNaN(date.getTime())) return formatHistoryDateParts(date);
}
const text = raw.replace("T", " ");
return text.length > 16 ? text.slice(0, 16) : text;
}
function rawHistoryTime(item) {
const transferCandidates = [item?.transferTime, item?.transferredAt, item?.transferAt, item?.outTime];
const receiveCandidates = [item?.receiveTime, item?.receivedAt, item?.receiveAt, item?.incomeTime];
const commonCandidates = [item?.createTime, item?.createdAt, item?.time, item?.timestamp, item?.updateTime, item?.updatedAt];
const candidates = Number(item?.type) === 1
? transferCandidates.concat(commonCandidates)
: receiveCandidates.concat(commonCandidates);
return candidates.find((candidate) => candidate !== null && candidate !== undefined && candidate !== "") || "";
}
function historyTimeLabel(item) {
return Number(item?.type) === 1
? message("transfer_time", "Transfer time")
: message("receive_time", "Receive time");
}
function formatBillPeriod(value) {
const text = String(value || "");
if (text.length < 6) return text;
@ -903,7 +933,7 @@
const meta = document.createElement("div");
meta.className = "salary-history-item-meta";
const metaItems = [];
if (item.date) metaItems.push(item.date);
if (item.date) metaItems.push(`${historyTimeLabel(item)}: ${item.date}`);
if (item.period) metaItems.push(`${message("period", "Period")}: ${item.period}`);
if (item.target) metaItems.push(`${message("target", "Target")}: ${item.target}`);
if (item.days) metaItems.push(`${message("days", "Days")}: ${item.days}`);
@ -1067,7 +1097,7 @@
type: item.type,
status: item.salaryEvent || "",
period: item.billBelong ? formatBillPeriod(item.billBelong) : "",
date: formatHistoryDate(item.createdAt)
date: formatHistoryDate(rawHistoryTime(item))
}))
};
}
@ -1089,7 +1119,7 @@
balance: item.balance,
type: item.type,
status: item.event || "",
date: formatHistoryDate(item.createTime)
date: formatHistoryDate(rawHistoryTime(item))
}))
};
}