fix(ui): tighten date parsing and back navigation

Entire-Checkpoint: fea62b38d8c7
This commit is contained in:
sagitchu
2026-03-07 17:59:33 +08:00
parent 775dfe19f1
commit c3e35fd416
6 changed files with 67 additions and 38 deletions
+11 -11
View File
@@ -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<Record<BrandPreviewKey, boolean>>
>({});
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() {
<div className="flex items-center gap-3 mb-6">
<Button
isIconOnly
aria-label="返回"
aria-label="返回上一页"
className="min-w-0 w-9 h-9"
size="sm"
variant="flat"
onPress={handleBack}
>
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
<path
clipRule="evenodd"
d="M12.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 111.414 1.414L9.414 9.5l3.293 3.293a1 1 0 010 1.414z"
fillRule="evenodd"
/>
</svg>
<BackIcon className="w-5 h-5" />
</Button>
<SettingsIcon className="w-8 h-8 text-primary" />
<div>
+2 -14
View File
@@ -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)}
>
<svg
aria-hidden="true"
className="w-5 h-5"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
d="M15 19l-7-7 7-7"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
/>
</svg>
<BackIcon className="w-5 h-5" />
</Button>
<h1 className="text-xl font-semibold text-gray-900 dark:text-white">
面板设置