mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-28 07:36:38 +08:00
fix(ui): improve date input parsing and add missing back navigation
This commit is contained in:
@@ -188,7 +188,7 @@ function App() {
|
||||
/>
|
||||
<Route
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<ProtectedRoute useSimpleLayout={true}>
|
||||
<PanelSharingPage />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
|
||||
@@ -234,6 +234,15 @@ export default function ConfigPage() {
|
||||
Partial<Record<BrandPreviewKey, boolean>>
|
||||
>({});
|
||||
|
||||
const handleBack = () => {
|
||||
if (window.history.length > 1) {
|
||||
navigate(-1);
|
||||
|
||||
return;
|
||||
}
|
||||
navigate("/profile");
|
||||
};
|
||||
|
||||
// 权限检查
|
||||
useEffect(() => {
|
||||
if (!isAdmin()) {
|
||||
@@ -846,6 +855,22 @@ export default function ConfigPage() {
|
||||
<div className="p-6 max-w-4xl mx-auto">
|
||||
{/* 页面标题 */}
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<Button
|
||||
isIconOnly
|
||||
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>
|
||||
</Button>
|
||||
<SettingsIcon className="w-8 h-8 text-primary" />
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">网站配置</h1>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user