From ffda0fb71a1da7eca5aa3369c6c9268ef83ab44c Mon Sep 17 00:00:00 2001 From: Su-cyber-art <72259479+Su-cyber-art@users.noreply.github.com> Date: Sat, 7 Mar 2026 14:19:23 +0800 Subject: [PATCH 1/2] fix(ui): improve date input parsing and add missing back navigation --- vite-frontend/src/App.tsx | 2 +- vite-frontend/src/pages/config.tsx | 25 +++++++++++++++++++ .../src/shadcn-bridge/heroui/date-picker.tsx | 24 ++++++++++++++---- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/vite-frontend/src/App.tsx b/vite-frontend/src/App.tsx index 75d28c4..1e15ab6 100644 --- a/vite-frontend/src/App.tsx +++ b/vite-frontend/src/App.tsx @@ -188,7 +188,7 @@ function App() { /> + } diff --git a/vite-frontend/src/pages/config.tsx b/vite-frontend/src/pages/config.tsx index 2f5b1e1..1390a0c 100644 --- a/vite-frontend/src/pages/config.tsx +++ b/vite-frontend/src/pages/config.tsx @@ -234,6 +234,15 @@ export default function ConfigPage() { Partial> >({}); + const handleBack = () => { + if (window.history.length > 1) { + navigate(-1); + + return; + } + navigate("/profile"); + }; + // 权限检查 useEffect(() => { if (!isAdmin()) { @@ -846,6 +855,22 @@ export default function ConfigPage() {
{/* 页面标题 */}
+

网站配置

diff --git a/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx b/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx index fe033cb..a467df1 100644 --- a/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx +++ b/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx @@ -38,15 +38,29 @@ function parseDateText(value: string) { return null; } - const matched = trimmed.match(/^(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})$/); + // 兼容纯数字输入:YYYYMMDD + const digitsOnly = trimmed.replace(/\D/g, ""); - if (!matched) { + if (digitsOnly.length === 8) { + const year = Number(digitsOnly.slice(0, 4)); + const month = Number(digitsOnly.slice(4, 6)); + const day = Number(digitsOnly.slice(6, 8)); + + if (isValidCalendarDate(year, month, day)) { + return { day, month, year }; + } + } + + // 兼容多种分隔输入:YYYY-MM-DD / YYYY/MM/DD / YYYY.MM.DD / YYYY年M月D日 / YYYY M D + const numberParts = trimmed.match(/\d+/g); + + if (!numberParts || numberParts.length < 3 || numberParts[0].length !== 4) { return null; } - const year = Number(matched[1]); - const month = Number(matched[2]); - const day = Number(matched[3]); + const year = Number(numberParts[0]); + const month = Number(numberParts[1]); + const day = Number(numberParts[2]); if (!isValidCalendarDate(year, month, day)) { return null; From c3e35fd416f6043ff708009d930398038bc9e27f Mon Sep 17 00:00:00 2001 From: sagitchu Date: Sat, 7 Mar 2026 17:59:33 +0800 Subject: [PATCH 2/2] fix(ui): tighten date parsing and back navigation Entire-Checkpoint: fea62b38d8c7 --- plans/017-pr-284-ui-followup-fixes.md | 16 ++++++++++++ vite-frontend/src/components/icons.tsx | 26 +++++++++++++++++++ vite-frontend/src/layouts/h5-simple.tsx | 9 ++----- vite-frontend/src/pages/config.tsx | 22 ++++++++-------- vite-frontend/src/pages/settings.tsx | 16 ++---------- .../src/shadcn-bridge/heroui/date-picker.tsx | 16 +++++++----- 6 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 plans/017-pr-284-ui-followup-fixes.md diff --git a/plans/017-pr-284-ui-followup-fixes.md b/plans/017-pr-284-ui-followup-fixes.md new file mode 100644 index 0000000..fa77c63 --- /dev/null +++ b/plans/017-pr-284-ui-followup-fixes.md @@ -0,0 +1,16 @@ +# 017 PR 284 UI Follow-up Fixes + +## Checklist + +- [x] Review the current frontend route and component state related to PR 284 follow-up fixes. +- [x] Restore the intended H5 simple-layout route behavior for panel sharing. +- [x] Improve date text parsing to support separator-free and flexible formats without ambiguous fallbacks. +- [x] Add config-page back navigation with a safer history fallback and shared icon usage. +- [x] Run focused frontend verification for the updated files and record the result. + +## Test Record + +- Command: `cd vite-frontend && npm install` +- Result: passed. +- Command: `cd vite-frontend && npm run build` +- Result: passed. diff --git a/vite-frontend/src/components/icons.tsx b/vite-frontend/src/components/icons.tsx index 720ed7a..2d25ecf 100644 --- a/vite-frontend/src/components/icons.tsx +++ b/vite-frontend/src/components/icons.tsx @@ -259,3 +259,29 @@ export const SettingsIcon = ({ /> ); + +export const BackIcon = ({ + size = 24, + width, + height, + ...props +}: IconSvgProps) => ( + +); diff --git a/vite-frontend/src/layouts/h5-simple.tsx b/vite-frontend/src/layouts/h5-simple.tsx index d29c666..85ad3d0 100644 --- a/vite-frontend/src/layouts/h5-simple.tsx +++ b/vite-frontend/src/layouts/h5-simple.tsx @@ -2,6 +2,7 @@ import React from "react"; import { useNavigate } from "react-router-dom"; import { Button } from "@/shadcn-bridge/heroui/button"; +import { BackIcon } from "@/components/icons"; import { BrandLogo } from "@/components/brand-logo"; import { siteConfig } from "@/config/site"; import { useScrollTopOnPathChange } from "@/hooks/useScrollTopOnPathChange"; @@ -25,13 +26,7 @@ export default function H5SimpleLayout({

diff --git a/vite-frontend/src/pages/config.tsx b/vite-frontend/src/pages/config.tsx index 1390a0c..9411845 100644 --- a/vite-frontend/src/pages/config.tsx +++ b/vite-frontend/src/pages/config.tsx @@ -26,7 +26,7 @@ import { updateAnnouncement, type AnnouncementData, } from "@/api"; -import { SettingsIcon } from "@/components/icons"; +import { BackIcon, SettingsIcon } from "@/components/icons"; import { isAdmin } from "@/utils/auth"; import { getCachedConfigs, configCache, updateSiteConfig } from "@/config/site"; import { @@ -234,13 +234,19 @@ export default function ConfigPage() { Partial> >({}); + const canGoBack = + typeof window !== "undefined" && + typeof window.history.state?.idx === "number" && + window.history.state.idx > 0; + const handleBack = () => { - if (window.history.length > 1) { + if (canGoBack) { navigate(-1); return; } - navigate("/profile"); + + navigate("/profile", { replace: true }); }; // 权限检查 @@ -857,19 +863,13 @@ export default function ConfigPage() {
diff --git a/vite-frontend/src/pages/settings.tsx b/vite-frontend/src/pages/settings.tsx index b196759..55e3217 100644 --- a/vite-frontend/src/pages/settings.tsx +++ b/vite-frontend/src/pages/settings.tsx @@ -9,6 +9,7 @@ import { Select, SelectItem } from "@/shadcn-bridge/heroui/select"; import { Switch } from "@/shadcn-bridge/heroui/switch"; import { reinitializeBaseURL } from "@/api/network"; import { getConfigByName, updateConfig } from "@/api"; +import { BackIcon } from "@/components/icons"; import { type UpdateReleaseChannel, getUpdateReleaseChannel, @@ -168,20 +169,7 @@ export const SettingsPage = () => { variant="light" onPress={() => navigate(-1)} > - +

面板设置 diff --git a/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx b/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx index a467df1..7eeff37 100644 --- a/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx +++ b/vite-frontend/src/shadcn-bridge/heroui/date-picker.tsx @@ -38,23 +38,27 @@ function parseDateText(value: string) { return null; } - // 兼容纯数字输入:YYYYMMDD const digitsOnly = trimmed.replace(/\D/g, ""); - if (digitsOnly.length === 8) { + if (/^\d+$/.test(trimmed)) { + if (digitsOnly.length !== 8) { + return null; + } + const year = Number(digitsOnly.slice(0, 4)); const month = Number(digitsOnly.slice(4, 6)); const day = Number(digitsOnly.slice(6, 8)); - if (isValidCalendarDate(year, month, day)) { - return { day, month, year }; + if (!isValidCalendarDate(year, month, day)) { + return null; } + + return { day, month, year }; } - // 兼容多种分隔输入:YYYY-MM-DD / YYYY/MM/DD / YYYY.MM.DD / YYYY年M月D日 / YYYY M D const numberParts = trimmed.match(/\d+/g); - if (!numberParts || numberParts.length < 3 || numberParts[0].length !== 4) { + if (!numberParts || numberParts.length !== 3 || numberParts[0].length !== 4) { return null; }