From 3fd608be7eb0cb634348a75096ceea1a4b412607 Mon Sep 17 00:00:00 2001 From: chenxing Date: Wed, 23 Sep 2026 14:49:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(front):=20=E5=86=92=E7=83=9F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E2=80=94=E2=80=94dateFormat=20=E5=85=BC=E5=AE=B9=20IS?= =?UTF-8?q?O=20=E6=97=B6=E9=97=B4=E4=B8=B2=E3=80=81=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E7=A0=B4=E5=9D=8F=E6=B7=B1=E9=93=BE=E6=8E=A5=E7=9A=84=20onMoun?= =?UTF-8?q?ted=20=E9=87=8D=E5=AE=9A=E5=90=91=E3=80=81=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E5=8F=8C=20toast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 时间列 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 回滚,全部通过 --- src/App.vue | 7 +++---- src/components/layout.vue | 2 +- src/utils/index.ts | 5 ++++- src/views/route/RouteList.vue | 3 +-- src/views/target/TargetList.vue | 3 +-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index 867568a..d1ccc2d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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; }); diff --git a/src/components/layout.vue b/src/components/layout.vue index c98af43..4e8c143 100644 --- a/src/components/layout.vue +++ b/src/components/layout.vue @@ -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; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 350e021..42f0eed 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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, //月份 diff --git a/src/views/route/RouteList.vue b/src/views/route/RouteList.vue index 63f3a46..57ad082 100644 --- a/src/views/route/RouteList.vue +++ b/src/views/route/RouteList.vue @@ -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; diff --git a/src/views/target/TargetList.vue b/src/views/target/TargetList.vue index f9ccafd..7abaa6a 100644 --- a/src/views/target/TargetList.vue +++ b/src/views/target/TargetList.vue @@ -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;