mirror of
https://github.com/CrazyJasonwell/clash-verge-rev.git
synced 2026-10-21 19:18:42 +08:00
feat: log info
This commit is contained in:
1 parent
000d6ebcd0
commit
5f3a71ed5f
6 files changed
+110
-34
No files matched your search
@@ -1,6 +1,29 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import Notice from "@/components/base/base-notice";
|
||||
|
||||
export async function getClashLogs() {
|
||||
const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/;
|
||||
const newRegex = /(.+?)\s+(.+?)\s+(.+)/;
|
||||
const logs = await invoke<string[]>("get_clash_logs");
|
||||
|
||||
return logs
|
||||
.map((log) => {
|
||||
const result = log.match(regex);
|
||||
if (result) {
|
||||
const [_, time, type, payload] = result;
|
||||
return { time, type, payload };
|
||||
}
|
||||
|
||||
const result2 = log.match(newRegex);
|
||||
if (result2) {
|
||||
const [_, time, type, payload] = result2;
|
||||
return { time, type, payload };
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean) as ApiType.LogItem[];
|
||||
}
|
||||
|
||||
export async function getProfiles() {
|
||||
return invoke<CmdType.ProfilesConfig>("get_profiles");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user