blob: 1e641abab040ab22f3d00e3f110c324605a78853 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
import type { ClashAPIConfig } from '~/types';
export type ClashAPIConfigWithAddedAt = ClashAPIConfig & { addedAt?: number };
export type StateApp = {
selectedClashAPIConfigIndex: number;
clashAPIConfigs: ClashAPIConfigWithAddedAt[];
latencyTestUrl: string;
selectedChartStyleIndex: number;
theme: string;
useEmojiFont: boolean;
collapsibleIsOpen: Record<string, boolean>;
proxySortBy: string;
hideUnavailableProxies: boolean;
autoCloseOldConns: boolean;
logStreamingPaused: boolean;
};
export type ClashTunConfig = {
enable: boolean;
device?: string;
stack: string;
'dns-hijack': string[];
'auto-route': boolean;
};
export type ClashGeneralConfig = {
port: number;
'socks-port': number;
'mixed-port': number;
'redir-port': number;
'tproxy-port': number;
'mitm-port'?: number;
'allow-lan': boolean;
'interface-name'?: string;
mode: string;
'mode-list'?: string[];
'log-level': string;
sniffing?: boolean;
tun?: ClashTunConfig;
};
export type TunPartial<T> = {
[P in keyof T]?: T[P] extends ClashTunConfig ? TunPartial<T[P]> : T[P];
};
///// store.proxies
type LatencyHistory = Array<{ time: string; delay: number }>;
type PrimitiveProxyType = 'Shadowsocks' | 'Snell' | 'Socks5' | 'Http' | 'Vmess';
export type SubscriptionInfo = {
Download?: number;
Upload?: number;
Total?: number;
Expire?: number;
};
export type ProxyItem = {
name: string;
type: PrimitiveProxyType;
udp: boolean;
xudp?: boolean;
tfo: boolean;
history: LatencyHistory;
all?: string[];
now?: string;
};
export type ProxiesMapping = Record<string, ProxyItem>;
export type DelayMapping = Record<string, { number?: number }>;
export type ProxyProvider = {
name: string;
type: 'Proxy';
updatedAt: string;
vehicleType: 'HTTP' | 'File' | 'Compatible';
proxies: Array<ProxyItem>;
subscriptionInfo?: SubscriptionInfo;
};
export type FormattedProxyProvider = Omit<ProxyProvider, 'proxies'> & {
proxies: string[];
};
export type SwitchProxyCtxItem = { groupName: string; itemName: string };
type SwitchProxyCtx = {
to: SwitchProxyCtxItem;
};
export type StateProxies = {
proxies: ProxiesMapping;
delay: DelayMapping;
groupNames: string[];
proxyProviders?: FormattedProxyProvider[];
dangleProxyNames?: string[];
showModalClosePrevConns: boolean;
switchProxyCtx?: SwitchProxyCtx;
};
///// store.logs
export type Log = {
time: string;
even: boolean;
payload: string;
type: string;
id: string;
};
export type StateLogs = {
searchText: string;
logs: Log[];
tail: number;
};
///// store.configs
export type StateConfigs = {
configs: ClashGeneralConfig;
haveFetchedConfig: boolean;
};
///// store.modals
export type StateModals = {
apiConfig: boolean;
};
//////
export type State = {
app: StateApp;
configs: StateConfigs;
proxies: StateProxies;
logs: StateLogs;
modals: StateModals;
};
export type GetStateFn = () => State;
export interface DispatchFn {
(msg: string, change: (s: State) => void): void;
(action: (dispatch: DispatchFn, getState: GetStateFn) => Promise<void>): ReturnType<
typeof action
>;
(action: (dispatch: DispatchFn, getState: GetStateFn) => void): ReturnType<typeof action>;
}
|