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
3 Commits
b10075737f
...
392285058e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
392285058e | ||
|
|
508d7d63c9 | ||
|
|
9863c1a1de |
@ -9,7 +9,13 @@ 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')
|
||||||
appConfig = parse(data) || defaultConfig
|
const parsedConfig = parse(data)
|
||||||
|
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
|
||||||
|
|||||||
@ -192,8 +192,25 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查状态码,例如: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.id === current) ?? {
|
const info = items?.find((item) => 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