Skip to content

Commit a183260

Browse files
committed
refactor: remove legacy compatibility code
1 parent 8177f2f commit a183260

File tree

6 files changed

+3
-176
lines changed

6 files changed

+3
-176
lines changed

frontend/src/bridge/io.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,3 @@ export const UnzipTarGZFile = async (path: string, output: string) => {
121121
}
122122
return data
123123
}
124-
125-
export const Writefile = WriteFile
126-
export const Readfile = ReadFile
127-
export const Movefile = MoveFile
128-
export const Removefile = RemoveFile
129-
export const Copyfile = CopyFile
130-
export const Makedir = MakeDir
131-
export const Readdir = ReadDir

frontend/src/stores/appSettings.ts

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
WindowSetSystemDefaultTheme,
1010
WindowIsMaximised,
1111
WindowIsMinimised,
12-
MoveFile,
1312
} from '@/bridge'
1413
import {
1514
Colors,
@@ -21,12 +20,7 @@ import {
2120
UserFilePath,
2221
LocalesFilePath,
2322
} from '@/constant/app'
24-
import {
25-
CorePidFilePath,
26-
CoreWorkingDirectory,
27-
DefaultConnections,
28-
DefaultCoreConfig,
29-
} from '@/constant/kernel'
23+
import { DefaultConnections, DefaultCoreConfig } from '@/constant/kernel'
3024
import {
3125
Theme,
3226
WindowStartState,
@@ -38,14 +32,7 @@ import {
3832
Branch,
3933
} from '@/enums/app'
4034
import i18n, { loadLocaleMessages, reloadLocale } from '@/lang'
41-
import {
42-
debounce,
43-
updateTrayMenus,
44-
ignoredError,
45-
sleep,
46-
getKernelFileName,
47-
GetSystemProxyBypass,
48-
} from '@/utils'
35+
import { debounce, updateTrayMenus, ignoredError, sleep, GetSystemProxyBypass } from '@/utils'
4936

5037
import { useEnvStore } from './env'
5138

@@ -157,62 +144,9 @@ export const useAppSettingsStore = defineStore('app-settings', () => {
157144
app.value.kernel.main = DefaultCoreConfig()
158145
app.value.kernel.alpha = DefaultCoreConfig()
159146
}
160-
161-
if (app.value.kernel.controllerCloseMode === undefined) {
162-
app.value.kernel.controllerCloseMode = ControllerCloseMode.All
163-
}
164-
if (app.value.kernel.controllerSensitivity === undefined) {
165-
app.value.kernel.controllerSensitivity = DefaultControllerSensitivity
166-
}
167-
if (app.value.addGroupToMenu === undefined) {
168-
app.value.addGroupToMenu = false
169-
}
170-
if (app.value.kernel.concurrencyLimit === undefined) {
171-
app.value.kernel.concurrencyLimit = DefaultConcurrencyLimit
172-
}
173-
// @ts-expect-error(Deprecated)
174-
if (app.value['font-family'] !== undefined) {
175-
// @ts-expect-error(Deprecated)
176-
app.value.fontFamily = app.value['font-family']
177-
// @ts-expect-error(Deprecated)
178-
delete app.value['font-family']
179-
}
180-
181-
if (!app.value.kernel.cardColumns) {
182-
app.value.kernel.cardColumns = DefaultCardColumns
183-
}
184-
// @ts-expect-error(Deprecated)
185-
if (app.value.kernel.running !== undefined) {
186-
// @ts-expect-error(Deprecated)
187-
await WriteFile(CorePidFilePath, String(app.value.kernel.pid))
188-
// @ts-expect-error(Deprecated)
189-
delete app.value.kernel.running
190-
// @ts-expect-error(Deprecated)
191-
delete app.value.kernel.pid
192-
}
193-
if (app.value.kernel.realMemoryUsage === undefined) {
194-
app.value.kernel.realMemoryUsage = false
195-
}
196147
if (!app.value.proxyBypassList) {
197148
app.value.proxyBypassList = await GetSystemProxyBypass()
198149
}
199-
200-
const files = await ReadDir(CoreWorkingDirectory).catch(() => [])
201-
const stable = getKernelFileName()
202-
const alpha = getKernelFileName(true)
203-
for (const file of files) {
204-
if (
205-
file.name.startsWith('mihomo') &&
206-
![stable, `${stable}.bak`, alpha, `${alpha}.bak`].includes(file.name)
207-
) {
208-
const isAlpha = file.name.includes('-alpha')
209-
const isBak = file.name.endsWith('.bak')
210-
await MoveFile(
211-
`${CoreWorkingDirectory}/${file.name}`,
212-
`${CoreWorkingDirectory}/${getKernelFileName(isAlpha)}${isBak ? '.bak' : ''}`,
213-
)
214-
}
215-
}
216150
}
217151

218152
const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')

frontend/src/stores/kernelApi.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -470,19 +470,5 @@ export const useKernelApiStore = defineStore('kernelApi', () => {
470470
onMemory: createCoreWSHandlerRegister(websocketHandlers.memory),
471471
onTraffic: createCoreWSHandlerRegister(websocketHandlers.traffic),
472472
onConnections: createCoreWSHandlerRegister(websocketHandlers.connections),
473-
474-
// Deprecated
475-
startKernel: () => {
476-
console.warn('[Deprecated] "startKernel" is deprecated. Please use "startCore" instead.')
477-
startCore()
478-
},
479-
stopKernel: () => {
480-
console.warn('[Deprecated] "stopKernel" is deprecated. Please use "stopCore" instead.')
481-
stopCore()
482-
},
483-
restartKernel: (...args: any[]) => {
484-
console.warn('[Deprecated] "restartKernel" is deprecated. Please use "restartCore" instead.')
485-
restartCore(...args)
486-
},
487473
}
488474
})

frontend/src/stores/plugins.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,39 +87,15 @@ export const usePluginsStore = defineStore('plugins', () => {
8787
list && (pluginHub.value = JSON.parse(list))
8888

8989
for (const plugin of plugins.value) {
90-
const { id, triggers, path, context, hasUI, tags } = plugin
90+
const { id, triggers, path } = plugin
9191
const code = await ignoredError(ReadFile, path)
9292
if (code) {
9393
PluginsCache[id] = { plugin, code }
9494
triggers.forEach((trigger) => {
9595
PluginsTriggerMap[trigger].observers.push(id)
9696
})
9797
}
98-
99-
if (!context) {
100-
plugin.context = {
101-
profiles: {},
102-
subscriptions: {},
103-
rulesets: {},
104-
plugins: {},
105-
scheduledtasks: {},
106-
}
107-
}
108-
109-
if (hasUI === undefined) {
110-
plugin.hasUI = false
111-
}
112-
113-
if (tags === undefined) {
114-
plugin.tags = []
115-
}
11698
}
117-
118-
pluginHub.value.forEach((plugin) => {
119-
if (plugin.tags === undefined) {
120-
plugin.tags = []
121-
}
122-
})
12399
}
124100

125101
const getPluginMetadata = (plugin: Plugin) => {

frontend/src/stores/profiles.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,6 @@ export const useProfilesStore = defineStore('profiles', () => {
150150
const setupProfiles = async () => {
151151
const data = await ignoredError(ReadFile, ProfilesFilePath)
152152
data && (profiles.value = parse(data))
153-
// compatibility code
154-
profiles.value.forEach((profile) => {
155-
if (!profile.mixinConfig.format) {
156-
profile.mixinConfig.format = 'json'
157-
}
158-
if (profile.tunConfig['route-exclude-address'] === undefined) {
159-
profile.tunConfig['route-exclude-address'] = []
160-
}
161-
profile.rulesConfig.forEach((rule) => {
162-
if (typeof rule.enable === 'undefined') {
163-
rule.enable = true
164-
}
165-
if (!rule['ruleset-type']) {
166-
rule['ruleset-type'] = 'file'
167-
rule['ruleset-name'] = ''
168-
rule['ruleset-behavior'] = RulesetBehavior.Domain
169-
rule['ruleset-format'] = RulesetFormat.Yaml
170-
rule['ruleset-proxy'] = ''
171-
}
172-
})
173-
})
174153
}
175154

176155
const saveProfiles = () => {

frontend/src/stores/subscribes.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,6 @@ export const useSubscribesStore = defineStore('subscribes', () => {
2626
const setupSubscribes = async () => {
2727
const data = await ignoredError(ReadFile, SubscribesFilePath)
2828
data && (subscribes.value = parse(data))
29-
30-
let needSync = false
31-
subscribes.value.forEach((sub) => {
32-
if (!sub.script) {
33-
sub.script = DefaultSubscribeScript
34-
needSync = true
35-
}
36-
// @ts-expect-error(Deprecated `healthCheck`)
37-
if (sub.healthCheck) {
38-
// @ts-expect-error(Deprecated `healthCheck`)
39-
delete sub.healthCheck
40-
needSync = true
41-
}
42-
if (!sub.requestMethod) {
43-
sub.requestMethod = RequestMethod.Get
44-
needSync = true
45-
}
46-
if (!sub.requestTimeout) {
47-
sub.requestTimeout = 15
48-
needSync = true
49-
}
50-
if (!sub.header) {
51-
sub.header = {
52-
request: {},
53-
response: {},
54-
}
55-
// @ts-expect-error(Deprecated `userAgent`)
56-
if (sub.userAgent) {
57-
// @ts-expect-error(Deprecated `userAgent`)
58-
sub.header.request['User-Agent'] = sub.userAgent
59-
// @ts-expect-error(Deprecated `userAgent`)
60-
delete sub.userAgent
61-
}
62-
needSync = true
63-
}
64-
})
65-
66-
if (needSync) {
67-
await saveSubscribes()
68-
}
6929
}
7030

7131
const saveSubscribes = () => {

0 commit comments

Comments
 (0)