mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-13 13:30:31 +08:00
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import { createContext, use } from 'react'
|
|
import {
|
|
BaseConfig,
|
|
ProxyProvider,
|
|
Rule,
|
|
RuleProvider,
|
|
} from 'tauri-plugin-mihomo-api'
|
|
|
|
export interface AppDataContextType {
|
|
proxies: any
|
|
clashConfig: BaseConfig
|
|
rules: Rule[]
|
|
sysproxy: any
|
|
runningMode?: string
|
|
uptime: number
|
|
proxyProviders: Record<string, ProxyProvider>
|
|
ruleProviders: Record<string, RuleProvider>
|
|
systemProxyAddress: string
|
|
|
|
refreshProxy: () => Promise<any>
|
|
refreshClashConfig: () => Promise<any>
|
|
refreshRules: () => Promise<any>
|
|
refreshSysproxy: () => Promise<any>
|
|
refreshProxyProviders: () => Promise<any>
|
|
refreshRuleProviders: () => Promise<any>
|
|
refreshAll: () => Promise<any>
|
|
}
|
|
|
|
export interface ConnectionWithSpeed extends IConnectionsItem {
|
|
curUpload: number
|
|
curDownload: number
|
|
}
|
|
|
|
export interface ConnectionSpeedData {
|
|
id: string
|
|
upload: number
|
|
download: number
|
|
timestamp: number
|
|
}
|
|
|
|
export const AppDataContext = createContext<AppDataContextType | null>(null)
|
|
|
|
export const useAppData = () => {
|
|
const context = use(AppDataContext)
|
|
|
|
if (!context) {
|
|
throw new Error('useAppData must be used within AppDataProvider')
|
|
}
|
|
|
|
return context
|
|
}
|