fix(front): 冒烟修复——dateFormat 兼容 ISO 时间串、去掉破坏深链接的 onMounted 重定向、消除双 toast
build / build (push) Successful in 2m23s

- 时间列 NaN:网关 Jackson 序列化为 ISO(2026-09-23T14:20:12.333),dateFormat 斜杠化后还须去 T
- 深链接:冷启动时初始导航未解析完 currentRoute 恒为 /,onMounted 的 replace 会把
  #/routes、#/targets(含刷新)全部弹回台账;/ 落点本就由 routes.ts 的 redirect 处理
- 业务错误由 alova 全局 onBizError 统一弹出,页面 catch 只做回滚,不再重复弹
- 浏览器实测:台账筛选/详情弹窗、路由列与只读列、重载注册表(22 路由/14 目标)、
  目标页空 baseUrl 保存被后端拒绝且 UI 回滚,全部通过
This commit is contained in:
chenxing
2026-09-23 14:49:49 +08:00
parent 73dbbcb06c
commit 3fd608be7e
5 changed files with 10 additions and 10 deletions
+3 -4
View File
@@ -3,9 +3,6 @@ import { ref, onMounted, reactive } from "vue";
import layout from "./components/layout.vue";
import { LayoutData } from "./types/Basics";
import { useRouter } from "vue-router";
const router = useRouter();
const isRouterAlive = ref(true), isLogin = ref(false);
@@ -36,7 +33,9 @@ provide("reload", reload);
onMounted(() => {
layoutData.modList = modList;
if (router.currentRoute.value.path === "/") router.replace("/ledger");
// "/" 落点由 routes.ts 的 { path: "/", redirect: "/ledger" } 处理。
// 这里不能再用 currentRoute 判断后 replace:冷启动时初始导航尚未解析完,
// currentRoute 恒为 "/",会把 #/routes、#/targets 深链接(含刷新)全部弹回台账。
isLogin.value = true;
});
+1 -1
View File
@@ -21,7 +21,7 @@ async function reloadRegistry() {
Message.success(`已重载:路由 ${d?.loaded ?? "-"} 条 / 目标 ${d?.targets ?? "-"} 条`);
lastReloadTime.value = Utils.dateFormat(new Date(), "HH:mm:ss");
} catch (e: any) {
Message.error(e?.message || "重载失败");
// 错误提示由 alova 全局 onBizError 弹出,这里不重复弹
} finally {
reloading.value = false;
}
+4 -1
View File
@@ -10,7 +10,10 @@ export default class Utils {
* @memberof Utils
*/
public static dateFormat(date: Date | string, fmt: string): string {
if (typeof date === "string") date = date.replace(/\-/g, "/");
if (typeof date === "string") {
// 网关 Jackson 默认序列化为 ISO(2026-09-23T14:20:12.333):斜杠化后还须去 T,否则 new Date 解析成 Invalid Date
date = date.replace(/\-/g, "/").replace(/T/, " ").replace(/Z$/, "");
}
let dt = new Date(date);
let o: IObj = {
"M+": dt.getMonth() + 1, //月份
+1 -2
View File
@@ -101,8 +101,7 @@ async function save(row: any) {
});
Message.success(`已保存,注册表加载 ${d?.loaded ?? '-'} 条路由`);
} catch (e: any) {
Message.error(e?.message || '保存失败');
// 失败不留假状态:重拉列表,行 UI 回滚到服务端真值
// 错误提示由 alova 全局 onBizError 弹出,这里只做回滚,避免双 toast
tableRef.value?.refreshData();
} finally {
savingId.value = null;
+1 -2
View File
@@ -67,8 +67,7 @@ async function save(row: any) {
});
Message.success(`已保存,目标表加载 ${d?.targets ?? '-'} 条`);
} catch (e: any) {
Message.error(e?.message || '保存失败');
// 失败不留假状态:重拉列表,行 UI 回滚到服务端真值
// 错误提示由 alova 全局 onBizError 弹出,这里只做回滚,避免双 toast
tableRef.value?.refreshData();
} finally {
savingId.value = null;