diff --git a/public/js/app.js b/public/js/app.js
index 1c696c0..bbf70e8 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -672,7 +672,7 @@ async function copyAddress() {
}
/**
- * 打开操作记录弹窗
+ * 打开访问记录弹窗
* @param {string|null} key - 为空时查当前项目全部记录;否则查指定配置键的记录
* @returns {Promise}
*/
@@ -689,19 +689,19 @@ async function openAudit(key) {
const logs = await API.getAudit(state.currentProject.id, key || "");
renderAudit(logs);
} catch (err) {
- toast("加载操作记录失败: " + err.message, "error");
+ toast("加载访问记录失败: " + err.message, "error");
}
}
/**
- * 渲染操作记录表格
- * @param {Array} logs - 操作记录列表
+ * 渲染访问记录表格
+ * @param {Array} logs - 访问记录列表
* @returns {void}
*/
function renderAudit(logs) {
const tbody = document.getElementById("audit-tbody");
if (!logs || !logs.length) {
- tbody.innerHTML = '| 暂无操作记录 |
';
+ tbody.innerHTML = '| 暂无访问记录 |
';
return;
}
const ACTION_NAMES = { read: "读取", create: "新增", update: "更新", delete: "删除" };
diff --git a/src/version.js b/src/version.js
index f1a8169..997df7b 100644
--- a/src/version.js
+++ b/src/version.js
@@ -2,26 +2,47 @@
* 版本信息
* 版本号格式: v1.0. build
* - commit hash: 优先取环境变量 GIT_COMMIT(Docker 构建时传入),否则本地 git rev-parse
- * - build time: 优先取环境变量 BUILD_TIME(Docker 构建时传入),否则为进程启动时刻
+ * - build time: 优先取环境变量 BUILD_TIME(Docker 构建时传入,按 UTC 时刻理解),否则为进程启动时刻
+ * 时间戳统一按东八区(UTC+8)展示。
*/
const { execFileSync } = require("child_process");
+const UTC8_MS = 8 * 60 * 60 * 1000;
+
function pad(n) {
return String(n).padStart(2, "0");
}
+/**
+ * 将日期换算为东八区墙钟时间并格式化 yyyyMMdd HHmmss
+ * @param {Date} d - UTC 时刻
+ * @returns {string}
+ */
function formatDateTime(d) {
+ const t = new Date(d.getTime() + UTC8_MS);
return (
- d.getFullYear() +
- pad(d.getMonth() + 1) +
- pad(d.getDate()) +
+ t.getUTCFullYear() +
+ pad(t.getUTCMonth() + 1) +
+ pad(t.getUTCDate()) +
" " +
- pad(d.getHours()) +
- pad(d.getMinutes()) +
- pad(d.getSeconds())
+ pad(t.getUTCHours()) +
+ pad(t.getUTCMinutes()) +
+ pad(t.getUTCSeconds())
);
}
+/**
+ * BUILD_TIME(CI 传入的 UTC yyyyMMddHHmmss)换算为东八区展示
+ * @param {string} ts - UTC 时间戳
+ * @returns {string}
+ */
+function formatBuildTimeUtc8(ts) {
+ const m = String(ts).match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);
+ if (!m) return ts;
+ const utc = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +m[6]));
+ return formatDateTime(utc);
+}
+
function shortenHash(hash) {
return (hash || "unknown").slice(0, 8);
}
@@ -43,7 +64,7 @@ function resolveCommitHash() {
function resolveBuildTime() {
if (process.env.BUILD_TIME && process.env.BUILD_TIME !== "unknown" && process.env.BUILD_TIME !== "") {
- return process.env.BUILD_TIME;
+ return formatBuildTimeUtc8(process.env.BUILD_TIME);
}
return formatDateTime(new Date());
}