fix: update_interval won't save when creating local profile while updating does & number input locales

This commit is contained in:
dongchengjie
2024-06-23 06:47:51 +08:00
parent d8b878b1bb
commit bfa3fa293f
7 changed files with 53 additions and 30 deletions

View File

@@ -95,6 +95,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
if (form.type !== "remote" && form.type !== "local") {
delete form.option;
}
if (form.option?.update_interval) {
form.option.update_interval = +form.option.update_interval;
} else {
@@ -228,16 +229,11 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
<TextField
{...text}
{...field}
onChange={(e) => {
e.target.value = e.target.value
?.replace(/\D/, "")
.slice(0, 10);
field.onChange(e);
}}
type="number"
label={t("Update Interval")}
InputProps={{
endAdornment: (
<InputAdornment position="end">mins</InputAdornment>
<InputAdornment position="end">{t("mins")}</InputAdornment>
),
}}
/>
@@ -248,10 +244,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
{isLocal && openType === "new" && (
<FileInput
onChange={(file, val) => {
if (!formIns.getValues("name")) {
const name = file.name.substring(0, file.name.lastIndexOf("."));
formIns.setValue("name", name);
}
formIns.setValue("name", formIns.getValues("name") || file.name);
fileDataRef.current = val;
}}
/>

View File

@@ -8,6 +8,7 @@ import {
MenuItem,
Select,
TextField,
InputAdornment,
} from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
@@ -81,12 +82,12 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
size="small"
sx={{ width: 100, "> div": { py: "7.5px" } }}
value={values.appLogLevel}
onChange={(e) => {
onChange={(e) =>
setValues((v) => ({
...v,
appLogLevel: e.target.value as string,
}));
}}
}))
}
>
{["trace", "debug", "info", "warn", "error", "silent"].map((i) => (
<MenuItem value={i} key={i}>
@@ -130,20 +131,20 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
</ListItem>
<ListItem sx={{ padding: "5px 2px" }}>
<ListItemText primary={t("Proxy Layout Column")} />
<ListItemText primary={t("Proxy Layout Columns")} />
<Select
size="small"
sx={{ width: 135, "> div": { py: "7.5px" } }}
value={values.proxyLayoutColumn}
onChange={(e) => {
onChange={(e) =>
setValues((v) => ({
...v,
proxyLayoutColumn: e.target.value as number,
}));
}}
}))
}
>
<MenuItem value={6} key={6}>
Auto
{t("Auto Columns")}
</MenuItem>
{[1, 2, 3, 4, 5].map((i) => (
<MenuItem value={i} key={i}>
@@ -159,12 +160,12 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
size="small"
sx={{ width: 135, "> div": { py: "7.5px" } }}
value={values.autoLogClean}
onChange={(e) => {
onChange={(e) =>
setValues((v) => ({
...v,
autoLogClean: e.target.value as number,
}));
}}
}))
}
>
{[
{ key: "Never Clean", value: 0 },
@@ -214,6 +215,11 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
defaultLatencyTimeout: parseInt(e.target.value),
}))
}
InputProps={{
endAdornment: (
<InputAdornment position="end">{t("millis")}</InputAdornment>
),
}}
/>
</ListItem>
</List>