mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
Compare commits
No commits in common. "392285058e1c502d67b875b49a667ee1e81267dc" and "b10075737fd4c453f6dcbd5958f1a77a93151a95" have entirely different histories.
392285058e
...
b10075737f
@ -9,13 +9,7 @@ let appConfig: IAppConfig // config.yaml
|
|||||||
export async function getAppConfig(force = false): Promise<IAppConfig> {
|
export async function getAppConfig(force = false): Promise<IAppConfig> {
|
||||||
if (force || !appConfig) {
|
if (force || !appConfig) {
|
||||||
const data = await readFile(appConfigPath(), 'utf-8')
|
const data = await readFile(appConfigPath(), 'utf-8')
|
||||||
const parsedConfig = parse(data)
|
appConfig = parse(data) || defaultConfig
|
||||||
const mergedConfig = deepMerge({ ...defaultConfig }, parsedConfig || {})
|
|
||||||
if (JSON.stringify(mergedConfig) !== JSON.stringify(parsedConfig)) {
|
|
||||||
await writeFile(appConfigPath(), stringify(mergedConfig))
|
|
||||||
}
|
|
||||||
|
|
||||||
appConfig = mergedConfig
|
|
||||||
}
|
}
|
||||||
if (typeof appConfig !== 'object') appConfig = defaultConfig
|
if (typeof appConfig !== 'object') appConfig = defaultConfig
|
||||||
return appConfig
|
return appConfig
|
||||||
|
|||||||
@ -191,26 +191,9 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||||||
timeout: subscriptionTimeout
|
timeout: subscriptionTimeout
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查状态码,例如:403
|
|
||||||
if (res.status < 200 || res.status >= 300) {
|
|
||||||
throw new Error(`Subscription failed: Request status code ${res.status}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = res.data
|
const data = res.data
|
||||||
const headers = res.headers
|
const headers = res.headers
|
||||||
|
|
||||||
// 校验是否为对象结构 (拦截 HTML字符串、普通文本、乱码)
|
|
||||||
const parsed = parse(data)
|
|
||||||
if (typeof parsed !== 'object' || parsed === null) {
|
|
||||||
throw new Error('Subscription failed: Profile is not a valid YAML')
|
|
||||||
}
|
|
||||||
// 检查是否包含必要的字段,防止空对象
|
|
||||||
const profile = parsed as any
|
|
||||||
if (!profile.proxies && !profile['proxy-providers']) {
|
|
||||||
throw new Error('Subscription failed: Profile missing proxies or providers')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headers['content-disposition'] && newItem.name === 'Remote File') {
|
if (headers['content-disposition'] && newItem.name === 'Remote File') {
|
||||||
newItem.name = parseFilename(headers['content-disposition'])
|
newItem.name = parseFilename(headers['content-disposition'])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ const ProfileCard: React.FC<Props> = (props) => {
|
|||||||
id: 'profile'
|
id: 'profile'
|
||||||
})
|
})
|
||||||
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
||||||
const info = items?.find((item) => item && item.id === current) ?? {
|
const info = items?.find((item) => item.id === current) ?? {
|
||||||
id: 'default',
|
id: 'default',
|
||||||
type: 'local',
|
type: 'local',
|
||||||
name: t('sider.cards.emptyProfile')
|
name: t('sider.cards.emptyProfile')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user