fix: update_interval won't save when creating local profile while updating does & number input locales
Some checks are pending
Alpha Build / alpha (macos-latest, aarch64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (macos-latest, x86_64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, aarch64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, armv7-unknown-linux-gnueabihf) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, i686-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (arm64, windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x86, windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / Update tag (push) Blocked by required conditions

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

@ -135,7 +135,7 @@ impl PrfItem {
"local" => { "local" => {
let name = item.name.unwrap_or("Local File".into()); let name = item.name.unwrap_or("Local File".into());
let desc = item.desc.unwrap_or("".into()); let desc = item.desc.unwrap_or("".into());
PrfItem::from_local(name, desc, file_data) PrfItem::from_local(name, desc, file_data, item.option)
} }
"merge" => { "merge" => {
let name = item.name.unwrap_or("Merge".into()); let name = item.name.unwrap_or("Merge".into());
@ -153,7 +153,12 @@ impl PrfItem {
/// ## Local type /// ## Local type
/// create a new item from name/desc /// create a new item from name/desc
pub fn from_local(name: String, desc: String, file_data: Option<String>) -> Result<PrfItem> { pub fn from_local(
name: String,
desc: String,
file_data: Option<String>,
option: Option<PrfOption>,
) -> Result<PrfItem> {
let uid = help::get_uid("l"); let uid = help::get_uid("l");
let file = format!("{uid}.yaml"); let file = format!("{uid}.yaml");
@ -166,7 +171,10 @@ impl PrfItem {
url: None, url: None,
selected: None, selected: None,
extra: None, extra: None,
option: None, option: Some(PrfOption {
update_interval: option.unwrap_or_default().update_interval,
..PrfOption::default()
}),
home: None, home: None,
updated: Some(chrono::Local::now().timestamp() as usize), updated: Some(chrono::Local::now().timestamp() as usize),
file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())), file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())),

View File

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

View File

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

View File

@ -1,4 +1,7 @@
{ {
"millis": "millis",
"mins": "mins",
"Back": "Back", "Back": "Back",
"Close": "Close", "Close": "Close",
"Cancel": "Cancel", "Cancel": "Cancel",
@ -208,7 +211,8 @@
"Auto Close Connections": "Auto Close Connections", "Auto Close Connections": "Auto Close Connections",
"Auto Check Update": "Auto Check Update", "Auto Check Update": "Auto Check Update",
"Enable Builtin Enhanced": "Enable Builtin Enhanced", "Enable Builtin Enhanced": "Enable Builtin Enhanced",
"Proxy Layout Column": "Proxy Layout Column", "Proxy Layout Columns": "Proxy Layout Columns",
"Auto Columns": "Auto Columns",
"Auto Log Clean": "Auto Log Clean", "Auto Log Clean": "Auto Log Clean",
"Never Clean": "Never Clean", "Never Clean": "Never Clean",
"Retain 7 Days": "Retain 7 Days", "Retain 7 Days": "Retain 7 Days",

View File

@ -1,4 +1,7 @@
{ {
"millis": "میلی‌ثانیه",
"mins": "دقیقه",
"Back": "بازگشت", "Back": "بازگشت",
"Close": "بستن", "Close": "بستن",
"Cancel": "لغو", "Cancel": "لغو",
@ -208,7 +211,8 @@
"Auto Close Connections": "بستن خودکار اتصالات", "Auto Close Connections": "بستن خودکار اتصالات",
"Auto Check Update": "بررسی خودکار به‌روزرسانی", "Auto Check Update": "بررسی خودکار به‌روزرسانی",
"Enable Builtin Enhanced": "فعال کردن تقویت داخلی", "Enable Builtin Enhanced": "فعال کردن تقویت داخلی",
"Proxy Layout Column": "ستون چیدمان پراکسی", "Proxy Layout Columns": "ستون چیدمان پراکسی",
"Auto Columns": "ستون‌های خودکار",
"Auto Log Clean": "پاکسازی خودکار لاگ", "Auto Log Clean": "پاکسازی خودکار لاگ",
"Never Clean": "هرگز پاک نکن", "Never Clean": "هرگز پاک نکن",
"Retain 7 Days": "نگهداری به مدت 7 روز", "Retain 7 Days": "نگهداری به مدت 7 روز",

View File

@ -1,4 +1,7 @@
{ {
"millis": "миллисекунды",
"mins": "минуты",
"Back": "Назад", "Back": "Назад",
"Close": "Закрыть", "Close": "Закрыть",
"Cancel": "Отмена", "Cancel": "Отмена",
@ -208,7 +211,8 @@
"Auto Close Connections": "Автоматическое закрытие соединений", "Auto Close Connections": "Автоматическое закрытие соединений",
"Auto Check Update": "Автоматическая проверка обновлений", "Auto Check Update": "Автоматическая проверка обновлений",
"Enable Builtin Enhanced": "Включить встроенные улучшения", "Enable Builtin Enhanced": "Включить встроенные улучшения",
"Proxy Layout Column": "Количество столбцов в макете прокси", "Proxy Layout Columns": "Количество столбцов в макете прокси",
"Auto Columns": "Авто колонки",
"Auto Log Clean": "Автоматическая очистка журналов", "Auto Log Clean": "Автоматическая очистка журналов",
"Never Clean": "Никогда не очищать", "Never Clean": "Никогда не очищать",
"Retain 7 Days": "Сохранять 7 дней", "Retain 7 Days": "Сохранять 7 дней",

View File

@ -1,4 +1,7 @@
{ {
"millis": "毫秒",
"mins": "分钟",
"Back": "返回", "Back": "返回",
"Close": "关闭", "Close": "关闭",
"Cancel": "取消", "Cancel": "取消",
@ -54,7 +57,7 @@
"Update Interval": "更新间隔", "Update Interval": "更新间隔",
"Choose File": "选择文件", "Choose File": "选择文件",
"Use System Proxy": "使用系统代理更新", "Use System Proxy": "使用系统代理更新",
"Use Clash Proxy": "使用 Clash 代理更新", "Use Clash Proxy": "使用内核代理更新",
"Accept Invalid Certs (Danger)": "允许无效证书 (危险)", "Accept Invalid Certs (Danger)": "允许无效证书 (危险)",
"Refresh": "刷新", "Refresh": "刷新",
"Home": "首页", "Home": "首页",
@ -208,7 +211,8 @@
"Auto Close Connections": "自动关闭连接", "Auto Close Connections": "自动关闭连接",
"Auto Check Update": "自动检查更新", "Auto Check Update": "自动检查更新",
"Enable Builtin Enhanced": "内置增强功能", "Enable Builtin Enhanced": "内置增强功能",
"Proxy Layout Column": "代理页布局列数", "Proxy Layout Columns": "代理页布局列数",
"Auto Columns": "自动列数",
"Auto Log Clean": "自动清理日志", "Auto Log Clean": "自动清理日志",
"Never Clean": "不清理", "Never Clean": "不清理",
"Retain 7 Days": "保留7天", "Retain 7 Days": "保留7天",