mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
fix websicket
This commit is contained in:
parent
4f335bddd5
commit
536ae67e29
@ -5,7 +5,7 @@ import {
|
||||
mihomoRules,
|
||||
mihomoVersion,
|
||||
patchMihomoConfig
|
||||
} from './mihomo-api'
|
||||
} from './mihomoApi'
|
||||
import { checkAutoRun, disableAutoRun, enableAutoRun } from './autoRun'
|
||||
import {
|
||||
getAppConfig,
|
||||
|
||||
@ -6,7 +6,7 @@ import { registerIpcMainHandlers } from './cmds'
|
||||
import { initConfig, appConfig } from './config'
|
||||
import { stopCore, startCore } from './manager'
|
||||
import { initDirs } from './dirs'
|
||||
import { mihomoTraffic } from './mihomo-api'
|
||||
import { mihomoTraffic } from './mihomoApi'
|
||||
import { createTray } from './tray'
|
||||
|
||||
export let window: BrowserWindow | null = null
|
||||
|
||||
@ -55,12 +55,17 @@ export const mihomoTraffic = (): void => {
|
||||
|
||||
mihomoTrafficWs = new WebSocket(`ws://${server}/traffic?secret=${secret}`)
|
||||
|
||||
mihomoTrafficWs.onmessage = (e: { data: string }): void => {
|
||||
window?.webContents.send('mihomoTraffic', JSON.parse(e.data) as IMihomoTrafficInfo)
|
||||
mihomoTrafficWs.onmessage = (e): void => {
|
||||
const data = e.data as string
|
||||
window?.webContents.send('mihomoTraffic', JSON.parse(data) as IMihomoTrafficInfo)
|
||||
}
|
||||
mihomoTrafficWs.onclose = (): void => {
|
||||
mihomoTraffic()
|
||||
}
|
||||
|
||||
mihomoTrafficWs.onerror = (): void => {
|
||||
console.error('Traffic ws error')
|
||||
mihomoConfig()
|
||||
if (mihomoTrafficWs) {
|
||||
mihomoTrafficWs.close()
|
||||
mihomoTrafficWs = null!
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
import { controledMihomoConfig, setControledMihomoConfig } from './config'
|
||||
import icoIcon from '../../resources/icon.ico?asset'
|
||||
import pngIcon from '../../resources/icon.png?asset'
|
||||
import { patchMihomoConfig } from './mihomo-api'
|
||||
import { patchMihomoConfig } from './mihomoApi'
|
||||
import { window } from '.'
|
||||
import { app, ipcMain, Menu, Tray } from 'electron'
|
||||
|
||||
|
||||
@ -26,7 +26,9 @@ const SysproxySwitcher: React.FC = () => {
|
||||
<AiOutlineGlobal color="default" className="text-[24px]" />
|
||||
</Button>
|
||||
<Switch
|
||||
classNames={{ wrapper: `${match && enable ? 'border-2' : ''}` }}
|
||||
classNames={{
|
||||
wrapper: `${match && enable ? 'border-2' : ''}`
|
||||
}}
|
||||
size="sm"
|
||||
isSelected={enable}
|
||||
onValueChange={setEnable}
|
||||
|
||||
@ -26,7 +26,9 @@ const TunSwitcher: React.FC = () => {
|
||||
<TbDeviceIpadHorizontalBolt color="default" className="text-[24px] font-bold" />
|
||||
</Button>
|
||||
<Switch
|
||||
classNames={{ wrapper: `${match && enable ? 'border-2' : ''}` }}
|
||||
classNames={{
|
||||
wrapper: `${match && enable ? 'border-2' : ''}`
|
||||
}}
|
||||
size="sm"
|
||||
isSelected={enable}
|
||||
onValueChange={setEnable}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user