mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
feat: add fetch timeout configuration
This commit is contained in:
parent
6d337818d0
commit
bcecca7ab7
@ -129,7 +129,7 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||||||
} as IProfileItem
|
} as IProfileItem
|
||||||
switch (newItem.type) {
|
switch (newItem.type) {
|
||||||
case 'remote': {
|
case 'remote': {
|
||||||
const { userAgent } = await getAppConfig()
|
const { userAgent, subscriptionTimeout = 30000 } = await getAppConfig()
|
||||||
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
||||||
if (!item.url) throw new Error('Empty URL')
|
if (!item.url) throw new Error('Empty URL')
|
||||||
let res: AxiosResponse
|
let res: AxiosResponse
|
||||||
@ -146,7 +146,8 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent || `mihomo.party/v${app.getVersion()} (clash.meta)`
|
'User-Agent': userAgent || `mihomo.party/v${app.getVersion()} (clash.meta)`
|
||||||
},
|
},
|
||||||
responseType: 'text'
|
responseType: 'text',
|
||||||
|
timeout: subscriptionTimeout
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
res = await axios.get(item.url, {
|
res = await axios.get(item.url, {
|
||||||
@ -160,7 +161,8 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent || `mihomo.party/v${app.getVersion()} (clash.meta)`
|
'User-Agent': userAgent || `mihomo.party/v${app.getVersion()} (clash.meta)`
|
||||||
},
|
},
|
||||||
responseType: 'text'
|
responseType: 'text',
|
||||||
|
timeout: subscriptionTimeout
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ export const defaultConfig: IAppConfig = {
|
|||||||
proxyDisplayOrder: 'default',
|
proxyDisplayOrder: 'default',
|
||||||
autoCheckUpdate: true,
|
autoCheckUpdate: true,
|
||||||
autoCloseConnection: true,
|
autoCloseConnection: true,
|
||||||
|
subscriptionTimeout: 30000,
|
||||||
useNameserverPolicy: false,
|
useNameserverPolicy: false,
|
||||||
controlDns: true,
|
controlDns: true,
|
||||||
controlSniff: true,
|
controlSniff: true,
|
||||||
|
|||||||
@ -23,6 +23,7 @@ const MihomoConfig: React.FC = () => {
|
|||||||
pauseSSID = [],
|
pauseSSID = [],
|
||||||
delayTestUrl,
|
delayTestUrl,
|
||||||
userAgent,
|
userAgent,
|
||||||
|
subscriptionTimeout = 30000,
|
||||||
mihomoCpuPriority = 'PRIORITY_NORMAL',
|
mihomoCpuPriority = 'PRIORITY_NORMAL',
|
||||||
proxyCols = 'auto'
|
proxyCols = 'auto'
|
||||||
} = appConfig || {}
|
} = appConfig || {}
|
||||||
@ -49,6 +50,27 @@ const MihomoConfig: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
></Input>
|
></Input>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
<SettingItem title={t('settings.subscriptionTimeout')} divider>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Input
|
||||||
|
size="sm"
|
||||||
|
className="w-[100px]"
|
||||||
|
type="number"
|
||||||
|
value={(subscriptionTimeout / 1000)?.toString()}
|
||||||
|
onValueChange={async (v: string) => {
|
||||||
|
let num = parseInt(v)
|
||||||
|
await patchAppConfig({ subscriptionTimeout: num * 1000 })
|
||||||
|
}}
|
||||||
|
onBlur={async (e) => {
|
||||||
|
let num = parseInt(e.target.value)
|
||||||
|
if (isNaN(num)) num = 30
|
||||||
|
if (num < 30) num = 30
|
||||||
|
await patchAppConfig({ subscriptionTimeout: num * 1000 })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span className="text-default-500">{t('common.seconds')}</span>
|
||||||
|
</div>
|
||||||
|
</SettingItem>
|
||||||
<SettingItem title={t('mihomo.delayTest.url')} divider>
|
<SettingItem title={t('mihomo.delayTest.url')} divider>
|
||||||
<Input
|
<Input
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
"settings.silentStart": "Silent Start",
|
"settings.silentStart": "Silent Start",
|
||||||
"settings.autoQuitWithoutCore": "Auto Enable Light Mode",
|
"settings.autoQuitWithoutCore": "Auto Enable Light Mode",
|
||||||
"settings.autoQuitWithoutCoreTooltip": "Automatically enter light mode after closing window for specified time",
|
"settings.autoQuitWithoutCoreTooltip": "Automatically enter light mode after closing window for specified time",
|
||||||
|
"settings.subscriptionTimeout": "Subscription Timeout",
|
||||||
"settings.autoQuitWithoutCoreDelay": "Light Mode Auto Enable Delay",
|
"settings.autoQuitWithoutCoreDelay": "Light Mode Auto Enable Delay",
|
||||||
"settings.envType": "Environment Variable Type",
|
"settings.envType": "Environment Variable Type",
|
||||||
"settings.showFloatingWindow": "Show Floating Window",
|
"settings.showFloatingWindow": "Show Floating Window",
|
||||||
|
|||||||
@ -52,6 +52,7 @@
|
|||||||
"settings.silentStart": "اجرای بیصدا",
|
"settings.silentStart": "اجرای بیصدا",
|
||||||
"settings.autoQuitWithoutCore": "ورود خودکار به حالت سبک",
|
"settings.autoQuitWithoutCore": "ورود خودکار به حالت سبک",
|
||||||
"settings.autoQuitWithoutCoreTooltip": "ورود خودکار به حالت سبک پس از بستن پنجره برای زمان مشخص",
|
"settings.autoQuitWithoutCoreTooltip": "ورود خودکار به حالت سبک پس از بستن پنجره برای زمان مشخص",
|
||||||
|
"settings.subscriptionTimeout": "زمان انتظار اشتراک",
|
||||||
"settings.autoQuitWithoutCoreDelay": "تاخیر فعالسازی خودکار حالت سبک",
|
"settings.autoQuitWithoutCoreDelay": "تاخیر فعالسازی خودکار حالت سبک",
|
||||||
"settings.envType": "نوع متغیر محیطی",
|
"settings.envType": "نوع متغیر محیطی",
|
||||||
"settings.showFloatingWindow": "نمایش پنجره شناور",
|
"settings.showFloatingWindow": "نمایش پنجره شناور",
|
||||||
|
|||||||
@ -52,6 +52,7 @@
|
|||||||
"settings.silentStart": "Тихий запуск",
|
"settings.silentStart": "Тихий запуск",
|
||||||
"settings.autoQuitWithoutCore": "Автоматический облегчённый режим",
|
"settings.autoQuitWithoutCore": "Автоматический облегчённый режим",
|
||||||
"settings.autoQuitWithoutCoreTooltip": "Автоматически переходить в облегчённый режим после закрытия окна",
|
"settings.autoQuitWithoutCoreTooltip": "Автоматически переходить в облегчённый режим после закрытия окна",
|
||||||
|
"settings.subscriptionTimeout": "Таймаут подписки",
|
||||||
"settings.autoQuitWithoutCoreDelay": "Задержка включения облегчённого режима",
|
"settings.autoQuitWithoutCoreDelay": "Задержка включения облегчённого режима",
|
||||||
"settings.envType": "Тип переменных окружения",
|
"settings.envType": "Тип переменных окружения",
|
||||||
"settings.showFloatingWindow": "Показывать плавающее окно",
|
"settings.showFloatingWindow": "Показывать плавающее окно",
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
"settings.silentStart": "静默启动",
|
"settings.silentStart": "静默启动",
|
||||||
"settings.autoQuitWithoutCore": "自动进入轻量模式",
|
"settings.autoQuitWithoutCore": "自动进入轻量模式",
|
||||||
"settings.autoQuitWithoutCoreTooltip": "关闭窗口后指定时间自动进入轻量模式",
|
"settings.autoQuitWithoutCoreTooltip": "关闭窗口后指定时间自动进入轻量模式",
|
||||||
|
"settings.subscriptionTimeout": "订阅超时时间",
|
||||||
"settings.autoQuitWithoutCoreDelay": "轻量模式自动启用延迟",
|
"settings.autoQuitWithoutCoreDelay": "轻量模式自动启用延迟",
|
||||||
"settings.envType": "环境变量类型",
|
"settings.envType": "环境变量类型",
|
||||||
"settings.showFloatingWindow": "显示悬浮窗",
|
"settings.showFloatingWindow": "显示悬浮窗",
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -282,6 +282,7 @@ interface IAppConfig {
|
|||||||
delayTestConcurrency?: number
|
delayTestConcurrency?: number
|
||||||
delayTestUrl?: string
|
delayTestUrl?: string
|
||||||
delayTestTimeout?: number
|
delayTestTimeout?: number
|
||||||
|
subscriptionTimeout?: number
|
||||||
encryptedPassword?: number[]
|
encryptedPassword?: number[]
|
||||||
controlDns?: boolean
|
controlDns?: boolean
|
||||||
controlSniff?: boolean
|
controlSniff?: boolean
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user