mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-14 14:00:30 +08:00
* 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
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { createContextState } from "foxact/create-context-state";
|
|
import { useLocalStorage } from "foxact/use-local-storage";
|
|
import { LogLevel } from "tauri-plugin-mihomo-api";
|
|
|
|
const [ThemeModeProvider, useThemeMode, useSetThemeMode] = createContextState<
|
|
"light" | "dark"
|
|
>("light");
|
|
|
|
export type LogFilter = "all" | "debug" | "info" | "warn" | "err";
|
|
|
|
interface IClashLog {
|
|
enable: boolean;
|
|
logLevel: LogLevel;
|
|
logFilter: LogFilter;
|
|
}
|
|
const defaultClashLog: IClashLog = {
|
|
enable: true,
|
|
logLevel: "info",
|
|
logFilter: "all",
|
|
};
|
|
export const useClashLog = () =>
|
|
useLocalStorage<IClashLog>("clash-log", defaultClashLog, {
|
|
serializer: JSON.stringify,
|
|
deserializer: JSON.parse,
|
|
});
|
|
|
|
// export const useEnableLog = () => useLocalStorage("enable-log", false);
|
|
|
|
interface IConnectionSetting {
|
|
layout: "table" | "list";
|
|
}
|
|
|
|
const defaultConnectionSetting: IConnectionSetting = { layout: "table" };
|
|
|
|
export const useConnectionSetting = () =>
|
|
useLocalStorage<IConnectionSetting>(
|
|
"connections-setting",
|
|
defaultConnectionSetting,
|
|
{
|
|
serializer: JSON.stringify,
|
|
deserializer: JSON.parse,
|
|
},
|
|
);
|
|
|
|
// save the state of each profile item loading
|
|
const [LoadingCacheProvider, useLoadingCache, useSetLoadingCache] =
|
|
createContextState<Record<string, boolean>>({});
|
|
|
|
// save update state
|
|
const [UpdateStateProvider, useUpdateState, useSetUpdateState] =
|
|
createContextState<boolean>(false);
|
|
|
|
export {
|
|
ThemeModeProvider,
|
|
useThemeMode,
|
|
useSetThemeMode,
|
|
LoadingCacheProvider,
|
|
useLoadingCache,
|
|
useSetLoadingCache,
|
|
UpdateStateProvider,
|
|
useUpdateState,
|
|
useSetUpdateState,
|
|
};
|