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" => {
let name = item.name.unwrap_or("Local File".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" => {
let name = item.name.unwrap_or("Merge".into());
@ -153,7 +153,12 @@ impl PrfItem {
/// ## Local type
/// 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 file = format!("{uid}.yaml");
@ -166,7 +171,10 @@ impl PrfItem {
url: None,
selected: None,
extra: None,
option: None,
option: Some(PrfOption {
update_interval: option.unwrap_or_default().update_interval,
..PrfOption::default()
}),
home: None,
updated: Some(chrono::Local::now().timestamp() as usize),
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") {
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>

View File

@ -1,4 +1,7 @@
{
"millis": "millis",
"mins": "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 Column",
"Proxy Layout Columns": "Proxy Layout Columns",
"Auto Columns": "Auto Columns",
"Auto Log Clean": "Auto Log Clean",
"Never Clean": "Never Clean",
"Retain 7 Days": "Retain 7 Days",

View File

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

View File

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

View File

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