fix: fallback to global timeout when profile timeout is empty

This commit is contained in:
zjdndjf 2026-04-06 01:27:34 +08:00
parent a5c59ce689
commit 0bedac12ed
No known key found for this signature in database
2 changed files with 8 additions and 7 deletions

View File

@ -250,7 +250,7 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
authToken: item.authToken,
userAgent: item.userAgent,
updated: new Date().getTime(),
updateTimeout: item.updateTimeout || 5
updateTimeout: item.updateTimeout
}
// Local
@ -264,7 +264,10 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
const { userAgent, subscriptionTimeout = 30000 } = await getAppConfig()
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
const userItemTimeoutMs = (newItem.updateTimeout || 5) * 1000
const userItemTimeoutMs =
typeof newItem.updateTimeout === 'number' && newItem.updateTimeout > 0
? newItem.updateTimeout * 1000
: subscriptionTimeout
const baseOptions: Omit<FetchOptions, 'useProxy' | 'timeout'> = {
url: item.url,
@ -454,7 +457,7 @@ export async function convertMrsRuleset(filePath: string, behavior: string): Pro
try {
// 使用 mihomo convert-ruleset 命令转换 MRS 文件为 text 格式
// 命令格式: mihomo convert-ruleset <behavior> <format> <source>
// 命令格式mihomo convert-ruleset <behavior> <format> <source>
await execAsync(`"${corePath}" convert-ruleset ${behavior} mrs "${fullPath}" "${tempFilePath}"`)
const content = await readFile(tempFilePath, 'utf-8')
await unlink(tempFilePath)

View File

@ -33,8 +33,7 @@ const EditInfoModal: React.FC<Props> = (props) => {
const { overrideConfig } = useOverrideConfig()
const { items: overrideItems = [] } = overrideConfig || {}
const [values, setValues] = useState({
...item,
updateTimeout: item.updateTimeout ?? 5
...item
})
const inputWidth = 'w-[400px] md:w-[400px] lg:w-[600px] xl:w-[800px]'
const { t } = useTranslation()
@ -43,7 +42,6 @@ const EditInfoModal: React.FC<Props> = (props) => {
try {
const updatedItem = {
...values,
updateTimeout: values.updateTimeout ?? 5,
override: values.override?.filter(
(i) =>
overrideItems.find((t) => t.id === i) && !overrideItems.find((t) => t.id === i)?.global
@ -215,7 +213,7 @@ const EditInfoModal: React.FC<Props> = (props) => {
value={values.updateTimeout?.toString() ?? ''}
onValueChange={(v) => {
if (v === '') {
setValues({ ...values, updateTimeout: undefined as unknown as number })
setValues({ ...values, updateTimeout: undefined })
return
}
if (/^\d+$/.test(v)) {