mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-26 14:12:10 +08:00
refactor: connect mihomo websocket
This commit is contained in:
@@ -15,7 +15,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
futures-util = "0.3"
|
||||
tokio = { version = "1", features = ["net", "sync", "macros"] }
|
||||
tokio-tungstenite = { version = "0.27" }
|
||||
tokio-tungstenite = { version = "0.28" }
|
||||
rand = "0.9"
|
||||
http = "1.3"
|
||||
base64 = "0.22"
|
||||
|
||||
@@ -419,6 +419,7 @@ class MihomoWebSocket {
|
||||
id: this.id,
|
||||
forceTimeout: 0,
|
||||
});
|
||||
this.listeners.clear();
|
||||
}
|
||||
catch (ignore) {
|
||||
// ignore
|
||||
|
||||
@@ -417,6 +417,7 @@ class MihomoWebSocket {
|
||||
id: this.id,
|
||||
forceTimeout: 0,
|
||||
});
|
||||
this.listeners.clear();
|
||||
}
|
||||
catch (ignore) {
|
||||
// ignore
|
||||
|
||||
@@ -532,6 +532,7 @@ export class MihomoWebSocket {
|
||||
id: this.id,
|
||||
forceTimeout: 0,
|
||||
});
|
||||
this.listeners.clear();
|
||||
} catch (ignore) {
|
||||
// ignore
|
||||
} finally {
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "12.1.4",
|
||||
"rollup": "4.52.3",
|
||||
"typescript": "5.9.2",
|
||||
"rollup": "4.52.4",
|
||||
"typescript": "5.9.3",
|
||||
"tslib": "2.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
+105
-105
@@ -14,16 +14,16 @@ importers:
|
||||
devDependencies:
|
||||
'@rollup/plugin-typescript':
|
||||
specifier: 12.1.4
|
||||
version: 12.1.4(rollup@4.52.3)(tslib@2.8.1)(typescript@5.9.2)
|
||||
version: 12.1.4(rollup@4.52.4)(tslib@2.8.1)(typescript@5.9.3)
|
||||
rollup:
|
||||
specifier: 4.52.3
|
||||
version: 4.52.3
|
||||
specifier: 4.52.4
|
||||
version: 4.52.4
|
||||
tslib:
|
||||
specifier: 2.8.1
|
||||
version: 2.8.1
|
||||
typescript:
|
||||
specifier: 5.9.2
|
||||
version: 5.9.2
|
||||
specifier: 5.9.3
|
||||
version: 5.9.3
|
||||
|
||||
packages:
|
||||
|
||||
@@ -49,113 +49,113 @@ packages:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.52.3':
|
||||
resolution: {integrity: sha512-h6cqHGZ6VdnwliFG1NXvMPTy/9PS3h8oLh7ImwR+kl+oYnQizgjxsONmmPSb2C66RksfkfIxEVtDSEcJiO0tqw==}
|
||||
'@rollup/rollup-android-arm-eabi@4.52.4':
|
||||
resolution: {integrity: sha512-BTm2qKNnWIQ5auf4deoetINJm2JzvihvGb9R6K/ETwKLql/Bb3Eg2H1FBp1gUb4YGbydMA3jcmQTR73q7J+GAA==}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-android-arm64@4.52.3':
|
||||
resolution: {integrity: sha512-wd+u7SLT/u6knklV/ifG7gr5Qy4GUbH2hMWcDauPFJzmCZUAJ8L2bTkVXC2niOIxp8lk3iH/QX8kSrUxVZrOVw==}
|
||||
'@rollup/rollup-android-arm64@4.52.4':
|
||||
resolution: {integrity: sha512-P9LDQiC5vpgGFgz7GSM6dKPCiqR3XYN1WwJKA4/BUVDjHpYsf3iBEmVz62uyq20NGYbiGPR5cNHI7T1HqxNs2w==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.52.3':
|
||||
resolution: {integrity: sha512-lj9ViATR1SsqycwFkJCtYfQTheBdvlWJqzqxwc9f2qrcVrQaF/gCuBRTiTolkRWS6KvNxSk4KHZWG7tDktLgjg==}
|
||||
'@rollup/rollup-darwin-arm64@4.52.4':
|
||||
resolution: {integrity: sha512-QRWSW+bVccAvZF6cbNZBJwAehmvG9NwfWHwMy4GbWi/BQIA/laTIktebT2ipVjNncqE6GLPxOok5hsECgAxGZg==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.52.3':
|
||||
resolution: {integrity: sha512-+Dyo7O1KUmIsbzx1l+4V4tvEVnVQqMOIYtrxK7ncLSknl1xnMHLgn7gddJVrYPNZfEB8CIi3hK8gq8bDhb3h5A==}
|
||||
'@rollup/rollup-darwin-x64@4.52.4':
|
||||
resolution: {integrity: sha512-hZgP05pResAkRJxL1b+7yxCnXPGsXU0fG9Yfd6dUaoGk+FhdPKCJ5L1Sumyxn8kvw8Qi5PvQ8ulenUbRjzeCTw==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.52.3':
|
||||
resolution: {integrity: sha512-u9Xg2FavYbD30g3DSfNhxgNrxhi6xVG4Y6i9Ur1C7xUuGDW3banRbXj+qgnIrwRN4KeJ396jchwy9bCIzbyBEQ==}
|
||||
'@rollup/rollup-freebsd-arm64@4.52.4':
|
||||
resolution: {integrity: sha512-xmc30VshuBNUd58Xk4TKAEcRZHaXlV+tCxIXELiE9sQuK3kG8ZFgSPi57UBJt8/ogfhAF5Oz4ZSUBN77weM+mQ==}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.52.3':
|
||||
resolution: {integrity: sha512-5M8kyi/OX96wtD5qJR89a/3x5x8x5inXBZO04JWhkQb2JWavOWfjgkdvUqibGJeNNaz1/Z1PPza5/tAPXICI6A==}
|
||||
'@rollup/rollup-freebsd-x64@4.52.4':
|
||||
resolution: {integrity: sha512-WdSLpZFjOEqNZGmHflxyifolwAiZmDQzuOzIq9L27ButpCVpD7KzTRtEG1I0wMPFyiyUdOO+4t8GvrnBLQSwpw==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.52.3':
|
||||
resolution: {integrity: sha512-IoerZJ4l1wRMopEHRKOO16e04iXRDyZFZnNZKrWeNquh5d6bucjezgd+OxG03mOMTnS1x7hilzb3uURPkJ0OfA==}
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.52.4':
|
||||
resolution: {integrity: sha512-xRiOu9Of1FZ4SxVbB0iEDXc4ddIcjCv2aj03dmW8UrZIW7aIQ9jVJdLBIhxBI+MaTnGAKyvMwPwQnoOEvP7FgQ==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.52.3':
|
||||
resolution: {integrity: sha512-ZYdtqgHTDfvrJHSh3W22TvjWxwOgc3ThK/XjgcNGP2DIwFIPeAPNsQxrJO5XqleSlgDux2VAoWQ5iJrtaC1TbA==}
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.52.4':
|
||||
resolution: {integrity: sha512-FbhM2p9TJAmEIEhIgzR4soUcsW49e9veAQCziwbR+XWB2zqJ12b4i/+hel9yLiD8pLncDH4fKIPIbt5238341Q==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-NcViG7A0YtuFDA6xWSgmFb6iPFzHlf5vcqb2p0lGEbT+gjrEEz8nC/EeDHvx6mnGXnGCC1SeVV+8u+smj0CeGQ==}
|
||||
'@rollup/rollup-linux-arm64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-4n4gVwhPHR9q/g8lKCyz0yuaD0MvDf7dV4f9tHt0C73Mp8h38UCtSCSE6R9iBlTbXlmA8CjpsZoujhszefqueg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.52.3':
|
||||
resolution: {integrity: sha512-d3pY7LWno6SYNXRm6Ebsq0DJGoiLXTb83AIPCXl9fmtIQs/rXoS8SJxxUNtFbJ5MiOvs+7y34np77+9l4nfFMw==}
|
||||
'@rollup/rollup-linux-arm64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-u0n17nGA0nvi/11gcZKsjkLj1QIpAuPFQbR48Subo7SmZJnGxDpspyw2kbpuoQnyK+9pwf3pAoEXerJs/8Mi9g==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-3y5GA0JkBuirLqmjwAKwB0keDlI6JfGYduMlJD/Rl7fvb4Ni8iKdQs1eiunMZJhwDWdCvrcqXRY++VEBbvk6Eg==}
|
||||
'@rollup/rollup-linux-loong64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-0G2c2lpYtbTuXo8KEJkDkClE/+/2AFPdPAbmaHoE870foRFs4pBrDehilMcrSScrN/fB/1HTaWO4bqw+ewBzMQ==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-AUUH65a0p3Q0Yfm5oD2KVgzTKgwPyp9DSXc3UA7DtxhEb/WSPfbG4wqXeSN62OG5gSo18em4xv6dbfcUGXcagw==}
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-teSACug1GyZHmPDv14VNbvZFX779UqWTsd7KtTM9JIZRDI5NUwYSIS30kzI8m06gOPB//jtpqlhmraQ68b5X2g==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-1makPhFFVBqZE+XFg3Dkq+IkQ7JvmUrwwqaYBL2CE+ZpxPaqkGaiWFEWVGyvTwZace6WLJHwjVh/+CXbKDGPmg==}
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-/MOEW3aHjjs1p4Pw1Xk4+3egRevx8Ji9N6HUIA1Ifh8Q+cg9dremvFCUbOX2Zebz80BwJIgCBUemjqhU5XI5Eg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.52.3':
|
||||
resolution: {integrity: sha512-OOFJa28dxfl8kLOPMUOQBCO6z3X2SAfzIE276fwT52uXDWUS178KWq0pL7d6p1kz7pkzA0yQwtqL0dEPoVcRWg==}
|
||||
'@rollup/rollup-linux-riscv64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-1HHmsRyh845QDpEWzOFtMCph5Ts+9+yllCrREuBR/vg2RogAQGGBRC8lDPrPOMnrdOJ+mt1WLMOC2Kao/UwcvA==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-jMdsML2VI5l+V7cKfZx3ak+SLlJ8fKvLJ0Eoa4b9/vCUrzXKgoKxvHqvJ/mkWhFiyp88nCkM5S2v6nIwRtPcgg==}
|
||||
'@rollup/rollup-linux-s390x-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-seoeZp4L/6D1MUyjWkOMRU6/iLmCU2EjbMTyAG4oIOs1/I82Y5lTeaxW0KBfkUdHAWN7j25bpkt0rjnOgAcQcA==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-tPgGd6bY2M2LJTA1uGq8fkSPK8ZLYjDjY+ZLK9WHncCnfIz29LIXIqUgzCR0hIefzy6Hpbe8Th5WOSwTM8E7LA==}
|
||||
'@rollup/rollup-linux-x64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-Wi6AXf0k0L7E2gteNsNHUs7UMwCIhsCTs6+tqQ5GPwVRWMaflqGec4Sd8n6+FNFDw9vGcReqk2KzBDhCa1DLYg==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.52.3':
|
||||
resolution: {integrity: sha512-BCFkJjgk+WFzP+tcSMXq77ymAPIxsX9lFJWs+2JzuZTLtksJ2o5hvgTdIcZ5+oKzUDMwI0PfWzRBYAydAHF2Mw==}
|
||||
'@rollup/rollup-linux-x64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-dtBZYjDmCQ9hW+WgEkaffvRRCKm767wWhxsFW3Lw86VXz/uJRuD438/XvbZT//B96Vs8oTA8Q4A0AfHbrxP9zw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-openharmony-arm64@4.52.3':
|
||||
resolution: {integrity: sha512-KTD/EqjZF3yvRaWUJdD1cW+IQBk4fbQaHYJUmP8N4XoKFZilVL8cobFSTDnjTtxWJQ3JYaMgF4nObY/+nYkumA==}
|
||||
'@rollup/rollup-openharmony-arm64@4.52.4':
|
||||
resolution: {integrity: sha512-1ox+GqgRWqaB1RnyZXL8PD6E5f7YyRUJYnCqKpNzxzP0TkaUh112NDrR9Tt+C8rJ4x5G9Mk8PQR3o7Ku2RKqKA==}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.52.3':
|
||||
resolution: {integrity: sha512-+zteHZdoUYLkyYKObGHieibUFLbttX2r+58l27XZauq0tcWYYuKUwY2wjeCN9oK1Um2YgH2ibd6cnX/wFD7DuA==}
|
||||
'@rollup/rollup-win32-arm64-msvc@4.52.4':
|
||||
resolution: {integrity: sha512-8GKr640PdFNXwzIE0IrkMWUNUomILLkfeHjXBi/nUvFlpZP+FA8BKGKpacjW6OUUHaNI6sUURxR2U2g78FOHWQ==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.52.3':
|
||||
resolution: {integrity: sha512-of1iHkTQSo3kr6dTIRX6t81uj/c/b15HXVsPcEElN5sS859qHrOepM5p9G41Hah+CTqSh2r8Bm56dL2z9UQQ7g==}
|
||||
'@rollup/rollup-win32-ia32-msvc@4.52.4':
|
||||
resolution: {integrity: sha512-AIy/jdJ7WtJ/F6EcfOb2GjR9UweO0n43jNObQMb6oGxkYTfLcnN7vYYpG+CN3lLxrQkzWnMOoNSHTW54pgbVxw==}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-x64-gnu@4.52.3':
|
||||
resolution: {integrity: sha512-s0hybmlHb56mWVZQj8ra9048/WZTPLILKxcvcq+8awSZmyiSUZjjem1AhU3Tf4ZKpYhK4mg36HtHDOe8QJS5PQ==}
|
||||
'@rollup/rollup-win32-x64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-UF9KfsH9yEam0UjTwAgdK0anlQ7c8/pWPU2yVjyWcF1I1thABt6WXE47cI71pGiZ8wGvxohBoLnxM04L/wj8mQ==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.52.3':
|
||||
resolution: {integrity: sha512-zGIbEVVXVtauFgl3MRwGWEN36P5ZGenHRMgNw88X5wEhEBpq0XrMEZwOn07+ICrwM17XO5xfMZqh0OldCH5VTA==}
|
||||
'@rollup/rollup-win32-x64-msvc@4.52.4':
|
||||
resolution: {integrity: sha512-bf9PtUa0u8IXDVxzRToFQKsNCRz9qLYfR/MpECxl4mRoWYjAeFjgxj1XdZr2M/GNVpT05p+LgQOHopYDlUu6/w==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
@@ -196,8 +196,8 @@ packages:
|
||||
engines: {node: '>= 0.4'}
|
||||
hasBin: true
|
||||
|
||||
rollup@4.52.3:
|
||||
resolution: {integrity: sha512-RIDh866U8agLgiIcdpB+COKnlCreHJLfIhWC3LVflku5YHfpnsIKigRZeFfMfCc4dVcqNVfQQ5gO/afOck064A==}
|
||||
rollup@4.52.4:
|
||||
resolution: {integrity: sha512-CLEVl+MnPAiKh5pl4dEWSyMTpuflgNQiLGhMv8ezD5W/qP8AKvmYpCOKRRNOh7oRKnauBZ4SyeYkMS+1VSyKwQ==}
|
||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||
hasBin: true
|
||||
|
||||
@@ -208,94 +208,94 @@ packages:
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
typescript@5.9.2:
|
||||
resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==}
|
||||
typescript@5.9.3:
|
||||
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@rollup/plugin-typescript@12.1.4(rollup@4.52.3)(tslib@2.8.1)(typescript@5.9.2)':
|
||||
'@rollup/plugin-typescript@12.1.4(rollup@4.52.4)(tslib@2.8.1)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.1.4(rollup@4.52.3)
|
||||
'@rollup/pluginutils': 5.1.4(rollup@4.52.4)
|
||||
resolve: 1.22.10
|
||||
typescript: 5.9.2
|
||||
typescript: 5.9.3
|
||||
optionalDependencies:
|
||||
rollup: 4.52.3
|
||||
rollup: 4.52.4
|
||||
tslib: 2.8.1
|
||||
|
||||
'@rollup/pluginutils@5.1.4(rollup@4.52.3)':
|
||||
'@rollup/pluginutils@5.1.4(rollup@4.52.4)':
|
||||
dependencies:
|
||||
'@types/estree': 1.0.8
|
||||
estree-walker: 2.0.2
|
||||
picomatch: 4.0.2
|
||||
optionalDependencies:
|
||||
rollup: 4.52.3
|
||||
rollup: 4.52.4
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.52.3':
|
||||
'@rollup/rollup-android-arm-eabi@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-android-arm64@4.52.3':
|
||||
'@rollup/rollup-android-arm64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.52.3':
|
||||
'@rollup/rollup-darwin-arm64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.52.3':
|
||||
'@rollup/rollup-darwin-x64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.52.3':
|
||||
'@rollup/rollup-freebsd-arm64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.52.3':
|
||||
'@rollup/rollup-freebsd-x64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.52.3':
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.52.3':
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-arm64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.52.3':
|
||||
'@rollup/rollup-linux-arm64-musl@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-loong64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.52.3':
|
||||
'@rollup/rollup-linux-riscv64-musl@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-s390x-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.52.3':
|
||||
'@rollup/rollup-linux-x64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.52.3':
|
||||
'@rollup/rollup-linux-x64-musl@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-openharmony-arm64@4.52.3':
|
||||
'@rollup/rollup-openharmony-arm64@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.52.3':
|
||||
'@rollup/rollup-win32-arm64-msvc@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.52.3':
|
||||
'@rollup/rollup-win32-ia32-msvc@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-x64-gnu@4.52.3':
|
||||
'@rollup/rollup-win32-x64-gnu@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.52.3':
|
||||
'@rollup/rollup-win32-x64-msvc@4.52.4':
|
||||
optional: true
|
||||
|
||||
'@tauri-apps/api@2.8.0': {}
|
||||
@@ -327,36 +327,36 @@ snapshots:
|
||||
path-parse: 1.0.7
|
||||
supports-preserve-symlinks-flag: 1.0.0
|
||||
|
||||
rollup@4.52.3:
|
||||
rollup@4.52.4:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.8
|
||||
optionalDependencies:
|
||||
'@rollup/rollup-android-arm-eabi': 4.52.3
|
||||
'@rollup/rollup-android-arm64': 4.52.3
|
||||
'@rollup/rollup-darwin-arm64': 4.52.3
|
||||
'@rollup/rollup-darwin-x64': 4.52.3
|
||||
'@rollup/rollup-freebsd-arm64': 4.52.3
|
||||
'@rollup/rollup-freebsd-x64': 4.52.3
|
||||
'@rollup/rollup-linux-arm-gnueabihf': 4.52.3
|
||||
'@rollup/rollup-linux-arm-musleabihf': 4.52.3
|
||||
'@rollup/rollup-linux-arm64-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-arm64-musl': 4.52.3
|
||||
'@rollup/rollup-linux-loong64-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-ppc64-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-riscv64-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-riscv64-musl': 4.52.3
|
||||
'@rollup/rollup-linux-s390x-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-x64-gnu': 4.52.3
|
||||
'@rollup/rollup-linux-x64-musl': 4.52.3
|
||||
'@rollup/rollup-openharmony-arm64': 4.52.3
|
||||
'@rollup/rollup-win32-arm64-msvc': 4.52.3
|
||||
'@rollup/rollup-win32-ia32-msvc': 4.52.3
|
||||
'@rollup/rollup-win32-x64-gnu': 4.52.3
|
||||
'@rollup/rollup-win32-x64-msvc': 4.52.3
|
||||
'@rollup/rollup-android-arm-eabi': 4.52.4
|
||||
'@rollup/rollup-android-arm64': 4.52.4
|
||||
'@rollup/rollup-darwin-arm64': 4.52.4
|
||||
'@rollup/rollup-darwin-x64': 4.52.4
|
||||
'@rollup/rollup-freebsd-arm64': 4.52.4
|
||||
'@rollup/rollup-freebsd-x64': 4.52.4
|
||||
'@rollup/rollup-linux-arm-gnueabihf': 4.52.4
|
||||
'@rollup/rollup-linux-arm-musleabihf': 4.52.4
|
||||
'@rollup/rollup-linux-arm64-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-arm64-musl': 4.52.4
|
||||
'@rollup/rollup-linux-loong64-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-ppc64-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-riscv64-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-riscv64-musl': 4.52.4
|
||||
'@rollup/rollup-linux-s390x-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-x64-gnu': 4.52.4
|
||||
'@rollup/rollup-linux-x64-musl': 4.52.4
|
||||
'@rollup/rollup-openharmony-arm64': 4.52.4
|
||||
'@rollup/rollup-win32-arm64-msvc': 4.52.4
|
||||
'@rollup/rollup-win32-ia32-msvc': 4.52.4
|
||||
'@rollup/rollup-win32-x64-gnu': 4.52.4
|
||||
'@rollup/rollup-win32-x64-msvc': 4.52.4
|
||||
fsevents: 2.3.3
|
||||
|
||||
supports-preserve-symlinks-flag@1.0.0: {}
|
||||
|
||||
tslib@2.8.1: {}
|
||||
|
||||
typescript@5.9.2: {}
|
||||
typescript@5.9.3: {}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
edition = "2024"
|
||||
style_edition = "2024"
|
||||
max_width = 120
|
||||
hard_tabs = false
|
||||
tab_spaces = 4
|
||||
newline_style = "Auto"
|
||||
use_small_heuristics = "Default"
|
||||
reorder_imports = true
|
||||
reorder_modules = true
|
||||
remove_nested_parens = true
|
||||
merge_derives = true
|
||||
use_try_shorthand = false
|
||||
use_field_init_shorthand = false
|
||||
force_explicit_abi = true
|
||||
|
||||
# -- wait for stable --
|
||||
# imports_granularity = "Crate"
|
||||
# group_imports = "StdExternalCrate"
|
||||
@@ -294,7 +294,8 @@ impl Mihomo {
|
||||
code: 1000.into(),
|
||||
reason: "Disconnected by client".into(),
|
||||
}));
|
||||
writer.send(close_message).await?;
|
||||
// ignore send error
|
||||
let _ = writer.send(close_message).await;
|
||||
if let Some(timeout) = force_timeout {
|
||||
let manager_ = self.connection_manager.clone();
|
||||
tokio::spawn(async move {
|
||||
|
||||
Generated
+4
-4
@@ -7865,9 +7865,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.27.0"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "489a59b6730eda1b0171fcfda8b121f4bee2b35cba8645ca35c5f7ba3eb736c1"
|
||||
checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
@@ -8293,9 +8293,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.27.0"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eadc29d668c91fcc564941132e17b28a7ceb2f3ebf0b9dae3e03fd7a6748eb0d"
|
||||
checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"data-encoding",
|
||||
|
||||
@@ -900,7 +900,6 @@ impl CoreManager {
|
||||
logging_error!(Type::Core, true, self.start_core_by_sidecar().await);
|
||||
}
|
||||
};
|
||||
handle::Handle::refresh_websocket();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -307,14 +307,6 @@ impl Handle {
|
||||
window
|
||||
}
|
||||
|
||||
pub fn refresh_websocket() {
|
||||
if let Some(window) = Self::get_window()
|
||||
&& let Err(e) = window.emit("verge://refresh-websocket", "yes")
|
||||
{
|
||||
log::error!("{e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_clash() {
|
||||
let handle = Self::global();
|
||||
if handle.is_exiting() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { useLocalStorage } from "foxact/use-local-storage";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { mutate } from "swr";
|
||||
@@ -17,28 +16,28 @@ export const useConnectionData = () => {
|
||||
|
||||
const ws = useRef<MihomoWebSocket | null>(null);
|
||||
const wsFirstConnection = useRef<boolean>(true);
|
||||
const listenerRef = useRef<() => void | null>(null);
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
|
||||
|
||||
const response = useSWRSubscription<IConnections, any, string | null>(
|
||||
subscriptKey,
|
||||
(_key, { next }) => {
|
||||
const reconnect = async () => {
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(async () => await connect(), 500);
|
||||
};
|
||||
|
||||
const connect = () =>
|
||||
MihomoWebSocket.connect_connections()
|
||||
.then((ws_) => {
|
||||
ws.current = ws_;
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
|
||||
listenerRef.current = ws_.addListener(async (msg) => {
|
||||
ws_.addListener(async (msg) => {
|
||||
if (msg.type === "Text") {
|
||||
if (msg.data.startsWith("Websocket error")) {
|
||||
next(msg.data);
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(
|
||||
async () => await connect(),
|
||||
500,
|
||||
);
|
||||
await reconnect();
|
||||
} else {
|
||||
const data = JSON.parse(msg.data) as IConnections;
|
||||
next(null, (old = initConnData) => {
|
||||
@@ -89,8 +88,6 @@ export const useConnectionData = () => {
|
||||
|
||||
return () => {
|
||||
ws.current?.close();
|
||||
listenerRef.current?.();
|
||||
listenerRef.current = null;
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -99,20 +96,6 @@ export const useConnectionData = () => {
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenRefreshWebsocket = listen(
|
||||
"verge://refresh-websocket",
|
||||
async () => {
|
||||
await ws.current?.close();
|
||||
setDate(Date.now());
|
||||
},
|
||||
);
|
||||
|
||||
return () => {
|
||||
unlistenRefreshWebsocket.then((fn) => fn());
|
||||
};
|
||||
}, [setDate]);
|
||||
|
||||
useEffect(() => {
|
||||
mutate(`$sub$${subscriptKey}`);
|
||||
}, [date, subscriptKey]);
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
// import { getClashLogs } from "@/services/cmds";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import dayjs from "dayjs";
|
||||
import { useLocalStorage } from "foxact/use-local-storage";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { mutate } from "swr";
|
||||
import useSWRSubscription from "swr/subscription";
|
||||
import { MihomoWebSocket } from "tauri-plugin-mihomo-api";
|
||||
import { useClashLog } from "@/services/states";
|
||||
|
||||
import { getClashLogs } from "@/services/cmds";
|
||||
import { useClashLog } from "@/services/states";
|
||||
|
||||
const MAX_LOG_NUM = 1000;
|
||||
|
||||
export const useLogData = () => {
|
||||
// const [enableLog] = useEnableLog();
|
||||
// const [logLevel] = useLocalStorage<LogLevel>("log:log-level", "info");
|
||||
const [clashLog] = useClashLog();
|
||||
const enableLog = clashLog.enable;
|
||||
const logLevel = clashLog.logLevel;
|
||||
@@ -23,12 +20,17 @@ export const useLogData = () => {
|
||||
|
||||
const ws = useRef<MihomoWebSocket | null>(null);
|
||||
const wsFirstConnection = useRef<boolean>(true);
|
||||
const listenerRef = useRef<() => void | null>(null);
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
|
||||
|
||||
const response = useSWRSubscription<ILogItem[], any, string | null>(
|
||||
subscriptKey,
|
||||
(_key, { next }) => {
|
||||
const reconnect = async () => {
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(async () => await connect(), 500);
|
||||
};
|
||||
|
||||
const connect = () =>
|
||||
MihomoWebSocket.connect_logs(logLevel)
|
||||
.then(async (ws_) => {
|
||||
@@ -81,16 +83,11 @@ export const useLogData = () => {
|
||||
}
|
||||
flushTimer = null;
|
||||
};
|
||||
listenerRef.current = ws_.addListener(async (msg) => {
|
||||
ws_.addListener(async (msg) => {
|
||||
if (msg.type === "Text") {
|
||||
if (msg.data.startsWith("Websocket error")) {
|
||||
next(msg.data);
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(
|
||||
async () => await connect(),
|
||||
500,
|
||||
);
|
||||
await reconnect();
|
||||
} else {
|
||||
const data = JSON.parse(msg.data) as ILogItem;
|
||||
data.time = dayjs().format("MM-DD HH:mm:ss");
|
||||
@@ -124,8 +121,6 @@ export const useLogData = () => {
|
||||
|
||||
return () => {
|
||||
ws.current?.close();
|
||||
listenerRef.current?.();
|
||||
listenerRef.current = null;
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -134,20 +129,6 @@ export const useLogData = () => {
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenRefreshWebsocket = listen(
|
||||
"verge://refresh-websocket",
|
||||
async () => {
|
||||
await ws.current?.close();
|
||||
setDate(Date.now());
|
||||
},
|
||||
);
|
||||
|
||||
return () => {
|
||||
unlistenRefreshWebsocket.then((fn) => fn());
|
||||
};
|
||||
}, [setDate]);
|
||||
|
||||
useEffect(() => {
|
||||
mutate(`$sub$${subscriptKey}`);
|
||||
}, [date, subscriptKey]);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { useLocalStorage } from "foxact/use-local-storage";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { mutate } from "swr";
|
||||
@@ -16,28 +15,28 @@ export const useMemoryData = () => {
|
||||
|
||||
const ws = useRef<MihomoWebSocket | null>(null);
|
||||
const wsFirstConnection = useRef<boolean>(true);
|
||||
const listenerRef = useRef<() => void | null>(null);
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
|
||||
|
||||
const response = useSWRSubscription<IMemoryUsageItem, any, string | null>(
|
||||
subscriptKey,
|
||||
(_key, { next }) => {
|
||||
const reconnect = async () => {
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(async () => await connect(), 500);
|
||||
};
|
||||
|
||||
const connect = () =>
|
||||
MihomoWebSocket.connect_memory()
|
||||
.then((ws_) => {
|
||||
ws.current = ws_;
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
|
||||
listenerRef.current = ws_.addListener(async (msg) => {
|
||||
ws_.addListener(async (msg) => {
|
||||
if (msg.type === "Text") {
|
||||
if (msg.data.startsWith("Websocket error")) {
|
||||
next(msg.data, { inuse: 0 });
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(
|
||||
async () => await connect(),
|
||||
500,
|
||||
);
|
||||
await reconnect();
|
||||
} else {
|
||||
const data = JSON.parse(msg.data) as IMemoryUsageItem;
|
||||
next(null, data);
|
||||
@@ -65,8 +64,6 @@ export const useMemoryData = () => {
|
||||
|
||||
return () => {
|
||||
ws.current?.close();
|
||||
listenerRef.current?.();
|
||||
listenerRef.current = null;
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -75,20 +72,6 @@ export const useMemoryData = () => {
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenRefreshWebsocket = listen(
|
||||
"verge://refresh-websocket",
|
||||
async () => {
|
||||
await ws.current?.close();
|
||||
setDate(Date.now());
|
||||
},
|
||||
);
|
||||
|
||||
return () => {
|
||||
unlistenRefreshWebsocket.then((fn) => fn());
|
||||
};
|
||||
}, [setDate]);
|
||||
|
||||
useEffect(() => {
|
||||
mutate(`$sub$${subscriptKey}`);
|
||||
}, [date, subscriptKey]);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { TrafficRef } from "@/components/layout/traffic-graph";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { useLocalStorage } from "foxact/use-local-storage";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { mutate } from "swr";
|
||||
import useSWRSubscription from "swr/subscription";
|
||||
import { MihomoWebSocket } from "tauri-plugin-mihomo-api";
|
||||
|
||||
import { TrafficRef } from "@/components/layout/traffic-graph";
|
||||
|
||||
export const useTrafficData = () => {
|
||||
const [date, setDate] = useLocalStorage("mihomo_traffic_date", Date.now());
|
||||
const subscriptKey = `getClashTraffic-${date}`;
|
||||
@@ -13,28 +13,28 @@ export const useTrafficData = () => {
|
||||
const trafficRef = useRef<TrafficRef>(null);
|
||||
const ws = useRef<MihomoWebSocket | null>(null);
|
||||
const wsFirstConnection = useRef<boolean>(true);
|
||||
const listenerRef = useRef<() => void | null>(null);
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
|
||||
|
||||
const response = useSWRSubscription<ITrafficItem, any, string | null>(
|
||||
subscriptKey,
|
||||
(_key, { next }) => {
|
||||
const reconnect = async () => {
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(async () => await connect(), 500);
|
||||
};
|
||||
|
||||
const connect = async () => {
|
||||
MihomoWebSocket.connect_traffic()
|
||||
.then(async (ws_) => {
|
||||
ws.current = ws_;
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
|
||||
listenerRef.current = ws_.addListener(async (msg) => {
|
||||
ws_.addListener(async (msg) => {
|
||||
if (msg.type === "Text") {
|
||||
if (msg.data.startsWith("Websocket error")) {
|
||||
next(msg.data, { up: 0, down: 0 });
|
||||
await ws.current?.close();
|
||||
ws.current = null;
|
||||
timeoutRef.current = setTimeout(
|
||||
async () => await connect(),
|
||||
500,
|
||||
);
|
||||
await reconnect();
|
||||
} else {
|
||||
const data = JSON.parse(msg.data) as ITrafficItem;
|
||||
trafficRef.current?.appendData(data);
|
||||
@@ -64,8 +64,6 @@ export const useTrafficData = () => {
|
||||
|
||||
return () => {
|
||||
ws.current?.close();
|
||||
listenerRef.current?.();
|
||||
listenerRef.current = null;
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -74,20 +72,6 @@ export const useTrafficData = () => {
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenRefreshWebsocket = listen(
|
||||
"verge://refresh-websocket",
|
||||
async () => {
|
||||
await ws.current?.close();
|
||||
setDate(Date.now());
|
||||
},
|
||||
);
|
||||
|
||||
return () => {
|
||||
unlistenRefreshWebsocket.then((fn) => fn());
|
||||
};
|
||||
}, [setDate]);
|
||||
|
||||
useEffect(() => {
|
||||
mutate(`$sub$${subscriptKey}`);
|
||||
}, [date, subscriptKey]);
|
||||
|
||||
Reference in New Issue
Block a user