refactor: invock mihomo api by use tauri-plugin-mihomo (#4926)

* feat: add tauri-plugin-mihomo

* refactor: invock mihomo api by use tauri-plugin-mihomo

* chore: todo

* chore: update

* chore: update

* chore: update

* chore: update

* fix: incorrect delay status and update pretty config

* chore: update

* chore: remove cache

* chore: update

* chore: update

* fix: app freezed when change group proxy

* chore: update

* chore: update

* chore: add rustfmt.toml to tauri-plugin-mihomo

* chore: happy clippy

* refactor: connect mihomo websocket

* chore: update

* chore: update

* fix: parse bigint to number

* chore: update

* Revert "fix: parse bigint to number"

This reverts commit 74c006522e23aa52cf8979a8fb47d2b1ae0bb043.

* chore: use number instead of bigint

* chore: cleanup

* fix: rule data not refresh when switch profile

* chore: update

* chore: cleanup

* chore: update

* fix: traffic graph data display

* feat: add ipc connection pool

* chore: update

* chore: clippy

* fix: incorrect delay status

* fix: typo

* fix: empty proxies tray menu

* chore: clippy

* chore: import tauri-plugin-mihomo by using git repo

* chore: cleanup

* fix: mihomo api

* fix: incorrect delay status

* chore: update tauri-plugin-mihomo dep

chore: update
This commit is contained in:
oomeow
2025-10-08 12:32:40 +08:00
committed by GitHub
parent 72aa56007c
commit 7fc238c27b
85 changed files with 1780 additions and 3344 deletions

View File

@@ -1,12 +1,6 @@
// IPC-based log service using Tauri commands with streaming support
import dayjs from "dayjs";
import {
getClashLogs,
startLogsMonitoring,
stopLogsMonitoring,
clearLogs as clearLogsCmd,
} from "@/services/cmds";
import { clearLogs as clearLogsCmd } from "@/services/cmds";
type LogLevel = "debug" | "info" | "warning" | "error" | "all";
@@ -21,7 +15,7 @@ interface ILogItem {
export const startLogsStreaming = async (logLevel: LogLevel = "info") => {
try {
const level = logLevel === "all" ? undefined : logLevel;
await startLogsMonitoring(level);
// await startLogsMonitoring(level);
console.log(
`[IPC-LogService] Started logs monitoring with level: ${logLevel}`,
);
@@ -33,7 +27,7 @@ export const startLogsStreaming = async (logLevel: LogLevel = "info") => {
// Stop logs monitoring
export const stopLogsStreaming = async () => {
try {
await stopLogsMonitoring();
// await stopLogsMonitoring();
console.log("[IPC-LogService] Stopped logs monitoring");
} catch (error) {
console.error("[IPC-LogService] Failed to stop logs monitoring:", error);
@@ -45,16 +39,16 @@ export const fetchLogsViaIPC = async (): Promise<ILogItem[]> => {
try {
// Server-side filtering handles the level via /logs?level={level}
// We just fetch all cached logs regardless of the logLevel parameter
const response = await getClashLogs();
// const response = await getClashLogs();
// The response should be in the format expected by the frontend
// Transform the logs to match the expected format
if (Array.isArray(response)) {
return response.map((log: any) => ({
...log,
time: log.time || dayjs().format("HH:mm:ss"),
}));
}
// // The response should be in the format expected by the frontend
// // Transform the logs to match the expected format
// if (Array.isArray(response)) {
// return response.map((log: any) => ({
// ...log,
// time: log.time || dayjs().format("HH:mm:ss"),
// }));
// }
return [];
} catch (error) {