diff --git a/frontend/src/stores/profiles.ts b/frontend/src/stores/profiles.ts index c02cbc53..3d1bc2ef 100644 --- a/frontend/src/stores/profiles.ts +++ b/frontend/src/stores/profiles.ts @@ -5,6 +5,7 @@ import { parse, stringify } from 'yaml' import { debounce, ignoredError } from '@/utils' import { Readfile, Writefile } from '@/bridge' import { ProfilesFilePath, ProxyGroup, FinalDnsType } from '@/constant' +import { useAlert } from '@/hooks' export type ProfileType = { id: string @@ -117,6 +118,22 @@ export const useProfilesStore = defineStore('profiles', () => { const data = await ignoredError(Readfile, ProfilesFilePath) data && (profiles.value = parse(data)) + const profilesCount = profiles.value.length + + profiles.value = profiles.value.filter((profile) => { + return !(profile as any).route + }) + + if (profilesCount !== profiles.value.length) { + const { alert } = useAlert() + const filteredProfiles = profiles.value.filter((profile) => (profile as any).route) + Writefile('data/.cache/latest-profiles.yaml', stringify(filteredProfiles)) + alert( + 'Tip', + 'The incompatible profiles has been saved to the file: data/.cache/profiles-backup.yaml.' + ) + } + // compatibility code profiles.value.forEach((profile) => { if (!profile.tunConfig['address']) {