fix(frontend): default forward speed rule to no limit

Make forward create/edit treat empty speed-limit selection as no limit so the dropdown no longer shows the generic placeholder, and remove announcement console logging to keep frontend lint clean.
This commit is contained in:
sagitchu
2026-02-27 19:37:59 +08:00
parent 6e8406f439
commit a9eac6d01f
3 changed files with 19 additions and 24 deletions
+12 -14
View File
@@ -28,11 +28,7 @@ import {
} from "@/api"; } from "@/api";
import { SettingsIcon } from "@/components/icons"; import { SettingsIcon } from "@/components/icons";
import { isAdmin } from "@/utils/auth"; import { isAdmin } from "@/utils/auth";
import { import { getCachedConfigs, configCache, updateSiteConfig } from "@/config/site";
getCachedConfigs,
configCache,
updateSiteConfig,
} from "@/config/site";
import { import {
type UpdateReleaseChannel, type UpdateReleaseChannel,
getUpdateReleaseChannel, getUpdateReleaseChannel,
@@ -112,15 +108,13 @@ const CONFIG_ITEMS: ConfigItem[] = [
{ {
key: "app_logo", key: "app_logo",
label: "网页角标 Logo", label: "网页角标 Logo",
description: description: "用于页面左上角导航角标,上传后会自动转换为 PNG 并持久化保存",
"用于页面左上角导航角标,上传后会自动转换为 PNG 并持久化保存",
type: "input", type: "input",
}, },
{ {
key: "app_favicon", key: "app_favicon",
label: "浏览器缩略图标", label: "浏览器缩略图标",
description: description: "用于浏览器标签页图标,上传后会自动转换为 PNG 并持久化保存",
"用于浏览器标签页图标,上传后会自动转换为 PNG 并持久化保存",
type: "input", type: "input",
}, },
{ {
@@ -293,8 +287,7 @@ export default function ConfigPage() {
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
setAnnouncement(res.data); setAnnouncement(res.data);
} }
} catch (error) { } catch {
console.error("Failed to load announcement:", error);
} finally { } finally {
setAnnouncementLoading(false); setAnnouncementLoading(false);
} }
@@ -534,7 +527,10 @@ export default function ConfigPage() {
); );
}; };
const renderBrandAssetUploader = (key: BrandPreviewKey, isChanged: boolean) => { const renderBrandAssetUploader = (
key: BrandPreviewKey,
isChanged: boolean,
) => {
const value = (configs[key] || "").trim(); const value = (configs[key] || "").trim();
const uploading = brandUploading[key] === true; const uploading = brandUploading[key] === true;
const isLogo = key === "app_logo"; const isLogo = key === "app_logo";
@@ -548,9 +544,9 @@ export default function ConfigPage() {
}`} }`}
> >
<input <input
ref={getBrandInputRef(key)}
accept={BRAND_FILE_ACCEPT} accept={BRAND_FILE_ACCEPT}
className="hidden" className="hidden"
ref={getBrandInputRef(key)}
type="file" type="file"
onChange={(event) => { onChange={(event) => {
void handleBrandFileChange(key, event); void handleBrandFileChange(key, event);
@@ -581,7 +577,9 @@ export default function ConfigPage() {
> >
清除 清除
</Button> </Button>
<span className="text-xs text-default-500">仅支持图片文件,自动转换为 PNG</span> <span className="text-xs text-default-500">
仅支持图片文件,自动转换为 PNG
</span>
</div> </div>
<p className="mt-2 text-xs text-default-500"> <p className="mt-2 text-xs text-default-500">
@@ -197,9 +197,7 @@ export const useDashboardData = (): DashboardDataState => {
if (res.code === 0 && res.data && res.data.enabled === 1) { if (res.code === 0 && res.data && res.data.enabled === 1) {
setAnnouncement(res.data); setAnnouncement(res.data);
} }
} catch (error) { } catch {}
console.error("Failed to load announcement:", error);
}
}; };
const loadPackageData = async () => { const loadPackageData = async () => {
+6 -7
View File
@@ -2349,25 +2349,24 @@ export default function ForwardPage() {
<Select <Select
label="限速规则" label="限速规则"
placeholder="不限速"
selectedKeys={ selectedKeys={
selectedSpeedId !== null selectedSpeedId !== null
? [selectedSpeedId.toString()] ? [selectedSpeedId.toString()]
: ["null"] : []
} }
variant="bordered" variant="bordered"
onSelectionChange={(keys) => { onSelectionChange={(keys) => {
const selectedKey = Array.from(keys)[0] as string; const selectedKey = Array.from(keys)[0] as
| string
| undefined;
setForm((prev) => ({ setForm((prev) => ({
...prev, ...prev,
speedId: speedId: selectedKey ? Number(selectedKey) : null,
selectedKey === "null" ? null : Number(selectedKey),
})); }));
}} }}
> >
<SelectItem key="null" textValue="不限速">
不限速
</SelectItem>
{availableSpeedLimits.map((speedLimit) => ( {availableSpeedLimits.map((speedLimit) => (
<SelectItem <SelectItem
key={speedLimit.id.toString()} key={speedLimit.id.toString()}