Compare commits
2822 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5dfb34082 | ||
|
|
2ba5c4e706 | ||
|
|
27bcc5f4f8 | ||
|
|
d884bd539b | ||
|
|
580a56727c | ||
|
|
ac3163d061 | ||
|
|
8bc7a6c3e1 | ||
|
|
31d368979e | ||
|
|
5e855e4755 | ||
|
|
a8b75aeabd | ||
|
|
854d42180a | ||
|
|
e94724595c | ||
|
|
6f1d9ba1b4 | ||
|
|
c090ae3b11 | ||
|
|
3303e95713 | ||
|
|
5cdc5075f8 | ||
|
|
eb1e4fe0c3 | ||
|
|
b1e3283a24 | ||
|
|
ce3b0bb479 | ||
|
|
25b295f2a8 | ||
|
|
18b7366258 | ||
|
|
565771a3ea | ||
|
|
f9376f6903 | ||
|
|
8e0f5b6abd | ||
|
|
41f32231f0 | ||
|
|
e1968891ac | ||
|
|
f04e707b10 | ||
|
|
0bb795b0e1 | ||
|
|
1c5e43690e | ||
|
|
f604416532 | ||
|
|
87ee07d481 | ||
|
|
7dec9cbe9b | ||
|
|
1274ba2324 | ||
|
|
d6014865d6 | ||
|
|
48a5ff6948 | ||
|
|
dd3950e46d | ||
|
|
1708246866 | ||
|
|
b0734f5935 | ||
|
|
11768862d3 | ||
|
|
ef409216d8 | ||
|
|
f739afea3d | ||
|
|
d5266fa003 | ||
|
|
149bdd5175 | ||
|
|
ec99e24ca1 | ||
|
|
7cc893383e | ||
|
|
3902480d39 | ||
|
|
686490ded1 | ||
|
|
4435a5aee4 | ||
|
|
d9e3a47894 | ||
|
|
c96be18187 | ||
|
|
47416dd3f8 | ||
|
|
4486f734bb | ||
|
|
bea6a2c8f7 | ||
|
|
82af9ed78e | ||
|
|
2b9e38d259 | ||
|
|
7c4222aed2 | ||
|
|
a574ced428 | ||
|
|
cf437e6d94 | ||
|
|
e1bb8aa125 | ||
|
|
c11bdd81e9 | ||
|
|
f1192c95a8 | ||
|
|
ae187cc21a | ||
|
|
a7875718f7 | ||
|
|
5db1f7cda7 | ||
|
|
cb98b17052 | ||
|
|
7aee1c6d6e | ||
|
|
f22199b7d9 | ||
|
|
0a8d6e5147 | ||
|
|
6d519dac1e | ||
|
|
d5a174c71b | ||
|
|
628de70e89 | ||
|
|
fee08f3826 | ||
|
|
bdfc383a18 | ||
|
|
f6b5524e0e | ||
|
|
e7461fccab | ||
|
|
a92872c831 | ||
|
|
094feb74ec | ||
|
|
9b1c660306 | ||
|
|
4b860ba897 | ||
|
|
3d8b2cf35f | ||
|
|
41fc13cfe2 | ||
|
|
5fde5dcc7c | ||
|
|
034885d810 | ||
|
|
3f7a7b8cd2 | ||
|
|
98dc50a9ed | ||
|
|
5dd820d12e | ||
|
|
bc30db2875 | ||
|
|
abe914d446 | ||
|
|
cc65ce6812 | ||
|
|
1a6454ee79 | ||
|
|
b72f397369 | ||
|
|
e698fe8d18 | ||
|
|
c8cad1c295 | ||
|
|
c423fe90e2 | ||
|
|
623461b649 | ||
|
|
1f9ba4de5c | ||
|
|
10f792b8bc | ||
|
|
357b64e9a0 | ||
|
|
f3ad6cee41 | ||
|
|
972310ea4e | ||
|
|
f5315fd737 | ||
|
|
c40c1960ed | ||
|
|
c8ae37811c | ||
|
|
15f05748a5 | ||
|
|
0a0a25913b | ||
|
|
945999889c | ||
|
|
ce7e1d6456 | ||
|
|
72c4b9de8a | ||
|
|
a8257e8cb2 | ||
|
|
15d3c765ac | ||
|
|
e7d3d7e0ae | ||
|
|
c0f3d35e13 | ||
|
|
fc30fab9cd | ||
|
|
a67e8388a9 | ||
|
|
ac7307b1f7 | ||
|
|
4068e5ec9c | ||
|
|
ea71181692 | ||
|
|
9b46c1a991 | ||
|
|
26acce94a4 | ||
|
|
2a0e1e206e | ||
|
|
f83d1d1582 | ||
|
|
77a090d5eb | ||
|
|
a9561e0ded | ||
|
|
dd505e4d58 | ||
|
|
dd0e9d4e1b | ||
|
|
8bc451ff08 | ||
|
|
032e5bf32e | ||
|
|
41ba8f6c7a | ||
|
|
799783d3ef | ||
|
|
77fb40506f | ||
|
|
5858f05c13 | ||
|
|
0432cad112 | ||
|
|
47ec8a348c | ||
|
|
eef348b8dc | ||
|
|
e78a02d0ba | ||
|
|
4e54b61380 | ||
|
|
cc39b2734e | ||
|
|
16eaccb10e | ||
|
|
dbc6f54a77 | ||
|
|
9bd5950f60 | ||
|
|
2c7c416f60 | ||
|
|
3eb0ab4197 | ||
|
|
b7cb511032 | ||
|
|
18850bb51a | ||
|
|
4d718e0cea | ||
|
|
3a2f567055 | ||
|
|
4f474e1098 | ||
|
|
22eac1a832 | ||
|
|
07738dd82d | ||
|
|
f07d508018 | ||
|
|
b591a90100 | ||
|
|
db3cfdf66f | ||
|
|
5cf3e1a817 | ||
|
|
25cfd162f6 | ||
|
|
7001ef2030 | ||
|
|
cbcab72a7c | ||
|
|
d05b1c3130 | ||
|
|
fbdcda9a7f | ||
|
|
0ebc482698 | ||
|
|
09969d95de | ||
|
|
689042df60 | ||
|
|
564fe15df2 | ||
|
|
30015dfd67 | ||
|
|
698c47da69 | ||
|
|
46b7a520cd | ||
|
|
cadd6c3497 | ||
|
|
c4682ab6e9 | ||
|
|
59594855b8 | ||
|
|
44b7af0c6e | ||
|
|
80f550d67e | ||
|
|
44f085604a | ||
|
|
1144f8017a | ||
|
|
d8fa17a3e7 | ||
|
|
bf868e0ae2 | ||
|
|
e1dac63f69 | ||
|
|
2657234761 | ||
|
|
4a345fdd41 | ||
|
|
fee6a586d7 | ||
|
|
7c738483b7 | ||
|
|
c3d8ed28a2 | ||
|
|
f47b4b961b | ||
|
|
7763abf6c2 | ||
|
|
9d9d078346 | ||
|
|
76cec7aa54 | ||
|
|
2223a99ed1 | ||
|
|
4926d33849 | ||
|
|
9978182cae | ||
|
|
1d77bc57df | ||
|
|
1bcb6646c4 | ||
|
|
06130b95d2 | ||
|
|
0536a45959 | ||
|
|
b150eb7e64 | ||
|
|
d5c0b09a2f | ||
|
|
a36d2633c9 | ||
|
|
72783e3ff5 | ||
|
|
929abb3c04 | ||
|
|
6810b1f221 | ||
|
|
a96678caea | ||
|
|
2d59177256 | ||
|
|
62b743fa20 | ||
|
|
b85aaa816e | ||
|
|
74fc3dea33 | ||
|
|
55167e75af | ||
|
|
63d39c24dc | ||
|
|
1d4d8aeb2b | ||
|
|
c9589fc75d | ||
|
|
d0c3a306bc | ||
|
|
1e3566ed7d | ||
|
|
756d303f6a | ||
|
|
a5b948a41c | ||
|
|
6440f856a2 | ||
|
|
25acb8121f | ||
|
|
c05bd31f6b | ||
|
|
9416de6442 | ||
|
|
c507c483fb | ||
|
|
32ee1b36d2 | ||
|
|
2b89f07fe5 | ||
|
|
0621a17d17 | ||
|
|
4840e07da8 | ||
|
|
af1689ee07 | ||
|
|
d3dbc11b1b | ||
|
|
10479b0936 | ||
|
|
fa1f9875d9 | ||
|
|
7466139320 | ||
|
|
7a5bcf67c5 | ||
|
|
10e3010324 | ||
|
|
464f8095ab | ||
|
|
8b800f679b | ||
|
|
5b2f946828 | ||
|
|
b1c31f7a6f | ||
|
|
d49618786e | ||
|
|
866ec2720d | ||
|
|
b4595d7886 | ||
|
|
9af0803e9b | ||
|
|
ebecabc0cc | ||
|
|
c9a9e934f4 | ||
|
|
544f63a2ff | ||
|
|
1dbfc96ebf | ||
|
|
250dcf569c | ||
|
|
0ef552d384 | ||
|
|
998ded5e0b | ||
|
|
d60c3b4d64 | ||
|
|
b6db209670 | ||
|
|
29fd97e402 | ||
|
|
32ebc8d174 | ||
|
|
420b0a254a | ||
|
|
400efa00ec | ||
|
|
4024b72954 | ||
|
|
7cd1816866 | ||
|
|
5983ac5449 | ||
|
|
b70e202201 | ||
|
|
cc5ebec0cb | ||
|
|
1d2fd06507 | ||
|
|
8d99af4c15 | ||
|
|
861428d3bd | ||
|
|
00e3f13bc9 | ||
|
|
2a897ecf8a | ||
|
|
8448217bd4 | ||
|
|
305a64c3e3 | ||
|
|
e1d6c74e4f | ||
|
|
7556758284 | ||
|
|
3926288b7f | ||
|
|
4d56a5cd8c | ||
|
|
d554679ee2 | ||
|
|
6fe7aabe14 | ||
|
|
f4e57a2831 | ||
|
|
32008b9364 | ||
|
|
9d89eeb974 | ||
|
|
95c23730ef | ||
|
|
7acbb5da4f | ||
|
|
ddd85d4d87 | ||
|
|
53a46d0dc6 | ||
|
|
92ae277e3a | ||
|
|
dd190659ef | ||
|
|
6c5488be70 | ||
|
|
316e1d4268 | ||
|
|
c3c13ba6e6 | ||
|
|
b0a82bc7ad | ||
|
|
7f0ebbd83d | ||
|
|
4f86f3c0ec | ||
|
|
c100b9c54d | ||
|
|
ebc9fc5eba | ||
|
|
29ae70bbf6 | ||
|
|
becc51bcd2 | ||
|
|
1993e5dd51 | ||
|
|
d1a2bd78d7 | ||
|
|
a5521404b6 | ||
|
|
8aa7b34197 | ||
|
|
1ddbe7c2cc | ||
|
|
6578cd8c51 | ||
|
|
c2c46d1cae | ||
|
|
95231e7cd3 | ||
|
|
5b6c9be99f | ||
|
|
d587ed09a5 | ||
|
|
10576780ed | ||
|
|
b37b121afb | ||
|
|
2b69ed4915 | ||
|
|
9a666d807c | ||
|
|
050b363066 | ||
|
|
8cae9d4e0a | ||
|
|
b5b65ac8c5 | ||
|
|
7370f00857 | ||
|
|
dc798fe2dd | ||
|
|
eda8fc125f | ||
|
|
8296675574 | ||
|
|
e2ad2d23f8 | ||
|
|
d8df283e93 | ||
|
|
ce42ca77a9 | ||
|
|
cfe8328f9e | ||
|
|
ff5a2c6ca4 | ||
|
|
23b0493d0b | ||
|
|
779291151e | ||
|
|
ba0f4cdde0 | ||
|
|
3983762202 | ||
|
|
c72413cbe6 | ||
|
|
73b9a71c84 | ||
|
|
e7bf997f8c | ||
|
|
dbfcc80afe | ||
|
|
32b6821b8a | ||
|
|
3ce5d3bf2d | ||
|
|
f6023dc618 | ||
|
|
9d9dd73790 | ||
|
|
7383459b9a | ||
|
|
55cde38562 | ||
|
|
d6a79316a6 | ||
|
|
bd3231bfa8 | ||
|
|
8d62c0d521 | ||
|
|
4d37e6870c | ||
|
|
0bb042e085 | ||
|
|
65ed9cb5b2 | ||
|
|
ffc0693afc | ||
|
|
2622cc06eb | ||
|
|
15b117dc15 | ||
|
|
16846aefd3 | ||
|
|
babc2c8f9b | ||
|
|
a0b70f9c34 | ||
|
|
dc46eb9d21 | ||
|
|
824ad9fa29 | ||
|
|
0646fa96a6 | ||
|
|
d05952e945 | ||
|
|
abe5cf1b84 | ||
|
|
07b424cb09 | ||
|
|
c7494de0a7 | ||
|
|
1a9a2ff9e0 | ||
|
|
4f15bdf74d | ||
|
|
541b78ba6f | ||
|
|
05b910dc17 | ||
|
|
41629df189 | ||
|
|
c718ef3058 | ||
|
|
2b1d02f0cc | ||
|
|
272a0c916d | ||
|
|
16187858a3 | ||
|
|
f6ea01238a | ||
|
|
ae4067aee6 | ||
|
|
d401a83c75 | ||
|
|
41a662f784 | ||
|
|
1df9fff0a7 | ||
|
|
40de99e65d | ||
|
|
76227770a4 | ||
|
|
b70cad537c | ||
|
|
1282cc56bf | ||
|
|
85d08fadd9 | ||
|
|
fad73a281a | ||
|
|
18d24d5952 | ||
|
|
6e6462742c | ||
|
|
16381d1895 | ||
|
|
1970155c51 | ||
|
|
51ef1329be | ||
|
|
b6a6f5f434 | ||
|
|
644fdc071f | ||
|
|
25d66a4eee | ||
|
|
9070ef1dbe | ||
|
|
f700dc124e | ||
|
|
5fcea4c684 | ||
|
|
843f40d7d5 | ||
|
|
84fbccbfd9 | ||
|
|
49c81f6201 | ||
|
|
c894a15d13 | ||
|
|
196b887381 | ||
|
|
2ad20ed239 | ||
|
|
98de91771e | ||
|
|
9dfd9bad20 | ||
|
|
0b8d08d13b | ||
|
|
0de304d4e3 | ||
|
|
55f1766ebc | ||
|
|
6d1a8fb264 | ||
|
|
d3958594d9 | ||
|
|
b5952f320b | ||
|
|
98be9621a6 | ||
|
|
e4eb13ce22 | ||
|
|
ecf2da7c0a | ||
|
|
7d7c8988d7 | ||
|
|
5e11d36972 | ||
|
|
3039f39d40 | ||
|
|
7b5fd104de | ||
|
|
30ea408019 | ||
|
|
3fa130695c | ||
|
|
fece31438a | ||
|
|
ad1f2bea3b | ||
|
|
cd4bfdd743 | ||
|
|
cde8c4004f | ||
|
|
c53514e060 | ||
|
|
8e99672265 | ||
|
|
5b9b5cb6a8 | ||
|
|
62141380d8 | ||
|
|
52a15bb281 | ||
|
|
b092f74c88 | ||
|
|
937f43c270 | ||
|
|
9b02088918 | ||
|
|
1bd503a654 | ||
|
|
c6477dfda4 | ||
|
|
4831d88467 | ||
|
|
9ebde802d4 | ||
|
|
a9cccc7b97 | ||
|
|
d54a765bd6 | ||
|
|
5a2751162f | ||
|
|
492a5a6de7 | ||
|
|
f6c0f144a6 | ||
|
|
1c046f3ca3 | ||
|
|
4a47c5bb6f | ||
|
|
b7e01aefb4 | ||
|
|
e8e16f7d57 | ||
|
|
59caa22431 | ||
|
|
e2046f3e48 | ||
|
|
8fdcffc731 | ||
|
|
3ec77c6256 | ||
|
|
b09313756e | ||
|
|
f800e2e3b6 | ||
|
|
daad623855 | ||
|
|
7716e2bc87 | ||
|
|
70bd5ec03c | ||
|
|
ce5c86c3b0 | ||
|
|
a6a6d9d036 | ||
|
|
971dd6a2cf | ||
|
|
42d0ea7e36 | ||
|
|
006bcffe8c | ||
|
|
ff4101fa47 | ||
|
|
7280635741 | ||
|
|
7ede91599c | ||
|
|
6e40dd9862 | ||
|
|
42db9ea0bb | ||
|
|
ca0cf4552c | ||
|
|
d91653b218 | ||
|
|
1ace560531 | ||
|
|
81968a579d | ||
|
|
5a0eb56f70 | ||
|
|
804fad6083 | ||
|
|
98d3a48710 | ||
|
|
0ec4f46052 | ||
|
|
a891341e35 | ||
|
|
10426af3ad | ||
|
|
5be1d604ee | ||
|
|
1baa840160 | ||
|
|
14347f60d5 | ||
|
|
df5424d55e | ||
|
|
12065330e1 | ||
|
|
e054ac67fb | ||
|
|
31a7750482 | ||
|
|
2e38307f65 | ||
|
|
47accdd2b1 | ||
|
|
cb0146573f | ||
|
|
cf78bb3686 | ||
|
|
b5b5ae4e7b | ||
|
|
b99bc7fcd1 | ||
|
|
f50fe9159d | ||
|
|
09f6917638 | ||
|
|
e330d75a89 | ||
|
|
4f0ce7458e | ||
|
|
a2811c4803 | ||
|
|
1c233783a7 | ||
|
|
3e45cc4650 | ||
|
|
1a7c076e07 | ||
|
|
da4fddf150 | ||
|
|
970eb62aa6 | ||
|
|
d669650758 | ||
|
|
69347160e9 | ||
|
|
a345b54a77 | ||
|
|
8aabcd77a5 | ||
|
|
c30f54609d | ||
|
|
0830236a73 | ||
|
|
44f21444bb | ||
|
|
1d88d98ea1 | ||
|
|
86f69fd574 | ||
|
|
e21846a2ce | ||
|
|
d5981ca94f | ||
|
|
8c5eb3b550 | ||
|
|
55dc416109 | ||
|
|
ec30b888d1 | ||
|
|
2a92755e65 | ||
|
|
6976ea3c09 | ||
|
|
b07ed2dbf5 | ||
|
|
2ab923da87 | ||
|
|
9799d4f747 | ||
|
|
f739836891 | ||
|
|
a28887be8e | ||
|
|
0f13691ae0 | ||
|
|
ae72b83dbe | ||
|
|
2e38404434 | ||
|
|
11b8c8be45 | ||
|
|
a06597a3a6 | ||
|
|
108840c4be | ||
|
|
16c8672aeb | ||
|
|
167edcf8ef | ||
|
|
d6dd89b674 | ||
|
|
fac2ee6374 | ||
|
|
dd7876845a | ||
|
|
56e6139c2b | ||
|
|
04bdd48a2a | ||
|
|
5b47fe5b88 | ||
|
|
84a5cf6b89 | ||
|
|
618ba52bca | ||
|
|
5c0cde517f | ||
|
|
1b249564a3 | ||
|
|
81b5501b0e | ||
|
|
91ccb3045c | ||
|
|
e31f176c25 | ||
|
|
ad45485009 | ||
|
|
25e5cf2ac2 | ||
|
|
bd58d935c6 | ||
|
|
da2705ff7d | ||
|
|
61f019f194 | ||
|
|
74e441df5b | ||
|
|
772ecdd3b0 | ||
|
|
baa535b609 | ||
|
|
a2ff0a7e20 | ||
|
|
84732f9835 | ||
|
|
dd17bcb0d6 | ||
|
|
cab8e613a6 | ||
|
|
fe1227618a | ||
|
|
596c52de87 | ||
|
|
ba5d5e9f86 | ||
|
|
530669d288 | ||
|
|
70b0f9a03a | ||
|
|
105de99d06 | ||
|
|
6239f81f36 | ||
|
|
697d200ffe | ||
|
|
16d5077f55 | ||
|
|
e0e1a05448 | ||
|
|
bcaafa67a3 | ||
|
|
36142656a4 | ||
|
|
d6a48deb5a | ||
|
|
e98ce0c2ae | ||
|
|
8118fc754c | ||
|
|
1ec7a0f23c | ||
|
|
488e8ef1d5 | ||
|
|
1f99cee78b | ||
|
|
c25015ed54 | ||
|
|
aaefc5b479 | ||
|
|
1c58816c73 | ||
|
|
0fd99358aa | ||
|
|
d4012bace9 | ||
|
|
af7660686d | ||
|
|
b57c6e408a | ||
|
|
124934b012 | ||
|
|
1bef6d085d | ||
|
|
c73927c5ba | ||
|
|
692deb6012 | ||
|
|
8ec499f631 | ||
|
|
2bcd653a56 | ||
|
|
0f10952979 | ||
|
|
58fa67100f | ||
|
|
8e294916c4 | ||
|
|
6877e0c95d | ||
|
|
37a333a023 | ||
|
|
48f1da963a | ||
|
|
e1905aced4 | ||
|
|
f18202a3a4 | ||
|
|
c1a9de4d66 | ||
|
|
18f86874ee | ||
|
|
e6686e0b82 | ||
|
|
4bf166986d | ||
|
|
0f60d84f6c | ||
|
|
15e54df67c | ||
|
|
4cb6ad7736 | ||
|
|
e27a32395a | ||
|
|
eddcf209c1 | ||
|
|
10a151d411 | ||
|
|
54d5586a60 | ||
|
|
30ca547e50 | ||
|
|
a1944d1a90 | ||
|
|
c2b35fdaa5 | ||
|
|
805b54d81e | ||
|
|
e3579dac65 | ||
|
|
f80591242e | ||
|
|
69cb9769c1 | ||
|
|
efd42d9da0 | ||
|
|
21a6340095 | ||
|
|
6c96724dce | ||
|
|
ebb194d2a2 | ||
|
|
1a51a92b70 | ||
|
|
5760f16272 | ||
|
|
4ed36f6223 | ||
|
|
7ea7ca1415 | ||
|
|
1ee8786ab7 | ||
|
|
44ca513241 | ||
|
|
73310b466b | ||
|
|
1ba688727e | ||
|
|
3b69465016 | ||
|
|
3e53ea7209 | ||
|
|
07bdc108ed | ||
|
|
a18efb0e71 | ||
|
|
de1c825ad3 | ||
|
|
de2cff824e | ||
|
|
aff504bddc | ||
|
|
277390e597 | ||
|
|
fdcefe458e | ||
|
|
9bb2160abe | ||
|
|
97d683541d | ||
|
|
9f7ffb80e1 | ||
|
|
c957ea7b24 | ||
|
|
181fce16b1 | ||
|
|
825f023505 | ||
|
|
347ea53b32 | ||
|
|
d525e0dd70 | ||
|
|
365e844b83 | ||
|
|
44bdeb555a | ||
|
|
520c33557e | ||
|
|
bfad5ac091 | ||
|
|
3ecf4bc238 | ||
|
|
028e4012aa | ||
|
|
dc6d429b9c | ||
|
|
625cf1a803 | ||
|
|
9ee011514a | ||
|
|
184fd4a1ba | ||
|
|
23dcfd9401 | ||
|
|
1cdba297fb | ||
|
|
1ed6743bbb | ||
|
|
41c42bba32 | ||
|
|
8fb66ea32c | ||
|
|
51d4c1c4a5 | ||
|
|
86e069994e | ||
|
|
1cb923b6d8 | ||
|
|
b1d003b073 | ||
|
|
0fb4254481 | ||
|
|
ae7f456011 | ||
|
|
cd4bec6bfd | ||
|
|
5906e0126d | ||
|
|
dce1395af1 | ||
|
|
e7db13af37 | ||
|
|
2eee8cd7d3 | ||
|
|
836a2abae1 | ||
|
|
a68a86d6db | ||
|
|
ee9f0990fd | ||
|
|
59d0629e3f | ||
|
|
17af292761 | ||
|
|
a4dd4bcc8a | ||
|
|
1a9b0a476b | ||
|
|
bb015506e7 | ||
|
|
76be5d8469 | ||
|
|
1258e187f5 | ||
|
|
4056a4c35f | ||
|
|
b6677f0f72 | ||
|
|
e8c1e6f241 | ||
|
|
618595ac4c | ||
|
|
d54ba48c11 | ||
|
|
a489012a0c | ||
|
|
a5acdc04e3 | ||
|
|
709a20ed7b | ||
|
|
c88f2099c1 | ||
|
|
f72a2a943b | ||
|
|
c51199719d | ||
|
|
bf374f2e85 | ||
|
|
34f450fcdb | ||
|
|
23f75598e5 | ||
|
|
afc238d60e | ||
|
|
1291c38d58 | ||
|
|
16caccde51 | ||
|
|
33f199fcd2 | ||
|
|
2b534e0d51 | ||
|
|
23d1d210c7 | ||
|
|
39a1d6202a | ||
|
|
f00a5af6c9 | ||
|
|
48d68f5766 | ||
|
|
f948da748e | ||
|
|
8b25d45109 | ||
|
|
c4ddc35746 | ||
|
|
0122e2bdcf | ||
|
|
94b75f463b | ||
|
|
3c2e04290c | ||
|
|
f0331ec2d9 | ||
|
|
3b4013a1b0 | ||
|
|
31ddccd3e1 | ||
|
|
d29fe4cb6c | ||
|
|
6763537f22 | ||
|
|
8ab4bd6293 | ||
|
|
31bc644763 | ||
|
|
fcd672abeb | ||
|
|
5f550da0bb | ||
|
|
e865a86eef | ||
|
|
80ee2e4289 | ||
|
|
4d327594d3 | ||
|
|
3363c37457 | ||
|
|
cee9be81bf | ||
|
|
932d36462f | ||
|
|
75c930f7ef | ||
|
|
bdb178d893 | ||
|
|
3b0635e8a1 | ||
|
|
f5760784bf | ||
|
|
67f3554095 | ||
|
|
3bb3872e38 | ||
|
|
c98330ea1f | ||
|
|
d895b68f04 | ||
|
|
e230981ac4 | ||
|
|
20763a741a | ||
|
|
4babcd9442 | ||
|
|
d75f36066a | ||
|
|
26ca4670ad | ||
|
|
c4d6c167a2 | ||
|
|
e5af9541da | ||
|
|
89d9f47191 | ||
|
|
ff2cf30238 | ||
|
|
ebe0899eb1 | ||
|
|
a3d0a38b1e | ||
|
|
63bd0c87b2 | ||
|
|
db593fb188 | ||
|
|
67ae10b593 | ||
|
|
c8d91c9e14 | ||
|
|
6c54f5e9b4 | ||
|
|
8749648d97 | ||
|
|
0b75b5ef26 | ||
|
|
fbcadd0493 | ||
|
|
75bb7a4dd7 | ||
|
|
4604fe4841 | ||
|
|
e8badb0c0f | ||
|
|
8906a8f3c6 | ||
|
|
4e32990a5d | ||
|
|
9f2583d1f2 | ||
|
|
a9b3d8885d | ||
|
|
29ec4dc546 | ||
|
|
d0d5204cbc | ||
|
|
3d84acd7ac | ||
|
|
5057221f59 | ||
|
|
3ddfbc5d2f | ||
|
|
362270e3ea | ||
|
|
db91177e90 | ||
|
|
d2f51ce509 | ||
|
|
146a66fb09 | ||
|
|
03305f03c1 | ||
|
|
82e76bc58e | ||
|
|
e8ff6c785a | ||
|
|
a8fafb469a | ||
|
|
b9a220cb63 | ||
|
|
0b44d40b39 | ||
|
|
6b349eda45 | ||
|
|
ad335ba005 | ||
|
|
04d766884a | ||
|
|
44d1ec433d | ||
|
|
97864e8df3 | ||
|
|
3916293e8f | ||
|
|
a527177b67 | ||
|
|
9c027b10b2 | ||
|
|
5da7086475 | ||
|
|
0006012ae7 | ||
|
|
a3f46ec037 | ||
|
|
bfea52f9dd | ||
|
|
53334f05b8 | ||
|
|
ba195c41b6 | ||
|
|
cca2f1ce61 | ||
|
|
a51191c661 | ||
|
|
4cdb5f93b9 | ||
|
|
fae658c9c2 | ||
|
|
886a469634 | ||
|
|
c3c1394e86 | ||
|
|
6a00255fff | ||
|
|
4f0aae0879 | ||
|
|
4f4fe4c41c | ||
|
|
2a4a3c8250 | ||
|
|
7864acbadb | ||
|
|
ba18e64be0 | ||
|
|
ba8c1e5eb2 | ||
|
|
2737fb2d87 | ||
|
|
899285735f | ||
|
|
f561d12d35 | ||
|
|
be258b13e0 | ||
|
|
dbce6b5f1a | ||
|
|
30f0c99a58 | ||
|
|
49880c05d9 | ||
|
|
dc2fc84f58 | ||
|
|
78c2a1694f | ||
|
|
baf34dd0d3 | ||
|
|
48f9dede7b | ||
|
|
a1f2a621ef | ||
|
|
a1e8ddb461 | ||
|
|
d33d90a36e | ||
|
|
c3114b876f | ||
|
|
50285aebde | ||
|
|
0eb5ee6ea8 | ||
|
|
16c9c95e19 | ||
|
|
3bc4da3e85 | ||
|
|
a028a2e1cc | ||
|
|
9675a35dff | ||
|
|
c1546fdd64 | ||
|
|
a109efc1d6 | ||
|
|
0782b25830 | ||
|
|
0041ff13b8 | ||
|
|
4693a25aa0 | ||
|
|
609df5b4a6 | ||
|
|
6df8140cb1 | ||
|
|
65b4cb3191 | ||
|
|
e1de481349 | ||
|
|
6e1cc80b91 | ||
|
|
b658ce7e75 | ||
|
|
f91f374dfa | ||
|
|
56f6de5410 | ||
|
|
94d22ecfc3 | ||
|
|
e25d71c6c8 | ||
|
|
bb1b156d2f | ||
|
|
1b80ddf1e9 | ||
|
|
66d2fe9074 | ||
|
|
6e36910734 | ||
|
|
a553a33c46 | ||
|
|
2a6f8b401b | ||
|
|
fa30567140 | ||
|
|
243f685b83 | ||
|
|
6cf2373b34 | ||
|
|
e842ea745a | ||
|
|
9696c7cec0 | ||
|
|
c4986eec50 | ||
|
|
61079e769e | ||
|
|
00d2c915d1 | ||
|
|
6ad975c420 | ||
|
|
1cd1a2d907 | ||
|
|
39a3c3d3a7 | ||
|
|
dfefcf03ad | ||
|
|
825b00e618 | ||
|
|
ae562e1e92 | ||
|
|
21c7888595 | ||
|
|
3b87a4f9d0 | ||
|
|
8564a58eab | ||
|
|
c5d009c2cd | ||
|
|
c2e165d825 | ||
|
|
922020c57a | ||
|
|
8cdc33beab | ||
|
|
23eafdfe00 | ||
|
|
e72e8ea631 | ||
|
|
a610a43db0 | ||
|
|
4a90ffe619 | ||
|
|
18e8357b6a | ||
|
|
df39347b19 | ||
|
|
a36261d705 | ||
|
|
f133d22124 | ||
|
|
6ba276b43f | ||
|
|
44db98f260 | ||
|
|
8873526619 | ||
|
|
37c2599754 | ||
|
|
a079b470b8 | ||
|
|
0f9ed02bf0 | ||
|
|
9aeb68205c | ||
|
|
82b4cf259c | ||
|
|
566fd3e88b | ||
|
|
fbecf4f47b | ||
|
|
52899d4def | ||
|
|
a89a828b35 | ||
|
|
4d0dbdaced | ||
|
|
8003f9902e | ||
|
|
15bd7324fe | ||
|
|
bb44fc51bd | ||
|
|
67a32e60c7 | ||
|
|
960725777c | ||
|
|
98c6e0311b | ||
|
|
95b7641f9c | ||
|
|
18b0c3f7aa | ||
|
|
49d3644d6a | ||
|
|
ee9d12d933 | ||
|
|
5d37015f4d | ||
|
|
dca25637c9 | ||
|
|
a7020fd46c | ||
|
|
1ef2b1aaf1 | ||
|
|
a7a661e60f | ||
|
|
2a9e2d47f5 | ||
|
|
e33b3043df | ||
|
|
3f41618aa1 | ||
|
|
a507d7567f | ||
|
|
62a6f58705 | ||
|
|
77dd074fc3 | ||
|
|
e8c0051be3 | ||
|
|
b3923eafc7 | ||
|
|
9ebd96611a | ||
|
|
824325a2eb | ||
|
|
e8b3bd5bdc | ||
|
|
a59fda512c | ||
|
|
ae181f6835 | ||
|
|
67bb242778 | ||
|
|
2028c189aa | ||
|
|
ba0dc4fb81 | ||
|
|
c40db417d2 | ||
|
|
0eb776cdd3 | ||
|
|
c79a7a7f6f | ||
|
|
1e3c995e6a | ||
|
|
3f79e42628 | ||
|
|
c16ae89a3d | ||
|
|
7132eaeb11 | ||
|
|
aef96f0d27 | ||
|
|
b20a56f1de | ||
|
|
3073b4e48e | ||
|
|
7b53752ccd | ||
|
|
03eedf6175 | ||
|
|
2330a4bc93 | ||
|
|
36afae50b1 | ||
|
|
272ee7577c | ||
|
|
7f34073da6 | ||
|
|
f46ee2a0a3 | ||
|
|
4a79f0c75d | ||
|
|
27a78af269 | ||
|
|
586af67829 | ||
|
|
575d8c4240 | ||
|
|
d32734214b | ||
|
|
22ce5aab25 | ||
|
|
9f90a1c58e | ||
|
|
b5e0374946 | ||
|
|
44cb1c7f3e | ||
|
|
80aba859e7 | ||
|
|
08360edd26 | ||
|
|
6e69b3f032 | ||
|
|
19bb9c7f50 | ||
|
|
f5dee51e9c | ||
|
|
bd37fef720 | ||
|
|
c22e4e5e2c | ||
|
|
2887a2b6d3 | ||
|
|
01bde19701 | ||
|
|
792f1826ee | ||
|
|
c16795dce9 | ||
|
|
c1597a0968 | ||
|
|
590aa950df | ||
|
|
402018b95c | ||
|
|
d5101ac2f3 | ||
|
|
251942c91d | ||
|
|
fe86b812cd | ||
|
|
cb3bff589f | ||
|
|
ec7d7ec559 | ||
|
|
24c7a5b805 | ||
|
|
0a4ecb1507 | ||
|
|
d736dace50 | ||
|
|
70bbab909f | ||
|
|
6625f78e4f | ||
|
|
da2b4c8858 | ||
|
|
12df415dfd | ||
|
|
2493f463f3 | ||
|
|
f4238b1fb9 | ||
|
|
794783ab4e | ||
|
|
02634622a5 | ||
|
|
ac24501e76 | ||
|
|
e40ea38112 | ||
|
|
b809b9bb80 | ||
|
|
73bad8f355 | ||
|
|
ac884da56b | ||
|
|
c35ab2e1cd | ||
|
|
ed3907c273 | ||
|
|
5e00287045 | ||
|
|
95c6578911 | ||
|
|
d22097ee33 | ||
|
|
74251af163 | ||
|
|
7c1b11851f | ||
|
|
f8724c4cb9 | ||
|
|
3baac034e5 | ||
|
|
114f1426f3 | ||
|
|
7de63cea5c | ||
|
|
34e3af2b38 | ||
|
|
da907d0eea | ||
|
|
9cbc2d9206 | ||
|
|
db2e466d60 | ||
|
|
e5cdbf7361 | ||
|
|
a919f493d6 | ||
|
|
3660298683 | ||
|
|
c845efe475 | ||
|
|
38eb47132d | ||
|
|
b1f097f32b | ||
|
|
d3123253b3 | ||
|
|
7b1ec1ec22 | ||
|
|
4cefacfe73 | ||
|
|
978acfa471 | ||
|
|
fb2d138cbf | ||
|
|
0edd63edb5 | ||
|
|
97b730668c | ||
|
|
26b8cf6d52 | ||
|
|
a979638368 | ||
|
|
97f434ad4a | ||
|
|
34af040c48 | ||
|
|
cc81b443be | ||
|
|
d44f3c22c7 | ||
|
|
3795b537f6 | ||
|
|
ecb5f0885c | ||
|
|
86d2234713 | ||
|
|
62ddf26150 | ||
|
|
ec14b7c52f | ||
|
|
5f9cc38e82 | ||
|
|
f48c58f299 | ||
|
|
c2843f3c4b | ||
|
|
5d33df4e12 | ||
|
|
c030fb47ca | ||
|
|
964daadb18 | ||
|
|
71a5698ac7 | ||
|
|
d41d74d0f8 | ||
|
|
f6c7a611a3 | ||
|
|
06f4e79e5c | ||
|
|
154cf44f0a | ||
|
|
f6e2ff0e44 | ||
|
|
2aba616f7f | ||
|
|
95e21386b8 | ||
|
|
250e908d9a | ||
|
|
9742fb296c | ||
|
|
9ff3c2c0d4 | ||
|
|
9dd7bd9530 | ||
|
|
6f477b7147 | ||
|
|
8389826e30 | ||
|
|
aa31fb7470 | ||
|
|
a013fe663c | ||
|
|
89ce497431 | ||
|
|
60c0b649e8 | ||
|
|
2bbb5ea23b | ||
|
|
4f9c1533c1 | ||
|
|
a6a3847e30 | ||
|
|
118f38dba3 | ||
|
|
879f946b28 | ||
|
|
6acb8a5a91 | ||
|
|
a38f1e92e3 | ||
|
|
4ca977466e | ||
|
|
ec45dc56fb | ||
|
|
5686302653 | ||
|
|
6322773513 | ||
|
|
8e845fc919 | ||
|
|
f90c8f2ae5 | ||
|
|
b5af06529f | ||
|
|
fac3669f8e | ||
|
|
28ff8d6dcc | ||
|
|
d0e7f6673c | ||
|
|
800dc21202 | ||
|
|
f52089a674 | ||
|
|
82543de95e | ||
|
|
12db69407e | ||
|
|
9b2b447b8b | ||
|
|
35f5e4ca41 | ||
|
|
8a69713f6c | ||
|
|
efd8ef0380 | ||
|
|
c5eacd1627 | ||
|
|
5fdb52d8d0 | ||
|
|
7869ce060f | ||
|
|
e0d96c0ce1 | ||
|
|
30678904ee | ||
|
|
953be61d89 | ||
|
|
d8c85007d4 | ||
|
|
591c1cb454 | ||
|
|
0ca90ed082 | ||
|
|
4c963b3978 | ||
|
|
071665f0c3 | ||
|
|
9a7826752f | ||
|
|
44b4187365 | ||
|
|
148807543f | ||
|
|
2b9fa09293 | ||
|
|
10211d1d03 | ||
|
|
46811f33ad | ||
|
|
32b16790d3 | ||
|
|
10592ca5a8 | ||
|
|
dc5cb2e1b8 | ||
|
|
c10d782524 | ||
|
|
d73366984f | ||
|
|
60b1e47ae6 | ||
|
|
9591fb2c21 | ||
|
|
c3cba03ac6 | ||
|
|
ce7818c436 | ||
|
|
f367a81e44 | ||
|
|
de507f7ec9 | ||
|
|
0a8be603c8 | ||
|
|
d7f033bd46 | ||
|
|
1fb3b87697 | ||
|
|
b9c8fa61b2 | ||
|
|
99ea6d5080 | ||
|
|
0bacfa9286 | ||
|
|
b350b605a8 | ||
|
|
d1eeeab7b1 | ||
|
|
54296ba84a | ||
|
|
f82b0f259c | ||
|
|
57f1c005e6 | ||
|
|
d9e5387bff | ||
|
|
3154b8ce55 | ||
|
|
45b48ede44 | ||
|
|
961b86dcd2 | ||
|
|
4d57c64b0d | ||
|
|
1c894f3cfa | ||
|
|
3d6faecaed | ||
|
|
2263ade187 | ||
|
|
2cdf33d8a1 | ||
|
|
f6fce6bd31 | ||
|
|
f9f1721d66 | ||
|
|
0792ac7de8 | ||
|
|
98edb048b7 | ||
|
|
52fcdf28fa | ||
|
|
d9671faca7 | ||
|
|
f456004543 | ||
|
|
a38040d0ea | ||
|
|
f18cd92318 | ||
|
|
06e1d0f8da | ||
|
|
dffd663d7a | ||
|
|
414f9e9e96 | ||
|
|
c17ea74856 | ||
|
|
9a08740e5b | ||
|
|
8bea0db843 | ||
|
|
2c612e371f | ||
|
|
2f61dc9bc6 | ||
|
|
d18b78c11c | ||
|
|
95fb4f2e50 | ||
|
|
f31fe1440d | ||
|
|
10cd0a1f30 | ||
|
|
659f854f62 | ||
|
|
4a7f8dbe09 | ||
|
|
3e19e574e6 | ||
|
|
2af2d3664f | ||
|
|
7dad46adb4 | ||
|
|
b6fc6a751a | ||
|
|
934674a8d7 | ||
|
|
c66986f065 | ||
|
|
fc49e4a0da | ||
|
|
b6e1d71b81 | ||
|
|
b3626a786d | ||
|
|
a398e28ac0 | ||
|
|
892d4e597e | ||
|
|
e8311dd306 | ||
|
|
a0b266fef8 | ||
|
|
983d1ea361 | ||
|
|
db615b932c | ||
|
|
07415e512f | ||
|
|
0c6d417d8c | ||
|
|
772e01ad40 | ||
|
|
1b2509d5bc | ||
|
|
fd963a8e66 | ||
|
|
3c17fca369 | ||
|
|
4a76997044 | ||
|
|
894960ef5a | ||
|
|
3c24d4bc4e | ||
|
|
ed7e6a3495 | ||
|
|
07de032e62 | ||
|
|
c07165531a | ||
|
|
b1a22d4412 | ||
|
|
6734e5ef57 | ||
|
|
6cc81fe6b8 | ||
|
|
ad80d21e89 | ||
|
|
97689c6cbb | ||
|
|
41c83dabde | ||
|
|
f909f0dcf9 | ||
|
|
5c9bf30c79 | ||
|
|
6efc518eed | ||
|
|
198bd3a3dc | ||
|
|
7b1055702b | ||
|
|
d21bcce3c4 | ||
|
|
b5a26941ef | ||
|
|
6ab7131378 | ||
|
|
22bcc2e438 | ||
|
|
32edc0f1fe | ||
|
|
8faa0ce2c2 | ||
|
|
bf05e5999b | ||
|
|
3d7bdded31 | ||
|
|
7507182097 | ||
|
|
6853b3c531 | ||
|
|
f2372a13e8 | ||
|
|
3f321c8801 | ||
|
|
8b47107df8 | ||
|
|
97e7136293 | ||
|
|
c8db58150e | ||
|
|
5e1067df59 | ||
|
|
175444c59f | ||
|
|
b09d5ff3c9 | ||
|
|
43fc97137e | ||
|
|
c67eee57d6 | ||
|
|
607aa78059 | ||
|
|
7edbae7b4c | ||
|
|
232ff38084 | ||
|
|
d9d9ca67cd | ||
|
|
57fa48aef4 | ||
|
|
5a8e0749c2 | ||
|
|
f834f069cd | ||
|
|
9b2dc10da2 | ||
|
|
c3730b7efd | ||
|
|
23499497a3 | ||
|
|
3b78d609b7 | ||
|
|
65529c3356 | ||
|
|
899849d4dc | ||
|
|
52393206e6 | ||
|
|
2cd1fa6601 | ||
|
|
e371bbedc0 | ||
|
|
9dde385073 | ||
|
|
afa3d39cb3 | ||
|
|
fe41817f25 | ||
|
|
a865465514 | ||
|
|
9278e74e9e | ||
|
|
689a1f739f | ||
|
|
19dee57b7e | ||
|
|
8690b91632 | ||
|
|
fa31cab11b | ||
|
|
46ee783f99 | ||
|
|
199bba5da4 | ||
|
|
16e8791472 | ||
|
|
1728442d62 | ||
|
|
22f7f059ce | ||
|
|
97629c1fc3 | ||
|
|
4727d613c0 | ||
|
|
9ed138ea2b | ||
|
|
2cbd998941 | ||
|
|
806d70c243 | ||
|
|
74a1c7d489 | ||
|
|
f6ed5dc126 | ||
|
|
e25185b9b8 | ||
|
|
5e6d8873b9 | ||
|
|
951b48c337 | ||
|
|
7f209b76bf | ||
|
|
890bfbe02d | ||
|
|
70f8c28ca6 | ||
|
|
47bacdaed0 | ||
|
|
bcd8eb2a09 | ||
|
|
e4855d0143 | ||
|
|
94f0ff1ed1 | ||
|
|
b5f0243a89 | ||
|
|
17e59b8783 | ||
|
|
ffdf308b40 | ||
|
|
cdadc80945 | ||
|
|
294e1f5b10 | ||
|
|
1c5eab6055 | ||
|
|
f74f06e403 | ||
|
|
f04ee0baf2 | ||
|
|
689273fc24 | ||
|
|
6f4c59a15c | ||
|
|
dc87097dfe | ||
|
|
24f4ab7597 | ||
|
|
ad94f0a292 | ||
|
|
695613a063 | ||
|
|
6f1828eabc | ||
|
|
bf158b3bf0 | ||
|
|
13618e6a0a | ||
|
|
c424e9dec8 | ||
|
|
a2e9523707 | ||
|
|
606817ae06 | ||
|
|
7124d326fc | ||
|
|
f9f4653e33 | ||
|
|
bf8eebe537 | ||
|
|
bd9eef6502 | ||
|
|
e343b1790e | ||
|
|
d81ef1d67c | ||
|
|
6e374bcd4e | ||
|
|
fb4648d2af | ||
|
|
a63fc25f14 | ||
|
|
5e20e9ae1c | ||
|
|
7d5d604ea6 | ||
|
|
a722581868 | ||
|
|
28f3044bdd | ||
|
|
497804434d | ||
|
|
d2d6ee806d | ||
|
|
2e106265f9 | ||
|
|
28fb0b433b | ||
|
|
171bd6b327 | ||
|
|
198e215d54 | ||
|
|
4d424e70bc | ||
|
|
3efef52398 | ||
|
|
b85929772e | ||
|
|
041522f94e | ||
|
|
80d3c9e96f | ||
|
|
6ee5e560cc | ||
|
|
2be9eb4bae | ||
|
|
0a8935686a | ||
|
|
0109d9148b | ||
|
|
212518c682 | ||
|
|
59b4f1ebab | ||
|
|
ee9462c221 | ||
|
|
c648dc6c99 | ||
|
|
4f1b8094a3 | ||
|
|
c89ccf7185 | ||
|
|
753395965a | ||
|
|
04be747d52 | ||
|
|
f828ed3edf | ||
|
|
b98d9c2932 | ||
|
|
aba2ce8390 | ||
|
|
8bd8e149cf | ||
|
|
e7c359a2e7 | ||
|
|
d64d25380a | ||
|
|
6cba6166fb | ||
|
|
e66f5fe253 | ||
|
|
1d4388d444 | ||
|
|
28ab08a7ca | ||
|
|
6fa0f92ceb | ||
|
|
3083ab74a6 | ||
|
|
b6ea73af83 | ||
|
|
1fa3ffb1ff | ||
|
|
af89630095 | ||
|
|
18f0177fce | ||
|
|
d89eecacba | ||
|
|
a9149fb92e | ||
|
|
9a04208a11 | ||
|
|
6cdf199531 | ||
|
|
44dc7fe24a | ||
|
|
455892b414 | ||
|
|
4f5227782a | ||
|
|
481e473b60 | ||
|
|
2c2a1f638b | ||
|
|
973e269f46 | ||
|
|
9f76e0e056 | ||
|
|
3a5f1b41a4 | ||
|
|
e2d8369daf | ||
|
|
a20d4959bf | ||
|
|
7b887e4cdd | ||
|
|
bc9cbd2993 | ||
|
|
9baa0e247f | ||
|
|
2df8d2bc69 | ||
|
|
b8165fb06e | ||
|
|
c698b24e01 | ||
|
|
e70249cb2e | ||
|
|
8a9bfe8281 | ||
|
|
8c2a4e627e | ||
|
|
bf35c92c14 | ||
|
|
019293a034 | ||
|
|
46dc40149e | ||
|
|
444643eb6f | ||
|
|
2913b911e3 | ||
|
|
ca323371a7 | ||
|
|
a06cb39777 | ||
|
|
b0ec8767a2 | ||
|
|
353fb49a87 | ||
|
|
e453b40e0b | ||
|
|
0c6f8ce77d | ||
|
|
c0219662bb | ||
|
|
aae71d375c | ||
|
|
b6228e4c59 | ||
|
|
3a9a1439d9 | ||
|
|
7cf256dc7c | ||
|
|
c3c26998bf | ||
|
|
02e860480b | ||
|
|
7737b8b596 | ||
|
|
2725322fd5 | ||
|
|
6c6ccda6b3 | ||
|
|
d71269e223 | ||
|
|
36266d2b10 | ||
|
|
acae62de87 | ||
|
|
9fe4197cae | ||
|
|
7fa1a8d54a | ||
|
|
2333271c20 | ||
|
|
5b83149567 | ||
|
|
250a35baab | ||
|
|
d60ba95532 | ||
|
|
c901472198 | ||
|
|
2a5b70fb13 | ||
|
|
dc6db6e4b3 | ||
|
|
8df6f32314 | ||
|
|
a2d8c894fe | ||
|
|
a1996768f1 | ||
|
|
205587cb9e | ||
|
|
224b2ef952 | ||
|
|
90a83dc753 | ||
|
|
a7cf968d04 | ||
|
|
80ff72bae1 | ||
|
|
5320fc8111 | ||
|
|
8753531e82 | ||
|
|
03a845f2b3 | ||
|
|
25b05f127d | ||
|
|
073beb0135 | ||
|
|
ef7659691b | ||
|
|
e69c0c079e | ||
|
|
dc31269a06 | ||
|
|
df9eccabea | ||
|
|
7788f5ae4c | ||
|
|
ff5456c178 | ||
|
|
40ed702437 | ||
|
|
65924e9a5d | ||
|
|
a88d149dad | ||
|
|
b9ec94d835 | ||
|
|
fc1675575a | ||
|
|
2f7229720f | ||
|
|
0187fc7b22 | ||
|
|
540e1a9650 | ||
|
|
a371cd1d79 | ||
|
|
16b11fee31 | ||
|
|
1bc46f22b4 | ||
|
|
554c8fe163 | ||
|
|
8f6bf6e002 | ||
|
|
d5dd8e9346 | ||
|
|
4a67e1021a | ||
|
|
c97061770a | ||
|
|
55b331511e | ||
|
|
4b9b5e861f | ||
|
|
b8599a0642 | ||
|
|
ae6530585a | ||
|
|
39aa1fa2a4 | ||
|
|
4f740acabd | ||
|
|
2cc9b91895 | ||
|
|
4eedc39e97 | ||
|
|
b99e8d7f46 | ||
|
|
a8a27aeadd | ||
|
|
21176d2fd3 | ||
|
|
224c65438f | ||
|
|
f1c21b642f | ||
|
|
030d1f374a | ||
|
|
0b29fa2288 | ||
|
|
b721f148f0 | ||
|
|
63434a2f87 | ||
|
|
0d6f0e66be | ||
|
|
fb3f1365c5 | ||
|
|
8de7d5d377 | ||
|
|
952d7494ac | ||
|
|
9aeba20086 | ||
|
|
9150c9c40e | ||
|
|
3e75897154 | ||
|
|
b0aa4402c2 | ||
|
|
41f80bcafd | ||
|
|
c67359c49d | ||
|
|
2f7c3cf21e | ||
|
|
9731c8a750 | ||
|
|
8092e5c3a8 | ||
|
|
f7ab8cc471 | ||
|
|
b593f62c4f | ||
|
|
6905b7a410 | ||
|
|
402f27b2a3 | ||
|
|
c9c46d05d0 | ||
|
|
6591575d22 | ||
|
|
6064119779 | ||
|
|
00cd9b581d | ||
|
|
a3d7b72485 | ||
|
|
88c73be2f4 | ||
|
|
39a9181cdd | ||
|
|
0e5c6f56a0 | ||
|
|
5147a070a1 | ||
|
|
b11be1838a | ||
|
|
be99768a32 | ||
|
|
fe439a0cb6 | ||
|
|
87f49ec879 | ||
|
|
20f2730125 | ||
|
|
bc5b34db6b | ||
|
|
bcf9df3744 | ||
|
|
4d3674ee0a | ||
|
|
28567e4629 | ||
|
|
1180a4fb0b | ||
|
|
71928d2c9f | ||
|
|
3853072a2e | ||
|
|
0cf630ef23 | ||
|
|
202015fe34 | ||
|
|
ae43e5cae4 | ||
|
|
67b67bae6a | ||
|
|
dbb8fe15cf | ||
|
|
56efa10f64 | ||
|
|
5ff776f90d | ||
|
|
a25b072bf6 | ||
|
|
c95951c0e4 | ||
|
|
4c8193b801 | ||
|
|
598a544ff8 | ||
|
|
465ef3fa9a | ||
|
|
2f876d93e3 | ||
|
|
84e8c44e4f | ||
|
|
855d794bdb | ||
|
|
a3333f8fe1 | ||
|
|
2e64d62ca4 | ||
|
|
26a3dbcbe1 | ||
|
|
fa2e86df29 | ||
|
|
b4f0ece78f | ||
|
|
630b319a37 | ||
|
|
4a37e49798 | ||
|
|
cfbe98a39a | ||
|
|
91f097d514 | ||
|
|
c545521cd9 | ||
|
|
11e0f49ada | ||
|
|
19ce53128b | ||
|
|
deccff623a | ||
|
|
b2a210ec0d | ||
|
|
bdb5169a6f | ||
|
|
0865b702a3 | ||
|
|
d13b8fd486 | ||
|
|
494911805e | ||
|
|
cba3a2be24 | ||
|
|
0686781359 | ||
|
|
e5b82dca4d | ||
|
|
2144a42a22 | ||
|
|
07a989e004 | ||
|
|
4f7e8116cb | ||
|
|
c0f650d7dc | ||
|
|
d4a0136504 | ||
|
|
5f25e027c4 | ||
|
|
9610dcce20 | ||
|
|
3ee3e7c17b | ||
|
|
98536250bd | ||
|
|
e95808e6be | ||
|
|
9fc819a410 | ||
|
|
b0f1ce1fa0 | ||
|
|
503579a638 | ||
|
|
3ad216751a | ||
|
|
ca8e3179bb | ||
|
|
fd84e56c00 | ||
|
|
8b67fb7290 | ||
|
|
2d1fdb319d | ||
|
|
c200e18434 | ||
|
|
b3ffcd020f | ||
|
|
9258a3dcd4 | ||
|
|
57f5478731 | ||
|
|
973d75ebdd | ||
|
|
33519b27c8 | ||
|
|
7da7ff4a69 | ||
|
|
dbd2f697f9 | ||
|
|
f435762b88 | ||
|
|
ae46332e42 | ||
|
|
d003883de9 | ||
|
|
4e438a44f1 | ||
|
|
02e19b3d44 | ||
|
|
ccc19512e7 | ||
|
|
c34539e389 | ||
|
|
f8aeacb949 | ||
|
|
9940190679 | ||
|
|
e2498b3e91 | ||
|
|
82246fd9c7 | ||
|
|
11538552eb | ||
|
|
4ce28f54de | ||
|
|
e887ed74a3 | ||
|
|
28c086e97c | ||
|
|
11465e89a3 | ||
|
|
b2197187c1 | ||
|
|
2b26a10745 | ||
|
|
daf726ebbf | ||
|
|
88dd886687 | ||
|
|
609da457f7 | ||
|
|
363e28ff69 | ||
|
|
bdd6bf9020 | ||
|
|
5c3dab3466 | ||
|
|
9b2c8fa25d | ||
|
|
df2f102d9e | ||
|
|
95ebb0e6d2 | ||
|
|
e5d03652a9 | ||
|
|
56b53e2dd8 | ||
|
|
cf0b7b213f | ||
|
|
d214c8e01b | ||
|
|
fba0f362a5 | ||
|
|
ec05d0857c | ||
|
|
54b744b7de | ||
|
|
1a76780fff | ||
|
|
58f5c44533 | ||
|
|
d085da4dbf | ||
|
|
c4a5c356f7 | ||
|
|
18fdc5c6a2 | ||
|
|
35dabaab9c | ||
|
|
9bf31b10bb | ||
|
|
7186575cb1 | ||
|
|
2ecae40130 | ||
|
|
778ed62a90 | ||
|
|
5e863a87dc | ||
|
|
7ce8597c25 | ||
|
|
1992237ce5 | ||
|
|
8f247b0f73 | ||
|
|
e2159d80af | ||
|
|
057023531e | ||
|
|
dfed65bf9f | ||
|
|
739161849a | ||
|
|
c65b280020 | ||
|
|
d3bcf25ef0 | ||
|
|
f6bd3340e7 | ||
|
|
6a7c09bfe3 | ||
|
|
8b9f294a5d | ||
|
|
4a282d9629 | ||
|
|
909b88864f | ||
|
|
1346a7992c | ||
|
|
bba607e987 | ||
|
|
f9cc490c35 | ||
|
|
a5aec2d9fa | ||
|
|
c0df368dc6 | ||
|
|
aa77433523 | ||
|
|
44ad99f693 | ||
|
|
b7f7a82ea9 | ||
|
|
c69978c9fd | ||
|
|
6174aa6ee1 | ||
|
|
74b8d2e908 | ||
|
|
63a515944f | ||
|
|
5b5db7b860 | ||
|
|
b3bbacf2ef | ||
|
|
3a0429d049 | ||
|
|
ab539081fa | ||
|
|
f0d88d4e73 | ||
|
|
772cbd6ffd | ||
|
|
17b9dbe9d7 | ||
|
|
75e5d42d8b | ||
|
|
031c15fd7d | ||
|
|
de1924cefc | ||
|
|
66db0a4751 | ||
|
|
c309410965 | ||
|
|
7f461b99e2 | ||
|
|
7bfe0eeae9 | ||
|
|
8619bd5be3 | ||
|
|
56011d37d4 | ||
|
|
c2852c8a82 | ||
|
|
6f546a424e | ||
|
|
447f7530af | ||
|
|
6136f1206b | ||
|
|
36a3c5b501 | ||
|
|
dcd6c1f522 | ||
|
|
2b074bcdcb | ||
|
|
b20ec7f0eb | ||
|
|
58cf69a2fe | ||
|
|
096c148228 | ||
|
|
a68005d4ab | ||
|
|
bf3a281987 | ||
|
|
2965a6827d | ||
|
|
9f43a73c36 | ||
|
|
7551b45da2 | ||
|
|
bca3685eda | ||
|
|
6d20175800 | ||
|
|
a62dd4c020 | ||
|
|
d1d9620a61 | ||
|
|
5106d77c77 | ||
|
|
69cf237d7a | ||
|
|
7d9d1c82b6 | ||
|
|
228ff5edf4 | ||
|
|
2baac618a8 | ||
|
|
e8f499a938 | ||
|
|
96ca20d0b4 | ||
|
|
54acdc86e7 | ||
|
|
0815e02895 | ||
|
|
30cbb72b57 | ||
|
|
0b91397709 | ||
|
|
89934c17ca | ||
|
|
e4a38e62eb | ||
|
|
5e1e09d7bf | ||
|
|
51ce3a1e42 | ||
|
|
54b46dfad9 | ||
|
|
787917ac66 | ||
|
|
619b49bdc4 | ||
|
|
4b3a73d440 | ||
|
|
54f9c59d6e | ||
|
|
1d123996f6 | ||
|
|
c4768f6138 | ||
|
|
5f3551ff34 | ||
|
|
d3985c2e3b | ||
|
|
3b1843f3a3 | ||
|
|
2c36796362 | ||
|
|
655ccba89b | ||
|
|
150d72f0f8 | ||
|
|
6a316b34a2 | ||
|
|
8e6b600609 | ||
|
|
5630a4dd67 | ||
|
|
38ee8aedc1 | ||
|
|
d594615532 | ||
|
|
2739fa60be | ||
|
|
327301782d | ||
|
|
8781c5db8d | ||
|
|
31c34ea158 | ||
|
|
ef9bbaca19 | ||
|
|
02d89072bc | ||
|
|
4e8bd640a7 | ||
|
|
8c71a00600 | ||
|
|
3d36c70d53 | ||
|
|
c72479c4d6 | ||
|
|
4bb88d8e44 | ||
|
|
0ee0958539 | ||
|
|
b6dd6f3a94 | ||
|
|
d11c322e1f | ||
|
|
cd92b34ef1 | ||
|
|
b6481cfcda | ||
|
|
db7eb92638 | ||
|
|
f2d0477550 | ||
|
|
776e207f09 | ||
|
|
733e8a0043 | ||
|
|
4fa19006ad | ||
|
|
73a597e3e5 | ||
|
|
d776f1765d | ||
|
|
741b6f6f9a | ||
|
|
b6f4695bcd | ||
|
|
b7d3b807d2 | ||
|
|
0cc386bc28 | ||
|
|
cb155707cd | ||
|
|
9b6b250cbd | ||
|
|
5b7e29b8ad | ||
|
|
b6d748b414 | ||
|
|
8fc4b338c2 | ||
|
|
6d3ea19ac5 | ||
|
|
d01ef48bf0 | ||
|
|
71103bb7b9 | ||
|
|
1c9bc00acc | ||
|
|
bed128e8cf | ||
|
|
b5c3f18f24 | ||
|
|
cbccdf5d93 | ||
|
|
a46f3a31e1 | ||
|
|
a808f7b04e | ||
|
|
3a883b9e41 | ||
|
|
17d8691300 | ||
|
|
523ce1dbdd | ||
|
|
4a3a9bf62c | ||
|
|
3b30177959 | ||
|
|
7e66f89260 | ||
|
|
1a93ba634f | ||
|
|
d93f823fc6 | ||
|
|
f2198bf938 | ||
|
|
965f10698b | ||
|
|
b71367cd2a | ||
|
|
abe18ac825 | ||
|
|
bb193d3768 | ||
|
|
7a7f5cd4a8 | ||
|
|
ac9f49f8c9 | ||
|
|
8f53859e00 | ||
|
|
bfb7ff88d9 | ||
|
|
c36425fd3a | ||
|
|
981f9d0b01 | ||
|
|
fa89fe3e87 | ||
|
|
d132357c20 | ||
|
|
a719237556 | ||
|
|
8955ca5216 | ||
|
|
f665762cc8 | ||
|
|
d16fc2b68b | ||
|
|
e1df32c32d | ||
|
|
943c6f77dc | ||
|
|
4964382966 | ||
|
|
021c6fdbe2 | ||
|
|
711f9805c9 | ||
|
|
0aaae3afd6 | ||
|
|
eadd1042fb | ||
|
|
16fa2c9f5e | ||
|
|
d4ab1df870 | ||
|
|
4a5aa1bcc1 | ||
|
|
01a9cda99a | ||
|
|
dcdf606ff6 | ||
|
|
ea021de5eb | ||
|
|
5cc3526f8f | ||
|
|
3060fc2af4 | ||
|
|
e4395dfeb4 | ||
|
|
f65dadf1d7 | ||
|
|
f048762fd9 | ||
|
|
bb985f826e | ||
|
|
bb239cba2a | ||
|
|
e7e66e580a | ||
|
|
689d689d3b | ||
|
|
125c3d3e0d | ||
|
|
ffaa06560e | ||
|
|
f9b716201f | ||
|
|
8b14a5f0d8 | ||
|
|
c5855119d8 | ||
|
|
a036597f5f | ||
|
|
b8688e2e66 | ||
|
|
d8b2e08717 | ||
|
|
7da78d3312 | ||
|
|
2292b107dc | ||
|
|
1fcc74c658 | ||
|
|
73be027951 | ||
|
|
132d91c2ab | ||
|
|
f08ce82c3f | ||
|
|
8de2712652 | ||
|
|
55835785c0 | ||
|
|
cb711b7758 | ||
|
|
19c75293bf | ||
|
|
33219f00d5 | ||
|
|
4aaedbb0e6 | ||
|
|
ee1f14d4eb | ||
|
|
feac8085c9 | ||
|
|
0a5ec11b1b | ||
|
|
03937174e5 | ||
|
|
e00529c05f | ||
|
|
5dbf8e1d2b | ||
|
|
bebf672186 | ||
|
|
6d4a8f2a5a | ||
|
|
14db0ae663 | ||
|
|
88d1c1d140 | ||
|
|
9106055be1 | ||
|
|
2cf52f15ab | ||
|
|
b7e9d61c72 | ||
|
|
0bc22db296 | ||
|
|
6a943acc70 | ||
|
|
7c97416e7d | ||
|
|
dd75504a66 | ||
|
|
04c4ab2289 | ||
|
|
310a2e2511 | ||
|
|
f6314431f0 | ||
|
|
89100d0ca0 | ||
|
|
2b646636c1 | ||
|
|
b10c1d5006 | ||
|
|
225b829c1a | ||
|
|
5f4c7076ab | ||
|
|
61c9b304d7 | ||
|
|
789d7000cf | ||
|
|
d23ef2bd59 | ||
|
|
8a77f832a3 | ||
|
|
5a6d318cfb | ||
|
|
e9f14de05d | ||
|
|
2d8da45bda | ||
|
|
83de33f5b8 | ||
|
|
e63844f786 | ||
|
|
0a805c16fd | ||
|
|
653c7d4430 | ||
|
|
306c3bea21 | ||
|
|
389ce60bc9 | ||
|
|
2d453a1a6c | ||
|
|
0775560ad2 | ||
|
|
2680c1e8b3 | ||
|
|
50ba2e3ad4 | ||
|
|
c16875d0de | ||
|
|
a4205cd0c2 | ||
|
|
2fb3e373c6 | ||
|
|
ac1fa7209c | ||
|
|
fd820d6af8 | ||
|
|
b88486601b | ||
|
|
92e712a508 | ||
|
|
64a9079ce4 | ||
|
|
f18d0ab923 | ||
|
|
def49e6d20 | ||
|
|
f142db3d49 | ||
|
|
e7b04a89e2 | ||
|
|
1cb59f46e3 | ||
|
|
a604746e0b | ||
|
|
aba706a293 | ||
|
|
c1b9113347 | ||
|
|
5e7db2807d | ||
|
|
203f830a30 | ||
|
|
3dbe9193e2 | ||
|
|
717cf29595 | ||
|
|
72300fec5e | ||
|
|
ec50b1d67a | ||
|
|
408a4420c9 | ||
|
|
568218204a | ||
|
|
bd39e98c66 | ||
|
|
01be65a624 | ||
|
|
a59d8a6a17 | ||
|
|
70b71aa4f9 | ||
|
|
aaf7991139 | ||
|
|
265d579fd9 | ||
|
|
f6dd91e47c | ||
|
|
cdae552ab0 | ||
|
|
730e887454 | ||
|
|
5a3852d82c | ||
|
|
5b35580d2d | ||
|
|
4b0705fe36 | ||
|
|
d219b4d12a | ||
|
|
6e38331328 | ||
|
|
c4bc9aea22 | ||
|
|
6c692d9308 | ||
|
|
7ce8bd8988 | ||
|
|
b4ead4076a | ||
|
|
052893bbf8 | ||
|
|
a319fe8632 | ||
|
|
8a84e68c13 | ||
|
|
0ca7defe83 | ||
|
|
b704706ee9 | ||
|
|
23fb634847 | ||
|
|
0bd37eb8f9 | ||
|
|
b86294e9cc | ||
|
|
f11f968f99 | ||
|
|
ad81642954 | ||
|
|
ea42103ae7 | ||
|
|
82435e37be | ||
|
|
b61d29b22a | ||
|
|
04392a6a4c | ||
|
|
6e9798d596 | ||
|
|
bef553c9ae | ||
|
|
7a76efa7a0 | ||
|
|
c5f64374ed | ||
|
|
b767caa704 | ||
|
|
63974f97ab | ||
|
|
37764a7caa | ||
|
|
fb586f0043 | ||
|
|
9990f4d8cf | ||
|
|
80f73cc5d0 | ||
|
|
8775f67416 | ||
|
|
2ce302f6f8 | ||
|
|
69b9944b8e | ||
|
|
37f35e8b2d | ||
|
|
8ad9531fa6 | ||
|
|
5ec37c08bf | ||
|
|
84cb008421 | ||
|
|
a744cca35a | ||
|
|
1950cf5f99 | ||
|
|
fbf230cd01 | ||
|
|
05abf1e419 | ||
|
|
f0c13980ed | ||
|
|
d136207d2f | ||
|
|
b331ee5d93 | ||
|
|
73cd6e981a | ||
|
|
6826be73c7 | ||
|
|
0a61a607c9 | ||
|
|
7444e1566b | ||
|
|
e401661cfc | ||
|
|
89d32f7109 | ||
|
|
5b4c88f933 | ||
|
|
966bce973a | ||
|
|
69cbcae7ed | ||
|
|
e26cf282d6 | ||
|
|
6ec7d55cbc | ||
|
|
9888f2a322 | ||
|
|
15d29b2c79 | ||
|
|
7e768e0a17 | ||
|
|
affa41b5a9 | ||
|
|
c8cf179ed9 | ||
|
|
9ef7310fc2 | ||
|
|
cdd7d0f4c5 | ||
|
|
813d706dac | ||
|
|
223d4133c5 | ||
|
|
bb62ebc23e | ||
|
|
a4c2adf69a | ||
|
|
0baff0a1e1 | ||
|
|
51766ad72c | ||
|
|
bf00b42941 | ||
|
|
56482acfc2 | ||
|
|
8898b1a608 | ||
|
|
525bc37649 | ||
|
|
9d29450f47 | ||
|
|
26c98bdace | ||
|
|
19ccd35f3f | ||
|
|
efa7529c5c | ||
|
|
334c11ccd1 | ||
|
|
c318a5dd79 | ||
|
|
25d1a8957d | ||
|
|
9f4853b9d6 | ||
|
|
ac58f50b0a | ||
|
|
36f22b660e | ||
|
|
398046eca6 | ||
|
|
a6f2ce4bdd | ||
|
|
950a8ea8df | ||
|
|
2b6b979f88 | ||
|
|
4b80e5ff47 | ||
|
|
a14d18c6b6 | ||
|
|
fe88c7ce97 | ||
|
|
c54b00a701 | ||
|
|
4a4b8c2e12 | ||
|
|
f1770711cb | ||
|
|
94757f0f0c | ||
|
|
15cf9be90d | ||
|
|
cb1955c217 | ||
|
|
2ce944034d | ||
|
|
53a207e859 | ||
|
|
dbdd2411c3 | ||
|
|
4ac3fbd726 | ||
|
|
8f8f62555c | ||
|
|
73b980c6a9 | ||
|
|
d2cce3cc40 | ||
|
|
4139360788 | ||
|
|
ca7bb50212 | ||
|
|
48ebf626b8 | ||
|
|
564eb802b1 | ||
|
|
c968949f49 | ||
|
|
74268ecce6 | ||
|
|
93f9db3af4 | ||
|
|
4cc0a9d4a9 | ||
|
|
a04dfba16b | ||
|
|
7f83b58b92 | ||
|
|
ca2e6353ae | ||
|
|
6bf7795529 | ||
|
|
401f4828b6 | ||
|
|
7a0ce1efe7 | ||
|
|
cdc2550e34 | ||
|
|
2d760241f3 | ||
|
|
3748e420a0 | ||
|
|
031a253101 | ||
|
|
cfce6d548b | ||
|
|
038e93ea6a | ||
|
|
8028e145f1 | ||
|
|
ddfb9fd0cc | ||
|
|
a36ed6ab1e | ||
|
|
0c7fe0664e | ||
|
|
7ae2f1980b | ||
|
|
0c89583b1b | ||
|
|
f5ec43276a | ||
|
|
e55e46011c | ||
|
|
77c0304faf | ||
|
|
ea476e26ae | ||
|
|
2eb47aef62 | ||
|
|
3e4084d99c | ||
|
|
955ac92043 | ||
|
|
5a65a07a39 | ||
|
|
554d73c6ee | ||
|
|
7bc7bc7c49 | ||
|
|
7b8d47cdeb | ||
|
|
63a8509f1f | ||
|
|
4e69454f72 | ||
|
|
ec3e237093 | ||
|
|
edd224a185 | ||
|
|
b5142b8ef5 | ||
|
|
ddfdf1d49d | ||
|
|
e7675c29da | ||
|
|
0bf3fef431 | ||
|
|
8cb0e81e89 | ||
|
|
d468cb051d | ||
|
|
0b24be7532 | ||
|
|
6316a0ede9 | ||
|
|
3c9d0e02f6 | ||
|
|
02d4360526 | ||
|
|
aedf80e382 | ||
|
|
51b492e1e2 | ||
|
|
d283f236db | ||
|
|
371e937a0e | ||
|
|
5778c25477 | ||
|
|
d2cd3ec879 | ||
|
|
ba0a59629b | ||
|
|
03fea7558d | ||
|
|
4901673c4e | ||
|
|
a4d84bd2e8 | ||
|
|
0289218c92 | ||
|
|
c3d32e59e7 | ||
|
|
8cab08351b | ||
|
|
5de0e58d5d | ||
|
|
438106f42e | ||
|
|
6b21f38047 | ||
|
|
1b07a5f3c0 | ||
|
|
a39ec5a061 | ||
|
|
015df9e6dd | ||
|
|
bf95284b72 | ||
|
|
07c04f0c2f | ||
|
|
b9976ee68e | ||
|
|
c8d9951ae4 | ||
|
|
97339512e1 | ||
|
|
95682a7a0b | ||
|
|
87038c4c75 | ||
|
|
1e5b5193fe | ||
|
|
9cc47678a2 | ||
|
|
198109cd43 | ||
|
|
16490541e4 | ||
|
|
6d5ca25e03 | ||
|
|
0ca44bd859 | ||
|
|
124b5b0549 | ||
|
|
fed62fae3c | ||
|
|
9e2812d55c | ||
|
|
fdcbc3904a | ||
|
|
cc0114cd90 | ||
|
|
f97753c1d0 | ||
|
|
fcdf545a3c | ||
|
|
bf28f887eb | ||
|
|
5f1f04e486 | ||
|
|
2242174749 | ||
|
|
e8af077fe2 | ||
|
|
055252f746 | ||
|
|
8dc84d7c17 | ||
|
|
f140c75fb9 | ||
|
|
c63dd46bac | ||
|
|
a23b0ba945 | ||
|
|
7e768aa6e9 | ||
|
|
18765508c0 | ||
|
|
efb3464ee2 | ||
|
|
f3319c5f75 | ||
|
|
384623fbb7 | ||
|
|
3bcccdf3dd | ||
|
|
d9b913fa69 | ||
|
|
7b9a430e8a | ||
|
|
4f3ab0dc69 | ||
|
|
427caaf9aa | ||
|
|
85eefdebbb | ||
|
|
b31b70302b | ||
|
|
c830ea676f | ||
|
|
9249059cb7 | ||
|
|
9fee228d1a | ||
|
|
20718c6ec1 | ||
|
|
b8754f3f44 | ||
|
|
6f598ae59e | ||
|
|
ca81fcaf37 | ||
|
|
75867da94f | ||
|
|
53c11701de | ||
|
|
4741793bb6 | ||
|
|
ab161a42ee | ||
|
|
4642b79b5b | ||
|
|
1cb43fe110 | ||
|
|
0123135237 | ||
|
|
1d77f91acc | ||
|
|
9b89333b1b | ||
|
|
829361d767 | ||
|
|
d3fca26499 | ||
|
|
ff3460e100 | ||
|
|
1a209a54c6 | ||
|
|
3bf0ac087f | ||
|
|
96cf6215ce | ||
|
|
71ce6120c3 | ||
|
|
21e82d0daa | ||
|
|
8c20bb003b | ||
|
|
90913d2486 | ||
|
|
ef0de04a0f | ||
|
|
8879a0ce8a | ||
|
|
18db46800e | ||
|
|
955c5b5605 | ||
|
|
c3b2c88213 | ||
|
|
7412bb35ad | ||
|
|
2a6fbc5c5d | ||
|
|
90c9b87f8d | ||
|
|
ffe2557e84 | ||
|
|
a77798e5b4 | ||
|
|
c1fa7bfce6 | ||
|
|
bf50da1e6b | ||
|
|
2cd4aac5ce | ||
|
|
208b96c092 | ||
|
|
36a53f8134 | ||
|
|
e8d8a8737e | ||
|
|
41b9f90a0b | ||
|
|
5e39493e89 | ||
|
|
31f3c60401 | ||
|
|
519c74e4dd | ||
|
|
4419770b15 | ||
|
|
b7fa86c848 | ||
|
|
4d620c3db9 | ||
|
|
319c8cb54c | ||
|
|
868b6f141c | ||
|
|
589fdd4cfe | ||
|
|
3f36dd9a14 | ||
|
|
0a6568bbab | ||
|
|
4e26d56746 | ||
|
|
d4e363fbd7 | ||
|
|
b721b822eb | ||
|
|
58d6985080 | ||
|
|
ee2abd415e | ||
|
|
09c9321159 | ||
|
|
0900a7cf80 | ||
|
|
d3ec7f65fb | ||
|
|
b24a94d6ce | ||
|
|
65769c7766 | ||
|
|
cbeef9fe06 | ||
|
|
b199209d0d | ||
|
|
cb48545600 | ||
|
|
5e626e2cc5 | ||
|
|
2709d1ff6e | ||
|
|
de3ca6e237 | ||
|
|
c2253e868c | ||
|
|
3a77c6f7eb | ||
|
|
8e3ff7670b | ||
|
|
7870147c16 | ||
|
|
64a371e5d8 | ||
|
|
f837736a20 | ||
|
|
dec503da81 | ||
|
|
1328299fda | ||
|
|
05190a52f1 | ||
|
|
46cc3105c4 | ||
|
|
8ba5853cdd | ||
|
|
e5fbcc4a8c | ||
|
|
e559194e8e | ||
|
|
c0d2994b8e | ||
|
|
89009aa1f8 | ||
|
|
ee8b580a98 | ||
|
|
f4656fa493 | ||
|
|
adf9405fd7 | ||
|
|
f46db7ce1a | ||
|
|
f00d726347 | ||
|
|
e8d8063ebc | ||
|
|
b4bc4f5ddc | ||
|
|
0d3ffe210f | ||
|
|
8eb88a161a | ||
|
|
346c964419 | ||
|
|
bc8be2460f | ||
|
|
a33f24d19c | ||
|
|
8f839fbf8e | ||
|
|
10dd9101cd | ||
|
|
aa5d3af8a1 | ||
|
|
dace993c21 | ||
|
|
32b72f0ef6 | ||
|
|
3dbc54c8ae | ||
|
|
9dd3b8fd68 | ||
|
|
5fb1afc681 | ||
|
|
a4c985a219 | ||
|
|
a1f819a458 | ||
|
|
166d7ba1cf | ||
|
|
a089accd23 | ||
|
|
38546e557f | ||
|
|
080dca7ee0 | ||
|
|
a89e433f3d | ||
|
|
f30ef61b06 | ||
|
|
03a36c1100 | ||
|
|
546eb6e73e | ||
|
|
bedd3abf8a | ||
|
|
ce2d4498e1 | ||
|
|
a786023160 | ||
|
|
98cf8aa445 | ||
|
|
d733d9fd4c | ||
|
|
58e9cb8b93 | ||
|
|
bb669acf95 | ||
|
|
4f3751b7ce | ||
|
|
84c12dee80 | ||
|
|
f5f865a139 | ||
|
|
902aed671a | ||
|
|
1423fe7e16 | ||
|
|
58ed2e6f33 | ||
|
|
a90939f46a | ||
|
|
db7456b9c5 | ||
|
|
a964b30c34 | ||
|
|
d566629d51 | ||
|
|
837422fbb8 | ||
|
|
afc37c71a6 | ||
|
|
e8b014ea6d | ||
|
|
b124512020 | ||
|
|
158f352328 | ||
|
|
f1895e32fb | ||
|
|
6c3be01093 | ||
|
|
ebe548438c | ||
|
|
a45c61f19e | ||
|
|
b07a4b95aa | ||
|
|
777b4e13e6 | ||
|
|
92cfc9324d | ||
|
|
97dfa18b9b | ||
|
|
515c07ea2b | ||
|
|
4d17e45f86 | ||
|
|
32095daf90 | ||
|
|
aa23ed892b | ||
|
|
3f079c8501 | ||
|
|
0aaf4bfde8 | ||
|
|
b967cfc775 | ||
|
|
2ca0483bf4 | ||
|
|
03cedc7b35 | ||
|
|
35049b5830 | ||
|
|
b707dde4da | ||
|
|
1ec8339b13 | ||
|
|
8bbe04a174 | ||
|
|
0b6a173ba0 | ||
|
|
8b41dfe94f | ||
|
|
a18b1ac99b | ||
|
|
e007bcb640 | ||
|
|
1090e7ceae | ||
|
|
933035dd7e | ||
|
|
aaaac78170 | ||
|
|
b5d2392def | ||
|
|
b88a736735 | ||
|
|
f238da416b | ||
|
|
10c7e75491 | ||
|
|
60af0735f4 | ||
|
|
273cbf333e | ||
|
|
189b17ad8f | ||
|
|
1eecf26429 | ||
|
|
2f9a3fa942 | ||
|
|
f166fb132e | ||
|
|
0adb69139e | ||
|
|
ab309e4b90 | ||
|
|
532c6d4fa5 | ||
|
|
14f627d0d3 | ||
|
|
947c38c124 | ||
|
|
f991e49203 | ||
|
|
4fbb6ed4ff | ||
|
|
2fa49303de | ||
|
|
f9527e9d2d | ||
|
|
80c63cb9d6 | ||
|
|
a2455eeade | ||
|
|
5d7ad4b3bd | ||
|
|
f46fa61cf3 | ||
|
|
da24a9637b | ||
|
|
2cdc11c2ad | ||
|
|
191cd3f25c | ||
|
|
f158bce8bd | ||
|
|
94eebb2dd6 | ||
|
|
375b146690 | ||
|
|
8c13214ff2 | ||
|
|
681dfadb57 | ||
|
|
b8b5d1cb09 | ||
|
|
e187dd86ed | ||
|
|
c380d6988c | ||
|
|
444acc8ef5 | ||
|
|
068f08aa45 | ||
|
|
bdc101f69c | ||
|
|
0ece530b9e | ||
|
|
5853a86091 | ||
|
|
20ba87bc88 | ||
|
|
be166ec158 | ||
|
|
02147891c2 | ||
|
|
c08cd588eb | ||
|
|
882bb564b1 | ||
|
|
18edf06a20 | ||
|
|
68b52b6130 | ||
|
|
3503f3eb4b | ||
|
|
a75706f329 | ||
|
|
29fe9d973c | ||
|
|
87d3320fa1 | ||
|
|
0b96dbc04c | ||
|
|
55ed58c4a0 | ||
|
|
8503e8c9ad | ||
|
|
fcdf783c40 | ||
|
|
008b92acb2 | ||
|
|
baf8ef8516 | ||
|
|
0cf89467e3 | ||
|
|
37d8a563c0 | ||
|
|
f3de93d73a | ||
|
|
4de23bd160 | ||
|
|
29397ca04f | ||
|
|
6038a36532 | ||
|
|
186a922d06 | ||
|
|
be1f9e66e3 | ||
|
|
9ac015e550 | ||
|
|
f7a9ac0ba2 | ||
|
|
39a8ddcfec | ||
|
|
3a9e28ba48 | ||
|
|
b6a479355e | ||
|
|
a791c964e8 | ||
|
|
9686a7f9bf | ||
|
|
6b65b89350 | ||
|
|
09a1915ec6 | ||
|
|
3424c421a4 | ||
|
|
77b89b6841 | ||
|
|
09807cfcad | ||
|
|
6ca81df40c | ||
|
|
2d00ddad2b | ||
|
|
04f4934adb | ||
|
|
0593007fd0 | ||
|
|
c07cbf9dbb | ||
|
|
ddd60aa1ff | ||
|
|
b5ecdbbc48 | ||
|
|
0cca613b04 | ||
|
|
b254ad177a | ||
|
|
4fd9213d2c | ||
|
|
982d1e219c | ||
|
|
3923b8631d | ||
|
|
72dcdf4483 | ||
|
|
5f3a71ed5f | ||
|
|
000d6ebcd0 | ||
|
|
7f0a04e3e3 | ||
|
|
005c6bb9f1 | ||
|
|
59c856fc0e | ||
|
|
5bf26619ee | ||
|
|
676c1d560b | ||
|
|
5afaa7c079 | ||
|
|
b0b49b72b8 | ||
|
|
e7600458a9 | ||
|
|
e0fa308984 | ||
|
|
6ce6fed10d | ||
|
|
b23ca2e138 | ||
|
|
2798dc3d42 | ||
|
|
0586d4d7a9 | ||
|
|
d2b3a52424 | ||
|
|
ffb97242d9 | ||
|
|
13ab400d6d | ||
|
|
db6d47b3f3 | ||
|
|
393943bb9f | ||
|
|
4c72ac14e6 | ||
|
|
7156871412 | ||
|
|
20665a49ed | ||
|
|
ad1dfc3137 | ||
|
|
8de67411ac | ||
|
|
2e75c9951b | ||
|
|
77f66f44a4 | ||
|
|
3278a397f4 | ||
|
|
d1c2abbaf3 | ||
|
|
8a443013c0 | ||
|
|
d3735c4763 | ||
|
|
f9887434d1 | ||
|
|
12afa005d9 | ||
|
|
7c0129b911 | ||
|
|
332f92d08e | ||
|
|
281ac16dca | ||
|
|
e8a2b9446d | ||
|
|
4e33f3e722 | ||
|
|
e46e60153d | ||
|
|
d3559bb1b7 | ||
|
|
c8a046996b | ||
|
|
6c85b8717f | ||
|
|
142a62e371 | ||
|
|
ff6abf08b7 | ||
|
|
2fd921cd60 | ||
|
|
1d7bd57357 | ||
|
|
1a4d76b4c3 | ||
|
|
853d869086 | ||
|
|
c99d669b06 | ||
|
|
19d3921637 | ||
|
|
4ee716457f | ||
|
|
5fb19bb187 | ||
|
|
8b83c5349d | ||
|
|
ac91942452 | ||
|
|
5ef23ddc1d | ||
|
|
2ad6c66a8d | ||
|
|
630f877e95 | ||
|
|
7dd5ce1356 | ||
|
|
54b18d15b6 | ||
|
|
2b0880af80 | ||
|
|
786ea17f95 | ||
|
|
c699bae99c | ||
|
|
588e8e019c | ||
|
|
1e7a86b7c0 | ||
|
|
2bb18b18b7 | ||
|
|
da77c549a7 | ||
|
|
fc707c157a | ||
|
|
5be6f550be | ||
|
|
66abf27edd | ||
|
|
3d1b6d7de7 | ||
|
|
115e604627 | ||
|
|
f9aeec8eb5 | ||
|
|
acf4d15a8d | ||
|
|
e5e08d1762 | ||
|
|
178c7817fa | ||
|
|
a93a428a89 | ||
|
|
d126a361e1 | ||
|
|
9e42ec0c06 | ||
|
|
1f05654faa | ||
|
|
3ddef6440a | ||
|
|
036b47acbc | ||
|
|
42e585e7a2 | ||
|
|
93d066bef7 | ||
|
|
580c6fca00 | ||
|
|
03300da93a | ||
|
|
2a1fc38799 | ||
|
|
646afbfa36 | ||
|
|
45a1435ce7 | ||
|
|
f4d7d32fd7 | ||
|
|
1b00f93091 | ||
|
|
9c9e5a54a7 | ||
|
|
4cf8c9c477 | ||
|
|
a78e1d7f2b | ||
|
|
00c1d6c42c | ||
|
|
5d92f09449 | ||
|
|
ac7d820e6f | ||
|
|
7d752443ca | ||
|
|
3311b5a6e3 | ||
|
|
3801443c9c | ||
|
|
9b2a2eb229 | ||
|
|
d165f66815 | ||
|
|
6715d52b81 | ||
|
|
ae160556d0 | ||
|
|
c040e1f9b7 | ||
|
|
db14a8ac1a | ||
|
|
9beafd03ee | ||
|
|
4f081c5e14 | ||
|
|
ff4e9e42e5 | ||
|
|
d5e3e6f256 | ||
|
|
cc9660c0e7 | ||
|
|
90d92707c8 | ||
|
|
fe77bc7c37 | ||
|
|
54a7d8291b | ||
|
|
7bb924ce5b | ||
|
|
9f2e25309e | ||
|
|
b32b39579e | ||
|
|
00513e66bc | ||
|
|
8850867b82 | ||
|
|
d6dfbbf8dd | ||
|
|
6c4797bce4 | ||
|
|
2c97eb4115 | ||
|
|
54b0828c20 | ||
|
|
0d241a4993 | ||
|
|
802b0d1a75 | ||
|
|
e76a7716bc | ||
|
|
a9cc0a61d9 | ||
|
|
fe50e47fc6 | ||
|
|
0006b286ca | ||
|
|
17f99da45e | ||
|
|
f7ce03a819 | ||
|
|
c073501ac0 | ||
|
|
d4a4747c08 | ||
|
|
e7b19a5f66 | ||
|
|
0070ec09a2 | ||
|
|
b3ec62a3db | ||
|
|
34ca4ad3b0 | ||
|
|
e0909731a4 | ||
|
|
d8d1cb2eda | ||
|
|
2a24fbadae | ||
|
|
85e1c4bd47 | ||
|
|
09fcb0739d | ||
|
|
0882c2b5c7 | ||
|
|
bb7763d72b | ||
|
|
b919d7364a | ||
|
|
942a37290c | ||
|
|
ef24c6cbbd | ||
|
|
cf05571f1c | ||
|
|
0fa038b4f2 | ||
|
|
10a33a2978 | ||
|
|
60a88381cf | ||
|
|
48d83c7d44 | ||
|
|
b967b7ed6b | ||
|
|
b60ecb6171 | ||
|
|
e8b80216e8 | ||
|
|
69a5472a16 | ||
|
|
bd6eb606ca | ||
|
|
e7f1e83a43 | ||
|
|
357fe3b793 | ||
|
|
ad6c06409e | ||
|
|
2a7feba808 | ||
|
|
45b7e28db2 | ||
|
|
daa9479352 | ||
|
|
0f688bd71a | ||
|
|
ffe0843bd6 | ||
|
|
0ee4039853 | ||
|
|
a3a6e8cdf6 | ||
|
|
30f60f87f4 | ||
|
|
0d91657557 | ||
|
|
ec9b80a64e | ||
|
|
91909f8886 | ||
|
|
cc335dae38 | ||
|
|
0d6ea03ac8 | ||
|
|
e1370b75e8 | ||
|
|
c2d0ccea3c | ||
|
|
9319851118 | ||
|
|
d45ad76fbc | ||
|
|
d8b9c3b832 | ||
|
|
9f2534af3d | ||
|
|
2c2978b93a | ||
|
|
c9b0f22a2e | ||
|
|
2959cd140b | ||
|
|
7834cfe5f0 | ||
|
|
2b9c5d0cff | ||
|
|
cb3b51dcde | ||
|
|
0c23fe96be | ||
|
|
9d0bd73ee6 | ||
|
|
15f096f764 | ||
|
|
9dd41be608 | ||
|
|
17f8703c71 | ||
|
|
5edfd7b6f7 | ||
|
|
4371772ec7 | ||
|
|
8e4e08a828 | ||
|
|
401e6b5a57 | ||
|
|
01dfe83fcd | ||
|
|
177c5700ff | ||
|
|
5d401a4fbb | ||
|
|
c60ab97103 | ||
|
|
f3d7a90ac7 | ||
|
|
7b114f961a | ||
|
|
8caaf13c84 | ||
|
|
0218da1ee6 | ||
|
|
f4786755f1 | ||
|
|
b9b1fcb4e5 | ||
|
|
5bfda557bc | ||
|
|
6e53df403e | ||
|
|
4a7246ec6e | ||
|
|
f53a021c08 | ||
|
|
8fa95d06e1 | ||
|
|
b34bd9ffd2 | ||
|
|
fd1a7e34a8 | ||
|
|
973653a690 | ||
|
|
11e4dfe940 | ||
|
|
e7804d39b3 | ||
|
|
6cfbde43ab | ||
|
|
30421bf247 | ||
|
|
ab1b6b45a2 | ||
|
|
59366c04dd | ||
|
|
fac437c1ef | ||
|
|
797f0d92b3 | ||
|
|
75f3fa5144 | ||
|
|
6ea1b5c7c3 | ||
|
|
6a81cc0e83 | ||
|
|
d3e2c7c51a | ||
|
|
1c930a2eb9 | ||
|
|
fb1ea5b37c | ||
|
|
e82f344a2c | ||
|
|
10ba205f97 | ||
|
|
fbc8b97c25 | ||
|
|
c6a31b21e3 | ||
|
|
4aa8c4b79d | ||
|
|
04179ae833 | ||
|
|
205ecde505 | ||
|
|
7cb467c960 | ||
|
|
cbe7c69154 | ||
|
|
c93cbb614d | ||
|
|
42c570a6e2 | ||
|
|
aed47c1178 | ||
|
|
a1ac4784c8 | ||
|
|
d8b751d56b | ||
|
|
213eb2ae88 | ||
|
|
17b7265a9a | ||
|
|
3afdf9571e | ||
|
|
bb8a59d1db | ||
|
|
d26830d81e | ||
|
|
1f2c703ddc | ||
|
|
dd51a6e4d1 | ||
|
|
caa7597097 | ||
|
|
409996cb29 | ||
|
|
a15b37d177 | ||
|
|
a436ef2126 | ||
|
|
4c53e6e89d | ||
|
|
083eb98949 | ||
|
|
418951415c | ||
|
|
bac0d0a175 | ||
|
|
7bde7ebc30 | ||
|
|
7b7e6555c1 | ||
|
|
ea8565d0ca | ||
|
|
1ba2902618 | ||
|
|
e91e8d565a | ||
|
|
206e613ace | ||
|
|
9a88dcf33e | ||
|
|
9fc9e8972f | ||
|
|
4fe6703dd4 | ||
|
|
d613cbb68f | ||
|
|
be2247b36f | ||
|
|
66d1f49116 | ||
|
|
37d35bbbdb | ||
|
|
321d4ccc8e | ||
|
|
6e4338d13c | ||
|
|
677d15d8a7 | ||
|
|
a7e978dc06 | ||
|
|
67f5218a73 | ||
|
|
c2d1329b8b | ||
|
|
0530ec0651 | ||
|
|
8a6e18badc | ||
|
|
1a144a7070 | ||
|
|
e115432e11 | ||
|
|
145f6e2d53 | ||
|
|
9c62311b56 | ||
|
|
a150d91c48 | ||
|
|
4730a4e352 | ||
|
|
67c57be830 | ||
|
|
d98e72ca25 | ||
|
|
d81fa1e610 | ||
|
|
8c12de8b73 | ||
|
|
9b5218f85b | ||
|
|
a6cf5c7667 | ||
|
|
4fca73ffbd | ||
|
|
46a9023782 | ||
|
|
5fed443476 | ||
|
|
0fab0f207c | ||
|
|
ee67358ee6 | ||
|
|
cefd44304b | ||
|
|
2a88cdc76d | ||
|
|
4c39d37ad5 | ||
|
|
9b9865f717 | ||
|
|
3f0456322d | ||
|
|
16ac005fd6 | ||
|
|
003fcf446a | ||
|
|
39703120a4 | ||
|
|
656c0efc0d | ||
|
|
63f7c0ed69 | ||
|
|
5103463524 | ||
|
|
97254a1e3a | ||
|
|
9f171a01e8 | ||
|
|
6c9b6007a3 | ||
|
|
f4a7c4bd69 | ||
|
|
5abad18e51 | ||
|
|
57f70a6d35 | ||
|
|
cb78f3a707 | ||
|
|
b331db74ee | ||
|
|
8fb9ad3fe7 | ||
|
|
d4b5c55169 | ||
|
|
a41438d779 | ||
|
|
0895d8a813 | ||
|
|
89310d7b7c | ||
|
|
ca0e936f7c | ||
|
|
afe767e28a | ||
|
|
1481b011d9 | ||
|
|
5f1b968b60 | ||
|
|
5a729043ce | ||
|
|
2de0dfcef7 | ||
|
|
7cc83ed080 | ||
|
|
31ec03f8e5 | ||
|
|
0d095c4cf1 | ||
|
|
dbde09d008 | ||
|
|
43d33e21e6 | ||
|
|
c8cf43a255 | ||
|
|
b2d05672b1 | ||
|
|
4123c789e6 | ||
|
|
c65f3c7b68 | ||
|
|
41e3642e02 | ||
|
|
eae7602f80 | ||
|
|
fd12c73cf9 | ||
|
|
2ef9d70224 | ||
|
|
3861531fb7 | ||
|
|
aeff41ff41 | ||
|
|
b5c8283575 | ||
|
|
b31cdce073 | ||
|
|
6040aae12a | ||
|
|
6ba4afc5bb | ||
|
|
4707e2b02a | ||
|
|
08dd73fd72 | ||
|
|
83bf67b8ca | ||
|
|
b758ead371 | ||
|
|
357a0db03e | ||
|
|
6a3219a5e8 | ||
|
|
b7e7e82f85 | ||
|
|
e4c66c8b2b | ||
|
|
4d4f8b5ee8 | ||
|
|
5ab75f7eb9 | ||
|
|
8ff22bc737 | ||
|
|
1d65287fbb | ||
|
|
dc24993bf6 | ||
|
|
ef606d1365 | ||
|
|
e26ecec545 | ||
|
|
28e8aa9111 | ||
|
|
a8ff67e3b8 | ||
|
|
c311b92ae2 | ||
|
|
b04e22cd2c | ||
|
|
4903c70686 | ||
|
|
04aa963b9a | ||
|
|
7fdd2e81cf | ||
|
|
38778c8cac | ||
|
|
565851b113 | ||
|
|
cd216b0591 | ||
|
|
031e2acc63 | ||
|
|
b3afa6b0a4 | ||
|
|
40fc2b78d3 | ||
|
|
24e6c1ea36 | ||
|
|
275b4e2944 | ||
|
|
061c93cb7d | ||
|
|
3b91117724 | ||
|
|
eb4fac28c4 | ||
|
|
acb5fc6393 | ||
|
|
961ed728a1 | ||
|
|
678fcfc3a3 | ||
|
|
79d60e6b4a | ||
|
|
858b2ff6da | ||
|
|
ba3355c74c | ||
|
|
6e3028cf86 | ||
|
|
a28598630d | ||
|
|
36810b2d42 | ||
|
|
de9923f2e1 | ||
|
|
716b1ac528 | ||
|
|
77663d64a0 | ||
|
|
49540c7151 | ||
|
|
03710bc6ba | ||
|
|
489ae6c9b6 | ||
|
|
3b54eeb1c5 | ||
|
|
a9bd753e38 | ||
|
|
bf15580081 | ||
|
|
5b5a299b55 | ||
|
|
051b529c11 | ||
|
|
fa5fb815fb | ||
|
|
a4c0a61698 | ||
|
|
80d8a8190d | ||
|
|
e69a62c41a | ||
|
|
46183d4d43 | ||
|
|
4f2d3cc250 | ||
|
|
79daf543b0 | ||
|
|
5b83fb496c | ||
|
|
3dfe7c27cd | ||
|
|
e50538c634 | ||
|
|
92b6ecc4dd | ||
|
|
588ade0ab2 | ||
|
|
4375aefb49 | ||
|
|
c5cba7775a | ||
|
|
7cf8ec6d61 | ||
|
|
46cbd3ae7b | ||
|
|
678cf8a341 | ||
|
|
3a0f1f6197 | ||
|
|
902ff23a95 | ||
|
|
7e2e9aa836 | ||
|
|
491ef4559f | ||
|
|
b7bad0f585 | ||
|
|
ce248bc169 | ||
|
|
d599be7e7c | ||
|
|
5b1fc0e6c0 | ||
|
|
aeece6c201 | ||
|
|
d7a1b974cd | ||
|
|
0db1872bd2 | ||
|
|
4333bc7004 | ||
|
|
f6caac749e | ||
|
|
723303e1b6 | ||
|
|
0daf5bae96 | ||
|
|
6d59fe2a34 | ||
|
|
3ed0f005ee | ||
|
|
66b89ee817 | ||
|
|
c596c875a6 | ||
|
|
08c1a29383 | ||
|
|
ab078d1ea0 | ||
|
|
b028b09041 | ||
|
|
44c3eb7b35 | ||
|
|
f54052c320 | ||
|
|
d23a055e3b | ||
|
|
8f76f3184f | ||
|
|
619c4853fd | ||
|
|
58fb6ade7c | ||
|
|
f2c0626c68 | ||
|
|
3956d2bd63 | ||
|
|
1d851631d6 | ||
|
|
517e38e33f | ||
|
|
a2644a4ebf | ||
|
|
f7bf6a8080 | ||
|
|
681c1d9e9a | ||
|
|
9ab2e69f4f | ||
|
|
9af2ab57d1 | ||
|
|
f14e4dc0be | ||
|
|
39bd9641f4 | ||
|
|
177c283011 | ||
|
|
62ff1421e7 | ||
|
|
2577cbe1ac | ||
|
|
7542f065a1 | ||
|
|
aa2abb92ef | ||
|
|
efc00c1610 | ||
|
|
7585893cf0 | ||
|
|
4fd9019c25 | ||
|
|
f4990aaa95 | ||
|
|
834fa77385 | ||
|
|
3acd20c04d | ||
|
|
878859d7cc | ||
|
|
7038776ec5 | ||
|
|
a74001ef6a | ||
|
|
0bad1794c4 | ||
|
|
ceec72b869 | ||
|
|
5c1ed0ec06 | ||
|
|
ce00fc502b | ||
|
|
ab82d2af4f | ||
|
|
2eb3e1aef6 | ||
|
|
32cb0388cf | ||
|
|
30f9039a2c | ||
|
|
8bad63f72d | ||
|
|
aec4d89550 | ||
|
|
e8639a37af | ||
|
|
a92ab2cbe3 | ||
|
|
fb0bb6e7f3 | ||
|
|
8dbf870122 | ||
|
|
50dab48f25 | ||
|
|
e0c6354ff3 | ||
|
|
5b03d251fd | ||
|
|
9c4b69d1ae | ||
|
|
feba220fff | ||
|
|
f9efa3bf8f | ||
|
|
6ebf333982 | ||
|
|
2c7d07d606 | ||
|
|
b05185e7cc | ||
|
|
148547de95 | ||
|
|
fb6a97789e | ||
|
|
271f34c7e3 | ||
|
|
9309f877d1 | ||
|
|
88db5fb38e | ||
|
|
4ee0a1b8c5 | ||
|
|
7617d734e2 | ||
|
|
a15ae9badb | ||
|
|
97b6fed909 | ||
|
|
ab653afae9 | ||
|
|
df158a741a | ||
|
|
fb1371ebfa | ||
|
|
82d5494235 | ||
|
|
6b754723d9 | ||
|
|
e003113132 | ||
|
|
dda492ff87 | ||
|
|
2459699d27 | ||
|
|
989acec027 | ||
|
|
701ab8b24f | ||
|
|
ed6bfa5fa2 | ||
|
|
2d2899b68a | ||
|
|
2d8b80bfa9 | ||
|
|
c1cc560458 | ||
|
|
95fb562533 | ||
|
|
17853ac237 | ||
|
|
e064a8bbdb | ||
|
|
8b9e3f1b59 | ||
|
|
1d38739016 | ||
|
|
3bb46eaa6f | ||
|
|
3b1561a99b | ||
|
|
a61e5c7310 | ||
|
|
ef8d1ebc0e | ||
|
|
348b3d3738 | ||
|
|
3550aa10ba | ||
|
|
c29eadd9ee | ||
|
|
aecefaee8d | ||
|
|
3bab5ec3a7 | ||
|
|
3c908963ae | ||
|
|
cba176cdc9 | ||
|
|
cfdc854409 | ||
|
|
1d87f78088 | ||
|
|
63b01376d6 | ||
|
|
010e518adb | ||
|
|
6570784b46 | ||
|
|
63b31f41a7 | ||
|
|
96eca59afc | ||
|
|
25978bde8e | ||
|
|
7691d2b5db | ||
|
|
edb108322e | ||
|
|
af3936b68e | ||
|
|
e76c25f9d3 | ||
|
|
124f455be2 | ||
|
|
f679eefe0a |
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: clash-verge-rev
|
||||||
32
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -12,14 +12,16 @@ body:
|
|||||||
1. 请 **确保** 您已经查阅了 [Clash Verge Rev 官方文档](https://clash-verge-rev.github.io/guide/term.html) 以及 [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
1. 请 **确保** 您已经查阅了 [Clash Verge Rev 官方文档](https://clash-verge-rev.github.io/guide/term.html) 以及 [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
||||||
2. 请 **确保** [已有的问题](https://github.com/clash-verge-rev/clash-verge-rev/issues?q=is%3Aissue) 中没有人提交过相似issue,否则请在已有的issue下进行讨论
|
2. 请 **确保** [已有的问题](https://github.com/clash-verge-rev/clash-verge-rev/issues?q=is%3Aissue) 中没有人提交过相似issue,否则请在已有的issue下进行讨论
|
||||||
3. 请 **务必** 给issue填写一个简洁明了的标题,以便他人快速检索
|
3. 请 **务必** 给issue填写一个简洁明了的标题,以便他人快速检索
|
||||||
4. 请 **务必** 先下载 [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) 版本测试,确保问题依然存在
|
4. 请 **务必** 查看 [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) 版本更新日志
|
||||||
5. 请 **务必** 按照模板规范详细描述问题,否则issue将会被关闭
|
5. 请 **务必** 尝试 [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) 版本,确定问题是否仍然存在
|
||||||
|
6. 请 **务必** 按照模板规范详细描述问题以及尝试更新 Alpha 版本,否则issue将会被直接关闭
|
||||||
## Before submitting the issue, please make sure of the following checklist:
|
## Before submitting the issue, please make sure of the following checklist:
|
||||||
1. Please make sure you have read the [Clash Verge Rev official documentation](https://clash-verge-rev.github.io/guide/term.html) and [FAQ](https://clash-verge-rev.github.io/faq/windows.html)
|
1. Please make sure you have read the [Clash Verge Rev official documentation](https://clash-verge-rev.github.io/guide/term.html) and [FAQ](https://clash-verge-rev.github.io/faq/windows.html)
|
||||||
2. Please make sure there is no similar issue in the [existing issues](https://github.com/clash-verge-rev/clash-verge-rev/issues?q=is%3Aissue), otherwise please discuss under the existing issue
|
2. Please make sure there is no similar issue in the [existing issues](https://github.com/clash-verge-rev/clash-verge-rev/issues?q=is%3Aissue), otherwise please discuss under the existing issue
|
||||||
3. Please be sure to fill in a concise and clear title for the issue so that others can quickly search
|
3. Please be sure to fill in a concise and clear title for the issue so that others can quickly search
|
||||||
4. Please be sure to download the [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) version for testing to ensure that the problem still exists
|
4. Please be sure to check out [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) version update log
|
||||||
5. Please describe the problem in detail according to the template specification, otherwise the issue will be closed
|
5. Please be sure to try the [Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha) version to ensure that the problem still exists
|
||||||
|
6. Please describe the problem in detail according to the template specification and try to update the Alpha version, otherwise the issue will be closed
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
@@ -55,20 +57,16 @@ body:
|
|||||||
description: 请提供你的操作系统版本,Linux请额外提供桌面环境及窗口系统 / Please provide your OS version, for Linux, please also provide the desktop environment and window system
|
description: 请提供你的操作系统版本,Linux请额外提供桌面环境及窗口系统 / Please provide your OS version, for Linux, please also provide the desktop environment and window system
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: checkboxes
|
|
||||||
id: os-labels
|
|
||||||
attributes:
|
|
||||||
label: 系统标签 / OS Labels
|
|
||||||
description: 请选择受影响的操作系统(至少选择一个) / Please select the affected operating system(s) (select at least one)
|
|
||||||
options:
|
|
||||||
- label: windows
|
|
||||||
- label: macos
|
|
||||||
- label: linux
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: 日志 / Log
|
label: 日志(勿上传日志文件,请粘贴日志内容) / Log (Do not upload the log file, paste the log content directly)
|
||||||
description: 请提供完整或相关部分的Debug日志(请在“软件左侧菜单”->“设置”->“日志等级”调整到debug,Verge错误请把“杂项设置”->“app日志等级”调整到debug/trace,并重启Verge生效。日志文件在“软件左侧菜单”->“设置”->“日志目录”下) / Please provide a complete or relevant part of the Debug log (please adjust the "Log level" to debug in "Software left menu" -> "Settings" -> "Log level". If there is a Verge error, please adjust "Miscellaneous settings" -> "app log level" to trace, and restart Verge to take effect. The log file is under "Software left menu" -> "Settings" -> "Log directory")
|
description: 请提供完整或相关部分的Debug日志(请在“软件左侧菜单”->“设置”->“日志等级”调整到debug,Verge错误请把“杂项设置”->“app日志等级”调整到debug,并重启Verge生效。日志文件在“软件左侧菜单”->“设置”->“日志目录”下) / Please provide a complete or relevant part of the Debug log (please adjust the "Log level" to debug in "Software left menu" -> "Settings" -> "Log level". If there is a Verge error, please adjust "Miscellaneous settings" -> "app log level" to debug, and restart Verge to take effect. The log file is under "Software left menu" -> "Settings" -> "Log directory")
|
||||||
|
value: |
|
||||||
|
<details><summary>日志内容 / Log Content</summary>
|
||||||
|
```log
|
||||||
|
<!-- 在此处粘贴完整日志 / Paste the full log here -->
|
||||||
|
|
||||||
|
```
|
||||||
|
</details>
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
58
.github/ISSUE_TEMPLATE/i18n_request.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: I18N / 多语言相关
|
||||||
|
title: "[I18N] "
|
||||||
|
description: 用于多语言翻译、国际化相关问题或建议 / For issues or suggestions related to translations and internationalization
|
||||||
|
labels: ["I18n"]
|
||||||
|
type: "Task"
|
||||||
|
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
## I18N 相关问题/建议
|
||||||
|
请用此模板提交翻译错误、缺失、建议或新增语言请求。
|
||||||
|
Please use this template for translation errors, missing translations, suggestions, or new language requests.
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: 问题描述 / Description
|
||||||
|
description: 详细描述你的 I18N 问题或建议 / Please describe your I18N issue or suggestion in detail
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: language
|
||||||
|
attributes:
|
||||||
|
label: 相关语言 / Language
|
||||||
|
description: 例如 zh, en, jp, ru, ... / e.g. zh, en, jp, ru, ...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: suggestion
|
||||||
|
attributes:
|
||||||
|
label: 建议或修正内容 / Suggestion or Correction
|
||||||
|
description: 如果是翻译修正或建议,请填写建议的内容 / If this is a translation correction or suggestion, please provide the suggested content
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: i18n-type
|
||||||
|
attributes:
|
||||||
|
label: 问题类型 / Issue Type
|
||||||
|
description: 请选择适用类型(可多选) / Please select the applicable type(s)
|
||||||
|
options:
|
||||||
|
- label: 翻译错误 / Translation error
|
||||||
|
- label: 翻译缺失 / Missing translation
|
||||||
|
- label: 建议优化 / Suggestion
|
||||||
|
- label: 新增语言 / New language
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: verge-version
|
||||||
|
attributes:
|
||||||
|
label: 软件版本 / Verge Version
|
||||||
|
description: 请提供你使用的 Verge 具体版本 / Please provide the specific version of Verge you are using
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
398
.github/workflows/alpha.yml
vendored
@@ -1,54 +1,262 @@
|
|||||||
name: Alpha Build
|
name: Alpha Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# 因为 alpha 不再负责频繁构建,且需要相对于 autobuild 更稳定使用环境
|
||||||
|
# 所以不再使用 workflow_dispatch 触发
|
||||||
|
# 应当通过 git tag 来触发构建
|
||||||
|
# TODO 手动控制版本号
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
# inputs:
|
||||||
# UTC+8 00:00 (UTC 16:00 previous day) and UTC+8 12:00 (UTC 04:00)
|
# tag_name:
|
||||||
- cron: "0 16,4 * * *"
|
# description: "Alpha tag name (e.g. v1.2.3-alpha.1)"
|
||||||
|
# required: true
|
||||||
|
# type: string
|
||||||
|
|
||||||
|
# push:
|
||||||
|
# # 应当限制在 dev 分支上触发发布。
|
||||||
|
# branches:
|
||||||
|
# - dev
|
||||||
|
# # 应当限制 v*.*.*-alpha* 的 tag 来触发发布。
|
||||||
|
# tags:
|
||||||
|
# - "v*.*.*-alpha*"
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
|
TAG_NAME: alpha
|
||||||
|
TAG_CHANNEL: Alpha
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: short
|
||||||
concurrency:
|
concurrency:
|
||||||
# only allow per workflow per commit (and not pr) to run at a time
|
|
||||||
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
|
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
|
||||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check_commit:
|
check_alpha_tag:
|
||||||
|
name: Check Alpha Tag package.json Version Consistency
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
should_run: ${{ steps.check.outputs.should_run }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
|
|
||||||
- name: Check if commit changed
|
- name: Check tag and package.json version
|
||||||
id: check
|
id: check_tag
|
||||||
run: |
|
run: |
|
||||||
# For manual workflow_dispatch, always run
|
TAG_REF="${GITHUB_REF##*/}"
|
||||||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
echo "Current tag: $TAG_REF"
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
if [[ ! "$TAG_REF" =~ -alpha ]]; then
|
||||||
exit 0
|
echo "Current tag is not an alpha tag."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
PKG_VERSION=$(jq -r .version package.json)
|
||||||
|
echo "package.json version: $PKG_VERSION"
|
||||||
|
if [[ "$PKG_VERSION" != *alpha* ]]; then
|
||||||
|
echo "package.json version is not an alpha version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$TAG_REF" != "v$PKG_VERSION" ]]; then
|
||||||
|
echo "Tag ($TAG_REF) does not match package.json version (v$PKG_VERSION)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Alpha tag and package.json version are consistent."
|
||||||
|
|
||||||
# Check if current commit is different from the previous one
|
delete_old_assets:
|
||||||
CURRENT_COMMIT=$(git rev-parse HEAD)
|
name: Delete Old Alpha Release Assets and Tags
|
||||||
PREVIOUS_COMMIT=$(git rev-parse HEAD~1)
|
needs: check_alpha_tag
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Delete Old Alpha Tags Except Latest
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const tagPattern = /-alpha.*/; // 匹配带有 -alpha 的 tag
|
||||||
|
const owner = context.repo.owner;
|
||||||
|
const repo = context.repo.repo;
|
||||||
|
|
||||||
if [ "$CURRENT_COMMIT" != "$PREVIOUS_COMMIT" ]; then
|
try {
|
||||||
echo "New commit detected: $CURRENT_COMMIT"
|
// 获取所有 tag
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
const { data: tags } = await github.rest.repos.listTags({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
per_page: 100 // 调整 per_page 以获取更多 tag
|
||||||
|
});
|
||||||
|
|
||||||
|
// 过滤出包含 -alpha 的 tag
|
||||||
|
const alphaTags = (await Promise.all(
|
||||||
|
tags
|
||||||
|
.filter(tag => tagPattern.test(tag.name))
|
||||||
|
.map(async tag => {
|
||||||
|
// 获取每个 tag 的 commit 信息以获得日期
|
||||||
|
const { data: commit } = await github.rest.repos.getCommit({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
ref: tag.commit.sha
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
...tag,
|
||||||
|
commitDate: commit.committer && commit.committer.date ? commit.committer.date : commit.commit.author.date
|
||||||
|
};
|
||||||
|
})
|
||||||
|
)).sort((a, b) => {
|
||||||
|
// 按 commit 日期降序排序(最新的在前面)
|
||||||
|
return new Date(b.commitDate) - new Date(a.commitDate);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Found ${alphaTags.length} alpha tags`);
|
||||||
|
|
||||||
|
if (alphaTags.length === 0) {
|
||||||
|
console.log('No alpha tags found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保留最新的 tag
|
||||||
|
const latestTag = alphaTags[0];
|
||||||
|
console.log(`Keeping latest alpha tag: ${latestTag.name}`);
|
||||||
|
|
||||||
|
// 处理其他旧的 alpha tag
|
||||||
|
for (const tag of alphaTags.slice(1)) {
|
||||||
|
console.log(`Processing tag: ${tag.name}`);
|
||||||
|
|
||||||
|
// 获取与 tag 关联的 release
|
||||||
|
try {
|
||||||
|
const { data: release } = await github.rest.repos.getReleaseByTag({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
tag: tag.name
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除 release 下的所有资产
|
||||||
|
if (release.assets && release.assets.length > 0) {
|
||||||
|
console.log(`Deleting ${release.assets.length} assets for release ${tag.name}`);
|
||||||
|
for (const asset of release.assets) {
|
||||||
|
console.log(`Deleting asset: ${asset.name} (${asset.id})`);
|
||||||
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
asset_id: asset.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除 release
|
||||||
|
console.log(`Deleting release for tag: ${tag.name}`);
|
||||||
|
await github.rest.repos.deleteRelease({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
release_id: release.id
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除 tag
|
||||||
|
console.log(`Deleting tag: ${tag.name}`);
|
||||||
|
await github.rest.git.deleteRef({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
ref: `tags/${tag.name}`
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 404) {
|
||||||
|
console.log(`No release found for tag ${tag.name}, deleting tag directly`);
|
||||||
|
await github.rest.git.deleteRef({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
ref: `tags/${tag.name}`
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error(`Error processing tag ${tag.name}:`, error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Old alpha tags and releases deleted successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_tag:
|
||||||
|
name: Update tag
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: delete_old_assets
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Fetch UPDATE logs
|
||||||
|
id: fetch_update_logs
|
||||||
|
run: |
|
||||||
|
if [ -f "UPDATELOG.md" ]; then
|
||||||
|
UPDATE_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
|
||||||
|
if [ -n "$UPDATE_LOGS" ]; then
|
||||||
|
echo "Found update logs"
|
||||||
|
echo "UPDATE_LOGS<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$UPDATE_LOGS" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "No update sections found in UPDATELOG.md"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "No new commits since last run"
|
echo "UPDATELOG.md file not found"
|
||||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Set Env
|
||||||
|
run: |
|
||||||
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
if [ -z "$UPDATE_LOGS" ]; then
|
||||||
|
echo "No update logs found, using default message"
|
||||||
|
UPDATE_LOGS="More new features are now supported. Check for detailed changelog soon."
|
||||||
|
else
|
||||||
|
echo "Using found update logs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
alpha:
|
cat > release.txt << EOF
|
||||||
needs: check_commit
|
$UPDATE_LOGS
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
|
||||||
|
## 我应该下载哪个版本?
|
||||||
|
|
||||||
|
### MacOS
|
||||||
|
- MacOS intel芯片: x64.dmg
|
||||||
|
- MacOS apple M芯片: aarch64.dmg
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
- Linux 64位: amd64.deb/amd64.rpm
|
||||||
|
- Linux arm64 architecture: arm64.deb/aarch64.rpm
|
||||||
|
- Linux armv7架构: armhf.deb/armhfp.rpm
|
||||||
|
|
||||||
|
### Windows (不再支持Win7)
|
||||||
|
#### 正常版本(推荐)
|
||||||
|
- 64位: x64-setup.exe
|
||||||
|
- arm64架构: arm64-setup.exe
|
||||||
|
#### 便携版问题很多不再提供
|
||||||
|
#### 内置Webview2版(体积较大,仅在企业版系统或无法安装webview2时使用)
|
||||||
|
- 64位: x64_fixed_webview2-setup.exe
|
||||||
|
- arm64架构: arm64_fixed_webview2-setup.exe
|
||||||
|
|
||||||
|
### FAQ
|
||||||
|
- [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
||||||
|
|
||||||
|
### 稳定机场VPN推荐
|
||||||
|
- [狗狗加速](https://verge.dginv.click/#/register?code=oaxsAGo6)
|
||||||
|
|
||||||
|
Created at ${{ env.BUILDTIME }}.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
|
body_path: release.txt
|
||||||
|
prerelease: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
generate_release_notes: true
|
||||||
|
|
||||||
|
alpha-x86-windows-macos-linux:
|
||||||
|
name: Alpha x86 Windows, MacOS and Linux
|
||||||
|
needs: update_tag
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -63,7 +271,6 @@ jobs:
|
|||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
- os: ubuntu-22.04
|
- os: ubuntu-22.04
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
@@ -79,14 +286,13 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.os == 'ubuntu-22.04'
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -101,10 +307,10 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Alpha Version update
|
# - name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
run: pnpm run fix-alpha-version
|
# run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
- name: Tauri build
|
- name: Tauri build
|
||||||
uses: tauri-apps/tauri-action@v0
|
uses: tauri-apps/tauri-action@v0
|
||||||
@@ -120,17 +326,17 @@ jobs:
|
|||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
with:
|
with:
|
||||||
tagName: alpha
|
tagName: ${{ env.TAG_NAME }}
|
||||||
releaseName: "Clash Verge Rev Alpha"
|
releaseName: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
releaseBody: "More new features are now supported."
|
releaseBody: "More new features are now supported."
|
||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
tauriScript: pnpm
|
tauriScript: pnpm
|
||||||
args: --target ${{ matrix.target }}
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
alpha-for-linux-arm:
|
alpha-arm-linux:
|
||||||
needs: check_commit
|
name: Alpha ARM Linux
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
needs: update_tag
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -156,7 +362,7 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -171,10 +377,13 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: "Setup for linux"
|
# - name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
run: |-
|
# run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
|
- name: Setup for linux
|
||||||
|
run: |
|
||||||
sudo ls -lR /etc/apt/
|
sudo ls -lR /etc/apt/
|
||||||
|
|
||||||
cat > /tmp/sources.list << EOF
|
cat > /tmp/sources.list << EOF
|
||||||
@@ -193,23 +402,29 @@ jobs:
|
|||||||
sudo mv /tmp/sources.list /etc/apt/sources.list
|
sudo mv /tmp/sources.list /etc/apt/sources.list
|
||||||
|
|
||||||
sudo dpkg --add-architecture ${{ matrix.arch }}
|
sudo dpkg --add-architecture ${{ matrix.arch }}
|
||||||
sudo apt update
|
sudo apt-get update -y
|
||||||
|
sudo apt-get -f install -y
|
||||||
|
|
||||||
sudo apt install -y \
|
sudo apt-get install -y \
|
||||||
|
linux-libc-dev:${{ matrix.arch }} \
|
||||||
|
libc6-dev:${{ matrix.arch }}
|
||||||
|
|
||||||
|
sudo apt-get install -y \
|
||||||
|
libxslt1.1:${{ matrix.arch }} \
|
||||||
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
|
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
|
||||||
libayatana-appindicator3-dev:${{ matrix.arch }} \
|
libayatana-appindicator3-dev:${{ matrix.arch }} \
|
||||||
libssl-dev:${{ matrix.arch }} \
|
libssl-dev:${{ matrix.arch }} \
|
||||||
patchelf:${{ matrix.arch }} \
|
patchelf:${{ matrix.arch }} \
|
||||||
librsvg2-dev:${{ matrix.arch }}
|
librsvg2-dev:${{ matrix.arch }}
|
||||||
|
|
||||||
- name: "Install aarch64 tools"
|
- name: Install aarch64 tools
|
||||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y \
|
sudo apt install -y \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
g++-aarch64-linux-gnu
|
g++-aarch64-linux-gnu
|
||||||
|
|
||||||
- name: "Install armv7 tools"
|
- name: Install armv7 tools
|
||||||
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
|
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y \
|
sudo apt install -y \
|
||||||
@@ -242,18 +457,17 @@ jobs:
|
|||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
name: "Clash Verge Rev Alpha"
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
body: "More new features are now supported."
|
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: |
|
files: |
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
alpha-for-fixed-webview2:
|
alpha-x86-arm-windows_webview2:
|
||||||
needs: check_commit
|
name: Alpha x86 and ARM Windows with WebView2
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
needs: update_tag
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -276,8 +490,7 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -292,7 +505,10 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
# - name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
|
# run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
- name: Download WebView2 Runtime
|
- name: Download WebView2 Runtime
|
||||||
run: |
|
run: |
|
||||||
@@ -336,77 +552,13 @@ jobs:
|
|||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
name: "Clash Verge Rev Alpha"
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
body: "More new features are now supported."
|
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
||||||
|
|
||||||
- name: Portable Bundle
|
- name: Portable Bundle
|
||||||
run: pnpm portable-fixed-webview2 ${{ matrix.target }} --alpha
|
run: pnpm portable-fixed-webview2 ${{ matrix.target }} --${{ env.TAG_NAME }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
update_tag:
|
|
||||||
name: Update tag
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [check_commit, alpha, alpha-for-linux-arm, alpha-for-fixed-webview2]
|
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set Env
|
|
||||||
run: |
|
|
||||||
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
# - name: Update Tag
|
|
||||||
# uses: richardsimko/update-tag@v1
|
|
||||||
# with:
|
|
||||||
# tag_name: alpha
|
|
||||||
# env:
|
|
||||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
cat > release.txt << 'EOF'
|
|
||||||
## 我应该下载哪个版本?
|
|
||||||
|
|
||||||
### MacOS
|
|
||||||
- MacOS intel芯片: x64.dmg
|
|
||||||
- MacOS apple M芯片: aarch64.dmg
|
|
||||||
|
|
||||||
### Linux
|
|
||||||
- Linux 64位: amd64.deb/amd64.rpm
|
|
||||||
- Linux arm64 architecture: arm64.deb/aarch64.rpm
|
|
||||||
- Linux armv7架构: armhf.deb/armhfp.rpm
|
|
||||||
|
|
||||||
### Windows (不再支持Win7)
|
|
||||||
#### 正常版本(推荐)
|
|
||||||
- 64位: x64-setup.exe
|
|
||||||
- arm64架构: arm64-setup.exe
|
|
||||||
#### 便携版问题很多不再提供
|
|
||||||
#### 内置Webview2版(体积较大,仅在企业版系统或无法安装webview2时使用)
|
|
||||||
- 64位: x64_fixed_webview2-setup.exe
|
|
||||||
- arm64架构: arm64_fixed_webview2-setup.exe
|
|
||||||
|
|
||||||
### FAQ
|
|
||||||
|
|
||||||
- [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
|
||||||
|
|
||||||
### 稳定机场VPN推荐
|
|
||||||
- [狗狗加速](https://verge.dginv.click/#/register?code=oaxsAGo6)
|
|
||||||
|
|
||||||
Created at ${{ env.BUILDTIME }}.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Upload Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
tag_name: alpha
|
|
||||||
name: "Clash Verge Rev Alpha"
|
|
||||||
body_path: release.txt
|
|
||||||
prerelease: true
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
generate_release_notes: true
|
|
||||||
|
|||||||
485
.github/workflows/autobuild.yml
vendored
Normal file
@@ -0,0 +1,485 @@
|
|||||||
|
name: Auto Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
# schedule:
|
||||||
|
# # UTC+8 0,6,12,18
|
||||||
|
# - cron: "0 16,22,4,10 * * *"
|
||||||
|
permissions: write-all
|
||||||
|
env:
|
||||||
|
TAG_NAME: autobuild
|
||||||
|
TAG_CHANNEL: AutoBuild
|
||||||
|
CARGO_INCREMENTAL: 0
|
||||||
|
RUST_BACKTRACE: short
|
||||||
|
concurrency:
|
||||||
|
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
|
||||||
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_commit:
|
||||||
|
name: Check Commit Needs Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_run: ${{ steps.check.outputs.should_run }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Check if version changed or src changed
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENT_VERSION=$(cat package.json | jq -r '.version')
|
||||||
|
echo "Current version: $CURRENT_VERSION"
|
||||||
|
|
||||||
|
git checkout HEAD~1 package.json
|
||||||
|
PREVIOUS_VERSION=$(cat package.json | jq -r '.version')
|
||||||
|
echo "Previous version: $PREVIOUS_VERSION"
|
||||||
|
|
||||||
|
git checkout HEAD package.json
|
||||||
|
|
||||||
|
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
||||||
|
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
|
||||||
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENT_SRC_HASH=$(git rev-parse HEAD:src)
|
||||||
|
PREVIOUS_SRC_HASH=$(git rev-parse HEAD~1:src 2>/dev/null || echo "")
|
||||||
|
CURRENT_TAURI_HASH=$(git rev-parse HEAD:src-tauri 2>/dev/null || echo "")
|
||||||
|
PREVIOUS_TAURI_HASH=$(git rev-parse HEAD~1:src-tauri 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
echo "Current src hash: $CURRENT_SRC_HASH"
|
||||||
|
echo "Previous src hash: $PREVIOUS_SRC_HASH"
|
||||||
|
echo "Current tauri hash: $CURRENT_TAURI_HASH"
|
||||||
|
echo "Previous tauri hash: $PREVIOUS_TAURI_HASH"
|
||||||
|
|
||||||
|
if [ "$CURRENT_SRC_HASH" != "$PREVIOUS_SRC_HASH" ] || [ "$CURRENT_TAURI_HASH" != "$PREVIOUS_TAURI_HASH" ]; then
|
||||||
|
echo "Source directories changed"
|
||||||
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Version and source directories unchanged"
|
||||||
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
update_tag:
|
||||||
|
name: Update tag
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: check_commit
|
||||||
|
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Update git tag
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git tag -f ${{ env.TAG_NAME }}
|
||||||
|
git push --force origin ${{ env.TAG_NAME }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Fetch UPDATE logs
|
||||||
|
id: fetch_update_logs
|
||||||
|
run: |
|
||||||
|
if [ -f "UPDATELOG.md" ]; then
|
||||||
|
UPDATE_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
|
||||||
|
if [ -n "$UPDATE_LOGS" ]; then
|
||||||
|
echo "Found update logs"
|
||||||
|
echo "UPDATE_LOGS<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$UPDATE_LOGS" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "No update sections found in UPDATELOG.md"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "UPDATELOG.md file not found"
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Set Env
|
||||||
|
run: |
|
||||||
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
if [ -z "$UPDATE_LOGS" ]; then
|
||||||
|
echo "No update logs found, using default message"
|
||||||
|
UPDATE_LOGS="More new features are now supported. Check for detailed changelog soon."
|
||||||
|
else
|
||||||
|
echo "Using found update logs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > release.txt << EOF
|
||||||
|
$UPDATE_LOGS
|
||||||
|
|
||||||
|
## Which version should I download?
|
||||||
|
|
||||||
|
### MacOS
|
||||||
|
- MacOS Intel Chip: x64.dmg
|
||||||
|
- MacOS Apple M Chip: aarch64.dmg
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
- Linux 64-bit: amd64.deb/amd64.rpm
|
||||||
|
- Linux arm64: arm64.deb/aarch64.rpm
|
||||||
|
- Linux armv7: armhf.deb/armhfp.rpm
|
||||||
|
|
||||||
|
### Windows (Win7 is no longer supported)
|
||||||
|
#### Normal version (recommended)
|
||||||
|
- 64-bit: x64-setup.exe
|
||||||
|
- arm64: arm64-setup.exe
|
||||||
|
#### Portable version is no longer available with many problems
|
||||||
|
#### Built-in Webview version 2 (large size, only used in enterprise version of the system or can not install webview2)
|
||||||
|
- 64-bit: x64_fixed_webview2-setup.exe
|
||||||
|
- arm64: arm64_fixed_webview2-setup.exe
|
||||||
|
|
||||||
|
Created at ${{ env.BUILDTIME }}.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
|
body_path: release.txt
|
||||||
|
prerelease: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
generate_release_notes: true
|
||||||
|
|
||||||
|
clean_old_assets:
|
||||||
|
name: Clean Old Release Assets
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: update_tag
|
||||||
|
if: ${{ needs.update_tag.result == 'success' }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Remove old assets from release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
TAG_NAME: ${{ env.TAG_NAME }}
|
||||||
|
run: |
|
||||||
|
VERSION=$(cat package.json | jq -r '.version')
|
||||||
|
assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true)
|
||||||
|
for asset in $assets; do
|
||||||
|
if [[ "$asset" != *"$VERSION"* ]]; then
|
||||||
|
echo "Deleting old asset: $asset"
|
||||||
|
gh release delete-asset "$TAG_NAME" "$asset" -y
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
autobuild-x86-windows-macos-linux:
|
||||||
|
name: Autobuild x86 Windows, MacOS and Linux
|
||||||
|
needs: update_tag
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
- os: windows-latest
|
||||||
|
target: aarch64-pc-windows-msvc
|
||||||
|
- os: macos-latest
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
- os: macos-latest
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust Stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
cache-all-crates: true
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
|
||||||
|
- name: Install dependencies (ubuntu only)
|
||||||
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
name: Install pnpm
|
||||||
|
with:
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Pnpm install and check
|
||||||
|
run: |
|
||||||
|
pnpm i
|
||||||
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
|
run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
|
- name: Tauri build
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
with:
|
||||||
|
tagName: ${{ env.TAG_NAME }}
|
||||||
|
releaseName: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
|
releaseBody: "More new features are now supported."
|
||||||
|
releaseDraft: false
|
||||||
|
prerelease: true
|
||||||
|
tauriScript: pnpm
|
||||||
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
|
autobuild-arm-linux:
|
||||||
|
name: Autobuild ARM Linux
|
||||||
|
needs: update_tag
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
arch: arm64
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
target: armv7-unknown-linux-gnueabihf
|
||||||
|
arch: armhf
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust Stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
cache-all-crates: true
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Pnpm install and check
|
||||||
|
run: |
|
||||||
|
pnpm i
|
||||||
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
|
run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
|
- name: Setup for linux
|
||||||
|
run: |
|
||||||
|
sudo ls -lR /etc/apt/
|
||||||
|
|
||||||
|
cat > /tmp/sources.list << EOF
|
||||||
|
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy main multiverse universe restricted
|
||||||
|
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-security main multiverse universe restricted
|
||||||
|
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse universe restricted
|
||||||
|
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse universe restricted
|
||||||
|
|
||||||
|
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main multiverse universe restricted
|
||||||
|
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main multiverse universe restricted
|
||||||
|
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main multiverse universe restricted
|
||||||
|
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main multiverse universe restricted
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo mv /etc/apt/sources.list /etc/apt/sources.list.default
|
||||||
|
sudo mv /tmp/sources.list /etc/apt/sources.list
|
||||||
|
|
||||||
|
sudo dpkg --add-architecture ${{ matrix.arch }}
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get -f install -y
|
||||||
|
|
||||||
|
sudo apt-get install -y \
|
||||||
|
linux-libc-dev:${{ matrix.arch }} \
|
||||||
|
libc6-dev:${{ matrix.arch }}
|
||||||
|
|
||||||
|
sudo apt-get install -y \
|
||||||
|
libxslt1.1:${{ matrix.arch }} \
|
||||||
|
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
|
||||||
|
libayatana-appindicator3-dev:${{ matrix.arch }} \
|
||||||
|
libssl-dev:${{ matrix.arch }} \
|
||||||
|
patchelf:${{ matrix.arch }} \
|
||||||
|
librsvg2-dev:${{ matrix.arch }}
|
||||||
|
|
||||||
|
- name: Install aarch64 tools
|
||||||
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||||
|
run: |
|
||||||
|
sudo apt install -y \
|
||||||
|
gcc-aarch64-linux-gnu \
|
||||||
|
g++-aarch64-linux-gnu
|
||||||
|
|
||||||
|
- name: Install armv7 tools
|
||||||
|
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
|
||||||
|
run: |
|
||||||
|
sudo apt install -y \
|
||||||
|
gcc-arm-linux-gnueabihf \
|
||||||
|
g++-arm-linux-gnueabihf
|
||||||
|
|
||||||
|
- name: Build for Linux
|
||||||
|
run: |
|
||||||
|
export PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
if [ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]; then
|
||||||
|
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
|
||||||
|
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
|
||||||
|
elif [ "${{ matrix.target }}" == "armv7-unknown-linux-gnueabihf" ]; then
|
||||||
|
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:$PKG_CONFIG_PATH
|
||||||
|
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
|
||||||
|
fi
|
||||||
|
pnpm build --target ${{ matrix.target }}
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Get Version
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install jq
|
||||||
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
|
prerelease: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: |
|
||||||
|
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
|
autobuild-x86-arm-windows_webview2:
|
||||||
|
name: Autobuild x86 and ARM Windows with WebView2
|
||||||
|
needs: update_tag
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
arch: x64
|
||||||
|
- os: windows-latest
|
||||||
|
target: aarch64-pc-windows-msvc
|
||||||
|
arch: arm64
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
cache-all-crates: true
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Pnpm install and check
|
||||||
|
run: |
|
||||||
|
pnpm i
|
||||||
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Release ${{ env.TAG_CHANNEL }} Version
|
||||||
|
run: pnpm release-version ${{ env.TAG_NAME }}
|
||||||
|
|
||||||
|
- name: Download WebView2 Runtime
|
||||||
|
run: |
|
||||||
|
invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/109.0.1518.78/Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab
|
||||||
|
Expand .\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -F:* ./src-tauri
|
||||||
|
Remove-Item .\src-tauri\tauri.windows.conf.json
|
||||||
|
Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json
|
||||||
|
|
||||||
|
- name: Tauri build
|
||||||
|
id: build
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
with:
|
||||||
|
tauriScript: pnpm
|
||||||
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rename
|
||||||
|
run: |
|
||||||
|
$files = Get-ChildItem ".\src-tauri\target\${{ matrix.target }}\release\bundle\nsis\*-setup.exe"
|
||||||
|
foreach ($file in $files) {
|
||||||
|
$newName = $file.Name -replace "-setup\.exe$", "_fixed_webview2-setup.exe"
|
||||||
|
Rename-Item $file.FullName $newName
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = Get-ChildItem ".\src-tauri\target\${{ matrix.target }}\release\bundle\nsis\*.nsis.zip"
|
||||||
|
foreach ($file in $files) {
|
||||||
|
$newName = $file.Name -replace "-setup\.nsis\.zip$", "_fixed_webview2-setup.nsis.zip"
|
||||||
|
Rename-Item $file.FullName $newName
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = Get-ChildItem ".\src-tauri\target\${{ matrix.target }}\release\bundle\nsis\*-setup.exe.sig"
|
||||||
|
foreach ($file in $files) {
|
||||||
|
$newName = $file.Name -replace "-setup\.exe\.sig$", "_fixed_webview2-setup.exe.sig"
|
||||||
|
Rename-Item $file.FullName $newName
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
name: "Clash Verge Rev ${{ env.TAG_CHANNEL }}"
|
||||||
|
prerelease: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
||||||
|
|
||||||
|
- name: Portable Bundle
|
||||||
|
run: pnpm portable-fixed-webview2 ${{ matrix.target }} --${{ env.TAG_NAME }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
63
.github/workflows/clippy.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
name: Clippy Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clippy:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
- os: macos-latest
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust Stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
save-if: false
|
||||||
|
|
||||||
|
- name: Install dependencies (ubuntu only)
|
||||||
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Pnpm install and check
|
||||||
|
run: |
|
||||||
|
pnpm i
|
||||||
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Build Web Assets
|
||||||
|
run: pnpm run web:build
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
|
|
||||||
|
- name: Run Clippy
|
||||||
|
run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets --all-features -- -D warnings
|
||||||
64
.github/workflows/cross_check.yaml
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Cross Platform Cargo Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
# pull_request:
|
||||||
|
# push:
|
||||||
|
# branches: [main, dev]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cargo-check:
|
||||||
|
# Treat all Rust compiler warnings as errors
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: "-D warnings"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: macos-latest
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
- os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust Stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
name: Install pnpm
|
||||||
|
with:
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Pnpm install and check
|
||||||
|
run: |
|
||||||
|
pnpm i
|
||||||
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
save-if: false
|
||||||
|
|
||||||
|
- name: Cargo Check (deny warnings)
|
||||||
|
working-directory: src-tauri
|
||||||
|
run: |
|
||||||
|
cargo check --target ${{ matrix.target }} --workspace --all-features
|
||||||
5
.github/workflows/dev.yml
vendored
@@ -42,8 +42,7 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -58,7 +57,7 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Tauri build
|
- name: Tauri build
|
||||||
uses: tauri-apps/tauri-action@v0
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
|||||||
50
.github/workflows/fmt.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
name: Check Formatting
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rustfmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: install Rust stable and rustfmt
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt
|
||||||
|
|
||||||
|
- name: run cargo fmt
|
||||||
|
run: cargo fmt --manifest-path ./src-tauri/Cargo.toml --all -- --check
|
||||||
|
|
||||||
|
prettier:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "lts/*"
|
||||||
|
- run: corepack enable
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm format:check
|
||||||
|
|
||||||
|
# taplo:
|
||||||
|
# name: taplo (.toml files)
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# - name: install Rust stable
|
||||||
|
# uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
# - name: install taplo-cli
|
||||||
|
# uses: taiki-e/install-action@v2
|
||||||
|
# with:
|
||||||
|
# tool: taplo-cli
|
||||||
|
|
||||||
|
# - run: taplo fmt --check --diff
|
||||||
155
.github/workflows/release.yml
vendored
@@ -1,7 +1,16 @@
|
|||||||
name: Release Build
|
name: Release Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
# ! 为了避免重复发布版本,应当通过独特 git tag 触发。
|
||||||
|
# ! 不再使用 workflow_dispatch 触发。
|
||||||
|
# workflow_dispatch:
|
||||||
|
push:
|
||||||
|
# 应当限制在 main 分支上触发发布。
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
# 应当限制 v*.*.* 的 tag 触发发布。
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
@@ -12,7 +21,28 @@ concurrency:
|
|||||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check_tag_version:
|
||||||
|
name: Check Release Tag and package.json Version Consistency
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check tag and package.json version
|
||||||
|
run: |
|
||||||
|
TAG_REF="${GITHUB_REF##*/}"
|
||||||
|
echo "Current tag: $TAG_REF"
|
||||||
|
PKG_VERSION=$(jq -r .version package.json)
|
||||||
|
echo "package.json version: $PKG_VERSION"
|
||||||
|
if [[ "$TAG_REF" != "v$PKG_VERSION" ]]; then
|
||||||
|
echo "Tag ($TAG_REF) does not match package.json version (v$PKG_VERSION)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Tag and package.json version are consistent."
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
name: Release Build
|
||||||
|
needs: check_tag_version
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -43,14 +73,13 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.os == 'ubuntu-22.04'
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -65,7 +94,7 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Tauri build
|
- name: Tauri build
|
||||||
uses: tauri-apps/tauri-action@v0
|
uses: tauri-apps/tauri-action@v0
|
||||||
@@ -74,20 +103,14 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
|
||||||
with:
|
with:
|
||||||
tagName: v__VERSION__
|
tagName: v__VERSION__
|
||||||
releaseName: "Clash Verge Rev v__VERSION__"
|
releaseName: "Clash Verge Rev Lite v__VERSION__"
|
||||||
releaseBody: "More new features are now supported."
|
|
||||||
tauriScript: pnpm
|
tauriScript: pnpm
|
||||||
args: --target ${{ matrix.target }}
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
release-for-linux-arm:
|
release-for-linux-arm:
|
||||||
|
name: Release Build for Linux ARM
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -113,7 +136,7 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -128,7 +151,7 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: "Setup for linux"
|
- name: "Setup for linux"
|
||||||
run: |-
|
run: |-
|
||||||
@@ -153,6 +176,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
|
|
||||||
sudo apt install -y \
|
sudo apt install -y \
|
||||||
|
libxslt1.1:${{ matrix.arch }} \
|
||||||
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
|
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
|
||||||
libayatana-appindicator3-dev:${{ matrix.arch }} \
|
libayatana-appindicator3-dev:${{ matrix.arch }} \
|
||||||
libssl-dev:${{ matrix.arch }} \
|
libssl-dev:${{ matrix.arch }} \
|
||||||
@@ -194,20 +218,20 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install jq
|
sudo apt-get install jq
|
||||||
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
echo "BUILDTIME=$(TZ=Europe/Moscow date)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: v${{env.VERSION}}
|
tag_name: v${{env.VERSION}}
|
||||||
name: "Clash Verge Rev v${{env.VERSION}}"
|
name: "Clash Verge Rev Lite v${{env.VERSION}}"
|
||||||
body: "More new features are now supported."
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: |
|
files: |
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
release-for-fixed-webview2:
|
release-for-fixed-webview2:
|
||||||
|
name: Release Build for Fixed WebView2
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -230,8 +254,7 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
cache-all-crates: true
|
save-if: false
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -246,12 +269,12 @@ jobs:
|
|||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check ${{ matrix.target }}
|
pnpm run prebuild ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Download WebView2 Runtime
|
- name: Download WebView2 Runtime
|
||||||
run: |
|
run: |
|
||||||
invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/109.0.1518.78/Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab
|
invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/133.0.3065.92/Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab
|
||||||
Expand .\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -F:* ./src-tauri
|
Expand .\Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab -F:* ./src-tauri
|
||||||
Remove-Item .\src-tauri\tauri.windows.conf.json
|
Remove-Item .\src-tauri\tauri.windows.conf.json
|
||||||
Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json
|
Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json
|
||||||
|
|
||||||
@@ -291,8 +314,7 @@ jobs:
|
|||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: v${{steps.build.outputs.appVersion}}
|
tag_name: v${{steps.build.outputs.appVersion}}
|
||||||
name: "Clash Verge Rev v${{steps.build.outputs.appVersion}}"
|
name: "Clash Verge Rev Lite v${{steps.build.outputs.appVersion}}"
|
||||||
body: "More new features are now supported."
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
||||||
|
|
||||||
@@ -302,6 +324,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
release-update:
|
release-update:
|
||||||
|
name: Release Update
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [release, release-for-linux-arm]
|
needs: [release, release-for-linux-arm]
|
||||||
steps:
|
steps:
|
||||||
@@ -351,24 +374,84 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
submit-to-winget:
|
create_release_notes:
|
||||||
|
name: Create Release Notes
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [release-update]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
- name: Fetch UPDATE logs
|
||||||
|
id: fetch_update_logs
|
||||||
|
run: |
|
||||||
|
if [ -f "UPDATELOG.md" ]; then
|
||||||
|
UPDATE_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
|
||||||
|
if [ -n "$UPDATE_LOGS" ]; then
|
||||||
|
echo "Found update logs"
|
||||||
|
echo "UPDATE_LOGS<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$UPDATE_LOGS" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "No update sections found in UPDATELOG.md"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "UPDATELOG.md file not found"
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install jq
|
sudo apt-get install jq
|
||||||
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
- name: Submit to Winget
|
echo "BUILDTIME=$(TZ=Europe/Moscow date)" >> $GITHUB_ENV
|
||||||
uses: vedantmgoyal9/winget-releaser@main
|
|
||||||
|
- run: |
|
||||||
|
if [ -z "$UPDATE_LOGS" ]; then
|
||||||
|
echo "No update logs found, using default message"
|
||||||
|
UPDATE_LOGS="More new features are now supported. Check for detailed changelog soon."
|
||||||
|
else
|
||||||
|
echo "Using found update logs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > release.txt << EOF
|
||||||
|
$UPDATE_LOGS
|
||||||
|
|
||||||
|
## Which version should I download?
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_aarch64.dmg"><img src="https://img.shields.io/badge/DMG-default?style=flat&logo=apple&label=Apple%20Silicon"></a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64.dmg"><img src="https://img.shields.io/badge/DMG-default?style=flat&logo=apple&label=Intel"></a><br>
|
||||||
|
> :warning: **Warning**
|
||||||
|
If you get a notification that the application is corrupted when you run it on macOS, run this command:<br>
|
||||||
|
`sudo xattr -r -c /Applications/Clash\ Verge\ Rev\ Lite.app`
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_amd64.deb"><img src="https://img.shields.io/badge/x64-default?style=flat&logo=debian&label=DEB"> </a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.x86_64.rpm"><img src="https://img.shields.io/badge/x64-default?style=flat&logo=fedora&label=RPM"> </a>
|
||||||
|
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64.deb"><img src="https://img.shields.io/badge/arm64-default?style=flat&logo=debian&label=DEB"> </a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.aarch64.rpm"><img src="https://img.shields.io/badge/aarch64-default?style=flat&logo=fedora&label=RPM"> </a>
|
||||||
|
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_armhf.deb"><img src="https://img.shields.io/badge/armhf-default?style=flat&logo=debian&label=DEB"> </a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.armhfp.rpm"><img src="https://img.shields.io/badge/armhfp-default?style=flat&logo=fedora&label=RPM"> </a>
|
||||||
|
|
||||||
|
### Windows (Win7 is no longer supported)
|
||||||
|
#### Normal version (recommended)
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64-setup.exe"><img src="https://badgen.net/badge/icon/x64?icon=windows&label=exe"></a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64-setup.exe"><img src="https://badgen.net/badge/icon/arm64?icon=windows&label=exe"></a>
|
||||||
|
#### Portable version is no longer available with many problems
|
||||||
|
#### Built-in Webview version 2 (large size, only used in enterprise version of the system or can not install webview2)
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64_fixed_webview2-setup.exe"><img src="https://badgen.net/badge/icon/x64?icon=windows&label=exe"></a><br>
|
||||||
|
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64_fixed_webview2-setup.exe"><img src="https://badgen.net/badge/icon/arm64?icon=windows&label=exe"></a>
|
||||||
|
|
||||||
|
Created at ${{ env.BUILDTIME }}.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
identifier: ClashVergeRev.ClashVergeRev
|
tag_name: v${{env.VERSION}}
|
||||||
version: ${{env.VERSION}}
|
name: "Clash Verge Rev Lite v${{env.VERSION}}"
|
||||||
release-tag: v${{env.VERSION}}
|
body_path: release.txt
|
||||||
installers-regex: '_(arm64|x64|x86)-setup\.exe$'
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
token: ${{ secrets.WINGET_TOKEN }}
|
|
||||||
|
|||||||
1
.gitignore
vendored
@@ -9,3 +9,4 @@ scripts/_env.sh
|
|||||||
.vscode
|
.vscode
|
||||||
.tool-versions
|
.tool-versions
|
||||||
.idea
|
.idea
|
||||||
|
.old
|
||||||
|
|||||||
@@ -1 +1,26 @@
|
|||||||
pnpm pretty-quick --staged
|
#!/bin/bash
|
||||||
|
|
||||||
|
#pnpm pretty-quick --staged
|
||||||
|
|
||||||
|
if git diff --cached --name-only | grep -q '^src/'; then
|
||||||
|
pnpm format:check
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Code format check failed in src/. Please fix formatting issues."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if git diff --cached --name-only | grep -q '^src-tauri/'; then
|
||||||
|
cd src-tauri
|
||||||
|
cargo fmt
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "rustfmt failed to format the code. Please fix the issues and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
#git add .
|
||||||
|
|
||||||
|
# 允许提交
|
||||||
|
exit 0
|
||||||
|
|||||||
28
.husky/pre-push
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1: remote name (e.g., origin)
|
||||||
|
# $2: remote url (e.g., git@github.com:clash-verge-rev/clash-verge-rev.git)
|
||||||
|
|
||||||
|
if git diff --cached --name-only | grep -q '^src-tauri/'; then
|
||||||
|
cargo clippy --manifest-path ./src-tauri/Cargo.toml
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Clippy found issues in src-tauri. Please fix them before pushing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 只在 push 到 origin 并且 origin 指向目标仓库时执行格式检查
|
||||||
|
if [ "$1" = "origin" ] && echo "$2" | grep -Eq 'github\.com[:/]+clash-verge-rev/clash-verge-rev(\.git)?$'; then
|
||||||
|
echo "[pre-push] Detected push to origin (clash-verge-rev/clash-verge-rev)"
|
||||||
|
echo "[pre-push] Running pnpm format:check..."
|
||||||
|
|
||||||
|
pnpm format:check
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ Code format check failed. Please fix formatting before pushing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[pre-push] Not pushing to target repo. Skipping format check."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
8
.prettierignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# README.md
|
||||||
|
# UPDATELOG.md
|
||||||
|
# CONTRIBUTING.md
|
||||||
|
|
||||||
|
pnpm-lock.yaml
|
||||||
|
|
||||||
|
src-tauri/target/
|
||||||
|
src-tauri/gen/
|
||||||
16
.prettierrc
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": false,
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"proseWrap": "preserve",
|
||||||
|
"htmlWhitespaceSensitivity": "css",
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"embeddedLanguageFormatting": "auto"
|
||||||
|
}
|
||||||
@@ -34,19 +34,27 @@ npm install pnpm -g
|
|||||||
|
|
||||||
### Install Dependencies
|
### Install Dependencies
|
||||||
|
|
||||||
|
Install node packages
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Install apt packages ONLY for Ubuntu
|
||||||
|
|
||||||
|
```shell
|
||||||
|
apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
```
|
||||||
|
|
||||||
### Download the Mihomo Core Binary
|
### Download the Mihomo Core Binary
|
||||||
|
|
||||||
You have two options for downloading the clash binary:
|
You have two options for downloading the clash binary:
|
||||||
|
|
||||||
- Automatically download it via the provided script:
|
- Automatically download it via the provided script:
|
||||||
```shell
|
```shell
|
||||||
pnpm run check
|
pnpm run prebuild
|
||||||
# Use '--force' to force update to the latest version
|
# Use '--force' to force update to the latest version
|
||||||
# pnpm run check --force
|
# pnpm run prebuild --force
|
||||||
```
|
```
|
||||||
- Manually download it from the [Mihomo release](https://github.com/MetaCubeX/mihomo/releases). After downloading, rename the binary according to the [Tauri configuration](https://tauri.app/v1/api/config#bundleconfig.externalbin).
|
- Manually download it from the [Mihomo release](https://github.com/MetaCubeX/mihomo/releases). After downloading, rename the binary according to the [Tauri configuration](https://tauri.app/v1/api/config#bundleconfig.externalbin).
|
||||||
|
|
||||||
@@ -96,6 +104,29 @@ pnpm portable
|
|||||||
|
|
||||||
## Contributing Your Changes
|
## Contributing Your Changes
|
||||||
|
|
||||||
|
#### Before commit your changes
|
||||||
|
|
||||||
|
If you changed the rust code, it's recommanded to execute code style formatting and quailty checks.
|
||||||
|
|
||||||
|
1. Code quailty checks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For rust backend
|
||||||
|
$ clash-verge-rev: pnpm clippy
|
||||||
|
# For frontend (not yet).
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Code style formatting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For rust backend
|
||||||
|
$ clash-verge-rev: cd src-tauri
|
||||||
|
$ clash-verge-rev/src-tauri: cargo fmt
|
||||||
|
# For frontend
|
||||||
|
$ clash-verge-rev: pnpm format:check
|
||||||
|
$ clash-verge-rev: pnpm format
|
||||||
|
```
|
||||||
|
|
||||||
Once you have made your changes:
|
Once you have made your changes:
|
||||||
|
|
||||||
1. Fork the repository.
|
1. Fork the repository.
|
||||||
|
|||||||
53
README.md
@@ -1,7 +1,7 @@
|
|||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
<img src="./src-tauri/icons/icon.png" alt="Clash" width="128" />
|
<img src="./src-tauri/icons/icon.png" alt="Clash" width="128" />
|
||||||
<br>
|
<br>
|
||||||
Continuation of <a href="https://github.com/zzzgydi/clash-verge">Clash Verge</a>
|
Fork of <a href="https://github.com/clash-verge-rev/clash-verge-rev">Clash Verge Rev</a>
|
||||||
<br>
|
<br>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
@@ -11,53 +11,26 @@ A Clash Meta GUI based on <a href="https://github.com/tauri-apps/tauri">Tauri</a
|
|||||||
|
|
||||||
## Preview
|
## Preview
|
||||||
|
|
||||||
| Dark | Light |
|
| Dark | Light |
|
||||||
| -------------------------------- | --------------------------------- |
|
| ----------------------------------- | ------------------------------------ |
|
||||||
|  |  |
|
|  |  |
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
请到发布页面下载对应的安装包:[Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases)<br>
|
Go to the [Release page](https://github.com/coolcoala/clash-verge-rev-lite/releases) to download the corresponding installation package<br>
|
||||||
Go to the [release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package<br>
|
|
||||||
Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple).
|
Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple).
|
||||||
|
|
||||||
### 安装说明和常见问题,请到[文档页](https://clash-verge-rev.github.io/)查看:[Doc](https://clash-verge-rev.github.io/)
|
### Telegram channel: ---
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### TG 频道: [@clash_verge_rev](https://t.me/clash_verge_re)
|
|
||||||
|
|
||||||
## Promotion
|
|
||||||
|
|
||||||
[狗狗加速 —— 技术流机场 Doggygo VPN](https://verge.dginv.click/#/register?code=oaxsAGo6)
|
|
||||||
|
|
||||||
- 高性能海外机场,免费试用,优惠套餐,解锁流媒体,全球首家支持 Hysteria 协议。
|
|
||||||
- 使用 Clash Verge 专属邀请链接注册送 3 天,每天 1G 流量免费试用:[点此注册](https://verge.dginv.click/#/register?code=oaxsAGo6)
|
|
||||||
- Clash Verge 专属 8 折优惠码: verge20 (仅有 500 份)
|
|
||||||
- 优惠套餐每月仅需 15.8 元,160G 流量,年付 8 折
|
|
||||||
- 海外团队,无跑路风险,高达 50% 返佣
|
|
||||||
- 集群负载均衡设计,高速专线(兼容老客户端),极低延迟,无视晚高峰,4K 秒开
|
|
||||||
- 全球首家 Hysteria 协议机场,现已上线更快的 `Hysteria2` 协议(Clash Verge 客户端最佳搭配)
|
|
||||||
- 解锁流媒体及 ChatGPT
|
|
||||||
- 官网:[https://狗狗加速.com](https://verge.dginv.click/#/register?code=oaxsAGo6)
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 基于性能强劲的 Rust 和 Tauri 2 框架
|
- Based on the powerful Rust and Tauri 2 frameworks.
|
||||||
- 内置[Clash.Meta(mihomo)](https://github.com/MetaCubeX/mihomo)内核,并支持切换 `Alpha` 版本内核。
|
- Built-in [Clash.Meta(mihomo)](https://github.com/MetaCubeX/mihomo) kernel with support for switching between `Alpha` versions of the kernel.
|
||||||
- 简洁美观的用户界面,支持自定义主题颜色、代理组/托盘图标以及 `CSS Injection`。
|
- Simple and beautiful user interface with support for custom theme colors, agent group/tray icons, and `CSS Injection`.
|
||||||
- 配置文件管理和增强(Merge 和 Script),配置文件语法提示。
|
- Configuration file management, configuration file syntax hints.
|
||||||
- 系统代理和守卫、`TUN(虚拟网卡)` 模式。
|
- System Agent and Guard, `TUN (Virtual NIC)` mode.
|
||||||
- 可视化节点和规则编辑
|
- Visual node and rule editing
|
||||||
- WebDav 配置备份和同步
|
- WebDav configuration backup and synchronization
|
||||||
|
|
||||||
### FAQ
|
|
||||||
|
|
||||||
Refer to [Doc FAQ Page](https://clash-verge-rev.github.io/faq/windows.html)
|
|
||||||
|
|
||||||
### Donation
|
|
||||||
|
|
||||||
[捐助Clash Verge Rev的开发](https://github.com/sponsors/clash-verge-rev)
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|||||||
1429
UPDATELOG.md
21
components.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://ui.shadcn.com/schema.json",
|
||||||
|
"style": "new-york",
|
||||||
|
"rsc": false,
|
||||||
|
"tsx": true,
|
||||||
|
"tailwind": {
|
||||||
|
"config": "",
|
||||||
|
"css": "src/index.css",
|
||||||
|
"baseColor": "slate",
|
||||||
|
"cssVariables": true,
|
||||||
|
"prefix": ""
|
||||||
|
},
|
||||||
|
"aliases": {
|
||||||
|
"components": "@root/src/components",
|
||||||
|
"utils": "@root/lib/utils",
|
||||||
|
"ui": "@root/src/components/ui",
|
||||||
|
"lib": "@root/lib",
|
||||||
|
"hooks": "@root/hooks"
|
||||||
|
},
|
||||||
|
"iconLibrary": "lucide"
|
||||||
|
}
|
||||||
4
crowdin.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
files:
|
||||||
|
- source: /src/locales/en.json
|
||||||
|
translation: /src/locales
|
||||||
|
multilingual: 1
|
||||||
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 712 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 671 KiB |
19
hooks/use-mobile.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
const MOBILE_BREAKPOINT = 768
|
||||||
|
|
||||||
|
export function useIsMobile() {
|
||||||
|
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||||
|
const onChange = () => {
|
||||||
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||||
|
}
|
||||||
|
mql.addEventListener("change", onChange)
|
||||||
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||||
|
return () => mql.removeEventListener("change", onChange)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return !!isMobile
|
||||||
|
}
|
||||||
6
lib/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { clsx, type ClassValue } from "clsx";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(inputs));
|
||||||
|
}
|
||||||
146
package.json
@@ -1,24 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "clash-verge",
|
"name": "clash-verge",
|
||||||
"version": "2.1.3-alpha",
|
"version": "0.2.2",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev -- --profile fast-dev",
|
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
|
||||||
"dev:diff": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev -- --profile fast-dev",
|
"dev:diff": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
|
||||||
"build": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tauri build",
|
"build": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tauri build",
|
||||||
"build:fast": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tauri build -- --profile fast-release",
|
"build:fast": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tauri build -- --profile fast-release",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"web:dev": "vite",
|
"web:dev": "vite",
|
||||||
"web:build": "tsc --noEmit && vite build",
|
"web:build": "tsc --noEmit && vite build",
|
||||||
"web:serve": "vite preview",
|
"web:serve": "vite preview",
|
||||||
"check": "node scripts/check.mjs",
|
"prebuild": "node scripts/prebuild.mjs",
|
||||||
"updater": "node scripts/updater.mjs",
|
"updater": "node scripts/updater.mjs",
|
||||||
"updater-fixed-webview2": "node scripts/updater-fixed-webview2.mjs",
|
"updater-fixed-webview2": "node scripts/updater-fixed-webview2.mjs",
|
||||||
"portable": "node scripts/portable.mjs",
|
"portable": "node scripts/portable.mjs",
|
||||||
"portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs",
|
"portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs",
|
||||||
"fix-alpha-version": "node scripts/alpha_version.mjs",
|
"fix-alpha-version": "node scripts/fix-alpha_version.mjs",
|
||||||
"prepare": "husky",
|
"release-version": "node scripts/release-version.mjs",
|
||||||
"clean": "cd ./src-tauri && cargo clean && cd -"
|
"publish-version": "node scripts/publish-version.mjs",
|
||||||
|
"fmt": "cargo fmt --manifest-path ./src-tauri/Cargo.toml",
|
||||||
|
"clippy": "cargo clippy --manifest-path ./src-tauri/Cargo.toml",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"format:check": "prettier --check ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
@@ -26,74 +30,108 @@
|
|||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
|
"@hookform/resolvers": "^5.1.1",
|
||||||
"@juggle/resize-observer": "^3.4.0",
|
"@juggle/resize-observer": "^3.4.0",
|
||||||
"@mui/icons-material": "^6.4.2",
|
"@mui/icons-material": "^7.1.1",
|
||||||
"@mui/lab": "6.0.0-beta.25",
|
"@mui/lab": "7.0.0-beta.13",
|
||||||
"@mui/material": "^6.4.2",
|
"@mui/material": "^7.1.1",
|
||||||
"@mui/x-data-grid": "^7.25.0",
|
"@mui/x-data-grid": "^8.5.1",
|
||||||
"@tauri-apps/api": "2.2.0",
|
"@radix-ui/react-alert-dialog": "^1.1.14",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "^2.2.1",
|
"@radix-ui/react-context-menu": "^2.2.15",
|
||||||
"@tauri-apps/plugin-dialog": "^2.2.0",
|
"@radix-ui/react-dialog": "^1.1.14",
|
||||||
"@tauri-apps/plugin-fs": "^2.2.0",
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||||
"@tauri-apps/plugin-global-shortcut": "^2.2.0",
|
"@radix-ui/react-icons": "^1.3.2",
|
||||||
"@tauri-apps/plugin-notification": "^2.2.1",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@tauri-apps/plugin-process": "^2.2.0",
|
"@radix-ui/react-popover": "^1.1.14",
|
||||||
"@tauri-apps/plugin-shell": "2.2.0",
|
"@radix-ui/react-progress": "^1.1.7",
|
||||||
"@tauri-apps/plugin-updater": "2.3.0",
|
"@radix-ui/react-select": "^2.2.5",
|
||||||
|
"@radix-ui/react-separator": "^1.1.7",
|
||||||
|
"@radix-ui/react-slot": "^1.2.3",
|
||||||
|
"@radix-ui/react-switch": "^1.2.5",
|
||||||
|
"@radix-ui/react-tooltip": "^1.2.7",
|
||||||
|
"@tailwindcss/vite": "^4.1.11",
|
||||||
|
"@tanstack/react-table": "^8.21.3",
|
||||||
|
"@tauri-apps/api": "2.5.0",
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": "^2.2.2",
|
||||||
|
"@tauri-apps/plugin-dialog": "^2.2.2",
|
||||||
|
"@tauri-apps/plugin-fs": "^2.3.0",
|
||||||
|
"@tauri-apps/plugin-global-shortcut": "^2.2.1",
|
||||||
|
"@tauri-apps/plugin-notification": "^2.2.2",
|
||||||
|
"@tauri-apps/plugin-process": "^2.2.1",
|
||||||
|
"@tauri-apps/plugin-shell": "2.2.1",
|
||||||
|
"@tauri-apps/plugin-updater": "2.7.1",
|
||||||
|
"@tauri-apps/plugin-window-state": "^2.2.2",
|
||||||
|
"@types/d3-shape": "^3.1.7",
|
||||||
"@types/json-schema": "^7.0.15",
|
"@types/json-schema": "^7.0.15",
|
||||||
"ahooks": "^3.8.4",
|
"ahooks": "^3.8.5",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.9.0",
|
||||||
|
"chart.js": "^4.4.9",
|
||||||
|
"class-variance-authority": "^0.7.1",
|
||||||
"cli-color": "^2.0.4",
|
"cli-color": "^2.0.4",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"cmdk": "^1.1.1",
|
||||||
|
"d3-shape": "^3.2.0",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"foxact": "^0.2.43",
|
"foxact": "^0.2.45",
|
||||||
"glob": "^11.0.1",
|
"glob": "^11.0.2",
|
||||||
"i18next": "^24.2.2",
|
"i18next": "^25.2.1",
|
||||||
"js-base64": "^3.7.7",
|
"js-base64": "^3.7.7",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
"lucide-react": "^0.514.0",
|
||||||
"monaco-editor": "^0.52.2",
|
"monaco-editor": "^0.52.2",
|
||||||
"monaco-yaml": "^5.2.3",
|
"monaco-yaml": "^5.4.0",
|
||||||
"nanoid": "^5.0.9",
|
"nanoid": "^5.1.5",
|
||||||
"peggy": "^4.2.0",
|
"next-themes": "^0.4.6",
|
||||||
"react": "^18.3.1",
|
"peggy": "^5.0.3",
|
||||||
"react-dom": "^18.3.1",
|
"react": "19.1.0",
|
||||||
"react-error-boundary": "^4.0.12",
|
"react-chartjs-2": "^5.3.0",
|
||||||
"react-hook-form": "^7.54.2",
|
"react-colorful": "^5.6.1",
|
||||||
"react-i18next": "^13.5.0",
|
"react-dom": "19.1.0",
|
||||||
"react-markdown": "^9.0.1",
|
"react-error-boundary": "6.0.0",
|
||||||
"react-monaco-editor": "^0.56.0",
|
"react-hook-form": "^7.57.0",
|
||||||
"react-router-dom": "^6.22.3",
|
"react-i18next": "15.5.2",
|
||||||
"react-transition-group": "^4.4.5",
|
"react-markdown": "10.1.0",
|
||||||
"react-virtuoso": "^4.6.3",
|
"react-monaco-editor": "0.58.0",
|
||||||
|
"react-router-dom": "7.6.2",
|
||||||
|
"react-virtuoso": "^4.12.8",
|
||||||
"sockette": "^2.0.6",
|
"sockette": "^2.0.6",
|
||||||
"swr": "^2.3.0",
|
"sonner": "^2.0.5",
|
||||||
|
"swr": "^2.3.3",
|
||||||
|
"tailwind-merge": "^3.3.1",
|
||||||
"tar": "^7.4.3",
|
"tar": "^7.4.3",
|
||||||
"types-pac": "^1.0.3",
|
"types-pac": "^1.0.3",
|
||||||
"zustand": "^5.0.3"
|
"zod": "^3.25.67",
|
||||||
|
"zustand": "^5.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.1",
|
||||||
"@tauri-apps/cli": "2.2.7",
|
"@tauri-apps/cli": "2.5.0",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/react": "^18.3.18",
|
"@types/node": "^24.0.0",
|
||||||
"@types/react-dom": "^18.3.5",
|
"@types/react": "19.1.6",
|
||||||
"@types/react-transition-group": "^4.4.12",
|
"@types/react-dom": "19.1.6",
|
||||||
"@vitejs/plugin-legacy": "^6.0.0",
|
"@vitejs/plugin-legacy": "^6.1.1",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "4.5.1",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
|
"autoprefixer": "^10.4.21",
|
||||||
|
"commander": "^14.0.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"https-proxy-agent": "^7.0.6",
|
"https-proxy-agent": "^7.0.6",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"meta-json-schema": "^1.19.1",
|
"meta-json-schema": "^1.19.10",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"prettier": "^3.4.2",
|
"postcss": "^8.5.4",
|
||||||
"pretty-quick": "^4.0.0",
|
"prettier": "^3.5.3",
|
||||||
"sass": "^1.83.4",
|
"pretty-quick": "^4.2.2",
|
||||||
"terser": "^5.37.0",
|
"sass": "^1.89.1",
|
||||||
"typescript": "^5.7.3",
|
"tailwindcss": "^4.1.11",
|
||||||
"vite": "^6.0.11",
|
"terser": "^5.41.0",
|
||||||
|
"tw-animate-css": "^1.3.4",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"vite": "^6.3.5",
|
||||||
"vite-plugin-monaco-editor": "^1.1.0",
|
"vite-plugin-monaco-editor": "^1.1.0",
|
||||||
"vite-plugin-svgr": "^4.3.0"
|
"vite-plugin-svgr": "^4.3.0"
|
||||||
},
|
},
|
||||||
|
|||||||
9674
pnpm-lock.yaml
generated
42
renovate.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"extends": ["config:recommended"],
|
||||||
|
"baseBranches": ["dev"],
|
||||||
|
"enabledManagers": ["cargo", "npm"],
|
||||||
|
"labels": ["dependencies"],
|
||||||
|
"ignorePaths": [
|
||||||
|
"**/node_modules/**",
|
||||||
|
"**/bower_components/**",
|
||||||
|
"**/vendor/**",
|
||||||
|
"**/__tests__/**",
|
||||||
|
"**/test/**",
|
||||||
|
"**/tests/**",
|
||||||
|
"**/__fixtures__/**",
|
||||||
|
"**/crate/**",
|
||||||
|
"shared/**"
|
||||||
|
],
|
||||||
|
"rangeStrategy": "bump",
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"semanticCommitType": "chore",
|
||||||
|
"matchPackageNames": ["*"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Disable node/pnpm version updates",
|
||||||
|
"matchPackageNames": ["node", "pnpm"],
|
||||||
|
"matchDepTypes": ["engines", "packageManager"],
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Group all cargo dependencies into a single PR",
|
||||||
|
"matchManagers": ["cargo"],
|
||||||
|
"groupName": "cargo dependencies"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Group all npm dependencies into a single PR",
|
||||||
|
"matchManagers": ["npm"],
|
||||||
|
"groupName": "npm dependencies"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"postUpdateOptions": ["pnpmDedupe"],
|
||||||
|
"ignoreDeps": ["serde_yaml"]
|
||||||
|
}
|
||||||
102
scripts/check-unused-i18n.js
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const LOCALES_DIR = path.resolve(__dirname, "../src/locales");
|
||||||
|
const SRC_DIRS = [
|
||||||
|
path.resolve(__dirname, "../src"),
|
||||||
|
path.resolve(__dirname, "../src-tauri"),
|
||||||
|
];
|
||||||
|
const exts = [".js", ".ts", ".tsx", ".jsx", ".vue", ".rs"];
|
||||||
|
|
||||||
|
// 递归获取所有文件
|
||||||
|
function getAllFiles(dir, exts) {
|
||||||
|
let files = [];
|
||||||
|
fs.readdirSync(dir).forEach((file) => {
|
||||||
|
const full = path.join(dir, file);
|
||||||
|
if (fs.statSync(full).isDirectory()) {
|
||||||
|
files = files.concat(getAllFiles(full, exts));
|
||||||
|
} else if (exts.includes(path.extname(full))) {
|
||||||
|
files.push(full);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取所有源码内容为一个大字符串
|
||||||
|
function getAllSourceContent() {
|
||||||
|
const files = SRC_DIRS.flatMap((dir) => getAllFiles(dir, exts));
|
||||||
|
return files.map((f) => fs.readFileSync(f, "utf8")).join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 白名单 key,不检查这些 key 是否被使用
|
||||||
|
const WHITELIST_KEYS = [
|
||||||
|
"theme.light",
|
||||||
|
"theme.dark",
|
||||||
|
"theme.system",
|
||||||
|
"Already Using Latest Core Version",
|
||||||
|
];
|
||||||
|
|
||||||
|
// 主流程
|
||||||
|
function processI18nFile(i18nPath, lang, allSource) {
|
||||||
|
const i18n = JSON.parse(fs.readFileSync(i18nPath, "utf8"));
|
||||||
|
const keys = Object.keys(i18n);
|
||||||
|
|
||||||
|
const used = {};
|
||||||
|
const unused = [];
|
||||||
|
|
||||||
|
let checked = 0;
|
||||||
|
const total = keys.length;
|
||||||
|
keys.forEach((key) => {
|
||||||
|
if (WHITELIST_KEYS.includes(key)) {
|
||||||
|
used[key] = i18n[key];
|
||||||
|
} else {
|
||||||
|
// 只查找一次
|
||||||
|
const regex = new RegExp(`["'\`]${key}["'\`]`);
|
||||||
|
if (regex.test(allSource)) {
|
||||||
|
used[key] = i18n[key];
|
||||||
|
} else {
|
||||||
|
unused.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checked++;
|
||||||
|
if (checked % 20 === 0 || checked === total) {
|
||||||
|
const percent = ((checked / total) * 100).toFixed(1);
|
||||||
|
process.stdout.write(
|
||||||
|
`\r[${lang}] Progress: ${checked}/${total} (${percent}%)`,
|
||||||
|
);
|
||||||
|
if (checked === total) process.stdout.write("\n");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 输出未使用的 key
|
||||||
|
console.log(`\n[${lang}] Unused keys:`, unused);
|
||||||
|
|
||||||
|
// 备份原文件
|
||||||
|
const oldPath = i18nPath + ".old";
|
||||||
|
fs.renameSync(i18nPath, oldPath);
|
||||||
|
|
||||||
|
// 写入精简后的 i18n 文件(保留原文件名)
|
||||||
|
fs.writeFileSync(i18nPath, JSON.stringify(used, null, 2), "utf8");
|
||||||
|
console.log(
|
||||||
|
`[${lang}] Cleaned i18n file written to src/locales/${path.basename(i18nPath)}`,
|
||||||
|
);
|
||||||
|
console.log(`[${lang}] Original file backed up as ${path.basename(oldPath)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
// 支持 zhtw.json、zh-tw.json、zh_CN.json 等
|
||||||
|
const files = fs
|
||||||
|
.readdirSync(LOCALES_DIR)
|
||||||
|
.filter((f) => /^[a-z0-9\-_]+\.json$/i.test(f) && !f.endsWith(".old"));
|
||||||
|
const allSource = getAllSourceContent();
|
||||||
|
files.forEach((file) => {
|
||||||
|
const lang = path.basename(file, ".json");
|
||||||
|
processI18nFile(path.join(LOCALES_DIR, file), lang, allSource);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
@@ -38,6 +38,17 @@ async function updatePackageVersion(newVersion) {
|
|||||||
const packageJson = JSON.parse(data);
|
const packageJson = JSON.parse(data);
|
||||||
// 获取键值替换
|
// 获取键值替换
|
||||||
let result = packageJson.version.replace("alpha", newVersion);
|
let result = packageJson.version.replace("alpha", newVersion);
|
||||||
|
// 检查当前版本号是否已经包含了 alpha- 后缀
|
||||||
|
if (!packageJson.version.includes(`alpha-`)) {
|
||||||
|
// 如果只有 alpha 而没有 alpha-,则替换为 alpha-newVersion
|
||||||
|
result = packageJson.version.replace("alpha", `alpha-${newVersion}`);
|
||||||
|
} else {
|
||||||
|
// 如果已经是 alpha-xxx 格式,则更新 xxx 部分
|
||||||
|
result = packageJson.version.replace(
|
||||||
|
/alpha-[^-]*/,
|
||||||
|
`alpha-${newVersion}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
console.log("[INFO]: Current version is: ", result);
|
console.log("[INFO]: Current version is: ", result);
|
||||||
packageJson.version = result;
|
packageJson.version = result;
|
||||||
// 写入版本号
|
// 写入版本号
|
||||||
@@ -49,9 +49,9 @@ async function resolvePortable() {
|
|||||||
zip.addLocalFolder(
|
zip.addLocalFolder(
|
||||||
path.join(
|
path.join(
|
||||||
releaseDir,
|
releaseDir,
|
||||||
`Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${arch}`,
|
`Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${arch}`,
|
||||||
),
|
),
|
||||||
`Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${arch}`,
|
`Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${arch}`,
|
||||||
);
|
);
|
||||||
zip.addLocalFolder(configDir, ".config");
|
zip.addLocalFolder(configDir, ".config");
|
||||||
|
|
||||||
|
|||||||
66
scripts/publish-version.mjs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
// scripts/publish-version.mjs
|
||||||
|
import { spawn } from "child_process";
|
||||||
|
import { existsSync } from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
const rootDir = process.cwd();
|
||||||
|
const scriptPath = path.join(rootDir, "scripts", "release-version.mjs");
|
||||||
|
|
||||||
|
if (!existsSync(scriptPath)) {
|
||||||
|
console.error("release-version.mjs not found!");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionArg = process.argv[2];
|
||||||
|
if (!versionArg) {
|
||||||
|
console.error("Usage: pnpm publish-version <version>");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 调用 release-version.mjs
|
||||||
|
const runRelease = () =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const child = spawn("node", [scriptPath, versionArg], { stdio: "inherit" });
|
||||||
|
child.on("exit", (code) => {
|
||||||
|
if (code === 0) resolve();
|
||||||
|
else reject(new Error("release-version failed"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. 判断是否需要打 tag
|
||||||
|
function isSemver(version) {
|
||||||
|
return /^v?\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?$/.test(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
await runRelease();
|
||||||
|
|
||||||
|
let tag = null;
|
||||||
|
if (versionArg === "alpha") {
|
||||||
|
// 读取 package.json 里的主版本
|
||||||
|
const pkg = await import(path.join(rootDir, "package.json"), {
|
||||||
|
assert: { type: "json" },
|
||||||
|
});
|
||||||
|
tag = `v${pkg.default.version}-alpha`;
|
||||||
|
} else if (isSemver(versionArg)) {
|
||||||
|
// 1.2.3 或 v1.2.3
|
||||||
|
tag = versionArg.startsWith("v") ? versionArg : `v${versionArg}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag) {
|
||||||
|
// 打 tag 并推送
|
||||||
|
const { execSync } = await import("child_process");
|
||||||
|
try {
|
||||||
|
execSync(`git tag ${tag}`, { stdio: "inherit" });
|
||||||
|
execSync(`git push origin ${tag}`, { stdio: "inherit" });
|
||||||
|
console.log(`[INFO]: Git tag ${tag} created and pushed.`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`[ERROR]: Failed to create or push git tag: ${tag}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("[INFO]: No git tag created for this version.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
253
scripts/release-version.mjs
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
/**
|
||||||
|
* CLI tool to update version numbers in package.json, src-tauri/Cargo.toml, and src-tauri/tauri.conf.json.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* pnpm release-version <version>
|
||||||
|
*
|
||||||
|
* <version> can be:
|
||||||
|
* - A full semver version (e.g., 1.2.3, v1.2.3, 1.2.3-beta, v1.2.3+build)
|
||||||
|
* - A tag: "alpha", "beta", "rc", or "autobuild"
|
||||||
|
* - "alpha", "beta", "rc": Appends the tag to the current base version (e.g., 1.2.3-beta)
|
||||||
|
* - "autobuild": Appends a timestamped autobuild tag (e.g., 1.2.3+autobuild.2406101530)
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* pnpm release-version 1.2.3
|
||||||
|
* pnpm release-version v1.2.3-beta
|
||||||
|
* pnpm release-version beta
|
||||||
|
* pnpm release-version autobuild
|
||||||
|
*
|
||||||
|
* The script will:
|
||||||
|
* - Validate and normalize the version argument
|
||||||
|
* - Update the version field in package.json
|
||||||
|
* - Update the version field in src-tauri/Cargo.toml
|
||||||
|
* - Update the version field in src-tauri/tauri.conf.json
|
||||||
|
*
|
||||||
|
* Errors are logged and the process exits with code 1 on failure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from "fs/promises";
|
||||||
|
import path from "path";
|
||||||
|
import { program } from "commander";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前 git 短 commit hash
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function getGitShortCommit() {
|
||||||
|
try {
|
||||||
|
return execSync("git rev-parse --short HEAD").toString().trim();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("[WARN]: Failed to get git short commit, fallback to 'nogit'");
|
||||||
|
return "nogit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成短时间戳(格式:YYMMDD)或带 commit(格式:YYMMDD.cc39b27)
|
||||||
|
* @param {boolean} withCommit 是否带 commit
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function generateShortTimestamp(withCommit = false) {
|
||||||
|
const now = new Date();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(now.getDate()).padStart(2, "0");
|
||||||
|
if (withCommit) {
|
||||||
|
const gitShort = getGitShortCommit();
|
||||||
|
return `${month}${day}.${gitShort}`;
|
||||||
|
}
|
||||||
|
return `${month}${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证版本号格式
|
||||||
|
* @param {string} version
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
function isValidVersion(version) {
|
||||||
|
return /^v?\d+\.\d+\.\d+(-(alpha|beta|rc)(\.\d+)?)?(\+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$/i.test(
|
||||||
|
version,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准化版本号
|
||||||
|
* @param {string} version
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function normalizeVersion(version) {
|
||||||
|
return version.startsWith("v") ? version : `v${version}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取基础版本号(去掉所有 -tag 和 +build 部分)
|
||||||
|
* @param {string} version
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function getBaseVersion(version) {
|
||||||
|
let base = version.replace(/-(alpha|beta|rc)(\.\d+)?/i, "");
|
||||||
|
base = base.replace(/\+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*/g, "");
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新 package.json 版本号
|
||||||
|
* @param {string} newVersion
|
||||||
|
*/
|
||||||
|
async function updatePackageVersion(newVersion) {
|
||||||
|
const _dirname = process.cwd();
|
||||||
|
const packageJsonPath = path.join(_dirname, "package.json");
|
||||||
|
try {
|
||||||
|
const data = await fs.readFile(packageJsonPath, "utf8");
|
||||||
|
const packageJson = JSON.parse(data);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[INFO]: Current package.json version is: ",
|
||||||
|
packageJson.version,
|
||||||
|
);
|
||||||
|
packageJson.version = newVersion.startsWith("v")
|
||||||
|
? newVersion.slice(1)
|
||||||
|
: newVersion;
|
||||||
|
await fs.writeFile(
|
||||||
|
packageJsonPath,
|
||||||
|
JSON.stringify(packageJson, null, 2),
|
||||||
|
"utf8",
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`[INFO]: package.json version updated to: ${packageJson.version}`,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating package.json version:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新 Cargo.toml 版本号
|
||||||
|
* @param {string} newVersion
|
||||||
|
*/
|
||||||
|
async function updateCargoVersion(newVersion) {
|
||||||
|
const _dirname = process.cwd();
|
||||||
|
const cargoTomlPath = path.join(_dirname, "src-tauri", "Cargo.toml");
|
||||||
|
try {
|
||||||
|
const data = await fs.readFile(cargoTomlPath, "utf8");
|
||||||
|
const lines = data.split("\n");
|
||||||
|
const versionWithoutV = newVersion.startsWith("v")
|
||||||
|
? newVersion.slice(1)
|
||||||
|
: newVersion;
|
||||||
|
const baseVersion = getBaseVersion(versionWithoutV);
|
||||||
|
|
||||||
|
const updatedLines = lines.map((line) => {
|
||||||
|
if (line.trim().startsWith("version =")) {
|
||||||
|
return line.replace(
|
||||||
|
/version\s*=\s*"[^"]+"/,
|
||||||
|
`version = "${baseVersion}"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
});
|
||||||
|
|
||||||
|
await fs.writeFile(cargoTomlPath, updatedLines.join("\n"), "utf8");
|
||||||
|
console.log(`[INFO]: Cargo.toml version updated to: ${baseVersion}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating Cargo.toml version:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新 tauri.conf.json 版本号
|
||||||
|
* @param {string} newVersion
|
||||||
|
*/
|
||||||
|
async function updateTauriConfigVersion(newVersion) {
|
||||||
|
const _dirname = process.cwd();
|
||||||
|
const tauriConfigPath = path.join(_dirname, "src-tauri", "tauri.conf.json");
|
||||||
|
try {
|
||||||
|
const data = await fs.readFile(tauriConfigPath, "utf8");
|
||||||
|
const tauriConfig = JSON.parse(data);
|
||||||
|
const versionWithoutV = newVersion.startsWith("v")
|
||||||
|
? newVersion.slice(1)
|
||||||
|
: newVersion;
|
||||||
|
const baseVersion = getBaseVersion(versionWithoutV);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[INFO]: Current tauri.conf.json version is: ",
|
||||||
|
tauriConfig.version,
|
||||||
|
);
|
||||||
|
tauriConfig.version = baseVersion;
|
||||||
|
await fs.writeFile(
|
||||||
|
tauriConfigPath,
|
||||||
|
JSON.stringify(tauriConfig, null, 2),
|
||||||
|
"utf8",
|
||||||
|
);
|
||||||
|
console.log(`[INFO]: tauri.conf.json version updated to: ${baseVersion}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating tauri.conf.json version:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前版本号
|
||||||
|
*/
|
||||||
|
async function getCurrentVersion() {
|
||||||
|
const _dirname = process.cwd();
|
||||||
|
const packageJsonPath = path.join(_dirname, "package.json");
|
||||||
|
try {
|
||||||
|
const data = await fs.readFile(packageJsonPath, "utf8");
|
||||||
|
const packageJson = JSON.parse(data);
|
||||||
|
return packageJson.version;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error getting current version:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主函数
|
||||||
|
*/
|
||||||
|
async function main(versionArg) {
|
||||||
|
if (!versionArg) {
|
||||||
|
console.error("Error: Version argument is required");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let newVersion;
|
||||||
|
const validTags = ["alpha", "beta", "rc", "autobuild"];
|
||||||
|
|
||||||
|
if (validTags.includes(versionArg.toLowerCase())) {
|
||||||
|
const currentVersion = await getCurrentVersion();
|
||||||
|
const baseVersion = getBaseVersion(currentVersion);
|
||||||
|
|
||||||
|
if (versionArg.toLowerCase() === "autobuild") {
|
||||||
|
// 格式: 2.3.0+autobuild.250613.cc39b27
|
||||||
|
newVersion = `${baseVersion}+autobuild.${generateShortTimestamp(true)}`;
|
||||||
|
} else {
|
||||||
|
newVersion = `${baseVersion}-${versionArg.toLowerCase()}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!isValidVersion(versionArg)) {
|
||||||
|
console.error("Error: Invalid version format");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
newVersion = normalizeVersion(versionArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[INFO]: Updating versions to: ${newVersion}`);
|
||||||
|
await updatePackageVersion(newVersion);
|
||||||
|
await updateCargoVersion(newVersion);
|
||||||
|
await updateTauriConfigVersion(newVersion);
|
||||||
|
console.log("[SUCCESS]: All version updates completed successfully!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR]: Failed to update versions:", error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
program
|
||||||
|
.name("pnpm release-version")
|
||||||
|
.description("Update project version numbers")
|
||||||
|
.argument("<version>", "version tag or full version")
|
||||||
|
.action(main)
|
||||||
|
.parse(process.argv);
|
||||||
@@ -43,3 +43,42 @@ export async function resolveUpdateLog(tag) {
|
|||||||
|
|
||||||
return map[tag].join("\n").trim();
|
return map[tag].join("\n").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function resolveUpdateLogDefault() {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const file = path.join(cwd, UPDATE_LOG);
|
||||||
|
|
||||||
|
if (!fs.existsSync(file)) {
|
||||||
|
throw new Error("could not found UPDATELOG.md");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await fsp.readFile(file, "utf-8");
|
||||||
|
|
||||||
|
const reTitle = /^## v[\d\.]+/;
|
||||||
|
const reEnd = /^---/;
|
||||||
|
|
||||||
|
let isCapturing = false;
|
||||||
|
let content = [];
|
||||||
|
let firstTag = "";
|
||||||
|
|
||||||
|
for (const line of data.split("\n")) {
|
||||||
|
if (reTitle.test(line) && !isCapturing) {
|
||||||
|
isCapturing = true;
|
||||||
|
firstTag = line.slice(3).trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCapturing) {
|
||||||
|
if (reEnd.test(line)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
content.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!firstTag) {
|
||||||
|
throw new Error("could not found any version tag in UPDATELOG.md");
|
||||||
|
}
|
||||||
|
|
||||||
|
return content.join("\n").trim();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { getOctokit, context } from "@actions/github";
|
import { getOctokit, context } from "@actions/github";
|
||||||
import { resolveUpdateLog } from "./updatelog.mjs";
|
import { resolveUpdateLog, resolveUpdateLogDefault } from "./updatelog.mjs";
|
||||||
|
|
||||||
// Add stable update JSON filenames
|
// Add stable update JSON filenames
|
||||||
const UPDATE_TAG_NAME = "updater";
|
const UPDATE_TAG_NAME = "updater";
|
||||||
@@ -8,8 +8,8 @@ const UPDATE_JSON_FILE = "update.json";
|
|||||||
const UPDATE_JSON_PROXY = "update-proxy.json";
|
const UPDATE_JSON_PROXY = "update-proxy.json";
|
||||||
// Add alpha update JSON filenames
|
// Add alpha update JSON filenames
|
||||||
const ALPHA_TAG_NAME = "updater-alpha";
|
const ALPHA_TAG_NAME = "updater-alpha";
|
||||||
const ALPHA_UPDATE_JSON_FILE = "update-alpha.json";
|
const ALPHA_UPDATE_JSON_FILE = "update.json";
|
||||||
const ALPHA_UPDATE_JSON_PROXY = "update-alpha-proxy.json";
|
const ALPHA_UPDATE_JSON_PROXY = "update-proxy.json";
|
||||||
|
|
||||||
/// generate update.json
|
/// generate update.json
|
||||||
/// upload to update tag's release asset
|
/// upload to update tag's release asset
|
||||||
@@ -78,192 +78,235 @@ async function resolveUpdater() {
|
|||||||
async function processRelease(github, options, tag, isAlpha) {
|
async function processRelease(github, options, tag, isAlpha) {
|
||||||
if (!tag) return;
|
if (!tag) return;
|
||||||
|
|
||||||
const { data: release } = await github.rest.repos.getReleaseByTag({
|
|
||||||
...options,
|
|
||||||
tag: tag.name,
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateData = {
|
|
||||||
name: tag.name,
|
|
||||||
notes: await resolveUpdateLog(tag.name).catch(
|
|
||||||
() => "No changelog available",
|
|
||||||
),
|
|
||||||
pub_date: new Date().toISOString(),
|
|
||||||
platforms: {
|
|
||||||
win64: { signature: "", url: "" }, // compatible with older formats
|
|
||||||
linux: { signature: "", url: "" }, // compatible with older formats
|
|
||||||
darwin: { signature: "", url: "" }, // compatible with older formats
|
|
||||||
"darwin-aarch64": { signature: "", url: "" },
|
|
||||||
"darwin-intel": { signature: "", url: "" },
|
|
||||||
"darwin-x86_64": { signature: "", url: "" },
|
|
||||||
"linux-x86_64": { signature: "", url: "" },
|
|
||||||
"linux-x86": { signature: "", url: "" },
|
|
||||||
"linux-i686": { signature: "", url: "" },
|
|
||||||
"linux-aarch64": { signature: "", url: "" },
|
|
||||||
"linux-armv7": { signature: "", url: "" },
|
|
||||||
"windows-x86_64": { signature: "", url: "" },
|
|
||||||
"windows-aarch64": { signature: "", url: "" },
|
|
||||||
"windows-x86": { signature: "", url: "" },
|
|
||||||
"windows-i686": { signature: "", url: "" },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const promises = release.assets.map(async (asset) => {
|
|
||||||
const { name, browser_download_url } = asset;
|
|
||||||
|
|
||||||
// Process all the platform URL and signature data
|
|
||||||
// win64 url
|
|
||||||
if (name.endsWith("x64-setup.exe")) {
|
|
||||||
updateData.platforms.win64.url = browser_download_url;
|
|
||||||
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
|
||||||
}
|
|
||||||
// win64 signature
|
|
||||||
if (name.endsWith("x64-setup.exe.sig")) {
|
|
||||||
const sig = await getSignature(browser_download_url);
|
|
||||||
updateData.platforms.win64.signature = sig;
|
|
||||||
updateData.platforms["windows-x86_64"].signature = sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// win32 url
|
|
||||||
if (name.endsWith("x86-setup.exe")) {
|
|
||||||
updateData.platforms["windows-x86"].url = browser_download_url;
|
|
||||||
updateData.platforms["windows-i686"].url = browser_download_url;
|
|
||||||
}
|
|
||||||
// win32 signature
|
|
||||||
if (name.endsWith("x86-setup.exe.sig")) {
|
|
||||||
const sig = await getSignature(browser_download_url);
|
|
||||||
updateData.platforms["windows-x86"].signature = sig;
|
|
||||||
updateData.platforms["windows-i686"].signature = sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// win arm url
|
|
||||||
if (name.endsWith("arm64-setup.exe")) {
|
|
||||||
updateData.platforms["windows-aarch64"].url = browser_download_url;
|
|
||||||
}
|
|
||||||
// win arm signature
|
|
||||||
if (name.endsWith("arm64-setup.exe.sig")) {
|
|
||||||
const sig = await getSignature(browser_download_url);
|
|
||||||
updateData.platforms["windows-aarch64"].signature = sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// darwin url (intel)
|
|
||||||
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
|
||||||
updateData.platforms.darwin.url = browser_download_url;
|
|
||||||
updateData.platforms["darwin-intel"].url = browser_download_url;
|
|
||||||
updateData.platforms["darwin-x86_64"].url = browser_download_url;
|
|
||||||
}
|
|
||||||
// darwin signature (intel)
|
|
||||||
if (name.endsWith(".app.tar.gz.sig") && !name.includes("aarch")) {
|
|
||||||
const sig = await getSignature(browser_download_url);
|
|
||||||
updateData.platforms.darwin.signature = sig;
|
|
||||||
updateData.platforms["darwin-intel"].signature = sig;
|
|
||||||
updateData.platforms["darwin-x86_64"].signature = sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// darwin url (aarch)
|
|
||||||
if (name.endsWith("aarch64.app.tar.gz")) {
|
|
||||||
updateData.platforms["darwin-aarch64"].url = browser_download_url;
|
|
||||||
// 使linux可以检查更新
|
|
||||||
updateData.platforms.linux.url = browser_download_url;
|
|
||||||
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-x86"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-i686"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-armv7"].url = browser_download_url;
|
|
||||||
}
|
|
||||||
// darwin signature (aarch)
|
|
||||||
if (name.endsWith("aarch64.app.tar.gz.sig")) {
|
|
||||||
const sig = await getSignature(browser_download_url);
|
|
||||||
updateData.platforms["darwin-aarch64"].signature = sig;
|
|
||||||
updateData.platforms.linux.signature = sig;
|
|
||||||
updateData.platforms["linux-x86_64"].signature = sig;
|
|
||||||
updateData.platforms["linux-x86"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-i686"].url = browser_download_url;
|
|
||||||
updateData.platforms["linux-aarch64"].signature = sig;
|
|
||||||
updateData.platforms["linux-armv7"].signature = sig;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await Promise.allSettled(promises);
|
|
||||||
console.log(updateData);
|
|
||||||
|
|
||||||
// maybe should test the signature as well
|
|
||||||
// delete the null field
|
|
||||||
Object.entries(updateData.platforms).forEach(([key, value]) => {
|
|
||||||
if (!value.url) {
|
|
||||||
console.log(`[Error]: failed to parse release for "${key}"`);
|
|
||||||
delete updateData.platforms[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Generate a proxy update file for accelerated GitHub resources
|
|
||||||
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
|
||||||
|
|
||||||
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
|
||||||
if (value.url) {
|
|
||||||
updateDataNew.platforms[key].url =
|
|
||||||
"https://download.clashverge.dev/" + value.url;
|
|
||||||
} else {
|
|
||||||
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get the appropriate updater release based on isAlpha flag
|
|
||||||
const releaseTag = isAlpha ? ALPHA_TAG_NAME : UPDATE_TAG_NAME;
|
|
||||||
console.log(
|
|
||||||
`Processing ${isAlpha ? "alpha" : "stable"} release:`,
|
|
||||||
releaseTag,
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data: updateRelease } = await github.rest.repos.getReleaseByTag({
|
const { data: release } = await github.rest.repos.getReleaseByTag({
|
||||||
...options,
|
...options,
|
||||||
tag: releaseTag,
|
tag: tag.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
// File names based on release type
|
const updateData = {
|
||||||
const jsonFile = isAlpha ? ALPHA_UPDATE_JSON_FILE : UPDATE_JSON_FILE;
|
name: tag.name,
|
||||||
const proxyFile = isAlpha ? ALPHA_UPDATE_JSON_PROXY : UPDATE_JSON_PROXY;
|
notes: await resolveUpdateLog(tag.name).catch(() =>
|
||||||
|
resolveUpdateLogDefault().catch(() => "No changelog available"),
|
||||||
|
),
|
||||||
|
pub_date: new Date().toISOString(),
|
||||||
|
platforms: {
|
||||||
|
win64: { signature: "", url: "" }, // compatible with older formats
|
||||||
|
linux: { signature: "", url: "" }, // compatible with older formats
|
||||||
|
darwin: { signature: "", url: "" }, // compatible with older formats
|
||||||
|
"darwin-aarch64": { signature: "", url: "" },
|
||||||
|
"darwin-intel": { signature: "", url: "" },
|
||||||
|
"darwin-x86_64": { signature: "", url: "" },
|
||||||
|
"linux-x86_64": { signature: "", url: "" },
|
||||||
|
"linux-x86": { signature: "", url: "" },
|
||||||
|
"linux-i686": { signature: "", url: "" },
|
||||||
|
"linux-aarch64": { signature: "", url: "" },
|
||||||
|
"linux-armv7": { signature: "", url: "" },
|
||||||
|
"windows-x86_64": { signature: "", url: "" },
|
||||||
|
"windows-aarch64": { signature: "", url: "" },
|
||||||
|
"windows-x86": { signature: "", url: "" },
|
||||||
|
"windows-i686": { signature: "", url: "" },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
// Delete existing assets with these names
|
const promises = release.assets.map(async (asset) => {
|
||||||
for (let asset of updateRelease.assets) {
|
const { name, browser_download_url } = asset;
|
||||||
if (asset.name === jsonFile) {
|
|
||||||
await github.rest.repos.deleteReleaseAsset({
|
// Process all the platform URL and signature data
|
||||||
...options,
|
// win64 url
|
||||||
asset_id: asset.id,
|
if (name.endsWith("x64-setup.exe")) {
|
||||||
});
|
updateData.platforms.win64.url = browser_download_url;
|
||||||
|
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// win64 signature
|
||||||
|
if (name.endsWith("x64-setup.exe.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms.win64.signature = sig;
|
||||||
|
updateData.platforms["windows-x86_64"].signature = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset.name === proxyFile) {
|
// win32 url
|
||||||
await github.rest.repos
|
if (name.endsWith("x86-setup.exe")) {
|
||||||
.deleteReleaseAsset({ ...options, asset_id: asset.id })
|
updateData.platforms["windows-x86"].url = browser_download_url;
|
||||||
.catch(console.error); // do not break the pipeline
|
updateData.platforms["windows-i686"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// win32 signature
|
||||||
|
if (name.endsWith("x86-setup.exe.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["windows-x86"].signature = sig;
|
||||||
|
updateData.platforms["windows-i686"].signature = sig;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Upload new assets
|
// win arm url
|
||||||
await github.rest.repos.uploadReleaseAsset({
|
if (name.endsWith("arm64-setup.exe")) {
|
||||||
...options,
|
updateData.platforms["windows-aarch64"].url = browser_download_url;
|
||||||
release_id: updateRelease.id,
|
}
|
||||||
name: jsonFile,
|
// win arm signature
|
||||||
data: JSON.stringify(updateData, null, 2),
|
if (name.endsWith("arm64-setup.exe.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["windows-aarch64"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// darwin url (intel)
|
||||||
|
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
||||||
|
updateData.platforms.darwin.url = browser_download_url;
|
||||||
|
updateData.platforms["darwin-intel"].url = browser_download_url;
|
||||||
|
updateData.platforms["darwin-x86_64"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// darwin signature (intel)
|
||||||
|
if (name.endsWith(".app.tar.gz.sig") && !name.includes("aarch")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms.darwin.signature = sig;
|
||||||
|
updateData.platforms["darwin-intel"].signature = sig;
|
||||||
|
updateData.platforms["darwin-x86_64"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// darwin url (aarch)
|
||||||
|
if (name.endsWith("aarch64.app.tar.gz")) {
|
||||||
|
updateData.platforms["darwin-aarch64"].url = browser_download_url;
|
||||||
|
// 使linux可以检查更新
|
||||||
|
updateData.platforms.linux.url = browser_download_url;
|
||||||
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-x86"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-i686"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-armv7"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// darwin signature (aarch)
|
||||||
|
if (name.endsWith("aarch64.app.tar.gz.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["darwin-aarch64"].signature = sig;
|
||||||
|
updateData.platforms.linux.signature = sig;
|
||||||
|
updateData.platforms["linux-x86_64"].signature = sig;
|
||||||
|
updateData.platforms["linux-x86"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-i686"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-aarch64"].signature = sig;
|
||||||
|
updateData.platforms["linux-armv7"].signature = sig;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await github.rest.repos.uploadReleaseAsset({
|
await Promise.allSettled(promises);
|
||||||
...options,
|
console.log(updateData);
|
||||||
release_id: updateRelease.id,
|
|
||||||
name: proxyFile,
|
// maybe should test the signature as well
|
||||||
data: JSON.stringify(updateDataNew, null, 2),
|
// delete the null field
|
||||||
|
Object.entries(updateData.platforms).forEach(([key, value]) => {
|
||||||
|
if (!value.url) {
|
||||||
|
console.log(`[Error]: failed to parse release for "${key}"`);
|
||||||
|
delete updateData.platforms[key];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Generate a proxy update file for accelerated GitHub resources
|
||||||
|
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
||||||
|
|
||||||
|
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
||||||
|
if (value.url) {
|
||||||
|
updateDataNew.platforms[key].url =
|
||||||
|
"https://download.clashverge.dev/" + value.url;
|
||||||
|
} else {
|
||||||
|
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get the appropriate updater release based on isAlpha flag
|
||||||
|
const releaseTag = isAlpha ? ALPHA_TAG_NAME : UPDATE_TAG_NAME;
|
||||||
console.log(
|
console.log(
|
||||||
`Successfully uploaded ${isAlpha ? "alpha" : "stable"} update files to ${releaseTag}`,
|
`Processing ${isAlpha ? "alpha" : "stable"} release:`,
|
||||||
|
releaseTag,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let updateRelease;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Try to get the existing release
|
||||||
|
const response = await github.rest.repos.getReleaseByTag({
|
||||||
|
...options,
|
||||||
|
tag: releaseTag,
|
||||||
|
});
|
||||||
|
updateRelease = response.data;
|
||||||
|
console.log(
|
||||||
|
`Found existing ${releaseTag} release with ID: ${updateRelease.id}`,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
// If release doesn't exist, create it
|
||||||
|
if (error.status === 404) {
|
||||||
|
console.log(
|
||||||
|
`Release with tag ${releaseTag} not found, creating new release...`,
|
||||||
|
);
|
||||||
|
const createResponse = await github.rest.repos.createRelease({
|
||||||
|
...options,
|
||||||
|
tag_name: releaseTag,
|
||||||
|
name: isAlpha
|
||||||
|
? "Auto-update Alpha Channel"
|
||||||
|
: "Auto-update Stable Channel",
|
||||||
|
body: `This release contains the update information for ${isAlpha ? "alpha" : "stable"} channel.`,
|
||||||
|
prerelease: isAlpha,
|
||||||
|
});
|
||||||
|
updateRelease = createResponse.data;
|
||||||
|
console.log(
|
||||||
|
`Created new ${releaseTag} release with ID: ${updateRelease.id}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// If it's another error, throw it
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// File names based on release type
|
||||||
|
const jsonFile = isAlpha ? ALPHA_UPDATE_JSON_FILE : UPDATE_JSON_FILE;
|
||||||
|
const proxyFile = isAlpha ? ALPHA_UPDATE_JSON_PROXY : UPDATE_JSON_PROXY;
|
||||||
|
|
||||||
|
// Delete existing assets with these names
|
||||||
|
for (let asset of updateRelease.assets) {
|
||||||
|
if (asset.name === jsonFile) {
|
||||||
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
|
...options,
|
||||||
|
asset_id: asset.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (asset.name === proxyFile) {
|
||||||
|
await github.rest.repos
|
||||||
|
.deleteReleaseAsset({ ...options, asset_id: asset.id })
|
||||||
|
.catch(console.error); // do not break the pipeline
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload new assets
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
...options,
|
||||||
|
release_id: updateRelease.id,
|
||||||
|
name: jsonFile,
|
||||||
|
data: JSON.stringify(updateData, null, 2),
|
||||||
|
});
|
||||||
|
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
...options,
|
||||||
|
release_id: updateRelease.id,
|
||||||
|
name: proxyFile,
|
||||||
|
data: JSON.stringify(updateDataNew, null, 2),
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Successfully uploaded ${isAlpha ? "alpha" : "stable"} update files to ${releaseTag}`,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
`Failed to process ${isAlpha ? "alpha" : "stable"} release:`,
|
||||||
|
error.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
if (error.status === 404) {
|
||||||
`Failed to process ${isAlpha ? "alpha" : "stable"} release:`,
|
console.log(`Release not found for tag: ${tag.name}, skipping...`);
|
||||||
error.message,
|
} else {
|
||||||
);
|
console.error(
|
||||||
|
`Failed to get release for tag: ${tag.name}`,
|
||||||
|
error.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
src-tauri/.clippy.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
avoid-breaking-exported-api = true
|
||||||
3186
src-tauri/Cargo.lock
generated
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "clash-verge"
|
name = "clash-verge"
|
||||||
version = "2.1.2"
|
version = "0.2.2"
|
||||||
description = "clash verge"
|
description = "clash verge"
|
||||||
authors = ["zzzgydi", "wonfen", "MystiPanda"]
|
authors = ["zzzgydi", "wonfen", "MystiPanda", "coolcoala"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
repository = "https://github.com/clash-verge-rev/clash-verge-rev.git"
|
repository = "https://github.com/coolcoala/clash-verge-rev-lite.git"
|
||||||
default-run = "clash-verge"
|
default-run = "clash-verge"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
@@ -13,80 +13,104 @@ build = "build.rs"
|
|||||||
identifier = "io.github.clash-verge-rev.clash-verge-rev"
|
identifier = "io.github.clash-verge-rev.clash-verge-rev"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.6", features = [] }
|
tauri-build = { version = "2.3.0", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
warp = "0.3"
|
url = "2.5.4"
|
||||||
anyhow = "1.0.97"
|
os_info = "3.0"
|
||||||
|
machine-uid = "0.2"
|
||||||
|
warp = "0.3.7"
|
||||||
|
anyhow = "1.0.98"
|
||||||
dirs = "6.0"
|
dirs = "6.0"
|
||||||
open = "5.1"
|
open = "5.3.2"
|
||||||
log = "0.4"
|
log = "0.4.27"
|
||||||
dunce = "1.0"
|
dunce = "1.0.5"
|
||||||
log4rs = "1"
|
log4rs = "1.3.0"
|
||||||
nanoid = "0.4"
|
nanoid = "0.4"
|
||||||
chrono = "0.4.40"
|
chrono = "0.4.41"
|
||||||
sysinfo = "0.33.1"
|
sysinfo = "0.35.2"
|
||||||
boa_engine = "0.20.0"
|
boa_engine = "0.20.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0.140"
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9.34-deprecated"
|
||||||
once_cell = "1.20.3"
|
once_cell = "1.21.3"
|
||||||
|
lazy_static = "1.5.0"
|
||||||
port_scanner = "0.1.5"
|
port_scanner = "0.1.5"
|
||||||
delay_timer = "0.11.6"
|
delay_timer = "0.11.6"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12.4"
|
||||||
percent-encoding = "2.3.1"
|
percent-encoding = "2.3.1"
|
||||||
window-shadows = { version = "0.2.2" }
|
tokio = { version = "1.45.1", features = [
|
||||||
tokio = { version = "1.43", features = ["full"] }
|
"rt-multi-thread",
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
"macros",
|
||||||
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }
|
"time",
|
||||||
sysproxy = { git = "https://github.com/clash-verge-rev/sysproxy-rs", rev = "3d748b5" }
|
"sync",
|
||||||
image = "0.25.5"
|
|
||||||
imageproc = "0.25.0"
|
|
||||||
rusttype = "0.9"
|
|
||||||
tauri = { version = "2.3.1", features = [
|
|
||||||
"protocol-asset",
|
|
||||||
"devtools",
|
|
||||||
"tray-icon",
|
|
||||||
"image-ico",
|
|
||||||
"image-png",
|
|
||||||
] }
|
] }
|
||||||
network-interface = { version = "2.0.0", features = ["serde"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
tauri-plugin-shell = "2.2.0"
|
reqwest = { version = "0.12.20", features = ["json", "rustls-tls", "cookies"] }
|
||||||
tauri-plugin-dialog = "2.2.0"
|
regex = "1.11.1"
|
||||||
tauri-plugin-fs = "2.2.0"
|
sysproxy = { git = "https://github.com/clash-verge-rev/sysproxy-rs" }
|
||||||
tauri-plugin-notification = "2.2.1"
|
image = "0.25.6"
|
||||||
tauri-plugin-process = "2.2.0"
|
imageproc = "0.25.0"
|
||||||
tauri-plugin-clipboard-manager = "2.2.1"
|
tauri = { version = "2.6.2", features = [
|
||||||
tauri-plugin-deep-link = "2.2.0"
|
"protocol-asset",
|
||||||
tauri-plugin-devtools = "2.0.0-rc"
|
"devtools",
|
||||||
url = "2.5.4"
|
"tray-icon",
|
||||||
zip = "2.2.3"
|
"image-ico",
|
||||||
reqwest_dav = "0.1.14"
|
"image-png",
|
||||||
|
] }
|
||||||
|
network-interface = { version = "2.0.1", features = ["serde"] }
|
||||||
|
tauri-plugin-shell = "2.3.0"
|
||||||
|
tauri-plugin-dialog = "2.3.0"
|
||||||
|
tauri-plugin-fs = "2.4.0"
|
||||||
|
tauri-plugin-process = "2.3.0"
|
||||||
|
tauri-plugin-clipboard-manager = "2.3.0"
|
||||||
|
tauri-plugin-deep-link = "2.4.0"
|
||||||
|
tauri-plugin-devtools = "2.0.0"
|
||||||
|
tauri-plugin-window-state = "2.3.0"
|
||||||
|
zip = "4.2.0"
|
||||||
|
reqwest_dav = "0.2.1"
|
||||||
aes-gcm = { version = "0.10.3", features = ["std"] }
|
aes-gcm = { version = "0.10.3", features = ["std"] }
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
getrandom = "0.3.1"
|
getrandom = "0.3.3"
|
||||||
tokio-tungstenite = "0.26.2"
|
tokio-tungstenite = "0.27.0"
|
||||||
futures = "0.3"
|
futures = "0.3.31"
|
||||||
sys-locale = "0.3.1"
|
sys-locale = "0.3.2"
|
||||||
async-trait = "0.1.87"
|
async-trait = "0.1.88"
|
||||||
mihomo_api = { path = "./src/crate_mihomo_api" }
|
mihomo_api = { path = "src_crates/crate_mihomo_api" }
|
||||||
ab_glyph = "0.2.29"
|
ab_glyph = "0.2.29"
|
||||||
tungstenite = "0.26.2"
|
tungstenite = "0.27.0"
|
||||||
|
libc = "0.2.174"
|
||||||
|
gethostname = "1.0.2"
|
||||||
|
hmac = "0.12.1"
|
||||||
|
sha2 = "0.10.9"
|
||||||
|
hex = "0.4.3"
|
||||||
|
scopeguard = "1.2.0"
|
||||||
|
tauri-plugin-notification = "2.3.0"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
runas = "=1.2.0"
|
runas = "=1.2.0"
|
||||||
deelevate = "0.2.0"
|
deelevate = "0.2.0"
|
||||||
winreg = "0.55.0"
|
winreg = "0.55.0"
|
||||||
url = "2.5.4"
|
winapi = { version = "0.3.9", features = [
|
||||||
|
"winbase",
|
||||||
|
"fileapi",
|
||||||
|
"winnt",
|
||||||
|
"handleapi",
|
||||||
|
"errhandlingapi",
|
||||||
|
"minwindef",
|
||||||
|
"winerror",
|
||||||
|
"tlhelp32",
|
||||||
|
"processthreadsapi",
|
||||||
|
"winhttp",
|
||||||
|
"winreg",
|
||||||
|
] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-autostart = "2.2.0"
|
tauri-plugin-autostart = "2.5.0"
|
||||||
tauri-plugin-global-shortcut = "2.2.0"
|
tauri-plugin-global-shortcut = "2.3.0"
|
||||||
tauri-plugin-updater = "2.5.1"
|
tauri-plugin-updater = "2.9.0"
|
||||||
tauri-plugin-window-state = "2.2.1"
|
|
||||||
#openssl
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["custom-protocol"]
|
default = ["custom-protocol"]
|
||||||
@@ -102,34 +126,31 @@ strip = true
|
|||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
incremental = true
|
incremental = true
|
||||||
|
codegen-units = 256 # 增加编译单元,提升编译速度
|
||||||
|
opt-level = 0 # 禁用优化,进一步提升编译速度
|
||||||
|
debug = true # 保留调试信息
|
||||||
|
strip = false # 不剥离符号,保留调试信息
|
||||||
|
|
||||||
[profile.fast-release]
|
[profile.fast-release]
|
||||||
inherits = "release" # 继承 release 的配置
|
inherits = "release" # 继承 release 的配置
|
||||||
panic = "abort" # 与 release 相同
|
panic = "abort" # 与 release 相同
|
||||||
codegen-units = 256 # 增加编译单元,提升编译速度
|
codegen-units = 256 # 增加编译单元,提升编译速度
|
||||||
lto = false # 禁用 LTO,提升编译速度
|
lto = false # 禁用 LTO,提升编译速度
|
||||||
opt-level = 0 # 禁用优化,大幅提升编译速度
|
opt-level = 0 # 禁用优化,大幅提升编译速度
|
||||||
debug = true # 保留调试信息
|
debug = true # 保留调试信息
|
||||||
strip = false # 不剥离符号,保留调试信息
|
strip = false # 不剥离符号,保留调试信息
|
||||||
|
|
||||||
[profile.fast-dev]
|
|
||||||
inherits = "dev" # 继承 dev 的配置
|
|
||||||
codegen-units = 256 # 增加编译单元,提升编译速度
|
|
||||||
opt-level = 0 # 禁用优化,进一步提升编译速度
|
|
||||||
incremental = true # 启用增量编译
|
|
||||||
debug = true # 保留调试信息
|
|
||||||
strip = false # 不剥离符号,保留调试信息
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "app_lib"
|
name = "app_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.11.0"
|
tempfile = "3.20.0"
|
||||||
mockito = "1.7.0"
|
|
||||||
tempfile = "3.17.1"
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = ["src_crates/crate_mihomo_api"]
|
||||||
"src/crate_mihomo_api"
|
|
||||||
]
|
# [patch.crates-io]
|
||||||
|
# bitflags = { git = "https://github.com/bitflags/bitflags", rev = "2.9.0" }
|
||||||
|
# zerocopy = { git = "https://github.com/google/zerocopy", rev = "v0.8.24" }
|
||||||
|
# tungstenite = { git = "https://github.com/snapview/tungstenite-rs", rev = "v0.26.2" }
|
||||||
|
|||||||
9
src-tauri/capabilities/desktop-windows.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"identifier": "desktop-windows-capability",
|
||||||
|
"description": "permissions for desktop windows applications",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": [
|
||||||
|
"core:webview:allow-create-webview",
|
||||||
|
"core:webview:allow-create-webview-window"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -14,8 +14,10 @@
|
|||||||
"updater:allow-download-and-install",
|
"updater:allow-download-and-install",
|
||||||
"process:allow-restart",
|
"process:allow-restart",
|
||||||
"deep-link:default",
|
"deep-link:default",
|
||||||
"window-state:default",
|
"autostart:allow-enable",
|
||||||
"window-state:default",
|
"autostart:allow-disable",
|
||||||
"autostart:default"
|
"autostart:allow-is-enabled",
|
||||||
|
"core:window:allow-set-theme",
|
||||||
|
"notification:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
"shell:allow-spawn",
|
"shell:allow-spawn",
|
||||||
"shell:allow-stdin-write",
|
"shell:allow-stdin-write",
|
||||||
"dialog:allow-open",
|
"dialog:allow-open",
|
||||||
"notification:default",
|
|
||||||
"global-shortcut:allow-is-registered",
|
"global-shortcut:allow-is-registered",
|
||||||
"global-shortcut:allow-register",
|
"global-shortcut:allow-register",
|
||||||
"global-shortcut:allow-register-all",
|
"global-shortcut:allow-register-all",
|
||||||
@@ -79,7 +78,6 @@
|
|||||||
"clipboard-manager:allow-read-text",
|
"clipboard-manager:allow-read-text",
|
||||||
"clipboard-manager:allow-write-text",
|
"clipboard-manager:allow-write-text",
|
||||||
"shell:default",
|
"shell:default",
|
||||||
"dialog:default",
|
"dialog:default"
|
||||||
"notification:default"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
236
src-tauri/deny.toml
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
# This template contains all of the possible sections and their default values
|
||||||
|
|
||||||
|
# Note that all fields that take a lint level have these possible values:
|
||||||
|
# * deny - An error will be produced and the check will fail
|
||||||
|
# * warn - A warning will be produced, but the check will not fail
|
||||||
|
# * allow - No warning or error will be produced, though in some cases a note
|
||||||
|
# will be
|
||||||
|
|
||||||
|
# The values provided in this template are the default values that will be used
|
||||||
|
# when any section or field is not specified in your own configuration
|
||||||
|
|
||||||
|
# Root options
|
||||||
|
|
||||||
|
# The graph table configures how the dependency graph is constructed and thus
|
||||||
|
# which crates the checks are performed against
|
||||||
|
[graph]
|
||||||
|
# If 1 or more target triples (and optionally, target_features) are specified,
|
||||||
|
# only the specified targets will be checked when running `cargo deny check`.
|
||||||
|
# This means, if a particular package is only ever used as a target specific
|
||||||
|
# dependency, such as, for example, the `nix` crate only being used via the
|
||||||
|
# `target_family = "unix"` configuration, that only having windows targets in
|
||||||
|
# this list would mean the nix crate, as well as any of its exclusive
|
||||||
|
# dependencies not shared by any other crates, would be ignored, as the target
|
||||||
|
# list here is effectively saying which targets you are building for.
|
||||||
|
targets = [
|
||||||
|
# The triple can be any string, but only the target triples built in to
|
||||||
|
# rustc (as of 1.40) can be checked against actual config expressions
|
||||||
|
#"x86_64-unknown-linux-musl",
|
||||||
|
# You can also specify which target_features you promise are enabled for a
|
||||||
|
# particular target. target_features are currently not validated against
|
||||||
|
# the actual valid features supported by the target architecture.
|
||||||
|
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
|
||||||
|
]
|
||||||
|
# When creating the dependency graph used as the source of truth when checks are
|
||||||
|
# executed, this field can be used to prune crates from the graph, removing them
|
||||||
|
# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate
|
||||||
|
# is pruned from the graph, all of its dependencies will also be pruned unless
|
||||||
|
# they are connected to another crate in the graph that hasn't been pruned,
|
||||||
|
# so it should be used with care. The identifiers are [Package ID Specifications]
|
||||||
|
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
|
||||||
|
#exclude = []
|
||||||
|
# If true, metadata will be collected with `--all-features`. Note that this can't
|
||||||
|
# be toggled off if true, if you want to conditionally enable `--all-features` it
|
||||||
|
# is recommended to pass `--all-features` on the cmd line instead
|
||||||
|
all-features = false
|
||||||
|
# If true, metadata will be collected with `--no-default-features`. The same
|
||||||
|
# caveat with `all-features` applies
|
||||||
|
no-default-features = false
|
||||||
|
# If set, these feature will be enabled when collecting metadata. If `--features`
|
||||||
|
# is specified on the cmd line they will take precedence over this option.
|
||||||
|
#features = []
|
||||||
|
|
||||||
|
# The output table provides options for how/if diagnostics are outputted
|
||||||
|
[output]
|
||||||
|
# When outputting inclusion graphs in diagnostics that include features, this
|
||||||
|
# option can be used to specify the depth at which feature edges will be added.
|
||||||
|
# This option is included since the graphs can be quite large and the addition
|
||||||
|
# of features from the crate(s) to all of the graph roots can be far too verbose.
|
||||||
|
# This option can be overridden via `--feature-depth` on the cmd line
|
||||||
|
feature-depth = 1
|
||||||
|
|
||||||
|
# This section is considered when running `cargo deny check advisories`
|
||||||
|
# More documentation for the advisories section can be found here:
|
||||||
|
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
|
||||||
|
[advisories]
|
||||||
|
# The path where the advisory databases are cloned/fetched into
|
||||||
|
#db-path = "$CARGO_HOME/advisory-dbs"
|
||||||
|
# The url(s) of the advisory databases to use
|
||||||
|
#db-urls = ["https://github.com/rustsec/advisory-db"]
|
||||||
|
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
||||||
|
# output a note when they are encountered.
|
||||||
|
ignore = [
|
||||||
|
#"RUSTSEC-0000-0000",
|
||||||
|
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
|
||||||
|
#"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish
|
||||||
|
#{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" },
|
||||||
|
"RUSTSEC-2024-0415",
|
||||||
|
]
|
||||||
|
# If this is true, then cargo deny will use the git executable to fetch advisory database.
|
||||||
|
# If this is false, then it uses a built-in git library.
|
||||||
|
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
|
||||||
|
# See Git Authentication for more information about setting up git authentication.
|
||||||
|
#git-fetch-with-cli = true
|
||||||
|
|
||||||
|
# This section is considered when running `cargo deny check licenses`
|
||||||
|
# More documentation for the licenses section can be found here:
|
||||||
|
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
|
||||||
|
[licenses]
|
||||||
|
# List of explicitly allowed licenses
|
||||||
|
# See https://spdx.org/licenses/ for list of possible licenses
|
||||||
|
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
|
||||||
|
allow = [
|
||||||
|
#"MIT",
|
||||||
|
#"Apache-2.0",
|
||||||
|
#"Apache-2.0 WITH LLVM-exception",
|
||||||
|
]
|
||||||
|
# The confidence threshold for detecting a license from license text.
|
||||||
|
# The higher the value, the more closely the license text must be to the
|
||||||
|
# canonical license text of a valid SPDX license file.
|
||||||
|
# [possible values: any between 0.0 and 1.0].
|
||||||
|
confidence-threshold = 0.85
|
||||||
|
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
|
||||||
|
# aren't accepted for every possible crate as with the normal allow list
|
||||||
|
exceptions = [
|
||||||
|
# Each entry is the crate and version constraint, and its specific allow
|
||||||
|
# list
|
||||||
|
#{ allow = ["Zlib"], crate = "adler32" },
|
||||||
|
]
|
||||||
|
|
||||||
|
# Some crates don't have (easily) machine readable licensing information,
|
||||||
|
# adding a clarification entry for it allows you to manually specify the
|
||||||
|
# licensing information
|
||||||
|
#[[licenses.clarify]]
|
||||||
|
# The package spec the clarification applies to
|
||||||
|
#crate = "ring"
|
||||||
|
# The SPDX expression for the license requirements of the crate
|
||||||
|
#expression = "MIT AND ISC AND OpenSSL"
|
||||||
|
# One or more files in the crate's source used as the "source of truth" for
|
||||||
|
# the license expression. If the contents match, the clarification will be used
|
||||||
|
# when running the license check, otherwise the clarification will be ignored
|
||||||
|
# and the crate will be checked normally, which may produce warnings or errors
|
||||||
|
# depending on the rest of your configuration
|
||||||
|
#license-files = [
|
||||||
|
# Each entry is a crate relative path, and the (opaque) hash of its contents
|
||||||
|
#{ path = "LICENSE", hash = 0xbd0eed23 }
|
||||||
|
#]
|
||||||
|
|
||||||
|
[licenses.private]
|
||||||
|
# If true, ignores workspace crates that aren't published, or are only
|
||||||
|
# published to private registries.
|
||||||
|
# To see how to mark a crate as unpublished (to the official registry),
|
||||||
|
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
|
||||||
|
ignore = false
|
||||||
|
# One or more private registries that you might publish crates to, if a crate
|
||||||
|
# is only published to private registries, and ignore is true, the crate will
|
||||||
|
# not have its license(s) checked
|
||||||
|
registries = [
|
||||||
|
#"https://sekretz.com/registry
|
||||||
|
]
|
||||||
|
|
||||||
|
# This section is considered when running `cargo deny check bans`.
|
||||||
|
# More documentation about the 'bans' section can be found here:
|
||||||
|
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
|
||||||
|
[bans]
|
||||||
|
# Lint level for when multiple versions of the same crate are detected
|
||||||
|
multiple-versions = "warn"
|
||||||
|
# Lint level for when a crate version requirement is `*`
|
||||||
|
wildcards = "allow"
|
||||||
|
# The graph highlighting used when creating dotgraphs for crates
|
||||||
|
# with multiple versions
|
||||||
|
# * lowest-version - The path to the lowest versioned duplicate is highlighted
|
||||||
|
# * simplest-path - The path to the version with the fewest edges is highlighted
|
||||||
|
# * all - Both lowest-version and simplest-path are used
|
||||||
|
highlight = "all"
|
||||||
|
# The default lint level for `default` features for crates that are members of
|
||||||
|
# the workspace that is being checked. This can be overridden by allowing/denying
|
||||||
|
# `default` on a crate-by-crate basis if desired.
|
||||||
|
workspace-default-features = "allow"
|
||||||
|
# The default lint level for `default` features for external crates that are not
|
||||||
|
# members of the workspace. This can be overridden by allowing/denying `default`
|
||||||
|
# on a crate-by-crate basis if desired.
|
||||||
|
external-default-features = "allow"
|
||||||
|
# List of crates that are allowed. Use with care!
|
||||||
|
allow = [
|
||||||
|
#"ansi_term@0.11.0",
|
||||||
|
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" },
|
||||||
|
]
|
||||||
|
# List of crates to deny
|
||||||
|
deny = [
|
||||||
|
#"ansi_term@0.11.0",
|
||||||
|
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" },
|
||||||
|
# Wrapper crates can optionally be specified to allow the crate when it
|
||||||
|
# is a direct dependency of the otherwise banned crate
|
||||||
|
#{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
|
||||||
|
]
|
||||||
|
|
||||||
|
# List of features to allow/deny
|
||||||
|
# Each entry the name of a crate and a version range. If version is
|
||||||
|
# not specified, all versions will be matched.
|
||||||
|
#[[bans.features]]
|
||||||
|
#crate = "reqwest"
|
||||||
|
# Features to not allow
|
||||||
|
#deny = ["json"]
|
||||||
|
# Features to allow
|
||||||
|
#allow = [
|
||||||
|
# "rustls",
|
||||||
|
# "__rustls",
|
||||||
|
# "__tls",
|
||||||
|
# "hyper-rustls",
|
||||||
|
# "rustls",
|
||||||
|
# "rustls-pemfile",
|
||||||
|
# "rustls-tls-webpki-roots",
|
||||||
|
# "tokio-rustls",
|
||||||
|
# "webpki-roots",
|
||||||
|
#]
|
||||||
|
# If true, the allowed features must exactly match the enabled feature set. If
|
||||||
|
# this is set there is no point setting `deny`
|
||||||
|
#exact = true
|
||||||
|
|
||||||
|
# Certain crates/versions that will be skipped when doing duplicate detection.
|
||||||
|
skip = [
|
||||||
|
#"ansi_term@0.11.0",
|
||||||
|
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" },
|
||||||
|
]
|
||||||
|
# Similarly to `skip` allows you to skip certain crates during duplicate
|
||||||
|
# detection. Unlike skip, it also includes the entire tree of transitive
|
||||||
|
# dependencies starting at the specified crate, up to a certain depth, which is
|
||||||
|
# by default infinite.
|
||||||
|
skip-tree = [
|
||||||
|
#"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies
|
||||||
|
#{ crate = "ansi_term@0.11.0", depth = 20 },
|
||||||
|
]
|
||||||
|
|
||||||
|
# This section is considered when running `cargo deny check sources`.
|
||||||
|
# More documentation about the 'sources' section can be found here:
|
||||||
|
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
|
||||||
|
[sources]
|
||||||
|
# Lint level for what to happen when a crate from a crate registry that is not
|
||||||
|
# in the allow list is encountered
|
||||||
|
unknown-registry = "warn"
|
||||||
|
# Lint level for what to happen when a crate from a git repository that is not
|
||||||
|
# in the allow list is encountered
|
||||||
|
unknown-git = "warn"
|
||||||
|
# List of URLs for allowed crate registries. Defaults to the crates.io index
|
||||||
|
# if not specified. If it is specified but empty, no registries are allowed.
|
||||||
|
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
||||||
|
# List of URLs for allowed Git repositories
|
||||||
|
allow-git = []
|
||||||
|
|
||||||
|
[sources.allow-org]
|
||||||
|
# github.com organizations to allow git sources for
|
||||||
|
github = []
|
||||||
|
# gitlab.com organizations to allow git sources for
|
||||||
|
gitlab = []
|
||||||
|
# bitbucket.org organizations to allow git sources for
|
||||||
|
bitbucket = []
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/tray-icon-sys-mono-new.ico
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
src-tauri/icons/tray-icon-tun-mono-new.ico
Normal file
|
After Width: | Height: | Size: 107 KiB |
@@ -916,6 +916,10 @@ FunctionEnd
|
|||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
Section Uninstall
|
Section Uninstall
|
||||||
|
;删除 window-state.json 文件
|
||||||
|
SetShellVarContext current
|
||||||
|
Delete "$APPDATA\io.github.clash-verge-rev.clash-verge-rev\window-state.json"
|
||||||
|
|
||||||
!insertmacro CheckIfAppIsRunning
|
!insertmacro CheckIfAppIsRunning
|
||||||
!insertmacro CheckAllVergeProcesses
|
!insertmacro CheckAllVergeProcesses
|
||||||
!insertmacro RemoveVergeService
|
!insertmacro RemoveVergeService
|
||||||
@@ -975,16 +979,23 @@ Section Uninstall
|
|||||||
RMDir "$INSTDIR"
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
!insertmacro DeleteAppUserModelId
|
!insertmacro DeleteAppUserModelId
|
||||||
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
!insertmacro UnpinShortcut "$DESKTOP\${MAINBINARYNAME}.lnk"
|
!insertmacro UnpinShortcut "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
|
; 兼容旧名称快捷方式
|
||||||
|
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\clash-verge.lnk"
|
||||||
|
!insertmacro UnpinShortcut "$DESKTOP\clash-verge.lnk"
|
||||||
|
|
||||||
; Remove start menu shortcut
|
; Remove start menu shortcut
|
||||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
||||||
Delete "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
Delete "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
|
; 兼容旧名称快捷方式
|
||||||
|
Delete "$SMPROGRAMS\$AppStartMenuFolder\clash-verge.lnk"
|
||||||
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
|
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
|
||||||
; Remove desktop shortcuts
|
; Remove desktop shortcuts
|
||||||
Delete "$DESKTOP\${MAINBINARYNAME}.lnk"
|
Delete "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
|
; 兼容旧名称快捷方式
|
||||||
|
Delete "$DESKTOP\clash-verge.lnk"
|
||||||
|
|
||||||
; Remove registry information for add/remove programs
|
; Remove registry information for add/remove programs
|
||||||
!if "${INSTALLMODE}" == "both"
|
!if "${INSTALLMODE}" == "both"
|
||||||
@@ -1004,6 +1015,10 @@ Section Uninstall
|
|||||||
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
|
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
;删除 window-state.json 文件
|
||||||
|
SetShellVarContext current
|
||||||
|
Delete "$APPDATA\io.github.clash-verge-rev.clash-verge-rev\window-state.json"
|
||||||
|
|
||||||
${GetOptions} $CMDLINE "/P" $R0
|
${GetOptions} $CMDLINE "/P" $R0
|
||||||
IfErrors +2 0
|
IfErrors +2 0
|
||||||
SetAutoClose true
|
SetAutoClose true
|
||||||
@@ -1046,12 +1061,12 @@ FunctionEnd
|
|||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
Function CreateDesktopShortcut
|
Function CreateDesktopShortcut
|
||||||
CreateShortcut "$DESKTOP\${MAINBINARYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
CreateShortcut "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
!insertmacro SetLnkAppUserModelId "$DESKTOP\${MAINBINARYNAME}.lnk"
|
!insertmacro SetLnkAppUserModelId "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function CreateStartMenuShortcut
|
Function CreateStartMenuShortcut
|
||||||
CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder"
|
CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|||||||
@@ -11,4 +11,3 @@ merge_derives = true
|
|||||||
use_try_shorthand = false
|
use_try_shorthand = false
|
||||||
use_field_init_shorthand = false
|
use_field_init_shorthand = false
|
||||||
force_explicit_abi = true
|
force_explicit_abi = true
|
||||||
imports_granularity = "Crate"
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::{feat, utils::dirs, wrap_err};
|
use crate::{
|
||||||
|
feat, logging,
|
||||||
|
utils::{dirs, logging::Type},
|
||||||
|
wrap_err,
|
||||||
|
};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
/// 打开应用程序所在目录
|
/// 打开应用程序所在目录
|
||||||
@@ -45,7 +49,7 @@ pub fn open_devtools(app_handle: tauri::AppHandle) {
|
|||||||
/// 退出应用
|
/// 退出应用
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn exit_app() {
|
pub fn exit_app() {
|
||||||
feat::quit(Some(0));
|
feat::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 重启应用
|
/// 重启应用
|
||||||
@@ -70,46 +74,46 @@ pub fn get_app_dir() -> CmdResult<String> {
|
|||||||
Ok(app_home_dir)
|
Ok(app_home_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 获取当前自启动状态
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_auto_launch_status() -> CmdResult<bool> {
|
||||||
|
use crate::core::sysopt::Sysopt;
|
||||||
|
wrap_err!(Sysopt::global().get_launch_status())
|
||||||
|
}
|
||||||
|
|
||||||
/// 下载图标缓存
|
/// 下载图标缓存
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String> {
|
pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String> {
|
||||||
let icon_cache_dir = wrap_err!(dirs::app_home_dir())?.join("icons").join("cache");
|
let icon_cache_dir = wrap_err!(dirs::app_home_dir())?.join("icons").join("cache");
|
||||||
let icon_path = icon_cache_dir.join(&name);
|
let icon_path = icon_cache_dir.join(&name);
|
||||||
|
|
||||||
// 如果文件已存在,直接返回路径
|
|
||||||
if icon_path.exists() {
|
if icon_path.exists() {
|
||||||
return Ok(icon_path.to_string_lossy().to_string());
|
return Ok(icon_path.to_string_lossy().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保缓存目录存在
|
|
||||||
if !icon_cache_dir.exists() {
|
if !icon_cache_dir.exists() {
|
||||||
let _ = std::fs::create_dir_all(&icon_cache_dir);
|
let _ = std::fs::create_dir_all(&icon_cache_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用临时文件名来下载
|
|
||||||
let temp_path = icon_cache_dir.join(format!("{}.downloading", &name));
|
let temp_path = icon_cache_dir.join(format!("{}.downloading", &name));
|
||||||
|
|
||||||
// 下载文件到临时位置
|
|
||||||
let response = wrap_err!(reqwest::get(&url).await)?;
|
let response = wrap_err!(reqwest::get(&url).await)?;
|
||||||
|
|
||||||
// 检查内容类型是否为图片
|
let content_type = response
|
||||||
let content_type = response.headers()
|
.headers()
|
||||||
.get(reqwest::header::CONTENT_TYPE)
|
.get(reqwest::header::CONTENT_TYPE)
|
||||||
.and_then(|v| v.to_str().ok())
|
.and_then(|v| v.to_str().ok())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
let is_image = content_type.starts_with("image/");
|
let is_image = content_type.starts_with("image/");
|
||||||
|
|
||||||
// 获取响应内容
|
|
||||||
let content = wrap_err!(response.bytes().await)?;
|
let content = wrap_err!(response.bytes().await)?;
|
||||||
|
|
||||||
// 检查内容是否为HTML (针对CDN错误页面)
|
let is_html = content.len() > 15
|
||||||
let is_html = content.len() > 15 &&
|
&& (content.starts_with(b"<!DOCTYPE html")
|
||||||
(content.starts_with(b"<!DOCTYPE html") ||
|
|| content.starts_with(b"<html")
|
||||||
content.starts_with(b"<html") ||
|
|| content.starts_with(b"<?xml"));
|
||||||
content.starts_with(b"<?xml"));
|
|
||||||
|
|
||||||
// 只有当内容确实是图片时才保存
|
|
||||||
if is_image && !is_html {
|
if is_image && !is_html {
|
||||||
{
|
{
|
||||||
let mut file = match std::fs::File::create(&temp_path) {
|
let mut file = match std::fs::File::create(&temp_path) {
|
||||||
@@ -126,10 +130,9 @@ pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String>
|
|||||||
wrap_err!(std::io::copy(&mut content.as_ref(), &mut file))?;
|
wrap_err!(std::io::copy(&mut content.as_ref(), &mut file))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 再次检查目标文件是否已存在,避免重命名覆盖其他线程已完成的文件
|
|
||||||
if !icon_path.exists() {
|
if !icon_path.exists() {
|
||||||
match std::fs::rename(&temp_path, &icon_path) {
|
match std::fs::rename(&temp_path, &icon_path) {
|
||||||
Ok(_) => {},
|
Ok(_) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = std::fs::remove_file(&temp_path);
|
let _ = std::fs::remove_file(&temp_path);
|
||||||
if icon_path.exists() {
|
if icon_path.exists() {
|
||||||
@@ -144,7 +147,7 @@ pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String>
|
|||||||
Ok(icon_path.to_string_lossy().to_string())
|
Ok(icon_path.to_string_lossy().to_string())
|
||||||
} else {
|
} else {
|
||||||
let _ = std::fs::remove_file(&temp_path);
|
let _ = std::fs::remove_file(&temp_path);
|
||||||
Err(format!("下载的内容不是有效图片: {}", url).into())
|
Err(format!("下载的内容不是有效图片: {url}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +161,7 @@ pub struct IconInfo {
|
|||||||
/// 复制图标文件
|
/// 复制图标文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn copy_icon_file(path: String, icon_info: IconInfo) -> CmdResult<String> {
|
pub fn copy_icon_file(path: String, icon_info: IconInfo) -> CmdResult<String> {
|
||||||
use std::fs;
|
use std::{fs, path::Path};
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
let file_path = Path::new(&path);
|
let file_path = Path::new(&path);
|
||||||
|
|
||||||
@@ -187,7 +189,14 @@ pub fn copy_icon_file(path: String, icon_info: IconInfo) -> CmdResult<String> {
|
|||||||
)
|
)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
}
|
}
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"Copying icon file path: {:?} -> file dist: {:?}",
|
||||||
|
path,
|
||||||
|
dest_path
|
||||||
|
);
|
||||||
match fs::copy(file_path, &dest_path) {
|
match fs::copy(file_path, &dest_path) {
|
||||||
Ok(_) => Ok(dest_path.to_string_lossy().to_string()),
|
Ok(_) => Ok(dest_path.to_string_lossy().to_string()),
|
||||||
Err(err) => Err(err.to_string()),
|
Err(err) => Err(err.to_string()),
|
||||||
@@ -196,3 +205,42 @@ pub fn copy_icon_file(path: String, icon_info: IconInfo) -> CmdResult<String> {
|
|||||||
Err("file not found".to_string())
|
Err("file not found".to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 通知UI已准备就绪
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn notify_ui_ready() -> CmdResult<()> {
|
||||||
|
log::info!(target: "app", "前端UI已准备就绪");
|
||||||
|
crate::utils::resolve::mark_ui_ready();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// UI加载阶段
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn update_ui_stage(stage: String) -> CmdResult<()> {
|
||||||
|
log::info!(target: "app", "UI加载阶段更新: {stage}");
|
||||||
|
|
||||||
|
use crate::utils::resolve::UiReadyStage;
|
||||||
|
|
||||||
|
let stage_enum = match stage.as_str() {
|
||||||
|
"NotStarted" => UiReadyStage::NotStarted,
|
||||||
|
"Loading" => UiReadyStage::Loading,
|
||||||
|
"DomReady" => UiReadyStage::DomReady,
|
||||||
|
"ResourcesLoaded" => UiReadyStage::ResourcesLoaded,
|
||||||
|
"Ready" => UiReadyStage::Ready,
|
||||||
|
_ => {
|
||||||
|
log::warn!(target: "app", "未知的UI加载阶段: {stage}");
|
||||||
|
return Err(format!("未知的UI加载阶段: {stage}"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
crate::utils::resolve::update_ui_ready_stage(stage_enum);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 重置UI就绪状态
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn reset_ui_ready_state() -> CmdResult<()> {
|
||||||
|
log::info!(target: "app", "重置UI就绪状态");
|
||||||
|
crate::utils::resolve::reset_ui_ready();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::{config::*, core::*, feat, module::mihomo::MihomoManager, wrap_err};
|
use crate::{
|
||||||
|
config::*, core::*, feat, module::mihomo::MihomoManager, process::AsyncHandler, wrap_err,
|
||||||
|
};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
|
|
||||||
/// 复制Clash环境变量
|
/// 复制Clash环境变量
|
||||||
@@ -24,7 +26,8 @@ pub async fn patch_clash_config(payload: Mapping) -> CmdResult {
|
|||||||
/// 修改Clash模式
|
/// 修改Clash模式
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn patch_clash_mode(payload: String) -> CmdResult {
|
pub async fn patch_clash_mode(payload: String) -> CmdResult {
|
||||||
Ok(feat::change_clash_mode(payload))
|
feat::change_clash_mode(payload);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 切换Clash核心
|
/// 切换Clash核心
|
||||||
@@ -37,10 +40,21 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
log::info!(target: "app", "core changed to {clash_core}");
|
// 切换内核后重启内核
|
||||||
handle::Handle::notice_message("config_core::change_success", &clash_core);
|
match CoreManager::global().restart_core().await {
|
||||||
handle::Handle::refresh_clash();
|
Ok(_) => {
|
||||||
Ok(None)
|
log::info!(target: "app", "core changed and restarted to {clash_core}");
|
||||||
|
handle::Handle::notice_message("config_core::change_success", &clash_core);
|
||||||
|
handle::Handle::refresh_clash();
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
let error_msg = format!("Core changed but failed to restart: {err}");
|
||||||
|
log::error!(target: "app", "{error_msg}");
|
||||||
|
handle::Handle::notice_message("config_core::change_error", &error_msg);
|
||||||
|
Ok(Some(error_msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let error_msg = err.to_string();
|
let error_msg = err.to_string();
|
||||||
@@ -51,6 +65,18 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 启动核心
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn start_core() -> CmdResult {
|
||||||
|
wrap_err!(CoreManager::global().start_core().await)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 关闭核心
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn stop_core() -> CmdResult {
|
||||||
|
wrap_err!(CoreManager::global().stop_core().await)
|
||||||
|
}
|
||||||
|
|
||||||
/// 重启核心
|
/// 重启核心
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn restart_core() -> CmdResult {
|
pub async fn restart_core() -> CmdResult {
|
||||||
@@ -90,7 +116,7 @@ pub async fn save_dns_config(dns_config: Mapping) -> CmdResult {
|
|||||||
// 保存DNS配置到文件
|
// 保存DNS配置到文件
|
||||||
let yaml_str = serde_yaml::to_string(&dns_config).map_err(|e| e.to_string())?;
|
let yaml_str = serde_yaml::to_string(&dns_config).map_err(|e| e.to_string())?;
|
||||||
fs::write(&dns_path, yaml_str).map_err(|e| e.to_string())?;
|
fs::write(&dns_path, yaml_str).map_err(|e| e.to_string())?;
|
||||||
log::info!(target: "app", "DNS config saved to {:?}", dns_path);
|
log::info!(target: "app", "DNS config saved to {dns_path:?}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -98,19 +124,20 @@ pub async fn save_dns_config(dns_config: Mapping) -> CmdResult {
|
|||||||
/// 应用或撤销DNS配置
|
/// 应用或撤销DNS配置
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn apply_dns_config(apply: bool) -> CmdResult {
|
pub fn apply_dns_config(apply: bool) -> CmdResult {
|
||||||
use crate::config::Config;
|
use crate::{
|
||||||
use crate::core::{handle, CoreManager};
|
config::Config,
|
||||||
use crate::utils::dirs;
|
core::{handle, CoreManager},
|
||||||
use tauri::async_runtime;
|
utils::dirs,
|
||||||
|
};
|
||||||
|
|
||||||
// 使用spawn来处理异步操作
|
// 使用spawn来处理异步操作
|
||||||
async_runtime::spawn(async move {
|
AsyncHandler::spawn(move || async move {
|
||||||
if apply {
|
if apply {
|
||||||
// 读取DNS配置文件
|
// 读取DNS配置文件
|
||||||
let dns_path = match dirs::app_home_dir() {
|
let dns_path = match dirs::app_home_dir() {
|
||||||
Ok(path) => path.join("dns_config.yaml"),
|
Ok(path) => path.join("dns_config.yaml"),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(target: "app", "Failed to get home dir: {}", e);
|
log::error!(target: "app", "Failed to get home dir: {e}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -123,7 +150,7 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
|
|||||||
let dns_yaml = match std::fs::read_to_string(&dns_path) {
|
let dns_yaml = match std::fs::read_to_string(&dns_path) {
|
||||||
Ok(content) => content,
|
Ok(content) => content,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(target: "app", "Failed to read DNS config: {}", e);
|
log::error!(target: "app", "Failed to read DNS config: {e}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -136,7 +163,7 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
|
|||||||
patch
|
patch
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(target: "app", "Failed to parse DNS config: {}", e);
|
log::error!(target: "app", "Failed to parse DNS config: {e}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -151,13 +178,13 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
|
|||||||
|
|
||||||
// 首先重新生成配置
|
// 首先重新生成配置
|
||||||
if let Err(err) = Config::generate().await {
|
if let Err(err) = Config::generate().await {
|
||||||
log::error!(target: "app", "Failed to regenerate config with DNS: {}", err);
|
log::error!(target: "app", "Failed to regenerate config with DNS: {err}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 然后应用新配置
|
// 然后应用新配置
|
||||||
if let Err(err) = CoreManager::global().update_config().await {
|
if let Err(err) = CoreManager::global().update_config().await {
|
||||||
log::error!(target: "app", "Failed to apply config with DNS: {}", err);
|
log::error!(target: "app", "Failed to apply config with DNS: {err}");
|
||||||
} else {
|
} else {
|
||||||
log::info!(target: "app", "DNS config successfully applied");
|
log::info!(target: "app", "DNS config successfully applied");
|
||||||
handle::Handle::refresh_clash();
|
handle::Handle::refresh_clash();
|
||||||
@@ -169,7 +196,7 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
|
|||||||
|
|
||||||
// 重新生成配置
|
// 重新生成配置
|
||||||
if let Err(err) = Config::generate().await {
|
if let Err(err) = Config::generate().await {
|
||||||
log::error!(target: "app", "Failed to regenerate config: {}", err);
|
log::error!(target: "app", "Failed to regenerate config: {err}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +207,7 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
|
|||||||
handle::Handle::refresh_clash();
|
handle::Handle::refresh_clash();
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!(target: "app", "Failed to apply regenerated config: {}", err);
|
log::error!(target: "app", "Failed to apply regenerated config: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,3 +245,25 @@ pub async fn get_dns_config_content() -> CmdResult<String> {
|
|||||||
let content = fs::read_to_string(&dns_path).map_err(|e| e.to_string())?;
|
let content = fs::read_to_string(&dns_path).map_err(|e| e.to_string())?;
|
||||||
Ok(content)
|
Ok(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 验证DNS配置文件
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn validate_dns_config() -> CmdResult<(bool, String)> {
|
||||||
|
use crate::{core::CoreManager, utils::dirs};
|
||||||
|
|
||||||
|
let app_dir = dirs::app_home_dir().map_err(|e| e.to_string())?;
|
||||||
|
let dns_path = app_dir.join("dns_config.yaml");
|
||||||
|
let dns_path_str = dns_path.to_str().unwrap_or_default();
|
||||||
|
|
||||||
|
if !dns_path.exists() {
|
||||||
|
return Ok((false, "DNS config file not found".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
match CoreManager::global()
|
||||||
|
.validate_config_file(dns_path_str, None)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(result) => Ok(result),
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
15
src-tauri/src/cmd/lightweight.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use crate::module::lightweight;
|
||||||
|
|
||||||
|
use super::CmdResult;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn entry_lightweight_mode() -> CmdResult {
|
||||||
|
lightweight::entry_lightweight_mode();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn exit_lightweight_mode() -> CmdResult {
|
||||||
|
lightweight::exit_lightweight_mode();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
1295
src-tauri/src/cmd/media_unlock_checker.rs
Normal file
@@ -4,29 +4,35 @@ use anyhow::Result;
|
|||||||
pub type CmdResult<T = ()> = Result<T, String>;
|
pub type CmdResult<T = ()> = Result<T, String>;
|
||||||
|
|
||||||
// Command modules
|
// Command modules
|
||||||
pub mod profile;
|
|
||||||
pub mod validate;
|
|
||||||
pub mod uwp;
|
|
||||||
pub mod webdav;
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
pub mod network;
|
|
||||||
pub mod clash;
|
pub mod clash;
|
||||||
pub mod verge;
|
pub mod lightweight;
|
||||||
|
pub mod media_unlock_checker;
|
||||||
|
pub mod network;
|
||||||
|
pub mod profile;
|
||||||
|
pub mod proxy;
|
||||||
pub mod runtime;
|
pub mod runtime;
|
||||||
pub mod save_profile;
|
pub mod save_profile;
|
||||||
|
pub mod service;
|
||||||
pub mod system;
|
pub mod system;
|
||||||
pub mod proxy;
|
pub mod uwp;
|
||||||
|
pub mod validate;
|
||||||
|
pub mod verge;
|
||||||
|
pub mod webdav;
|
||||||
|
|
||||||
// Re-export all command functions for backwards compatibility
|
// Re-export all command functions for backwards compatibility
|
||||||
pub use profile::*;
|
|
||||||
pub use validate::*;
|
|
||||||
pub use uwp::*;
|
|
||||||
pub use webdav::*;
|
|
||||||
pub use app::*;
|
pub use app::*;
|
||||||
pub use network::*;
|
|
||||||
pub use clash::*;
|
pub use clash::*;
|
||||||
pub use verge::*;
|
pub use lightweight::*;
|
||||||
|
pub use media_unlock_checker::*;
|
||||||
|
pub use network::*;
|
||||||
|
pub use profile::*;
|
||||||
|
pub use proxy::*;
|
||||||
pub use runtime::*;
|
pub use runtime::*;
|
||||||
pub use save_profile::*;
|
pub use save_profile::*;
|
||||||
|
pub use service::*;
|
||||||
pub use system::*;
|
pub use system::*;
|
||||||
pub use proxy::*;
|
pub use uwp::*;
|
||||||
|
pub use validate::*;
|
||||||
|
pub use verge::*;
|
||||||
|
pub use webdav::*;
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
use crate::wrap_err;
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use sysproxy::{Autoproxy, Sysproxy};
|
use crate::core::{async_proxy_query::AsyncProxyQuery, EventDrivenProxyManager};
|
||||||
use serde_yaml::Mapping;
|
use crate::wrap_err;
|
||||||
use network_interface::NetworkInterface;
|
use network_interface::NetworkInterface;
|
||||||
|
use serde_yaml::Mapping;
|
||||||
|
|
||||||
/// get the system proxy
|
/// get the system proxy
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_sys_proxy() -> CmdResult<Mapping> {
|
pub async fn get_sys_proxy() -> CmdResult<Mapping> {
|
||||||
let current = wrap_err!(Sysproxy::get_system_proxy())?;
|
log::debug!(target: "app", "异步获取系统代理配置");
|
||||||
|
|
||||||
|
let current = AsyncProxyQuery::get_system_proxy().await;
|
||||||
|
|
||||||
let mut map = Mapping::new();
|
let mut map = Mapping::new();
|
||||||
map.insert("enable".into(), current.enable.into());
|
map.insert("enable".into(), current.enable.into());
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -16,21 +19,50 @@ pub fn get_sys_proxy() -> CmdResult<Mapping> {
|
|||||||
);
|
);
|
||||||
map.insert("bypass".into(), current.bypass.into());
|
map.insert("bypass".into(), current.bypass.into());
|
||||||
|
|
||||||
|
log::debug!(target: "app", "返回系统代理配置: enable={}, {}:{}", current.enable, current.host, current.port);
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get the system proxy
|
/// 获取自动代理配置
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_auto_proxy() -> CmdResult<Mapping> {
|
pub async fn get_auto_proxy() -> CmdResult<Mapping> {
|
||||||
let current = wrap_err!(Autoproxy::get_auto_proxy())?;
|
log::debug!(target: "app", "开始获取自动代理配置(事件驱动)");
|
||||||
|
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
|
||||||
|
let current = proxy_manager.get_auto_proxy_cached();
|
||||||
|
// 异步请求更新,立即返回缓存数据
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = proxy_manager.get_auto_proxy_async().await;
|
||||||
|
});
|
||||||
|
|
||||||
let mut map = Mapping::new();
|
let mut map = Mapping::new();
|
||||||
map.insert("enable".into(), current.enable.into());
|
map.insert("enable".into(), current.enable.into());
|
||||||
map.insert("url".into(), current.url.into());
|
map.insert("url".into(), current.url.clone().into());
|
||||||
|
|
||||||
|
log::debug!(target: "app", "返回自动代理配置(缓存): enable={}, url={}", current.enable, current.url);
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 获取系统主机名
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_system_hostname() -> CmdResult<String> {
|
||||||
|
use gethostname::gethostname;
|
||||||
|
|
||||||
|
// 获取系统主机名,处理可能的非UTF-8字符
|
||||||
|
let hostname = match gethostname().into_string() {
|
||||||
|
Ok(name) => name,
|
||||||
|
Err(os_string) => {
|
||||||
|
// 对于包含非UTF-8的主机名,使用调试格式化
|
||||||
|
let fallback = format!("{os_string:?}");
|
||||||
|
// 去掉可能存在的引号
|
||||||
|
fallback.trim_matches('"').to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(hostname)
|
||||||
|
}
|
||||||
|
|
||||||
/// 获取网络接口列表
|
/// 获取网络接口列表
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_network_interfaces() -> Vec<String> {
|
pub fn get_network_interfaces() -> Vec<String> {
|
||||||
@@ -46,8 +78,7 @@ pub fn get_network_interfaces() -> Vec<String> {
|
|||||||
/// 获取网络接口详细信息
|
/// 获取网络接口详细信息
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_network_interfaces_info() -> CmdResult<Vec<NetworkInterface>> {
|
pub fn get_network_interfaces_info() -> CmdResult<Vec<NetworkInterface>> {
|
||||||
use network_interface::NetworkInterface;
|
use network_interface::{NetworkInterface, NetworkInterfaceConfig};
|
||||||
use network_interface::NetworkInterfaceConfig;
|
|
||||||
|
|
||||||
let names = get_network_interfaces();
|
let names = get_network_interfaces();
|
||||||
let interfaces = wrap_err!(NetworkInterface::show())?;
|
let interfaces = wrap_err!(NetworkInterface::show())?;
|
||||||
|
|||||||
@@ -1,47 +1,152 @@
|
|||||||
use crate::{
|
|
||||||
config::*,
|
|
||||||
core::*,
|
|
||||||
feat,
|
|
||||||
utils::{dirs, help},
|
|
||||||
log_err, ret_err, wrap_err,
|
|
||||||
};
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
|
use crate::{
|
||||||
|
config::{Config, IProfiles, PrfItem, PrfOption},
|
||||||
|
core::{handle, timer::Timer, tray::Tray, CoreManager},
|
||||||
|
feat, logging, ret_err,
|
||||||
|
utils::{dirs, help, logging::Type},
|
||||||
|
wrap_err,
|
||||||
|
};
|
||||||
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
use std::time::Duration;
|
||||||
|
use tokio::sync::{Mutex, RwLock};
|
||||||
|
|
||||||
/// 获取配置文件列表
|
// 全局互斥锁防止并发配置更新
|
||||||
|
static PROFILE_UPDATE_MUTEX: Mutex<()> = Mutex::const_new(());
|
||||||
|
|
||||||
|
// 全局请求序列号跟踪,用于避免队列化执行
|
||||||
|
static CURRENT_REQUEST_SEQUENCE: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
|
static CURRENT_PROCESSING_PROFILE: RwLock<Option<String>> = RwLock::const_new(None);
|
||||||
|
|
||||||
|
/// 清理配置处理状态
|
||||||
|
async fn cleanup_processing_state(sequence: u64, reason: &str) {
|
||||||
|
*CURRENT_PROCESSING_PROFILE.write().await = None;
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"{},清理状态,序列号: {}",
|
||||||
|
reason,
|
||||||
|
sequence
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取配置文件避免锁竞争
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_profiles() -> CmdResult<IProfiles> {
|
pub async fn get_profiles() -> CmdResult<IProfiles> {
|
||||||
let _ = tray::Tray::global().update_menu();
|
// 策略1: 尝试快速获取latest数据
|
||||||
Ok(Config::profiles().data().clone())
|
let latest_result = tokio::time::timeout(
|
||||||
|
Duration::from_millis(500),
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let profiles = Config::profiles();
|
||||||
|
let latest = profiles.latest();
|
||||||
|
IProfiles {
|
||||||
|
current: latest.current.clone(),
|
||||||
|
items: latest.items.clone(),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match latest_result {
|
||||||
|
Ok(Ok(profiles)) => {
|
||||||
|
logging!(info, Type::Cmd, false, "快速获取配置列表成功");
|
||||||
|
return Ok(profiles);
|
||||||
|
}
|
||||||
|
Ok(Err(join_err)) => {
|
||||||
|
logging!(warn, Type::Cmd, true, "快速获取配置任务失败: {}", join_err);
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
logging!(warn, Type::Cmd, true, "快速获取配置超时(500ms)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 策略2: 如果快速获取失败,尝试获取data()
|
||||||
|
let data_result = tokio::time::timeout(
|
||||||
|
Duration::from_secs(2),
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let profiles = Config::profiles();
|
||||||
|
let data = profiles.data();
|
||||||
|
IProfiles {
|
||||||
|
current: data.current.clone(),
|
||||||
|
items: data.items.clone(),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match data_result {
|
||||||
|
Ok(Ok(profiles)) => {
|
||||||
|
logging!(info, Type::Cmd, false, "获取draft配置列表成功");
|
||||||
|
return Ok(profiles);
|
||||||
|
}
|
||||||
|
Ok(Err(join_err)) => {
|
||||||
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"获取draft配置任务失败: {}",
|
||||||
|
join_err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
logging!(error, Type::Cmd, true, "获取draft配置超时(2秒)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 策略3: fallback,尝试重新创建配置
|
||||||
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"所有获取配置策略都失败,尝试fallback"
|
||||||
|
);
|
||||||
|
|
||||||
|
match tokio::task::spawn_blocking(IProfiles::new).await {
|
||||||
|
Ok(profiles) => {
|
||||||
|
logging!(info, Type::Cmd, true, "使用fallback配置成功");
|
||||||
|
Ok(profiles)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
logging!(error, Type::Cmd, true, "fallback配置也失败: {}", err);
|
||||||
|
// 返回空配置避免崩溃
|
||||||
|
Ok(IProfiles {
|
||||||
|
current: None,
|
||||||
|
items: Some(vec![]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 增强配置文件
|
/// 增强配置文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn enhance_profiles() -> CmdResult {
|
pub async fn enhance_profiles() -> CmdResult {
|
||||||
match CoreManager::global().update_config().await {
|
wrap_err!(feat::enhance_profiles().await)?;
|
||||||
Ok((true, _)) => {
|
handle::Handle::refresh_clash();
|
||||||
println!("[enhance_profiles] 配置更新成功");
|
Ok(())
|
||||||
log_err!(tray::Tray::global().update_tooltip());
|
|
||||||
handle::Handle::refresh_clash();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Ok((false, error_msg)) => {
|
|
||||||
println!("[enhance_profiles] 配置验证失败: {}", error_msg);
|
|
||||||
handle::Handle::notice_message("config_validate::error", &error_msg);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
println!("[enhance_profiles] 更新过程发生错误: {}", e);
|
|
||||||
handle::Handle::notice_message("config_validate::process_terminated", &e.to_string());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 导入配置文件
|
/// 导入配置文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult {
|
pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult {
|
||||||
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
|
let existing_uid = {
|
||||||
wrap_err!(Config::profiles().data().append_item(item))
|
let profiles = Config::profiles();
|
||||||
|
let profiles = profiles.latest();
|
||||||
|
|
||||||
|
profiles.items.as_ref()
|
||||||
|
.and_then(|items| items.iter().find(|item| item.url.as_deref() == Some(&url)))
|
||||||
|
.and_then(|item| item.uid.clone())
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(uid) = existing_uid {
|
||||||
|
logging!(info, Type::Cmd, true, "The profile with URL {} already exists (UID: {}). Running the update...", url, uid);
|
||||||
|
update_profile(uid, option).await
|
||||||
|
} else {
|
||||||
|
logging!(info, Type::Cmd, true, "Profile with URL {} not found. Create a new one...", url);
|
||||||
|
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
|
||||||
|
wrap_err!(Config::profiles().data().append_item(item))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 重新排序配置文件
|
/// 重新排序配置文件
|
||||||
@@ -60,13 +165,17 @@ pub async fn create_profile(item: PrfItem, file_data: Option<String>) -> CmdResu
|
|||||||
/// 更新配置文件
|
/// 更新配置文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn update_profile(index: String, option: Option<PrfOption>) -> CmdResult {
|
pub async fn update_profile(index: String, option: Option<PrfOption>) -> CmdResult {
|
||||||
wrap_err!(feat::update_profile(index, option).await)
|
wrap_err!(feat::update_profile(index, option, Some(true)).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 删除配置文件
|
/// 删除配置文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn delete_profile(index: String) -> CmdResult {
|
pub async fn delete_profile(index: String) -> CmdResult {
|
||||||
let should_update = wrap_err!({ Config::profiles().data().delete_item(index) })?;
|
let should_update = wrap_err!({ Config::profiles().data().delete_item(index) })?;
|
||||||
|
|
||||||
|
// 删除后自动清理冗余文件
|
||||||
|
let _ = Config::profiles().latest().auto_cleanup();
|
||||||
|
|
||||||
if should_update {
|
if should_update {
|
||||||
wrap_err!(CoreManager::global().update_config().await)?;
|
wrap_err!(CoreManager::global().update_config().await)?;
|
||||||
handle::Handle::refresh_clash();
|
handle::Handle::refresh_clash();
|
||||||
@@ -76,36 +185,322 @@ pub async fn delete_profile(index: String) -> CmdResult {
|
|||||||
|
|
||||||
/// 修改profiles的配置
|
/// 修改profiles的配置
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn patch_profiles_config(
|
pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult<bool> {
|
||||||
profiles: IProfiles
|
// 为当前请求分配序列号
|
||||||
) -> CmdResult<bool> {
|
let current_sequence = CURRENT_REQUEST_SEQUENCE.fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
println!("[cmd配置patch] 开始修改配置文件");
|
let target_profile = profiles.current.clone();
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"开始修改配置文件,请求序列号: {}, 目标profile: {:?}",
|
||||||
|
current_sequence,
|
||||||
|
target_profile
|
||||||
|
);
|
||||||
|
|
||||||
|
let mutex_result =
|
||||||
|
tokio::time::timeout(Duration::from_millis(100), PROFILE_UPDATE_MUTEX.lock()).await;
|
||||||
|
|
||||||
|
let _guard = match mutex_result {
|
||||||
|
Ok(guard) => guard,
|
||||||
|
Err(_) => {
|
||||||
|
let latest_sequence = CURRENT_REQUEST_SEQUENCE.load(Ordering::SeqCst);
|
||||||
|
if current_sequence < latest_sequence {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"检测到更新的请求 (序列号: {} < {}),放弃当前请求",
|
||||||
|
current_sequence,
|
||||||
|
latest_sequence
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"强制获取锁以处理最新请求: {}",
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
PROFILE_UPDATE_MUTEX.lock().await
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let latest_sequence = CURRENT_REQUEST_SEQUENCE.load(Ordering::SeqCst);
|
||||||
|
if current_sequence < latest_sequence {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"获取锁后发现更新的请求 (序列号: {} < {}),放弃当前请求",
|
||||||
|
current_sequence,
|
||||||
|
latest_sequence
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
// 保存当前配置,以便在验证失败时恢复
|
// 保存当前配置,以便在验证失败时恢复
|
||||||
let current_profile = Config::profiles().latest().current.clone();
|
let current_profile = Config::profiles().latest().current.clone();
|
||||||
println!("[cmd配置patch] 当前配置: {:?}", current_profile);
|
logging!(info, Type::Cmd, true, "当前配置: {:?}", current_profile);
|
||||||
|
|
||||||
|
// 如果要切换配置,先检查目标配置文件是否有语法错误
|
||||||
|
if let Some(new_profile) = profiles.current.as_ref() {
|
||||||
|
if current_profile.as_ref() != Some(new_profile) {
|
||||||
|
logging!(info, Type::Cmd, true, "正在切换到新配置: {}", new_profile);
|
||||||
|
|
||||||
|
// 获取目标配置文件路径
|
||||||
|
let config_file_result = {
|
||||||
|
let profiles_config = Config::profiles();
|
||||||
|
let profiles_data = profiles_config.latest();
|
||||||
|
match profiles_data.get_item(new_profile) {
|
||||||
|
Ok(item) => {
|
||||||
|
if let Some(file) = &item.file {
|
||||||
|
let path = dirs::app_profiles_dir().map(|dir| dir.join(file));
|
||||||
|
path.ok()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Cmd, true, "获取目标配置信息失败: {}", e);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 如果获取到文件路径,检查YAML语法
|
||||||
|
if let Some(file_path) = config_file_result {
|
||||||
|
if !file_path.exists() {
|
||||||
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"目标配置文件不存在: {}",
|
||||||
|
file_path.display()
|
||||||
|
);
|
||||||
|
handle::Handle::notice_message(
|
||||||
|
"config_validate::file_not_found",
|
||||||
|
format!("{}", file_path.display()),
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 超时保护
|
||||||
|
let file_read_result = tokio::time::timeout(
|
||||||
|
Duration::from_secs(5),
|
||||||
|
tokio::fs::read_to_string(&file_path),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match file_read_result {
|
||||||
|
Ok(Ok(content)) => {
|
||||||
|
let yaml_parse_result = tokio::task::spawn_blocking(move || {
|
||||||
|
serde_yaml::from_str::<serde_yaml::Value>(&content)
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match yaml_parse_result {
|
||||||
|
Ok(Ok(_)) => {
|
||||||
|
logging!(info, Type::Cmd, true, "目标配置文件语法正确");
|
||||||
|
}
|
||||||
|
Ok(Err(err)) => {
|
||||||
|
let error_msg = format!(" {err}");
|
||||||
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"目标配置文件存在YAML语法错误:{}",
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
|
handle::Handle::notice_message(
|
||||||
|
"config_validate::yaml_syntax_error",
|
||||||
|
&error_msg,
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
Err(join_err) => {
|
||||||
|
let error_msg = format!("YAML解析任务失败: {join_err}");
|
||||||
|
logging!(error, Type::Cmd, true, "{}", error_msg);
|
||||||
|
handle::Handle::notice_message(
|
||||||
|
"config_validate::yaml_parse_error",
|
||||||
|
&error_msg,
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Err(err)) => {
|
||||||
|
let error_msg = format!("无法读取目标配置文件: {err}");
|
||||||
|
logging!(error, Type::Cmd, true, "{}", error_msg);
|
||||||
|
handle::Handle::notice_message(
|
||||||
|
"config_validate::file_read_error",
|
||||||
|
&error_msg,
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
let error_msg = "读取配置文件超时(5秒)".to_string();
|
||||||
|
logging!(error, Type::Cmd, true, "{}", error_msg);
|
||||||
|
handle::Handle::notice_message(
|
||||||
|
"config_validate::file_read_timeout",
|
||||||
|
&error_msg,
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查请求有效性
|
||||||
|
let latest_sequence = CURRENT_REQUEST_SEQUENCE.load(Ordering::SeqCst);
|
||||||
|
if current_sequence < latest_sequence {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"在核心操作前发现更新的请求 (序列号: {} < {}),放弃当前请求",
|
||||||
|
current_sequence,
|
||||||
|
latest_sequence
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(ref profile) = target_profile {
|
||||||
|
*CURRENT_PROCESSING_PROFILE.write().await = Some(profile.clone());
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"设置当前处理profile: {}, 序列号: {}",
|
||||||
|
profile,
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 更新profiles配置
|
// 更新profiles配置
|
||||||
println!("[cmd配置patch] 正在更新配置草稿");
|
logging!(
|
||||||
wrap_err!({ Config::profiles().draft().patch_config(profiles) })?;
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"正在更新配置草稿,序列号: {}",
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
|
||||||
|
let current_value = profiles.current.clone();
|
||||||
|
|
||||||
|
let _ = Config::profiles().draft().patch_config(profiles);
|
||||||
|
|
||||||
|
// 在调用内核前再次验证请求有效性
|
||||||
|
let latest_sequence = CURRENT_REQUEST_SEQUENCE.load(Ordering::SeqCst);
|
||||||
|
if current_sequence < latest_sequence {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"在内核交互前发现更新的请求 (序列号: {} < {}),放弃当前请求",
|
||||||
|
current_sequence,
|
||||||
|
latest_sequence
|
||||||
|
);
|
||||||
|
Config::profiles().discard();
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为配置更新添加超时保护
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"开始内核配置更新,序列号: {}",
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
let update_result = tokio::time::timeout(
|
||||||
|
Duration::from_secs(30), // 30秒超时
|
||||||
|
CoreManager::global().update_config(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
// 更新配置并进行验证
|
// 更新配置并进行验证
|
||||||
match CoreManager::global().update_config().await {
|
match update_result {
|
||||||
Ok((true, _)) => {
|
Ok(Ok((true, _))) => {
|
||||||
println!("[cmd配置patch] 配置更新成功");
|
// 内核操作完成后再次检查请求有效性
|
||||||
handle::Handle::refresh_clash();
|
let latest_sequence = CURRENT_REQUEST_SEQUENCE.load(Ordering::SeqCst);
|
||||||
let _ = tray::Tray::global().update_tooltip();
|
if current_sequence < latest_sequence {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"内核操作后发现更新的请求 (序列号: {} < {}),忽略当前结果",
|
||||||
|
current_sequence,
|
||||||
|
latest_sequence
|
||||||
|
);
|
||||||
|
Config::profiles().discard();
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"配置更新成功,序列号: {}",
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
Config::profiles().apply();
|
Config::profiles().apply();
|
||||||
wrap_err!(Config::profiles().data().save_file())?;
|
handle::Handle::refresh_clash();
|
||||||
|
|
||||||
|
// 强制刷新代理缓存,确保profile切换后立即获取最新节点数据
|
||||||
|
crate::process::AsyncHandler::spawn(|| async move {
|
||||||
|
if let Err(e) = super::proxy::force_refresh_proxies().await {
|
||||||
|
log::warn!(target: "app", "强制刷新代理缓存失败: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
crate::process::AsyncHandler::spawn(|| async move {
|
||||||
|
if let Err(e) = Tray::global().update_tooltip() {
|
||||||
|
log::warn!(target: "app", "异步更新托盘提示失败: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(e) = Tray::global().update_menu() {
|
||||||
|
log::warn!(target: "app", "异步更新托盘菜单失败: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存配置文件
|
||||||
|
if let Err(e) = Config::profiles().data().save_file() {
|
||||||
|
log::warn!(target: "app", "异步保存配置文件失败: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 立即通知前端配置变更
|
||||||
|
if let Some(current) = ¤t_value {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"向前端发送配置变更事件: {}, 序列号: {}",
|
||||||
|
current,
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
handle::Handle::notify_profile_changed(current.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_processing_state(current_sequence, "配置切换完成").await;
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
Ok((false, error_msg)) => {
|
Ok(Ok((false, error_msg))) => {
|
||||||
println!("[cmd配置patch] 配置验证失败: {}", error_msg);
|
logging!(warn, Type::Cmd, true, "配置验证失败: {}", error_msg);
|
||||||
Config::profiles().discard();
|
Config::profiles().discard();
|
||||||
|
|
||||||
// 如果验证失败,恢复到之前的配置
|
// 如果验证失败,恢复到之前的配置
|
||||||
if let Some(prev_profile) = current_profile {
|
if let Some(prev_profile) = current_profile {
|
||||||
println!("[cmd配置patch] 尝试恢复到之前的配置: {}", prev_profile);
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"尝试恢复到之前的配置: {}",
|
||||||
|
prev_profile
|
||||||
|
);
|
||||||
let restore_profiles = IProfiles {
|
let restore_profiles = IProfiles {
|
||||||
current: Some(prev_profile),
|
current: Some(prev_profile),
|
||||||
items: None,
|
items: None,
|
||||||
@@ -113,18 +508,73 @@ pub async fn patch_profiles_config(
|
|||||||
// 静默恢复,不触发验证
|
// 静默恢复,不触发验证
|
||||||
wrap_err!({ Config::profiles().draft().patch_config(restore_profiles) })?;
|
wrap_err!({ Config::profiles().draft().patch_config(restore_profiles) })?;
|
||||||
Config::profiles().apply();
|
Config::profiles().apply();
|
||||||
wrap_err!(Config::profiles().data().save_file())?;
|
|
||||||
println!("[cmd配置patch] 成功恢复到之前的配置");
|
crate::process::AsyncHandler::spawn(|| async move {
|
||||||
|
if let Err(e) = Config::profiles().data().save_file() {
|
||||||
|
log::warn!(target: "app", "异步保存恢复配置文件失败: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
logging!(info, Type::Cmd, true, "成功恢复到之前的配置");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送验证错误通知
|
// 发送验证错误通知
|
||||||
handle::Handle::notice_message("config_validate::error", &error_msg);
|
handle::Handle::notice_message("config_validate::error", &error_msg);
|
||||||
|
|
||||||
|
cleanup_processing_state(current_sequence, "配置验证失败").await;
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Ok(Err(e)) => {
|
||||||
println!("[cmd配置patch] 更新过程发生错误: {}", e);
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"更新过程发生错误: {}, 序列号: {}",
|
||||||
|
e,
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
Config::profiles().discard();
|
Config::profiles().discard();
|
||||||
handle::Handle::notice_message("config_validate::boot_error", &e.to_string());
|
handle::Handle::notice_message("config_validate::boot_error", e.to_string());
|
||||||
|
|
||||||
|
cleanup_processing_state(current_sequence, "更新过程错误").await;
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
// 超时处理
|
||||||
|
let timeout_msg = "配置更新超时(30秒),可能是配置验证或核心通信阻塞";
|
||||||
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"{}, 序列号: {}",
|
||||||
|
timeout_msg,
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
Config::profiles().discard();
|
||||||
|
|
||||||
|
if let Some(prev_profile) = current_profile {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Cmd,
|
||||||
|
true,
|
||||||
|
"超时后尝试恢复到之前的配置: {}, 序列号: {}",
|
||||||
|
prev_profile,
|
||||||
|
current_sequence
|
||||||
|
);
|
||||||
|
let restore_profiles = IProfiles {
|
||||||
|
current: Some(prev_profile),
|
||||||
|
items: None,
|
||||||
|
};
|
||||||
|
wrap_err!({ Config::profiles().draft().patch_config(restore_profiles) })?;
|
||||||
|
Config::profiles().apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
handle::Handle::notice_message("config_validate::timeout", timeout_msg);
|
||||||
|
|
||||||
|
cleanup_processing_state(current_sequence, "配置更新超时").await;
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,16 +584,47 @@ pub async fn patch_profiles_config(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn patch_profiles_config_by_profile_index(
|
pub async fn patch_profiles_config_by_profile_index(
|
||||||
_app_handle: tauri::AppHandle,
|
_app_handle: tauri::AppHandle,
|
||||||
profile_index: String
|
profile_index: String,
|
||||||
) -> CmdResult<bool> {
|
) -> CmdResult<bool> {
|
||||||
let profiles = IProfiles{current: Some(profile_index), items: None};
|
logging!(info, Type::Cmd, true, "切换配置到: {}", profile_index);
|
||||||
|
|
||||||
|
let profiles = IProfiles {
|
||||||
|
current: Some(profile_index),
|
||||||
|
items: None,
|
||||||
|
};
|
||||||
patch_profiles_config(profiles).await
|
patch_profiles_config(profiles).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改某个profile item的
|
/// 修改某个profile item的
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn patch_profile(index: String, profile: PrfItem) -> CmdResult {
|
pub fn patch_profile(index: String, profile: PrfItem) -> CmdResult {
|
||||||
wrap_err!(Config::profiles().data().patch_item(index, profile))?;
|
// 保存修改前检查是否有更新 update_interval
|
||||||
|
let update_interval_changed =
|
||||||
|
if let Ok(old_profile) = Config::profiles().latest().get_item(&index) {
|
||||||
|
let old_interval = old_profile.option.as_ref().and_then(|o| o.update_interval);
|
||||||
|
let new_interval = profile.option.as_ref().and_then(|o| o.update_interval);
|
||||||
|
old_interval != new_interval
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
// 保存修改
|
||||||
|
wrap_err!(Config::profiles().data().patch_item(index.clone(), profile))?;
|
||||||
|
|
||||||
|
// 如果更新间隔变更,异步刷新定时器
|
||||||
|
if update_interval_changed {
|
||||||
|
let index_clone = index.clone();
|
||||||
|
crate::process::AsyncHandler::spawn(move || async move {
|
||||||
|
logging!(info, Type::Timer, "定时器更新间隔已变更,正在刷新定时器...");
|
||||||
|
if let Err(e) = crate::core::Timer::global().refresh() {
|
||||||
|
logging!(error, Type::Timer, "刷新定时器失败: {}", e);
|
||||||
|
} else {
|
||||||
|
// 刷新成功后发送自定义事件,不触发配置重载
|
||||||
|
crate::core::handle::Handle::notify_timer_updated(index_clone);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,3 +655,56 @@ pub fn read_profile_file(index: String) -> CmdResult<String> {
|
|||||||
let data = wrap_err!(item.read_file())?;
|
let data = wrap_err!(item.read_file())?;
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 获取下一次更新时间
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_next_update_time(uid: String) -> CmdResult<Option<i64>> {
|
||||||
|
let timer = Timer::global();
|
||||||
|
let next_time = timer.get_next_update_time(&uid);
|
||||||
|
Ok(next_time)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn update_profiles_on_startup() -> CmdResult {
|
||||||
|
logging!(info, Type::Cmd, true, "Checking profiles for updates at startup...");
|
||||||
|
|
||||||
|
let profiles_to_update = {
|
||||||
|
let profiles = Config::profiles();
|
||||||
|
let profiles = profiles.latest();
|
||||||
|
|
||||||
|
profiles.items.as_ref()
|
||||||
|
.map_or_else(
|
||||||
|
Vec::new,
|
||||||
|
|items| items.iter()
|
||||||
|
.filter(|item| item.option.as_ref().is_some_and(|opt| opt.update_always == Some(true)))
|
||||||
|
.filter_map(|item| item.uid.clone())
|
||||||
|
.collect()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if profiles_to_update.is_empty() {
|
||||||
|
logging!(info, Type::Cmd, true, "No profiles to update immediately.");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(info, Type::Cmd, true, "Found profiles to update: {:?}", profiles_to_update);
|
||||||
|
|
||||||
|
let mut update_futures = Vec::new();
|
||||||
|
for uid in profiles_to_update {
|
||||||
|
update_futures.push(update_profile(uid, None));
|
||||||
|
}
|
||||||
|
|
||||||
|
let results = futures::future::join_all(update_futures).await;
|
||||||
|
|
||||||
|
|
||||||
|
if results.iter().any(|res| res.is_ok()) {
|
||||||
|
logging!(info, Type::Cmd, true, "The startup update is complete, restart the kernel...");
|
||||||
|
CoreManager::global().update_config().await.map_err(|e| e.to_string())?;
|
||||||
|
handle::Handle::refresh_clash();
|
||||||
|
} else {
|
||||||
|
logging!(warn, Type::Cmd, true, "All updates completed with errors on startup.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,99 @@
|
|||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::module::mihomo::MihomoManager;
|
use crate::{core::handle, module::mihomo::MihomoManager, state::proxy::CmdProxyState};
|
||||||
|
use std::{
|
||||||
|
sync::Mutex,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
use tauri::Manager;
|
||||||
|
|
||||||
|
const PROVIDERS_REFRESH_INTERVAL: Duration = Duration::from_secs(3);
|
||||||
|
const PROXIES_REFRESH_INTERVAL: Duration = Duration::from_secs(1);
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn get_proxies() -> CmdResult<serde_json::Value> {
|
pub async fn get_proxies() -> CmdResult<serde_json::Value> {
|
||||||
let mannager = MihomoManager::global();
|
let manager = MihomoManager::global();
|
||||||
mannager.refresh_proxies().await.unwrap();
|
|
||||||
Ok(mannager.get_proxies())
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
|
let cmd_proxy_state = app_handle.state::<Mutex<CmdProxyState>>();
|
||||||
|
|
||||||
|
let should_refresh = {
|
||||||
|
let mut state = cmd_proxy_state.lock().unwrap();
|
||||||
|
let now = Instant::now();
|
||||||
|
if now.duration_since(state.last_refresh_time) > PROXIES_REFRESH_INTERVAL {
|
||||||
|
state.need_refresh = true;
|
||||||
|
state.last_refresh_time = now;
|
||||||
|
}
|
||||||
|
state.need_refresh
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_refresh {
|
||||||
|
let proxies = manager.get_refresh_proxies().await?;
|
||||||
|
{
|
||||||
|
let mut state = cmd_proxy_state.lock().unwrap();
|
||||||
|
state.proxies = Box::new(proxies);
|
||||||
|
state.need_refresh = false;
|
||||||
|
}
|
||||||
|
log::debug!(target: "app", "proxies刷新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
let proxies = {
|
||||||
|
let state = cmd_proxy_state.lock().unwrap();
|
||||||
|
state.proxies.clone()
|
||||||
|
};
|
||||||
|
Ok(*proxies)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 强制刷新代理缓存用于profile切换
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn force_refresh_proxies() -> CmdResult<serde_json::Value> {
|
||||||
|
let manager = MihomoManager::global();
|
||||||
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
|
let cmd_proxy_state = app_handle.state::<Mutex<CmdProxyState>>();
|
||||||
|
|
||||||
|
log::debug!(target: "app", "强制刷新代理缓存");
|
||||||
|
|
||||||
|
let proxies = manager.get_refresh_proxies().await?;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut state = cmd_proxy_state.lock().unwrap();
|
||||||
|
state.proxies = Box::new(proxies.clone());
|
||||||
|
state.need_refresh = false;
|
||||||
|
state.last_refresh_time = Instant::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
log::debug!(target: "app", "强制刷新代理缓存完成");
|
||||||
|
Ok(proxies)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn get_providers_proxies() -> CmdResult<serde_json::Value> {
|
pub async fn get_providers_proxies() -> CmdResult<serde_json::Value> {
|
||||||
let mannager = MihomoManager::global();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
mannager.refresh_providers_proxies().await.unwrap();
|
let cmd_proxy_state = app_handle.state::<Mutex<CmdProxyState>>();
|
||||||
Ok(mannager.get_providers_proxies())
|
|
||||||
|
let should_refresh = {
|
||||||
|
let mut state = cmd_proxy_state.lock().unwrap();
|
||||||
|
let now = Instant::now();
|
||||||
|
if now.duration_since(state.last_refresh_time) > PROVIDERS_REFRESH_INTERVAL {
|
||||||
|
state.need_refresh = true;
|
||||||
|
state.last_refresh_time = now;
|
||||||
|
}
|
||||||
|
state.need_refresh
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_refresh {
|
||||||
|
let manager = MihomoManager::global();
|
||||||
|
let providers = manager.get_providers_proxies().await?;
|
||||||
|
{
|
||||||
|
let mut state = cmd_proxy_state.lock().unwrap();
|
||||||
|
state.providers_proxies = Box::new(providers);
|
||||||
|
state.need_refresh = false;
|
||||||
|
}
|
||||||
|
log::debug!(target: "app", "providers_proxies刷新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
let providers_proxies = {
|
||||||
|
let state = cmd_proxy_state.lock().unwrap();
|
||||||
|
state.providers_proxies.clone()
|
||||||
|
};
|
||||||
|
Ok(*providers_proxies)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
use crate::{
|
|
||||||
config::*,
|
|
||||||
wrap_err,
|
|
||||||
};
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
|
use crate::{config::*, wrap_err};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use std::collections::HashMap;
|
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// 获取运行时配置
|
/// 获取运行时配置
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
use super::CmdResult;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::*,
|
config::*,
|
||||||
core::*,
|
core::*,
|
||||||
utils::dirs,
|
logging,
|
||||||
|
utils::{dirs, logging::Type},
|
||||||
wrap_err,
|
wrap_err,
|
||||||
};
|
};
|
||||||
use super::CmdResult;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
/// 保存profiles的配置
|
/// 保存profiles的配置
|
||||||
@@ -20,7 +21,7 @@ pub async fn save_profile_file(index: String, file_data: Option<String>) -> CmdR
|
|||||||
let profiles_guard = profiles.latest();
|
let profiles_guard = profiles.latest();
|
||||||
let item = wrap_err!(profiles_guard.get_item(&index))?;
|
let item = wrap_err!(profiles_guard.get_item(&index))?;
|
||||||
// 确定是否为merge类型文件
|
// 确定是否为merge类型文件
|
||||||
let is_merge = item.itype.as_ref().map_or(false, |t| t == "merge");
|
let is_merge = item.itype.as_ref().is_some_and(|t| t == "merge");
|
||||||
let content = wrap_err!(item.read_file())?;
|
let content = wrap_err!(item.read_file())?;
|
||||||
let path = item.file.clone().ok_or("file field is null")?;
|
let path = item.file.clone().ok_or("file field is null")?;
|
||||||
let profiles_dir = wrap_err!(dirs::app_profiles_dir())?;
|
let profiles_dir = wrap_err!(dirs::app_profiles_dir())?;
|
||||||
@@ -31,23 +32,54 @@ pub async fn save_profile_file(index: String, file_data: Option<String>) -> CmdR
|
|||||||
wrap_err!(fs::write(&file_path, file_data.clone().unwrap()))?;
|
wrap_err!(fs::write(&file_path, file_data.clone().unwrap()))?;
|
||||||
|
|
||||||
let file_path_str = file_path.to_string_lossy().to_string();
|
let file_path_str = file_path.to_string_lossy().to_string();
|
||||||
println!("[cmd配置save] 开始验证配置文件: {}, 是否为merge文件: {}", file_path_str, is_merge_file);
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 开始验证配置文件: {}, 是否为merge文件: {}",
|
||||||
|
file_path_str,
|
||||||
|
is_merge_file
|
||||||
|
);
|
||||||
|
|
||||||
// 对于 merge 文件,只进行语法验证,不进行后续内核验证
|
// 对于 merge 文件,只进行语法验证,不进行后续内核验证
|
||||||
if is_merge_file {
|
if is_merge_file {
|
||||||
println!("[cmd配置save] 检测到merge文件,只进行语法验证");
|
logging!(
|
||||||
match CoreManager::global().validate_config_file(&file_path_str, Some(true)).await {
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 检测到merge文件,只进行语法验证"
|
||||||
|
);
|
||||||
|
match CoreManager::global()
|
||||||
|
.validate_config_file(&file_path_str, Some(true))
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok((true, _)) => {
|
Ok((true, _)) => {
|
||||||
println!("[cmd配置save] merge文件语法验证通过");
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] merge文件语法验证通过"
|
||||||
|
);
|
||||||
// 成功后尝试更新整体配置
|
// 成功后尝试更新整体配置
|
||||||
if let Err(e) = CoreManager::global().update_config().await {
|
if let Err(e) = CoreManager::global().update_config().await {
|
||||||
println!("[cmd配置save] 更新整体配置时发生错误: {}", e);
|
logging!(
|
||||||
log::warn!(target: "app", "更新整体配置时发生错误: {}", e);
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 更新整体配置时发生错误: {}",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Ok((false, error_msg)) => {
|
Ok((false, error_msg)) => {
|
||||||
println!("[cmd配置save] merge文件语法验证失败: {}", error_msg);
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] merge文件语法验证失败: {}",
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
// 恢复原始配置文件
|
// 恢复原始配置文件
|
||||||
wrap_err!(fs::write(&file_path, original_content))?;
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
// 发送合并文件专用错误通知
|
// 发送合并文件专用错误通知
|
||||||
@@ -56,7 +88,13 @@ pub async fn save_profile_file(index: String, file_data: Option<String>) -> CmdR
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("[cmd配置save] 验证过程发生错误: {}", e);
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 验证过程发生错误: {}",
|
||||||
|
e
|
||||||
|
);
|
||||||
// 恢复原始配置文件
|
// 恢复原始配置文件
|
||||||
wrap_err!(fs::write(&file_path, original_content))?;
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@@ -65,44 +103,60 @@ pub async fn save_profile_file(index: String, file_data: Option<String>) -> CmdR
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 非merge文件使用完整验证流程
|
// 非merge文件使用完整验证流程
|
||||||
match CoreManager::global().validate_config_file(&file_path_str, None).await {
|
match CoreManager::global()
|
||||||
|
.validate_config_file(&file_path_str, None)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok((true, _)) => {
|
Ok((true, _)) => {
|
||||||
println!("[cmd配置save] 验证成功");
|
logging!(info, Type::Config, true, "[cmd配置save] 验证成功");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Ok((false, error_msg)) => {
|
Ok((false, error_msg)) => {
|
||||||
println!("[cmd配置save] 验证失败: {}", error_msg);
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 验证失败: {}",
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
// 恢复原始配置文件
|
// 恢复原始配置文件
|
||||||
wrap_err!(fs::write(&file_path, original_content))?;
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
|
|
||||||
// 智能判断错误类型
|
// 智能判断错误类型
|
||||||
let is_script_error = file_path_str.ends_with(".js") ||
|
let is_script_error = file_path_str.ends_with(".js")
|
||||||
error_msg.contains("Script syntax error") ||
|
|| error_msg.contains("Script syntax error")
|
||||||
error_msg.contains("Script must contain a main function") ||
|
|| error_msg.contains("Script must contain a main function")
|
||||||
error_msg.contains("Failed to read script file");
|
|| error_msg.contains("Failed to read script file");
|
||||||
|
|
||||||
if error_msg.contains("YAML syntax error") ||
|
if error_msg.contains("YAML syntax error")
|
||||||
error_msg.contains("Failed to read file:") ||
|
|| error_msg.contains("Failed to read file:")
|
||||||
(!file_path_str.ends_with(".js") && !is_script_error) {
|
|| (!file_path_str.ends_with(".js") && !is_script_error)
|
||||||
|
{
|
||||||
// 普通YAML错误使用YAML通知处理
|
// 普通YAML错误使用YAML通知处理
|
||||||
println!("[cmd配置save] YAML配置文件验证失败,发送通知");
|
log::info!(target: "app", "[cmd配置save] YAML配置文件验证失败,发送通知");
|
||||||
let result = (false, error_msg.clone());
|
let result = (false, error_msg.clone());
|
||||||
crate::cmd::validate::handle_yaml_validation_notice(&result, "YAML配置文件");
|
crate::cmd::validate::handle_yaml_validation_notice(&result, "YAML配置文件");
|
||||||
} else if is_script_error {
|
} else if is_script_error {
|
||||||
// 脚本错误使用专门的通知处理
|
// 脚本错误使用专门的通知处理
|
||||||
println!("[cmd配置save] 脚本文件验证失败,发送通知");
|
log::info!(target: "app", "[cmd配置save] 脚本文件验证失败,发送通知");
|
||||||
let result = (false, error_msg.clone());
|
let result = (false, error_msg.clone());
|
||||||
crate::cmd::validate::handle_script_validation_notice(&result, "脚本文件");
|
crate::cmd::validate::handle_script_validation_notice(&result, "脚本文件");
|
||||||
} else {
|
} else {
|
||||||
// 普通配置错误使用一般通知
|
// 普通配置错误使用一般通知
|
||||||
println!("[cmd配置save] 其他类型验证失败,发送一般通知");
|
log::info!(target: "app", "[cmd配置save] 其他类型验证失败,发送一般通知");
|
||||||
handle::Handle::notice_message("config_validate::error", &error_msg);
|
handle::Handle::notice_message("config_validate::error", &error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("[cmd配置save] 验证过程发生错误: {}", e);
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[cmd配置save] 验证过程发生错误: {}",
|
||||||
|
e
|
||||||
|
);
|
||||||
// 恢复原始配置文件
|
// 恢复原始配置文件
|
||||||
wrap_err!(fs::write(&file_path, original_content))?;
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
Err(e.to_string())
|
Err(e.to_string())
|
||||||
|
|||||||
48
src-tauri/src/cmd/service.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use super::CmdResult;
|
||||||
|
use crate::{
|
||||||
|
core::{service, CoreManager},
|
||||||
|
utils::i18n::t,
|
||||||
|
};
|
||||||
|
|
||||||
|
async fn execute_service_operation(
|
||||||
|
service_op: impl std::future::Future<Output = Result<(), impl ToString + std::fmt::Debug>>,
|
||||||
|
op_type: &str,
|
||||||
|
) -> CmdResult {
|
||||||
|
if service_op.await.is_err() {
|
||||||
|
let emsg = format!("{} {} failed", op_type, "Service");
|
||||||
|
return Err(t(emsg.as_str()));
|
||||||
|
}
|
||||||
|
if CoreManager::global().restart_core().await.is_err() {
|
||||||
|
let emsg = format!("{} {} failed", "Restart", "Core");
|
||||||
|
return Err(t(emsg.as_str()));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn install_service() -> CmdResult {
|
||||||
|
execute_service_operation(service::install_service(), "Install").await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn uninstall_service() -> CmdResult {
|
||||||
|
execute_service_operation(service::uninstall_service(), "Uninstall").await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn reinstall_service() -> CmdResult {
|
||||||
|
execute_service_operation(service::reinstall_service(), "Reinstall").await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn repair_service() -> CmdResult {
|
||||||
|
execute_service_operation(service::force_reinstall_service(), "Repair").await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn is_service_available() -> CmdResult<bool> {
|
||||||
|
service::is_service_available()
|
||||||
|
.await
|
||||||
|
.map(|_| true)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
@@ -1,35 +1,94 @@
|
|||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::core::handle;
|
use crate::{
|
||||||
use crate::module::sysinfo::PlatformSpecification;
|
core::{handle, CoreManager},
|
||||||
|
module::sysinfo::PlatformSpecification,
|
||||||
|
};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use std::{
|
||||||
|
sync::atomic::{AtomicI64, Ordering},
|
||||||
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
use tauri_plugin_clipboard_manager::ClipboardExt;
|
use tauri_plugin_clipboard_manager::ClipboardExt;
|
||||||
use crate::{core::{self, CoreManager, service}, wrap_err};
|
|
||||||
|
// 存储应用启动时间的全局变量
|
||||||
|
static APP_START_TIME: Lazy<AtomicI64> = Lazy::new(|| {
|
||||||
|
// 获取当前系统时间,转换为毫秒级时间戳
|
||||||
|
let now = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_millis() as i64;
|
||||||
|
|
||||||
|
AtomicI64::new(now)
|
||||||
|
});
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn export_diagnostic_info() -> CmdResult<()> {
|
pub async fn export_diagnostic_info() -> CmdResult<()> {
|
||||||
let sysinfo = PlatformSpecification::new();
|
let sysinfo = PlatformSpecification::new_async().await;
|
||||||
let info = format!("{:?}", sysinfo);
|
let info = format!("{sysinfo:?}");
|
||||||
|
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
let cliboard = app_handle.clipboard();
|
let cliboard = app_handle.clipboard();
|
||||||
|
if cliboard.write_text(info).is_err() {
|
||||||
if let Err(_) = cliboard.write_text(info) {
|
|
||||||
log::error!(target: "app", "Failed to write to clipboard");
|
log::error!(target: "app", "Failed to write to clipboard");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn get_system_info() -> CmdResult<String> {
|
||||||
|
let sysinfo = PlatformSpecification::new_async().await;
|
||||||
|
let info = format!("{sysinfo:?}");
|
||||||
|
Ok(info)
|
||||||
|
}
|
||||||
|
|
||||||
/// 获取当前内核运行模式
|
/// 获取当前内核运行模式
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn get_running_mode() -> Result<String, String> {
|
pub async fn get_running_mode() -> Result<String, String> {
|
||||||
match CoreManager::global().get_running_mode().await {
|
Ok(CoreManager::global().get_running_mode().await.to_string())
|
||||||
core::RunningMode::Service => Ok("service".to_string()),
|
|
||||||
core::RunningMode::Sidecar => Ok("sidecar".to_string()),
|
|
||||||
core::RunningMode::NotRunning => Ok("not_running".to_string()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 安装/重装系统服务
|
/// 获取应用的运行时间(毫秒)
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn install_service() -> CmdResult {
|
pub fn get_app_uptime() -> CmdResult<i64> {
|
||||||
wrap_err!(service::reinstall_service().await)
|
let start_time = APP_START_TIME.load(Ordering::Relaxed);
|
||||||
|
let now = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_millis() as i64;
|
||||||
|
|
||||||
|
Ok(now - start_time)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 检查应用是否以管理员身份运行
|
||||||
|
#[tauri::command]
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
pub fn is_admin() -> CmdResult<bool> {
|
||||||
|
use deelevate::{PrivilegeLevel, Token};
|
||||||
|
|
||||||
|
let result = Token::with_current_process()
|
||||||
|
.and_then(|token| token.privilege_level())
|
||||||
|
.map(|level| level != PrivilegeLevel::NotPrivileged)
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 非Windows平台检测是否以管理员身份运行
|
||||||
|
#[tauri::command]
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
pub fn is_admin() -> CmdResult<bool> {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
Ok(unsafe { libc::geteuid() } == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
Ok(unsafe { libc::geteuid() } == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
|
||||||
|
{
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ use super::CmdResult;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod platform {
|
mod platform {
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::core::win_uwp;
|
use crate::{core::win_uwp, wrap_err};
|
||||||
use crate::wrap_err;
|
|
||||||
|
|
||||||
pub async fn invoke_uwp_tool() -> CmdResult {
|
pub async fn invoke_uwp_tool() -> CmdResult {
|
||||||
wrap_err!(win_uwp::invoke_uwptools().await)
|
wrap_err!(win_uwp::invoke_uwptools().await)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::core::*;
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
|
use crate::{core::*, logging, utils::logging::Type};
|
||||||
|
|
||||||
/// 发送脚本验证通知消息
|
/// 发送脚本验证通知消息
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -28,7 +28,14 @@ pub fn handle_script_validation_notice(result: &(bool, String), file_type: &str)
|
|||||||
"config_validate::script_error"
|
"config_validate::script_error"
|
||||||
};
|
};
|
||||||
|
|
||||||
log::warn!(target: "app", "{} 验证失败: {}", file_type, error_msg);
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"{} 验证失败: {}",
|
||||||
|
file_type,
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
handle::Handle::notice_message(status, error_msg);
|
handle::Handle::notice_message(status, error_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,16 +43,25 @@ pub fn handle_script_validation_notice(result: &(bool, String), file_type: &str)
|
|||||||
/// 验证指定脚本文件
|
/// 验证指定脚本文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn validate_script_file(file_path: String) -> CmdResult<bool> {
|
pub async fn validate_script_file(file_path: String) -> CmdResult<bool> {
|
||||||
log::info!(target: "app", "验证脚本文件: {}", file_path);
|
logging!(info, Type::Config, true, "验证脚本文件: {}", file_path);
|
||||||
|
|
||||||
match CoreManager::global().validate_config_file(&file_path, None).await {
|
match CoreManager::global()
|
||||||
|
.validate_config_file(&file_path, None)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
handle_script_validation_notice(&result, "脚本文件");
|
handle_script_validation_notice(&result, "脚本文件");
|
||||||
Ok(result.0) // 返回验证结果布尔值
|
Ok(result.0) // 返回验证结果布尔值
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let error_msg = e.to_string();
|
let error_msg = e.to_string();
|
||||||
log::error!(target: "app", "验证脚本文件过程发生错误: {}", error_msg);
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"验证脚本文件过程发生错误: {}",
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
handle::Handle::notice_message("config_validate::process_terminated", &error_msg);
|
handle::Handle::notice_message("config_validate::process_terminated", &error_msg);
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
@@ -57,7 +73,14 @@ pub async fn validate_script_file(file_path: String) -> CmdResult<bool> {
|
|||||||
pub fn handle_yaml_validation_notice(result: &(bool, String), file_type: &str) {
|
pub fn handle_yaml_validation_notice(result: &(bool, String), file_type: &str) {
|
||||||
if !result.0 {
|
if !result.0 {
|
||||||
let error_msg = &result.1;
|
let error_msg = &result.1;
|
||||||
println!("[通知] 处理{}验证错误: {}", file_type, error_msg);
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[通知] 处理{}验证错误: {}",
|
||||||
|
file_type,
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
|
|
||||||
// 检查是否为merge文件
|
// 检查是否为merge文件
|
||||||
let is_merge_file = file_type.contains("合并");
|
let is_merge_file = file_type.contains("合并");
|
||||||
@@ -94,8 +117,22 @@ pub fn handle_yaml_validation_notice(result: &(bool, String), file_type: &str) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
log::warn!(target: "app", "{} 验证失败: {}", file_type, error_msg);
|
logging!(
|
||||||
println!("[通知] 发送通知: status={}, msg={}", status, error_msg);
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"{} 验证失败: {}",
|
||||||
|
file_type,
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[通知] 发送通知: status={}, msg={}",
|
||||||
|
status,
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
handle::Handle::notice_message(status, error_msg);
|
handle::Handle::notice_message(status, error_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
use crate::{
|
|
||||||
config::*,
|
|
||||||
feat,
|
|
||||||
wrap_err,
|
|
||||||
};
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
|
use crate::{config::*, feat, wrap_err};
|
||||||
|
|
||||||
/// 获取Verge配置
|
/// 获取Verge配置
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_verge_config() -> CmdResult<IVergeResponse> {
|
pub fn get_verge_config() -> CmdResult<IVergeResponse> {
|
||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
let verge_data = verge.data().clone();
|
let verge_data = verge.data().clone();
|
||||||
Ok(IVergeResponse::from(verge_data))
|
Ok(IVergeResponse::from(*verge_data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改Verge配置
|
/// 修改Verge配置
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
use crate::{
|
|
||||||
core,
|
|
||||||
config::*,
|
|
||||||
feat,
|
|
||||||
wrap_err,
|
|
||||||
};
|
|
||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
|
use crate::{config::*, core, feat, wrap_err};
|
||||||
use reqwest_dav::list_cmd::ListFile;
|
use reqwest_dav::list_cmd::ListFile;
|
||||||
|
|
||||||
/// 保存 WebDAV 配置
|
/// 保存 WebDAV 配置
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ impl IClashTemp {
|
|||||||
map.insert(key.clone(), template.0.get(key).unwrap().clone());
|
map.insert(key.clone(), template.0.get(key).unwrap().clone());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// 确保 secret 字段存在且不为空
|
||||||
|
if let Some(Value::String(s)) = map.get_mut("secret") {
|
||||||
|
if s.is_empty() {
|
||||||
|
*s = "set-your-secret".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
Self(Self::guard(map))
|
Self(Self::guard(map))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -32,13 +38,13 @@ impl IClashTemp {
|
|||||||
pub fn template() -> Self {
|
pub fn template() -> Self {
|
||||||
let mut map = Mapping::new();
|
let mut map = Mapping::new();
|
||||||
let mut tun = Mapping::new();
|
let mut tun = Mapping::new();
|
||||||
|
let mut cors_map = Mapping::new();
|
||||||
tun.insert("enable".into(), false.into());
|
tun.insert("enable".into(), false.into());
|
||||||
tun.insert("stack".into(), "mixed".into());
|
tun.insert("stack".into(), "gvisor".into());
|
||||||
tun.insert("auto-route".into(), true.into());
|
tun.insert("auto-route".into(), true.into());
|
||||||
tun.insert("strict-route".into(), false.into());
|
tun.insert("strict-route".into(), false.into());
|
||||||
tun.insert("auto-detect-interface".into(), true.into());
|
tun.insert("auto-detect-interface".into(), true.into());
|
||||||
tun.insert("dns-hijack".into(), vec!["any:53"].into());
|
tun.insert("dns-hijack".into(), vec!["any:53"].into());
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
map.insert("redir-port".into(), 7895.into());
|
map.insert("redir-port".into(), 7895.into());
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -46,14 +52,27 @@ impl IClashTemp {
|
|||||||
map.insert("mixed-port".into(), 7897.into());
|
map.insert("mixed-port".into(), 7897.into());
|
||||||
map.insert("socks-port".into(), 7898.into());
|
map.insert("socks-port".into(), 7898.into());
|
||||||
map.insert("port".into(), 7899.into());
|
map.insert("port".into(), 7899.into());
|
||||||
map.insert("log-level".into(), "info".into());
|
map.insert("log-level".into(), "warning".into());
|
||||||
map.insert("allow-lan".into(), false.into());
|
map.insert("allow-lan".into(), false.into());
|
||||||
|
map.insert("ipv6".into(), true.into());
|
||||||
map.insert("mode".into(), "rule".into());
|
map.insert("mode".into(), "rule".into());
|
||||||
map.insert("external-controller".into(), "127.0.0.1:9097".into());
|
map.insert("external-controller".into(), "127.0.0.1:9097".into());
|
||||||
let mut cors_map = Mapping::new();
|
|
||||||
cors_map.insert("allow-private-network".into(), true.into());
|
cors_map.insert("allow-private-network".into(), true.into());
|
||||||
cors_map.insert("allow-origins".into(), vec!["*"].into());
|
cors_map.insert(
|
||||||
map.insert("secret".into(), "".into());
|
"allow-origins".into(),
|
||||||
|
vec![
|
||||||
|
"tauri://localhost",
|
||||||
|
"http://tauri.localhost",
|
||||||
|
// Only enable this in dev mode
|
||||||
|
#[cfg(feature = "verge-dev")]
|
||||||
|
"http://localhost:3000",
|
||||||
|
"https://yacd.metacubex.one",
|
||||||
|
"https://metacubex.github.io",
|
||||||
|
"https://board.zash.run.place",
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
map.insert("secret".into(), "set-your-secret".into());
|
||||||
map.insert("tun".into(), tun.into());
|
map.insert("tun".into(), tun.into());
|
||||||
map.insert("external-controller-cors".into(), cors_map.into());
|
map.insert("external-controller-cors".into(), cors_map.into());
|
||||||
map.insert("unified-delay".into(), true.into());
|
map.insert("unified-delay".into(), true.into());
|
||||||
@@ -77,6 +96,26 @@ impl IClashTemp {
|
|||||||
config.insert("socks-port".into(), socks_port.into());
|
config.insert("socks-port".into(), socks_port.into());
|
||||||
config.insert("port".into(), port.into());
|
config.insert("port".into(), port.into());
|
||||||
config.insert("external-controller".into(), ctrl.into());
|
config.insert("external-controller".into(), ctrl.into());
|
||||||
|
|
||||||
|
// 强制覆盖 external-controller-cors 字段,允许本地和 tauri 前端
|
||||||
|
let mut cors_map = Mapping::new();
|
||||||
|
cors_map.insert("allow-private-network".into(), true.into());
|
||||||
|
cors_map.insert(
|
||||||
|
"allow-origins".into(),
|
||||||
|
vec![
|
||||||
|
"tauri://localhost",
|
||||||
|
"http://tauri.localhost",
|
||||||
|
// Only enable this in dev mode
|
||||||
|
#[cfg(feature = "verge-dev")]
|
||||||
|
"http://localhost:3000",
|
||||||
|
"https://yacd.metacubex.one",
|
||||||
|
"https://metacubex.github.io",
|
||||||
|
"https://board.zash.run.place",
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
config.insert("external-controller-cors".into(), cors_map.into());
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +355,13 @@ fn test_clash_info() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
pub struct IClashExternalControllerCors {
|
||||||
|
pub allow_origins: Option<Vec<String>>,
|
||||||
|
pub allow_private_network: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct IClash {
|
pub struct IClash {
|
||||||
@@ -329,6 +375,7 @@ pub struct IClash {
|
|||||||
pub dns: Option<IClashDNS>,
|
pub dns: Option<IClashDNS>,
|
||||||
pub tun: Option<IClashTUN>,
|
pub tun: Option<IClashTUN>,
|
||||||
pub interface_name: Option<String>,
|
pub interface_name: Option<String>,
|
||||||
|
pub external_controller_cors: Option<IClashExternalControllerCors>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use super::{Draft, IClashTemp, IProfiles, IRuntime, IVerge};
|
use super::{Draft, IClashTemp, IProfiles, IRuntime, IVerge};
|
||||||
use crate::{
|
use crate::{
|
||||||
config::PrfItem,
|
config::PrfItem,
|
||||||
enhance,
|
|
||||||
utils::{dirs, help},
|
|
||||||
core::{handle, CoreManager},
|
core::{handle, CoreManager},
|
||||||
|
enhance, logging,
|
||||||
|
process::AsyncHandler,
|
||||||
|
utils::{dirs, help, logging::Type},
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
@@ -14,10 +15,10 @@ pub const RUNTIME_CONFIG: &str = "clash-verge.yaml";
|
|||||||
pub const CHECK_CONFIG: &str = "clash-verge-check.yaml";
|
pub const CHECK_CONFIG: &str = "clash-verge-check.yaml";
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
clash_config: Draft<IClashTemp>,
|
clash_config: Draft<Box<IClashTemp>>,
|
||||||
verge_config: Draft<IVerge>,
|
verge_config: Draft<Box<IVerge>>,
|
||||||
profiles_config: Draft<IProfiles>,
|
profiles_config: Draft<Box<IProfiles>>,
|
||||||
runtime_config: Draft<IRuntime>,
|
runtime_config: Draft<Box<IRuntime>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@@ -25,26 +26,26 @@ impl Config {
|
|||||||
static CONFIG: OnceCell<Config> = OnceCell::new();
|
static CONFIG: OnceCell<Config> = OnceCell::new();
|
||||||
|
|
||||||
CONFIG.get_or_init(|| Config {
|
CONFIG.get_or_init(|| Config {
|
||||||
clash_config: Draft::from(IClashTemp::new()),
|
clash_config: Draft::from(Box::new(IClashTemp::new())),
|
||||||
verge_config: Draft::from(IVerge::new()),
|
verge_config: Draft::from(Box::new(IVerge::new())),
|
||||||
profiles_config: Draft::from(IProfiles::new()),
|
profiles_config: Draft::from(Box::new(IProfiles::new())),
|
||||||
runtime_config: Draft::from(IRuntime::new()),
|
runtime_config: Draft::from(Box::new(IRuntime::new())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clash() -> Draft<IClashTemp> {
|
pub fn clash() -> Draft<Box<IClashTemp>> {
|
||||||
Self::global().clash_config.clone()
|
Self::global().clash_config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn verge() -> Draft<IVerge> {
|
pub fn verge() -> Draft<Box<IVerge>> {
|
||||||
Self::global().verge_config.clone()
|
Self::global().verge_config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn profiles() -> Draft<IProfiles> {
|
pub fn profiles() -> Draft<Box<IProfiles>> {
|
||||||
Self::global().profiles_config.clone()
|
Self::global().profiles_config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn runtime() -> Draft<IRuntime> {
|
pub fn runtime() -> Draft<Box<IRuntime>> {
|
||||||
Self::global().runtime_config.clone()
|
Self::global().runtime_config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,32 +67,41 @@ impl Config {
|
|||||||
let script_item = PrfItem::from_script(Some("Script".to_string()))?;
|
let script_item = PrfItem::from_script(Some("Script".to_string()))?;
|
||||||
Self::profiles().data().append_item(script_item.clone())?;
|
Self::profiles().data().append_item(script_item.clone())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成运行时配置
|
// 生成运行时配置
|
||||||
crate::log_err!(Self::generate().await);
|
if let Err(err) = Self::generate().await {
|
||||||
|
logging!(error, Type::Config, true, "生成运行时配置失败: {}", err);
|
||||||
|
} else {
|
||||||
|
logging!(info, Type::Config, true, "生成运行时配置成功");
|
||||||
|
}
|
||||||
|
|
||||||
// 生成运行时配置文件并验证
|
// 生成运行时配置文件并验证
|
||||||
let config_result = Self::generate_file(ConfigType::Run);
|
let config_result = Self::generate_file(ConfigType::Run);
|
||||||
|
|
||||||
let validation_result = if let Ok(_) = config_result {
|
let validation_result = if config_result.is_ok() {
|
||||||
// 验证配置文件
|
// 验证配置文件
|
||||||
println!("[首次启动] 开始验证配置");
|
logging!(info, Type::Config, true, "开始验证配置");
|
||||||
|
|
||||||
match CoreManager::global().validate_config().await {
|
match CoreManager::global().validate_config().await {
|
||||||
Ok((is_valid, error_msg)) => {
|
Ok((is_valid, error_msg)) => {
|
||||||
if !is_valid {
|
if !is_valid {
|
||||||
println!("[首次启动] 配置验证失败,使用默认最小配置启动: {}", error_msg);
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"[首次启动] 配置验证失败,使用默认最小配置启动: {}",
|
||||||
|
error_msg
|
||||||
|
);
|
||||||
CoreManager::global()
|
CoreManager::global()
|
||||||
.use_default_config("config_validate::boot_error", &error_msg)
|
.use_default_config("config_validate::boot_error", &error_msg)
|
||||||
.await?;
|
.await?;
|
||||||
Some(("config_validate::boot_error", error_msg))
|
Some(("config_validate::boot_error", error_msg))
|
||||||
} else {
|
} else {
|
||||||
println!("[首次启动] 配置验证成功");
|
logging!(info, Type::Config, true, "配置验证成功");
|
||||||
Some(("config_validate::success", String::new()))
|
Some(("config_validate::success", String::new()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("[首次启动] 验证进程执行失败: {}", err);
|
logging!(warn, Type::Config, true, "验证进程执行失败: {}", err);
|
||||||
CoreManager::global()
|
CoreManager::global()
|
||||||
.use_default_config("config_validate::process_terminated", "")
|
.use_default_config("config_validate::process_terminated", "")
|
||||||
.await?;
|
.await?;
|
||||||
@@ -99,19 +109,16 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("[首次启动] 生成配置文件失败,使用默认配置");
|
logging!(warn, Type::Config, true, "生成配置文件失败,使用默认配置");
|
||||||
CoreManager::global()
|
CoreManager::global()
|
||||||
.use_default_config(
|
.use_default_config("config_validate::error", "")
|
||||||
"config_validate::error",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
Some(("config_validate::error", String::new()))
|
Some(("config_validate::error", String::new()))
|
||||||
};
|
};
|
||||||
|
|
||||||
// 在单独的任务中发送通知
|
// 在单独的任务中发送通知
|
||||||
if let Some((msg_type, msg_content)) = validation_result {
|
if let Some((msg_type, msg_content)) = validation_result {
|
||||||
tauri::async_runtime::spawn(async move {
|
AsyncHandler::spawn(move || async move {
|
||||||
sleep(Duration::from_secs(2)).await;
|
sleep(Duration::from_secs(2)).await;
|
||||||
handle::Handle::notice_message(msg_type, &msg_content);
|
handle::Handle::notice_message(msg_type, &msg_content);
|
||||||
});
|
});
|
||||||
@@ -142,11 +149,11 @@ impl Config {
|
|||||||
pub async fn generate() -> Result<()> {
|
pub async fn generate() -> Result<()> {
|
||||||
let (config, exists_keys, logs) = enhance::enhance().await;
|
let (config, exists_keys, logs) = enhance::enhance().await;
|
||||||
|
|
||||||
*Config::runtime().draft() = IRuntime {
|
*Config::runtime().draft() = Box::new(IRuntime {
|
||||||
config: Some(config),
|
config: Some(config),
|
||||||
exists_keys,
|
exists_keys,
|
||||||
chain_logs: logs,
|
chain_logs: logs,
|
||||||
};
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -157,3 +164,42 @@ pub enum ConfigType {
|
|||||||
Run,
|
Run,
|
||||||
Check,
|
Check,
|
||||||
}
|
}
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_prfitem_from_merge_size() {
|
||||||
|
let merge_item = PrfItem::from_merge(Some("Merge".to_string())).unwrap();
|
||||||
|
dbg!(&merge_item);
|
||||||
|
let prfitem_size = mem::size_of_val(&merge_item);
|
||||||
|
dbg!(prfitem_size);
|
||||||
|
// Boxed version
|
||||||
|
let boxed_merge_item = Box::new(merge_item);
|
||||||
|
let box_prfitem_size = mem::size_of_val(&boxed_merge_item);
|
||||||
|
dbg!(box_prfitem_size);
|
||||||
|
// The size of Box<T> is always pointer-sized (usually 8 bytes on 64-bit)
|
||||||
|
// assert_eq!(box_prfitem_size, mem::size_of::<Box<PrfItem>>());
|
||||||
|
assert!(box_prfitem_size < prfitem_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_draft_size_non_boxed() {
|
||||||
|
let draft = Draft::from(IRuntime::new());
|
||||||
|
let iruntime_size = std::mem::size_of_val(&draft);
|
||||||
|
dbg!(iruntime_size);
|
||||||
|
assert_eq!(iruntime_size, std::mem::size_of::<Draft<IRuntime>>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_draft_size_boxed() {
|
||||||
|
let draft = Draft::from(Box::new(IRuntime::new()));
|
||||||
|
let box_iruntime_size = std::mem::size_of_val(&draft);
|
||||||
|
dbg!(box_iruntime_size);
|
||||||
|
assert_eq!(
|
||||||
|
box_iruntime_size,
|
||||||
|
std::mem::size_of::<Draft<Box<IRuntime>>>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,13 +9,21 @@ pub struct Draft<T: Clone + ToOwned> {
|
|||||||
|
|
||||||
macro_rules! draft_define {
|
macro_rules! draft_define {
|
||||||
($id: ident) => {
|
($id: ident) => {
|
||||||
impl Draft<$id> {
|
impl From<$id> for Draft<$id> {
|
||||||
|
fn from(data: $id) -> Self {
|
||||||
|
Draft {
|
||||||
|
inner: Arc::new(Mutex::new((data, None))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Draft<Box<$id>> {
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn data(&self) -> MappedMutexGuard<$id> {
|
pub fn data(&self) -> MappedMutexGuard<Box<$id>> {
|
||||||
MutexGuard::map(self.inner.lock(), |guard| &mut guard.0)
|
MutexGuard::map(self.inner.lock(), |guard| &mut guard.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest(&self) -> MappedMutexGuard<$id> {
|
pub fn latest(&self) -> MappedMutexGuard<Box<$id>> {
|
||||||
MutexGuard::map(self.inner.lock(), |inner| {
|
MutexGuard::map(self.inner.lock(), |inner| {
|
||||||
if inner.1.is_none() {
|
if inner.1.is_none() {
|
||||||
&mut inner.0
|
&mut inner.0
|
||||||
@@ -25,7 +33,7 @@ macro_rules! draft_define {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draft(&self) -> MappedMutexGuard<$id> {
|
pub fn draft(&self) -> MappedMutexGuard<Box<$id>> {
|
||||||
MutexGuard::map(self.inner.lock(), |inner| {
|
MutexGuard::map(self.inner.lock(), |inner| {
|
||||||
if inner.1.is_none() {
|
if inner.1.is_none() {
|
||||||
inner.1 = Some(inner.0.clone());
|
inner.1 = Some(inner.0.clone());
|
||||||
@@ -35,7 +43,7 @@ macro_rules! draft_define {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(&self) -> Option<$id> {
|
pub fn apply(&self) -> Option<Box<$id>> {
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.lock();
|
||||||
|
|
||||||
match inner.1.take() {
|
match inner.1.take() {
|
||||||
@@ -48,14 +56,14 @@ macro_rules! draft_define {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn discard(&self) -> Option<$id> {
|
pub fn discard(&self) -> Option<Box<$id>> {
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.lock();
|
||||||
inner.1.take()
|
inner.1.take()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<$id> for Draft<$id> {
|
impl From<Box<$id>> for Draft<Box<$id>> {
|
||||||
fn from(data: $id) -> Self {
|
fn from(data: Box<$id>) -> Self {
|
||||||
Draft {
|
Draft {
|
||||||
inner: Arc::new(Mutex::new((data, None))),
|
inner: Arc::new(Mutex::new((data, None))),
|
||||||
}
|
}
|
||||||
@@ -71,12 +79,12 @@ draft_define!(IRuntime);
|
|||||||
draft_define!(IVerge);
|
draft_define!(IVerge);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_draft() {
|
fn test_draft_box() {
|
||||||
let verge = IVerge {
|
let verge = Box::new(IVerge {
|
||||||
enable_auto_launch: Some(true),
|
enable_auto_launch: Some(true),
|
||||||
enable_tun_mode: Some(false),
|
enable_tun_mode: Some(false),
|
||||||
..IVerge::default()
|
..IVerge::default()
|
||||||
};
|
});
|
||||||
|
|
||||||
let draft = Draft::from(verge);
|
let draft = Draft::from(verge);
|
||||||
|
|
||||||
@@ -86,10 +94,11 @@ fn test_draft() {
|
|||||||
assert_eq!(draft.draft().enable_auto_launch, Some(true));
|
assert_eq!(draft.draft().enable_auto_launch, Some(true));
|
||||||
assert_eq!(draft.draft().enable_tun_mode, Some(false));
|
assert_eq!(draft.draft().enable_tun_mode, Some(false));
|
||||||
|
|
||||||
let mut d = draft.draft();
|
{
|
||||||
d.enable_auto_launch = Some(false);
|
let mut d = draft.draft();
|
||||||
d.enable_tun_mode = Some(true);
|
d.enable_auto_launch = Some(false);
|
||||||
drop(d);
|
d.enable_tun_mode = Some(true);
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(draft.data().enable_auto_launch, Some(true));
|
assert_eq!(draft.data().enable_auto_launch, Some(true));
|
||||||
assert_eq!(draft.data().enable_tun_mode, Some(false));
|
assert_eq!(draft.data().enable_tun_mode, Some(false));
|
||||||
@@ -109,18 +118,17 @@ fn test_draft() {
|
|||||||
assert_eq!(draft.draft().enable_auto_launch, Some(false));
|
assert_eq!(draft.draft().enable_auto_launch, Some(false));
|
||||||
assert_eq!(draft.draft().enable_tun_mode, Some(true));
|
assert_eq!(draft.draft().enable_tun_mode, Some(true));
|
||||||
|
|
||||||
let mut d = draft.draft();
|
{
|
||||||
d.enable_auto_launch = Some(true);
|
let mut d = draft.draft();
|
||||||
drop(d);
|
d.enable_auto_launch = Some(true);
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(draft.data().enable_auto_launch, Some(false));
|
assert_eq!(draft.data().enable_auto_launch, Some(false));
|
||||||
|
|
||||||
assert_eq!(draft.draft().enable_auto_launch, Some(true));
|
assert_eq!(draft.draft().enable_auto_launch, Some(true));
|
||||||
|
|
||||||
assert!(draft.discard().is_some());
|
assert!(draft.discard().is_some());
|
||||||
|
|
||||||
assert_eq!(draft.data().enable_auto_launch, Some(false));
|
assert_eq!(draft.data().enable_auto_launch, Some(false));
|
||||||
|
|
||||||
assert!(draft.discard().is_none());
|
assert!(draft.discard().is_none());
|
||||||
|
|
||||||
assert_eq!(draft.draft().enable_auto_launch, Some(false));
|
assert_eq!(draft.draft().enable_auto_launch, Some(false));
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub fn encrypt_data(data: &str) -> Result<String, Box<dyn std::error::Error>> {
|
|||||||
// Encrypt data
|
// Encrypt data
|
||||||
let ciphertext = cipher
|
let ciphertext = cipher
|
||||||
.encrypt(nonce.as_slice().into(), data.as_bytes())
|
.encrypt(nonce.as_slice().into(), data.as_bytes())
|
||||||
.map_err(|e| format!("Encryption failed: {}", e))?;
|
.map_err(|e| format!("Encryption failed: {e}"))?;
|
||||||
|
|
||||||
// Concatenate nonce and ciphertext and encode them in base64
|
// Concatenate nonce and ciphertext and encode them in base64
|
||||||
let mut combined = nonce;
|
let mut combined = nonce;
|
||||||
@@ -46,7 +46,7 @@ pub fn decrypt_data(encrypted: &str) -> Result<String, Box<dyn std::error::Error
|
|||||||
// Decrypt data
|
// Decrypt data
|
||||||
let plaintext = cipher
|
let plaintext = cipher
|
||||||
.decrypt(nonce.into(), ciphertext)
|
.decrypt(nonce.into(), ciphertext)
|
||||||
.map_err(|e| format!("Decryption failed: {}", e))?;
|
.map_err(|e| format!("Decryption failed: {e}"))?;
|
||||||
|
|
||||||
String::from_utf8(plaintext).map_err(|e| e.into())
|
String::from_utf8(plaintext).map_err(|e| e.into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,9 @@ mod profiles;
|
|||||||
mod runtime;
|
mod runtime;
|
||||||
mod verge;
|
mod verge;
|
||||||
|
|
||||||
pub use self::clash::*;
|
pub use self::{
|
||||||
pub use self::config::*;
|
clash::*, config::*, draft::*, encrypt::*, prfitem::*, profiles::*, runtime::*, verge::*,
|
||||||
pub use self::draft::*;
|
};
|
||||||
pub use self::encrypt::*;
|
|
||||||
pub use self::prfitem::*;
|
|
||||||
pub use self::profiles::*;
|
|
||||||
pub use self::runtime::*;
|
|
||||||
pub use self::verge::*;
|
|
||||||
|
|
||||||
pub const DEFAULT_PAC: &str = r#"function FindProxyForURL(url, host) {
|
pub const DEFAULT_PAC: &str = r#"function FindProxyForURL(url, host) {
|
||||||
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;";
|
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;";
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
use crate::utils::{dirs, help, resolve::VERSION, tmpl};
|
use crate::utils::{
|
||||||
|
dirs, help,
|
||||||
|
network::{NetworkManager, ProxyType},
|
||||||
|
tmpl,
|
||||||
|
};
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::fs;
|
use std::{fs, time::Duration};
|
||||||
use sysproxy::Sysproxy;
|
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use super::Config;
|
use super::Config;
|
||||||
|
|
||||||
@@ -50,6 +55,18 @@ pub struct PrfItem {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub home: Option<String>,
|
pub home: Option<String>,
|
||||||
|
|
||||||
|
/// profile support url
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub support_url: Option<String>,
|
||||||
|
|
||||||
|
/// profile announce
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub announce: Option<String>,
|
||||||
|
|
||||||
|
/// profile announce url
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub announce_url: Option<String>,
|
||||||
|
|
||||||
/// the file data
|
/// the file data
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub file_data: Option<String>,
|
pub file_data: Option<String>,
|
||||||
@@ -89,6 +106,12 @@ pub struct PrfOption {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub update_interval: Option<u64>,
|
pub update_interval: Option<u64>,
|
||||||
|
|
||||||
|
/// for `remote` profile
|
||||||
|
/// HTTP request timeout in seconds
|
||||||
|
/// default is 60 seconds
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub timeout_seconds: Option<u64>,
|
||||||
|
|
||||||
/// for `remote` profile
|
/// for `remote` profile
|
||||||
/// disable certificate validation
|
/// disable certificate validation
|
||||||
/// default is `false`
|
/// default is `false`
|
||||||
@@ -104,6 +127,12 @@ pub struct PrfOption {
|
|||||||
pub proxies: Option<String>,
|
pub proxies: Option<String>,
|
||||||
|
|
||||||
pub groups: Option<String>,
|
pub groups: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub use_hwid: Option<bool>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub update_always: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrfOption {
|
impl PrfOption {
|
||||||
@@ -122,6 +151,9 @@ impl PrfOption {
|
|||||||
a.rules = b.rules.or(a.rules);
|
a.rules = b.rules.or(a.rules);
|
||||||
a.proxies = b.proxies.or(a.proxies);
|
a.proxies = b.proxies.or(a.proxies);
|
||||||
a.groups = b.groups.or(a.groups);
|
a.groups = b.groups.or(a.groups);
|
||||||
|
a.timeout_seconds = b.timeout_seconds.or(a.timeout_seconds);
|
||||||
|
a.use_hwid = b.use_hwid.or(a.use_hwid);
|
||||||
|
a.update_always = b.update_always.or(a.update_always);
|
||||||
Some(a)
|
Some(a)
|
||||||
}
|
}
|
||||||
t => t.0.or(t.1),
|
t => t.0.or(t.1),
|
||||||
@@ -220,6 +252,9 @@ impl PrfItem {
|
|||||||
..PrfOption::default()
|
..PrfOption::default()
|
||||||
}),
|
}),
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||||
file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())),
|
file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())),
|
||||||
})
|
})
|
||||||
@@ -234,64 +269,47 @@ impl PrfItem {
|
|||||||
option: Option<PrfOption>,
|
option: Option<PrfOption>,
|
||||||
) -> Result<PrfItem> {
|
) -> Result<PrfItem> {
|
||||||
let opt_ref = option.as_ref();
|
let opt_ref = option.as_ref();
|
||||||
let with_proxy = opt_ref.map_or(false, |o| o.with_proxy.unwrap_or(false));
|
let with_proxy = opt_ref.is_some_and(|o| o.with_proxy.unwrap_or(false));
|
||||||
let self_proxy = opt_ref.map_or(false, |o| o.self_proxy.unwrap_or(false));
|
let self_proxy = opt_ref.is_some_and(|o| o.self_proxy.unwrap_or(false));
|
||||||
let accept_invalid_certs =
|
let accept_invalid_certs =
|
||||||
opt_ref.map_or(false, |o| o.danger_accept_invalid_certs.unwrap_or(false));
|
opt_ref.is_some_and(|o| o.danger_accept_invalid_certs.unwrap_or(false));
|
||||||
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
||||||
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
||||||
|
let timeout = opt_ref.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
||||||
|
let use_hwid = Config::verge().latest().enable_send_hwid.unwrap_or(true);
|
||||||
let mut merge = opt_ref.and_then(|o| o.merge.clone());
|
let mut merge = opt_ref.and_then(|o| o.merge.clone());
|
||||||
let mut script = opt_ref.and_then(|o| o.script.clone());
|
let mut script = opt_ref.and_then(|o| o.script.clone());
|
||||||
let mut rules = opt_ref.and_then(|o| o.rules.clone());
|
let mut rules = opt_ref.and_then(|o| o.rules.clone());
|
||||||
let mut proxies = opt_ref.and_then(|o| o.proxies.clone());
|
let mut proxies = opt_ref.and_then(|o| o.proxies.clone());
|
||||||
let mut groups = opt_ref.and_then(|o| o.groups.clone());
|
let mut groups = opt_ref.and_then(|o| o.groups.clone());
|
||||||
let mut builder = reqwest::ClientBuilder::new().use_rustls_tls().no_proxy();
|
|
||||||
|
|
||||||
// 使用软件自己的代理
|
// 选择代理类型
|
||||||
if self_proxy {
|
let proxy_type = if self_proxy {
|
||||||
let port = Config::verge()
|
ProxyType::Localhost
|
||||||
.latest()
|
} else if with_proxy {
|
||||||
.verge_mixed_port
|
ProxyType::System
|
||||||
.unwrap_or(Config::clash().data().get_mixed_port());
|
} else {
|
||||||
|
ProxyType::None
|
||||||
let proxy_scheme = format!("http://127.0.0.1:{port}");
|
|
||||||
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 使用系统代理
|
|
||||||
else if with_proxy {
|
|
||||||
if let Ok(p @ Sysproxy { enable: true, .. }) = Sysproxy::get_system_proxy() {
|
|
||||||
let proxy_scheme = format!("http://{}:{}", p.host, p.port);
|
|
||||||
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
|
|
||||||
builder = builder.proxy(proxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let version = match VERSION.get() {
|
|
||||||
Some(v) => format!("clash-verge/v{}", v),
|
|
||||||
None => "clash-verge/unknown".to_string(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
builder = builder.danger_accept_invalid_certs(accept_invalid_certs);
|
// 使用网络管理器发送请求
|
||||||
builder = builder.user_agent(user_agent.unwrap_or(version));
|
let resp = match NetworkManager::global()
|
||||||
|
.get_with_interrupt(
|
||||||
let resp = builder.build()?.get(url).send().await?;
|
url,
|
||||||
|
proxy_type,
|
||||||
|
Some(timeout),
|
||||||
|
user_agent.clone(),
|
||||||
|
accept_invalid_certs,
|
||||||
|
use_hwid,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||||
|
bail!("failed to fetch remote profile: {}", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let status_code = resp.status();
|
let status_code = resp.status();
|
||||||
if !StatusCode::is_success(&status_code) {
|
if !StatusCode::is_success(&status_code) {
|
||||||
@@ -300,6 +318,21 @@ impl PrfItem {
|
|||||||
|
|
||||||
let header = resp.headers();
|
let header = resp.headers();
|
||||||
|
|
||||||
|
let mut final_url = url.to_string();
|
||||||
|
|
||||||
|
if let Some(new_domain_value) = header.get("new-sub-domain") {
|
||||||
|
if let Ok(new_domain) = new_domain_value.to_str() {
|
||||||
|
if !new_domain.is_empty() {
|
||||||
|
if let Ok(mut parsed_url) = Url::parse(url) {
|
||||||
|
if parsed_url.set_host(Some(new_domain)).is_ok() {
|
||||||
|
final_url = parsed_url.to_string();
|
||||||
|
log::info!(target: "app", "URL host updated to -> {}", final_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// parse the Subscription UserInfo
|
// parse the Subscription UserInfo
|
||||||
let extra = match header.get("Subscription-Userinfo") {
|
let extra = match header.get("Subscription-Userinfo") {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
@@ -349,6 +382,11 @@ impl PrfItem {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let update_always = match header.get("update-always") {
|
||||||
|
Some(value) => value.to_str().unwrap_or("false").parse::<bool>().ok(),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
let home = match header.get("profile-web-page-url") {
|
let home = match header.get("profile-web-page-url") {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let str_value = value.to_str().unwrap_or("");
|
let str_value = value.to_str().unwrap_or("");
|
||||||
@@ -357,9 +395,53 @@ impl PrfItem {
|
|||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let support_url = match header.get("support-url") {
|
||||||
|
Some(value) => {
|
||||||
|
let str_value = value.to_str().unwrap_or("");
|
||||||
|
Some(str_value.to_string())
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let announce = match header.get("announce") {
|
||||||
|
Some(value) => {
|
||||||
|
let str_value = value.to_str().unwrap_or("");
|
||||||
|
if let Some(b64_data) = str_value.strip_prefix("base64:") {
|
||||||
|
STANDARD.decode(b64_data)
|
||||||
|
.ok()
|
||||||
|
.and_then(|bytes| String::from_utf8(bytes).ok())
|
||||||
|
} else {
|
||||||
|
Some(str_value.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let announce_url = match header.get("announce-url") {
|
||||||
|
Some(value) => {
|
||||||
|
let str_value = value.to_str().unwrap_or("");
|
||||||
|
Some(str_value.to_string())
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let profile_title = match header.get("profile-title") {
|
||||||
|
Some(value) => {
|
||||||
|
let str_value = value.to_str().unwrap_or("");
|
||||||
|
if let Some(b64_data) = str_value.strip_prefix("base64:") {
|
||||||
|
STANDARD.decode(b64_data)
|
||||||
|
.ok()
|
||||||
|
.and_then(|bytes| String::from_utf8(bytes).ok())
|
||||||
|
} else {
|
||||||
|
Some(str_value.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
let uid = help::get_uid("R");
|
let uid = help::get_uid("R");
|
||||||
let file = format!("{uid}.yaml");
|
let file = format!("{uid}.yaml");
|
||||||
let name = name.unwrap_or(filename.unwrap_or("Remote File".into()));
|
let name = name.or(profile_title).unwrap_or(filename.unwrap_or("Remote File".into()));
|
||||||
let data = resp.text_with_charset("utf-8").await?;
|
let data = resp.text_with_charset("utf-8").await?;
|
||||||
|
|
||||||
// process the charset "UTF-8 with BOM"
|
// process the charset "UTF-8 with BOM"
|
||||||
@@ -407,11 +489,12 @@ impl PrfItem {
|
|||||||
name: Some(name),
|
name: Some(name),
|
||||||
desc,
|
desc,
|
||||||
file: Some(file),
|
file: Some(file),
|
||||||
url: Some(url.into()),
|
url: Some(final_url),
|
||||||
selected: None,
|
selected: None,
|
||||||
extra,
|
extra,
|
||||||
option: Some(PrfOption {
|
option: Some(PrfOption {
|
||||||
update_interval,
|
update_interval,
|
||||||
|
update_always,
|
||||||
merge,
|
merge,
|
||||||
script,
|
script,
|
||||||
rules,
|
rules,
|
||||||
@@ -420,6 +503,9 @@ impl PrfItem {
|
|||||||
..PrfOption::default()
|
..PrfOption::default()
|
||||||
}),
|
}),
|
||||||
home,
|
home,
|
||||||
|
support_url,
|
||||||
|
announce,
|
||||||
|
announce_url,
|
||||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||||
file_data: Some(data.into()),
|
file_data: Some(data.into()),
|
||||||
})
|
})
|
||||||
@@ -447,6 +533,9 @@ impl PrfItem {
|
|||||||
extra: None,
|
extra: None,
|
||||||
option: None,
|
option: None,
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||||
file_data: Some(template),
|
file_data: Some(template),
|
||||||
})
|
})
|
||||||
@@ -469,6 +558,9 @@ impl PrfItem {
|
|||||||
file: Some(file),
|
file: Some(file),
|
||||||
url: None,
|
url: None,
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
option: None,
|
option: None,
|
||||||
@@ -490,6 +582,9 @@ impl PrfItem {
|
|||||||
file: Some(file),
|
file: Some(file),
|
||||||
url: None,
|
url: None,
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
option: None,
|
option: None,
|
||||||
@@ -511,6 +606,9 @@ impl PrfItem {
|
|||||||
file: Some(file),
|
file: Some(file),
|
||||||
url: None,
|
url: None,
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
option: None,
|
option: None,
|
||||||
@@ -532,6 +630,9 @@ impl PrfItem {
|
|||||||
file: Some(file),
|
file: Some(file),
|
||||||
url: None,
|
url: None,
|
||||||
home: None,
|
home: None,
|
||||||
|
support_url: None,
|
||||||
|
announce: None,
|
||||||
|
announce_url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
option: None,
|
option: None,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::utils::{dirs, help};
|
|||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::{fs, io::Write};
|
use std::{collections::HashSet, fs, io::Write};
|
||||||
|
|
||||||
/// Define the `profiles.yaml` schema
|
/// Define the `profiles.yaml` schema
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
@@ -15,6 +15,14 @@ pub struct IProfiles {
|
|||||||
pub items: Option<Vec<PrfItem>>,
|
pub items: Option<Vec<PrfItem>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 清理结果
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct CleanupResult {
|
||||||
|
pub total_files: usize,
|
||||||
|
pub deleted_files: Vec<String>,
|
||||||
|
pub failed_deletions: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! patch {
|
macro_rules! patch {
|
||||||
($lv: expr, $rv: expr, $key: tt) => {
|
($lv: expr, $rv: expr, $key: tt) => {
|
||||||
if ($rv.$key).is_some() {
|
if ($rv.$key).is_some() {
|
||||||
@@ -123,9 +131,9 @@ impl IProfiles {
|
|||||||
let path = dirs::app_profiles_dir()?.join(&file);
|
let path = dirs::app_profiles_dir()?.join(&file);
|
||||||
|
|
||||||
fs::File::create(path)
|
fs::File::create(path)
|
||||||
.with_context(|| format!("failed to create file \"{}\"", file))?
|
.with_context(|| format!("failed to create file \"{file}\""))?
|
||||||
.write(file_data.as_bytes())
|
.write(file_data.as_bytes())
|
||||||
.with_context(|| format!("failed to write to file \"{}\"", file))?;
|
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.current.is_none()
|
if self.current.is_none()
|
||||||
@@ -212,6 +220,11 @@ impl IProfiles {
|
|||||||
each.extra = item.extra;
|
each.extra = item.extra;
|
||||||
each.updated = item.updated;
|
each.updated = item.updated;
|
||||||
each.home = item.home;
|
each.home = item.home;
|
||||||
|
each.announce = item.announce;
|
||||||
|
each.announce_url = item.announce_url;
|
||||||
|
each.support_url = item.support_url;
|
||||||
|
each.name = item.name;
|
||||||
|
each.url = item.url;
|
||||||
each.option = PrfOption::merge(each.option.clone(), item.option);
|
each.option = PrfOption::merge(each.option.clone(), item.option);
|
||||||
// save the file data
|
// save the file data
|
||||||
// move the field value after save
|
// move the field value after save
|
||||||
@@ -226,9 +239,9 @@ impl IProfiles {
|
|||||||
let path = dirs::app_profiles_dir()?.join(&file);
|
let path = dirs::app_profiles_dir()?.join(&file);
|
||||||
|
|
||||||
fs::File::create(path)
|
fs::File::create(path)
|
||||||
.with_context(|| format!("failed to create file \"{}\"", file))?
|
.with_context(|| format!("failed to create file \"{file}\""))?
|
||||||
.write(file_data.as_bytes())
|
.write(file_data.as_bytes())
|
||||||
.with_context(|| format!("failed to write to file \"{}\"", file))?;
|
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -472,15 +485,210 @@ impl IProfiles {
|
|||||||
|
|
||||||
/// 获取所有的profiles(uid,名称)
|
/// 获取所有的profiles(uid,名称)
|
||||||
pub fn all_profile_uid_and_name(&self) -> Option<Vec<(String, String)>> {
|
pub fn all_profile_uid_and_name(&self) -> Option<Vec<(String, String)>> {
|
||||||
match self.items.as_ref() {
|
self.items.as_ref().map(|items| {
|
||||||
Some(items) => Some(items.iter().filter_map(|e| {
|
items
|
||||||
if let (Some(uid), Some(name)) = (e.uid.clone(), e.name.clone()) {
|
.iter()
|
||||||
Some((uid, name))
|
.filter_map(|e| {
|
||||||
} else {
|
if let (Some(uid), Some(name)) = (e.uid.clone(), e.name.clone()) {
|
||||||
None
|
Some((uid, name))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 以 app 中的 profile 列表为准,删除不再需要的文件
|
||||||
|
pub fn cleanup_orphaned_files(&self) -> Result<CleanupResult> {
|
||||||
|
let profiles_dir = dirs::app_profiles_dir()?;
|
||||||
|
|
||||||
|
if !profiles_dir.exists() {
|
||||||
|
return Ok(CleanupResult {
|
||||||
|
total_files: 0,
|
||||||
|
deleted_files: vec![],
|
||||||
|
failed_deletions: vec![],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有 active profile 的文件名集合
|
||||||
|
let active_files = self.get_all_active_files();
|
||||||
|
|
||||||
|
// 添加全局扩展配置文件到保护列表
|
||||||
|
let protected_files = self.get_protected_global_files();
|
||||||
|
|
||||||
|
// 扫描 profiles 目录下的所有文件
|
||||||
|
let mut total_files = 0;
|
||||||
|
let mut deleted_files = vec![];
|
||||||
|
let mut failed_deletions = vec![];
|
||||||
|
|
||||||
|
for entry in std::fs::read_dir(&profiles_dir)? {
|
||||||
|
let entry = entry?;
|
||||||
|
let path = entry.path();
|
||||||
|
|
||||||
|
if !path.is_file() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
total_files += 1;
|
||||||
|
|
||||||
|
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
|
||||||
|
if Self::is_profile_file(file_name) {
|
||||||
|
// 检查是否为全局扩展文件
|
||||||
|
if protected_files.contains(file_name) {
|
||||||
|
log::debug!(target: "app", "保护全局扩展配置文件: {file_name}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否为活跃文件
|
||||||
|
if !active_files.contains(file_name) {
|
||||||
|
match std::fs::remove_file(&path) {
|
||||||
|
Ok(_) => {
|
||||||
|
deleted_files.push(file_name.to_string());
|
||||||
|
log::info!(target: "app", "已清理冗余文件: {file_name}");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
failed_deletions.push(format!("{file_name}: {e}"));
|
||||||
|
log::warn!(target: "app", "清理文件失败: {file_name} - {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).collect()),
|
}
|
||||||
None => None,
|
}
|
||||||
|
|
||||||
|
let result = CleanupResult {
|
||||||
|
total_files,
|
||||||
|
deleted_files,
|
||||||
|
failed_deletions,
|
||||||
|
};
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
target: "app",
|
||||||
|
"Profile 文件清理完成: 总文件数={}, 删除文件数={}, 失败数={}",
|
||||||
|
result.total_files,
|
||||||
|
result.deleted_files.len(),
|
||||||
|
result.failed_deletions.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 不删除全局扩展配置
|
||||||
|
fn get_protected_global_files(&self) -> HashSet<String> {
|
||||||
|
let mut protected_files = HashSet::new();
|
||||||
|
|
||||||
|
protected_files.insert("Merge.yaml".to_string());
|
||||||
|
protected_files.insert("Script.js".to_string());
|
||||||
|
|
||||||
|
protected_files
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取所有 active profile 关联的文件名
|
||||||
|
fn get_all_active_files(&self) -> HashSet<String> {
|
||||||
|
let mut active_files = HashSet::new();
|
||||||
|
|
||||||
|
if let Some(items) = &self.items {
|
||||||
|
for item in items {
|
||||||
|
// 收集所有类型 profile 的文件
|
||||||
|
if let Some(file) = &item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对于主 profile 类型(remote/local),还需要收集其关联的扩展文件
|
||||||
|
if let Some(itype) = &item.itype {
|
||||||
|
if itype == "remote" || itype == "local" {
|
||||||
|
if let Some(option) = &item.option {
|
||||||
|
// 收集关联的扩展文件
|
||||||
|
if let Some(merge_uid) = &option.merge {
|
||||||
|
if let Ok(merge_item) = self.get_item(merge_uid) {
|
||||||
|
if let Some(file) = &merge_item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(script_uid) = &option.script {
|
||||||
|
if let Ok(script_item) = self.get_item(script_uid) {
|
||||||
|
if let Some(file) = &script_item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(rules_uid) = &option.rules {
|
||||||
|
if let Ok(rules_item) = self.get_item(rules_uid) {
|
||||||
|
if let Some(file) = &rules_item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(proxies_uid) = &option.proxies {
|
||||||
|
if let Ok(proxies_item) = self.get_item(proxies_uid) {
|
||||||
|
if let Some(file) = &proxies_item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(groups_uid) = &option.groups {
|
||||||
|
if let Ok(groups_item) = self.get_item(groups_uid) {
|
||||||
|
if let Some(file) = &groups_item.file {
|
||||||
|
active_files.insert(file.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
active_files
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 检查文件名是否符合 profile 文件的命名规则
|
||||||
|
fn is_profile_file(filename: &str) -> bool {
|
||||||
|
// 匹配各种 profile 文件格式
|
||||||
|
// R12345678.yaml (remote)
|
||||||
|
// L12345678.yaml (local)
|
||||||
|
// m12345678.yaml (merge)
|
||||||
|
// s12345678.js (script)
|
||||||
|
// r12345678.yaml (rules)
|
||||||
|
// p12345678.yaml (proxies)
|
||||||
|
// g12345678.yaml (groups)
|
||||||
|
|
||||||
|
let patterns = [
|
||||||
|
r"^[RL][a-zA-Z0-9]+\.yaml$", // Remote/Local profiles
|
||||||
|
r"^m[a-zA-Z0-9]+\.yaml$", // Merge files
|
||||||
|
r"^s[a-zA-Z0-9]+\.js$", // Script files
|
||||||
|
r"^[rpg][a-zA-Z0-9]+\.yaml$", // Rules/Proxies/Groups files
|
||||||
|
];
|
||||||
|
|
||||||
|
patterns.iter().any(|pattern| {
|
||||||
|
regex::Regex::new(pattern)
|
||||||
|
.map(|re| re.is_match(filename))
|
||||||
|
.unwrap_or(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn auto_cleanup(&self) -> Result<()> {
|
||||||
|
match self.cleanup_orphaned_files() {
|
||||||
|
Ok(result) => {
|
||||||
|
if !result.deleted_files.is_empty() {
|
||||||
|
log::info!(
|
||||||
|
target: "app",
|
||||||
|
"自动清理完成,删除了 {} 个冗余文件",
|
||||||
|
result.deleted_files.len()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!(target: "app", "自动清理失败: {e}");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use crate::config::DEFAULT_PAC;
|
use crate::{
|
||||||
use crate::config::{deserialize_encrypted, serialize_encrypted};
|
config::{deserialize_encrypted, serialize_encrypted, DEFAULT_PAC},
|
||||||
use crate::utils::i18n;
|
logging,
|
||||||
use crate::utils::{dirs, help};
|
utils::{dirs, help, i18n, logging::Type},
|
||||||
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -73,6 +74,10 @@ pub struct IVerge {
|
|||||||
/// enable dns settings - this controls whether dns_config.yaml is applied
|
/// enable dns settings - this controls whether dns_config.yaml is applied
|
||||||
pub enable_dns_settings: Option<bool>,
|
pub enable_dns_settings: Option<bool>,
|
||||||
|
|
||||||
|
pub enable_send_hwid: Option<bool>,
|
||||||
|
|
||||||
|
pub primary_action: Option<String>,
|
||||||
|
|
||||||
/// always use default bypass
|
/// always use default bypass
|
||||||
pub use_default_bypass: Option<bool>,
|
pub use_default_bypass: Option<bool>,
|
||||||
|
|
||||||
@@ -88,6 +93,9 @@ pub struct IVerge {
|
|||||||
/// pac script content
|
/// pac script content
|
||||||
pub pac_file_content: Option<String>,
|
pub pac_file_content: Option<String>,
|
||||||
|
|
||||||
|
/// proxy host address
|
||||||
|
pub proxy_host: Option<String>,
|
||||||
|
|
||||||
/// theme setting
|
/// theme setting
|
||||||
pub theme_setting: Option<IVergeTheme>,
|
pub theme_setting: Option<IVergeTheme>,
|
||||||
|
|
||||||
@@ -105,6 +113,10 @@ pub struct IVerge {
|
|||||||
/// enable global hotkey
|
/// enable global hotkey
|
||||||
pub enable_global_hotkey: Option<bool>,
|
pub enable_global_hotkey: Option<bool>,
|
||||||
|
|
||||||
|
/// 首页卡片设置
|
||||||
|
/// 控制首页各个卡片的显示和隐藏
|
||||||
|
pub home_cards: Option<serde_json::Value>,
|
||||||
|
|
||||||
/// 切换代理时自动关闭连接
|
/// 切换代理时自动关闭连接
|
||||||
pub auto_close_connection: Option<bool>,
|
pub auto_close_connection: Option<bool>,
|
||||||
|
|
||||||
@@ -127,7 +139,7 @@ pub struct IVerge {
|
|||||||
pub test_list: Option<Vec<IVergeTestItem>>,
|
pub test_list: Option<Vec<IVergeTestItem>>,
|
||||||
|
|
||||||
/// 日志清理
|
/// 日志清理
|
||||||
/// 0: 不清理; 1: 7天; 2: 30天; 3: 90天
|
/// 0: 不清理; 1: 1天;2: 7天; 3: 30天; 4: 90天
|
||||||
pub auto_log_clean: Option<i32>,
|
pub auto_log_clean: Option<i32>,
|
||||||
|
|
||||||
/// 是否启用随机端口
|
/// 是否启用随机端口
|
||||||
@@ -185,8 +197,19 @@ pub struct IVerge {
|
|||||||
|
|
||||||
pub enable_tray_speed: Option<bool>,
|
pub enable_tray_speed: Option<bool>,
|
||||||
|
|
||||||
/// 轻量模式 - 只保留内核运行
|
pub enable_tray_icon: Option<bool>,
|
||||||
pub enable_lite_mode: Option<bool>,
|
|
||||||
|
/// 自动进入轻量模式
|
||||||
|
pub enable_auto_light_weight_mode: Option<bool>,
|
||||||
|
|
||||||
|
/// 自动进入轻量模式的延迟(分钟)
|
||||||
|
pub auto_light_weight_minutes: Option<u64>,
|
||||||
|
|
||||||
|
/// 启用代理页面自动滚动
|
||||||
|
pub enable_hover_jump_navigator: Option<bool>,
|
||||||
|
|
||||||
|
/// 服务状态跟踪
|
||||||
|
pub service_state: Option<crate::core::service::ServiceState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
@@ -214,6 +237,93 @@ pub struct IVergeTheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IVerge {
|
impl IVerge {
|
||||||
|
/// 有效的clash核心名称
|
||||||
|
pub const VALID_CLASH_CORES: &'static [&'static str] = &["verge-mihomo", "verge-mihomo-alpha"];
|
||||||
|
|
||||||
|
/// 验证并修正配置文件中的clash_core值
|
||||||
|
pub fn validate_and_fix_config() -> Result<()> {
|
||||||
|
let config_path = dirs::verge_path()?;
|
||||||
|
let mut config = match help::read_yaml::<IVerge>(&config_path) {
|
||||||
|
Ok(config) => config,
|
||||||
|
Err(_) => Self::template(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut needs_fix = false;
|
||||||
|
|
||||||
|
if let Some(ref core) = config.clash_core {
|
||||||
|
let core_str = core.trim();
|
||||||
|
if core_str.is_empty() || !Self::VALID_CLASH_CORES.contains(&core_str) {
|
||||||
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"启动时发现无效的clash_core配置: '{}', 将自动修正为 'verge-mihomo'",
|
||||||
|
core
|
||||||
|
);
|
||||||
|
config.clash_core = Some("verge-mihomo".to_string());
|
||||||
|
needs_fix = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"启动时发现未配置clash_core, 将设置为默认值 'verge-mihomo'"
|
||||||
|
);
|
||||||
|
config.clash_core = Some("verge-mihomo".to_string());
|
||||||
|
needs_fix = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修正后保存配置
|
||||||
|
if needs_fix {
|
||||||
|
logging!(info, Type::Config, true, "正在保存修正后的配置文件...");
|
||||||
|
help::save_yaml(&config_path, &config, Some("# Clash Verge Config"))?;
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"配置文件修正完成,需要重新加载配置"
|
||||||
|
);
|
||||||
|
|
||||||
|
Self::reload_config_after_fix(config)?;
|
||||||
|
} else {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"clash_core配置验证通过: {:?}",
|
||||||
|
config.clash_core
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 配置修正后重新加载配置
|
||||||
|
fn reload_config_after_fix(updated_config: IVerge) -> Result<()> {
|
||||||
|
use crate::config::Config;
|
||||||
|
|
||||||
|
let config_draft = Config::verge();
|
||||||
|
*config_draft.draft() = Box::new(updated_config.clone());
|
||||||
|
config_draft.apply();
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
true,
|
||||||
|
"内存配置已强制更新,新的clash_core: {:?}",
|
||||||
|
updated_config.clash_core
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_valid_clash_core(&self) -> String {
|
||||||
|
self.clash_core
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| "verge-mihomo".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
fn get_system_language() -> String {
|
fn get_system_language() -> String {
|
||||||
let sys_lang = sys_locale::get_locale()
|
let sys_lang = sys_locale::get_locale()
|
||||||
.unwrap_or_else(|| String::from("en"))
|
.unwrap_or_else(|| String::from("en"))
|
||||||
@@ -248,7 +358,7 @@ impl IVerge {
|
|||||||
env_type: Some("bash".into()),
|
env_type: Some("bash".into()),
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
env_type: Some("powershell".into()),
|
env_type: Some("powershell".into()),
|
||||||
start_page: Some("/".into()),
|
start_page: Some("/home".into()),
|
||||||
traffic_graph: Some(true),
|
traffic_graph: Some(true),
|
||||||
enable_memory_usage: Some(true),
|
enable_memory_usage: Some(true),
|
||||||
enable_group_icon: Some(true),
|
enable_group_icon: Some(true),
|
||||||
@@ -260,9 +370,11 @@ impl IVerge {
|
|||||||
tun_tray_icon: Some(false),
|
tun_tray_icon: Some(false),
|
||||||
enable_auto_launch: Some(false),
|
enable_auto_launch: Some(false),
|
||||||
enable_silent_start: Some(false),
|
enable_silent_start: Some(false),
|
||||||
|
enable_hover_jump_navigator: Some(true),
|
||||||
enable_system_proxy: Some(false),
|
enable_system_proxy: Some(false),
|
||||||
proxy_auto_config: Some(false),
|
proxy_auto_config: Some(false),
|
||||||
pac_file_content: Some(DEFAULT_PAC.into()),
|
pac_file_content: Some(DEFAULT_PAC.into()),
|
||||||
|
proxy_host: Some("127.0.0.1".into()),
|
||||||
enable_random_port: Some(false),
|
enable_random_port: Some(false),
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
verge_redir_port: Some(7895),
|
verge_redir_port: Some(7895),
|
||||||
@@ -283,14 +395,20 @@ impl IVerge {
|
|||||||
auto_close_connection: Some(true),
|
auto_close_connection: Some(true),
|
||||||
auto_check_update: Some(true),
|
auto_check_update: Some(true),
|
||||||
enable_builtin_enhanced: Some(true),
|
enable_builtin_enhanced: Some(true),
|
||||||
auto_log_clean: Some(3),
|
auto_log_clean: Some(2),
|
||||||
webdav_url: None,
|
webdav_url: None,
|
||||||
webdav_username: None,
|
webdav_username: None,
|
||||||
webdav_password: None,
|
webdav_password: None,
|
||||||
enable_tray_speed: Some(true),
|
enable_tray_speed: Some(false),
|
||||||
|
enable_tray_icon: Some(true),
|
||||||
enable_global_hotkey: Some(true),
|
enable_global_hotkey: Some(true),
|
||||||
enable_lite_mode: Some(false),
|
enable_auto_light_weight_mode: Some(false),
|
||||||
enable_dns_settings: Some(true),
|
auto_light_weight_minutes: Some(10),
|
||||||
|
enable_dns_settings: Some(false),
|
||||||
|
enable_send_hwid: Some(true),
|
||||||
|
primary_action: Some("tun-mode".into()),
|
||||||
|
home_cards: None,
|
||||||
|
service_state: None,
|
||||||
..Self::default()
|
..Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,6 +449,7 @@ impl IVerge {
|
|||||||
patch!(enable_tun_mode);
|
patch!(enable_tun_mode);
|
||||||
patch!(enable_auto_launch);
|
patch!(enable_auto_launch);
|
||||||
patch!(enable_silent_start);
|
patch!(enable_silent_start);
|
||||||
|
patch!(enable_hover_jump_navigator);
|
||||||
patch!(enable_random_port);
|
patch!(enable_random_port);
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
patch!(verge_redir_port);
|
patch!(verge_redir_port);
|
||||||
@@ -352,7 +471,7 @@ impl IVerge {
|
|||||||
patch!(proxy_guard_duration);
|
patch!(proxy_guard_duration);
|
||||||
patch!(proxy_auto_config);
|
patch!(proxy_auto_config);
|
||||||
patch!(pac_file_content);
|
patch!(pac_file_content);
|
||||||
|
patch!(proxy_host);
|
||||||
patch!(theme_setting);
|
patch!(theme_setting);
|
||||||
patch!(web_ui_list);
|
patch!(web_ui_list);
|
||||||
patch!(clash_core);
|
patch!(clash_core);
|
||||||
@@ -372,8 +491,14 @@ impl IVerge {
|
|||||||
patch!(webdav_username);
|
patch!(webdav_username);
|
||||||
patch!(webdav_password);
|
patch!(webdav_password);
|
||||||
patch!(enable_tray_speed);
|
patch!(enable_tray_speed);
|
||||||
patch!(enable_lite_mode);
|
patch!(enable_tray_icon);
|
||||||
|
patch!(enable_auto_light_weight_mode);
|
||||||
|
patch!(auto_light_weight_minutes);
|
||||||
patch!(enable_dns_settings);
|
patch!(enable_dns_settings);
|
||||||
|
patch!(enable_send_hwid);
|
||||||
|
patch!(primary_action);
|
||||||
|
patch!(home_cards);
|
||||||
|
patch!(service_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 在初始化前尝试拿到单例端口的值
|
/// 在初始化前尝试拿到单例端口的值
|
||||||
@@ -432,6 +557,7 @@ pub struct IVergeResponse {
|
|||||||
pub proxy_guard_duration: Option<u64>,
|
pub proxy_guard_duration: Option<u64>,
|
||||||
pub proxy_auto_config: Option<bool>,
|
pub proxy_auto_config: Option<bool>,
|
||||||
pub pac_file_content: Option<String>,
|
pub pac_file_content: Option<String>,
|
||||||
|
pub proxy_host: Option<String>,
|
||||||
pub theme_setting: Option<IVergeTheme>,
|
pub theme_setting: Option<IVergeTheme>,
|
||||||
pub web_ui_list: Option<Vec<String>>,
|
pub web_ui_list: Option<Vec<String>>,
|
||||||
pub clash_core: Option<String>,
|
pub clash_core: Option<String>,
|
||||||
@@ -462,12 +588,21 @@ pub struct IVergeResponse {
|
|||||||
pub webdav_username: Option<String>,
|
pub webdav_username: Option<String>,
|
||||||
pub webdav_password: Option<String>,
|
pub webdav_password: Option<String>,
|
||||||
pub enable_tray_speed: Option<bool>,
|
pub enable_tray_speed: Option<bool>,
|
||||||
pub enable_lite_mode: Option<bool>,
|
pub enable_tray_icon: Option<bool>,
|
||||||
|
pub enable_auto_light_weight_mode: Option<bool>,
|
||||||
|
pub auto_light_weight_minutes: Option<u64>,
|
||||||
pub enable_dns_settings: Option<bool>,
|
pub enable_dns_settings: Option<bool>,
|
||||||
|
pub enable_send_hwid: Option<bool>,
|
||||||
|
pub primary_action: Option<String>,
|
||||||
|
pub home_cards: Option<serde_json::Value>,
|
||||||
|
pub enable_hover_jump_navigator: Option<bool>,
|
||||||
|
pub service_state: Option<crate::core::service::ServiceState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<IVerge> for IVergeResponse {
|
impl From<IVerge> for IVergeResponse {
|
||||||
fn from(verge: IVerge) -> Self {
|
fn from(verge: IVerge) -> Self {
|
||||||
|
// 先获取验证后的clash_core值,避免后续借用冲突
|
||||||
|
let valid_clash_core = verge.get_valid_clash_core();
|
||||||
Self {
|
Self {
|
||||||
app_log_level: verge.app_log_level,
|
app_log_level: verge.app_log_level,
|
||||||
language: verge.language,
|
language: verge.language,
|
||||||
@@ -496,9 +631,10 @@ impl From<IVerge> for IVergeResponse {
|
|||||||
proxy_guard_duration: verge.proxy_guard_duration,
|
proxy_guard_duration: verge.proxy_guard_duration,
|
||||||
proxy_auto_config: verge.proxy_auto_config,
|
proxy_auto_config: verge.proxy_auto_config,
|
||||||
pac_file_content: verge.pac_file_content,
|
pac_file_content: verge.pac_file_content,
|
||||||
|
proxy_host: verge.proxy_host,
|
||||||
theme_setting: verge.theme_setting,
|
theme_setting: verge.theme_setting,
|
||||||
web_ui_list: verge.web_ui_list,
|
web_ui_list: verge.web_ui_list,
|
||||||
clash_core: verge.clash_core,
|
clash_core: Some(valid_clash_core),
|
||||||
hotkeys: verge.hotkeys,
|
hotkeys: verge.hotkeys,
|
||||||
auto_close_connection: verge.auto_close_connection,
|
auto_close_connection: verge.auto_close_connection,
|
||||||
auto_check_update: verge.auto_check_update,
|
auto_check_update: verge.auto_check_update,
|
||||||
@@ -526,8 +662,15 @@ impl From<IVerge> for IVergeResponse {
|
|||||||
webdav_username: verge.webdav_username,
|
webdav_username: verge.webdav_username,
|
||||||
webdav_password: verge.webdav_password,
|
webdav_password: verge.webdav_password,
|
||||||
enable_tray_speed: verge.enable_tray_speed,
|
enable_tray_speed: verge.enable_tray_speed,
|
||||||
enable_lite_mode: verge.enable_lite_mode,
|
enable_tray_icon: verge.enable_tray_icon,
|
||||||
|
enable_auto_light_weight_mode: verge.enable_auto_light_weight_mode,
|
||||||
|
auto_light_weight_minutes: verge.auto_light_weight_minutes,
|
||||||
enable_dns_settings: verge.enable_dns_settings,
|
enable_dns_settings: verge.enable_dns_settings,
|
||||||
|
enable_send_hwid: verge.enable_send_hwid,
|
||||||
|
primary_action: verge.primary_action,
|
||||||
|
home_cards: verge.home_cards,
|
||||||
|
enable_hover_jump_navigator: verge.enable_hover_jump_navigator,
|
||||||
|
service_state: verge.service_state,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
531
src-tauri/src/core/async_proxy_query.rs
Normal file
@@ -0,0 +1,531 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tokio::time::{timeout, Duration};
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use anyhow::anyhow;
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
|
pub struct AsyncAutoproxy {
|
||||||
|
pub enable: bool,
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct AsyncSysproxy {
|
||||||
|
pub enable: bool,
|
||||||
|
pub host: String,
|
||||||
|
pub port: u16,
|
||||||
|
pub bypass: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AsyncSysproxy {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
enable: false,
|
||||||
|
host: "127.0.0.1".to_string(),
|
||||||
|
port: 7890,
|
||||||
|
bypass: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AsyncProxyQuery;
|
||||||
|
|
||||||
|
impl AsyncProxyQuery {
|
||||||
|
/// 异步获取自动代理配置(PAC)
|
||||||
|
pub async fn get_auto_proxy() -> AsyncAutoproxy {
|
||||||
|
match timeout(Duration::from_secs(3), Self::get_auto_proxy_impl()).await {
|
||||||
|
Ok(Ok(proxy)) => {
|
||||||
|
log::debug!(target: "app", "异步获取自动代理成功: enable={}, url={}", proxy.enable, proxy.url);
|
||||||
|
proxy
|
||||||
|
}
|
||||||
|
Ok(Err(e)) => {
|
||||||
|
log::warn!(target: "app", "异步获取自动代理失败: {e}");
|
||||||
|
AsyncAutoproxy::default()
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
log::warn!(target: "app", "异步获取自动代理超时");
|
||||||
|
AsyncAutoproxy::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 异步获取系统代理配置
|
||||||
|
pub async fn get_system_proxy() -> AsyncSysproxy {
|
||||||
|
match timeout(Duration::from_secs(3), Self::get_system_proxy_impl()).await {
|
||||||
|
Ok(Ok(proxy)) => {
|
||||||
|
log::debug!(target: "app", "异步获取系统代理成功: enable={}, {}:{}", proxy.enable, proxy.host, proxy.port);
|
||||||
|
proxy
|
||||||
|
}
|
||||||
|
Ok(Err(e)) => {
|
||||||
|
log::warn!(target: "app", "异步获取系统代理失败: {e}");
|
||||||
|
AsyncSysproxy::default()
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
log::warn!(target: "app", "异步获取系统代理超时");
|
||||||
|
AsyncSysproxy::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn get_auto_proxy_impl() -> Result<AsyncAutoproxy> {
|
||||||
|
// Windows: 从注册表读取PAC配置
|
||||||
|
tokio::task::spawn_blocking(move || -> Result<AsyncAutoproxy> {
|
||||||
|
Self::get_pac_config_from_registry()
|
||||||
|
})
|
||||||
|
.await?
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn get_pac_config_from_registry() -> Result<AsyncAutoproxy> {
|
||||||
|
use std::ptr;
|
||||||
|
use winapi::shared::minwindef::{DWORD, HKEY};
|
||||||
|
use winapi::um::winnt::{KEY_READ, REG_DWORD, REG_SZ};
|
||||||
|
use winapi::um::winreg::{RegCloseKey, RegOpenKeyExW, RegQueryValueExW, HKEY_CURRENT_USER};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let key_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\0"
|
||||||
|
.encode_utf16()
|
||||||
|
.collect::<Vec<u16>>();
|
||||||
|
|
||||||
|
let mut hkey: HKEY = ptr::null_mut();
|
||||||
|
let result =
|
||||||
|
RegOpenKeyExW(HKEY_CURRENT_USER, key_path.as_ptr(), 0, KEY_READ, &mut hkey);
|
||||||
|
|
||||||
|
if result != 0 {
|
||||||
|
log::debug!(target: "app", "无法打开注册表项");
|
||||||
|
return Ok(AsyncAutoproxy::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 检查自动配置是否启用 (AutoConfigURL 存在且不为空即表示启用)
|
||||||
|
let auto_config_url_name = "AutoConfigURL\0".encode_utf16().collect::<Vec<u16>>();
|
||||||
|
let mut url_buffer = vec![0u16; 1024];
|
||||||
|
let mut url_buffer_size: DWORD = (url_buffer.len() * 2) as DWORD;
|
||||||
|
let mut url_value_type: DWORD = 0;
|
||||||
|
|
||||||
|
let url_query_result = RegQueryValueExW(
|
||||||
|
hkey,
|
||||||
|
auto_config_url_name.as_ptr(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
&mut url_value_type,
|
||||||
|
url_buffer.as_mut_ptr() as *mut u8,
|
||||||
|
&mut url_buffer_size,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut pac_url = String::new();
|
||||||
|
if url_query_result == 0 && url_value_type == REG_SZ && url_buffer_size > 0 {
|
||||||
|
let end_pos = url_buffer
|
||||||
|
.iter()
|
||||||
|
.position(|&x| x == 0)
|
||||||
|
.unwrap_or(url_buffer.len());
|
||||||
|
pac_url = String::from_utf16_lossy(&url_buffer[..end_pos]);
|
||||||
|
log::debug!(target: "app", "从注册表读取到PAC URL: {}", pac_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 检查自动检测设置是否启用
|
||||||
|
let auto_detect_name = "AutoDetect\0".encode_utf16().collect::<Vec<u16>>();
|
||||||
|
let mut auto_detect: DWORD = 0;
|
||||||
|
let mut detect_buffer_size: DWORD = 4;
|
||||||
|
let mut detect_value_type: DWORD = 0;
|
||||||
|
|
||||||
|
let detect_query_result = RegQueryValueExW(
|
||||||
|
hkey,
|
||||||
|
auto_detect_name.as_ptr(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
&mut detect_value_type,
|
||||||
|
&mut auto_detect as *mut DWORD as *mut u8,
|
||||||
|
&mut detect_buffer_size,
|
||||||
|
);
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
// PAC 启用的条件:AutoConfigURL 不为空,或 AutoDetect 被启用
|
||||||
|
let pac_enabled = !pac_url.is_empty()
|
||||||
|
|| (detect_query_result == 0 && detect_value_type == REG_DWORD && auto_detect != 0);
|
||||||
|
|
||||||
|
if pac_enabled {
|
||||||
|
log::debug!(target: "app", "PAC配置启用: URL={}, AutoDetect={}", pac_url, auto_detect);
|
||||||
|
|
||||||
|
if pac_url.is_empty() && auto_detect != 0 {
|
||||||
|
pac_url = "auto-detect".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(AsyncAutoproxy {
|
||||||
|
enable: true,
|
||||||
|
url: pac_url,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
log::debug!(target: "app", "PAC配置未启用");
|
||||||
|
Ok(AsyncAutoproxy::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
async fn get_auto_proxy_impl() -> Result<AsyncAutoproxy> {
|
||||||
|
// macOS: 使用 scutil --proxy 命令
|
||||||
|
let output = Command::new("scutil").args(["--proxy"]).output().await?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return Ok(AsyncAutoproxy::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
|
log::debug!(target: "app", "scutil output: {stdout}");
|
||||||
|
|
||||||
|
let mut pac_enabled = false;
|
||||||
|
let mut pac_url = String::new();
|
||||||
|
|
||||||
|
// 解析 scutil 输出
|
||||||
|
for line in stdout.lines() {
|
||||||
|
let line = line.trim();
|
||||||
|
if line.contains("ProxyAutoConfigEnable") && line.contains("1") {
|
||||||
|
pac_enabled = true;
|
||||||
|
} else if line.contains("ProxyAutoConfigURLString") {
|
||||||
|
// 正确解析包含冒号的URL
|
||||||
|
// 格式: "ProxyAutoConfigURLString : http://127.0.0.1:11233/commands/pac"
|
||||||
|
if let Some(colon_pos) = line.find(" : ") {
|
||||||
|
pac_url = line[colon_pos + 3..].trim().to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log::debug!(target: "app", "解析结果: pac_enabled={pac_enabled}, pac_url={pac_url}");
|
||||||
|
|
||||||
|
Ok(AsyncAutoproxy {
|
||||||
|
enable: pac_enabled && !pac_url.is_empty(),
|
||||||
|
url: pac_url,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
async fn get_auto_proxy_impl() -> Result<AsyncAutoproxy> {
|
||||||
|
// Linux: 检查环境变量和GNOME设置
|
||||||
|
|
||||||
|
// 首先检查环境变量
|
||||||
|
if let Ok(auto_proxy) = std::env::var("auto_proxy") {
|
||||||
|
if !auto_proxy.is_empty() {
|
||||||
|
return Ok(AsyncAutoproxy {
|
||||||
|
enable: true,
|
||||||
|
url: auto_proxy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试使用 gsettings 获取 GNOME 代理设置
|
||||||
|
let output = Command::new("gsettings")
|
||||||
|
.args(["get", "org.gnome.system.proxy", "mode"])
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Ok(output) = output {
|
||||||
|
if output.status.success() {
|
||||||
|
let mode = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||||
|
if mode.contains("auto") {
|
||||||
|
// 获取 PAC URL
|
||||||
|
let pac_output = Command::new("gsettings")
|
||||||
|
.args(["get", "org.gnome.system.proxy", "autoconfig-url"])
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Ok(pac_output) = pac_output {
|
||||||
|
if pac_output.status.success() {
|
||||||
|
let pac_url = String::from_utf8_lossy(&pac_output.stdout)
|
||||||
|
.trim()
|
||||||
|
.trim_matches('\'')
|
||||||
|
.trim_matches('"')
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
if !pac_url.is_empty() {
|
||||||
|
return Ok(AsyncAutoproxy {
|
||||||
|
enable: true,
|
||||||
|
url: pac_url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(AsyncAutoproxy::default())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn get_system_proxy_impl() -> Result<AsyncSysproxy> {
|
||||||
|
// Windows: 使用注册表直接读取代理设置
|
||||||
|
tokio::task::spawn_blocking(move || -> Result<AsyncSysproxy> {
|
||||||
|
Self::get_system_proxy_from_registry()
|
||||||
|
})
|
||||||
|
.await?
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn get_system_proxy_from_registry() -> Result<AsyncSysproxy> {
|
||||||
|
use std::ptr;
|
||||||
|
use winapi::shared::minwindef::{DWORD, HKEY};
|
||||||
|
use winapi::um::winnt::{KEY_READ, REG_DWORD, REG_SZ};
|
||||||
|
use winapi::um::winreg::{RegCloseKey, RegOpenKeyExW, RegQueryValueExW, HKEY_CURRENT_USER};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let key_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\0"
|
||||||
|
.encode_utf16()
|
||||||
|
.collect::<Vec<u16>>();
|
||||||
|
|
||||||
|
let mut hkey: HKEY = ptr::null_mut();
|
||||||
|
let result =
|
||||||
|
RegOpenKeyExW(HKEY_CURRENT_USER, key_path.as_ptr(), 0, KEY_READ, &mut hkey);
|
||||||
|
|
||||||
|
if result != 0 {
|
||||||
|
return Ok(AsyncSysproxy::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查代理是否启用
|
||||||
|
let proxy_enable_name = "ProxyEnable\0".encode_utf16().collect::<Vec<u16>>();
|
||||||
|
let mut proxy_enable: DWORD = 0;
|
||||||
|
let mut buffer_size: DWORD = 4;
|
||||||
|
let mut value_type: DWORD = 0;
|
||||||
|
|
||||||
|
let enable_result = RegQueryValueExW(
|
||||||
|
hkey,
|
||||||
|
proxy_enable_name.as_ptr(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
&mut value_type,
|
||||||
|
&mut proxy_enable as *mut DWORD as *mut u8,
|
||||||
|
&mut buffer_size,
|
||||||
|
);
|
||||||
|
|
||||||
|
if enable_result != 0 || value_type != REG_DWORD || proxy_enable == 0 {
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
return Ok(AsyncSysproxy::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取代理服务器设置
|
||||||
|
let proxy_server_name = "ProxyServer\0".encode_utf16().collect::<Vec<u16>>();
|
||||||
|
let mut buffer = vec![0u16; 1024];
|
||||||
|
let mut buffer_size: DWORD = (buffer.len() * 2) as DWORD;
|
||||||
|
let mut value_type: DWORD = 0;
|
||||||
|
|
||||||
|
let server_result = RegQueryValueExW(
|
||||||
|
hkey,
|
||||||
|
proxy_server_name.as_ptr(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
&mut value_type,
|
||||||
|
buffer.as_mut_ptr() as *mut u8,
|
||||||
|
&mut buffer_size,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut proxy_server = String::new();
|
||||||
|
if server_result == 0 && value_type == REG_SZ && buffer_size > 0 {
|
||||||
|
let end_pos = buffer.iter().position(|&x| x == 0).unwrap_or(buffer.len());
|
||||||
|
proxy_server = String::from_utf16_lossy(&buffer[..end_pos]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取代理绕过列表
|
||||||
|
let proxy_override_name = "ProxyOverride\0".encode_utf16().collect::<Vec<u16>>();
|
||||||
|
let mut bypass_buffer = vec![0u16; 1024];
|
||||||
|
let mut bypass_buffer_size: DWORD = (bypass_buffer.len() * 2) as DWORD;
|
||||||
|
let mut bypass_value_type: DWORD = 0;
|
||||||
|
|
||||||
|
let override_result = RegQueryValueExW(
|
||||||
|
hkey,
|
||||||
|
proxy_override_name.as_ptr(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
&mut bypass_value_type,
|
||||||
|
bypass_buffer.as_mut_ptr() as *mut u8,
|
||||||
|
&mut bypass_buffer_size,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut bypass_list = String::new();
|
||||||
|
if override_result == 0 && bypass_value_type == REG_SZ && bypass_buffer_size > 0 {
|
||||||
|
let end_pos = bypass_buffer
|
||||||
|
.iter()
|
||||||
|
.position(|&x| x == 0)
|
||||||
|
.unwrap_or(bypass_buffer.len());
|
||||||
|
bypass_list = String::from_utf16_lossy(&bypass_buffer[..end_pos]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
if !proxy_server.is_empty() {
|
||||||
|
// 解析服务器地址和端口
|
||||||
|
let (host, port) = if let Some(colon_pos) = proxy_server.rfind(':') {
|
||||||
|
let host = proxy_server[..colon_pos].to_string();
|
||||||
|
let port = proxy_server[colon_pos + 1..].parse::<u16>().unwrap_or(8080);
|
||||||
|
(host, port)
|
||||||
|
} else {
|
||||||
|
(proxy_server, 8080)
|
||||||
|
};
|
||||||
|
|
||||||
|
log::debug!(target: "app", "从注册表读取到代理设置: {}:{}, bypass: {}", host, port, bypass_list);
|
||||||
|
|
||||||
|
Ok(AsyncSysproxy {
|
||||||
|
enable: true,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
bypass: bypass_list,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Ok(AsyncSysproxy::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
async fn get_system_proxy_impl() -> Result<AsyncSysproxy> {
|
||||||
|
let output = Command::new("scutil").args(["--proxy"]).output().await?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return Ok(AsyncSysproxy::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
|
log::debug!(target: "app", "scutil proxy output: {stdout}");
|
||||||
|
|
||||||
|
let mut http_enabled = false;
|
||||||
|
let mut http_host = String::new();
|
||||||
|
let mut http_port = 8080u16;
|
||||||
|
let mut exceptions = Vec::new();
|
||||||
|
|
||||||
|
for line in stdout.lines() {
|
||||||
|
let line = line.trim();
|
||||||
|
if line.contains("HTTPEnable") && line.contains("1") {
|
||||||
|
http_enabled = true;
|
||||||
|
} else if line.contains("HTTPProxy") && !line.contains("Port") {
|
||||||
|
if let Some(host_part) = line.split(':').nth(1) {
|
||||||
|
http_host = host_part.trim().to_string();
|
||||||
|
}
|
||||||
|
} else if line.contains("HTTPPort") {
|
||||||
|
if let Some(port_part) = line.split(':').nth(1) {
|
||||||
|
if let Ok(port) = port_part.trim().parse::<u16>() {
|
||||||
|
http_port = port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if line.contains("ExceptionsList") {
|
||||||
|
// 解析异常列表
|
||||||
|
if let Some(list_part) = line.split(':').nth(1) {
|
||||||
|
let list = list_part.trim();
|
||||||
|
if !list.is_empty() {
|
||||||
|
exceptions.push(list.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(AsyncSysproxy {
|
||||||
|
enable: http_enabled && !http_host.is_empty(),
|
||||||
|
host: http_host,
|
||||||
|
port: http_port,
|
||||||
|
bypass: exceptions.join(","),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
async fn get_system_proxy_impl() -> Result<AsyncSysproxy> {
|
||||||
|
// Linux: 检查环境变量和桌面环境设置
|
||||||
|
|
||||||
|
// 首先检查环境变量
|
||||||
|
if let Ok(http_proxy) = std::env::var("http_proxy") {
|
||||||
|
if let Ok(proxy_info) = Self::parse_proxy_url(&http_proxy) {
|
||||||
|
return Ok(proxy_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(https_proxy) = std::env::var("https_proxy") {
|
||||||
|
if let Ok(proxy_info) = Self::parse_proxy_url(&https_proxy) {
|
||||||
|
return Ok(proxy_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试使用 gsettings 获取 GNOME 代理设置
|
||||||
|
let mode_output = Command::new("gsettings")
|
||||||
|
.args(["get", "org.gnome.system.proxy", "mode"])
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Ok(mode_output) = mode_output {
|
||||||
|
if mode_output.status.success() {
|
||||||
|
let mode = String::from_utf8_lossy(&mode_output.stdout)
|
||||||
|
.trim()
|
||||||
|
.to_string();
|
||||||
|
if mode.contains("manual") {
|
||||||
|
// 获取HTTP代理设置
|
||||||
|
let host_result = Command::new("gsettings")
|
||||||
|
.args(["get", "org.gnome.system.proxy.http", "host"])
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let port_result = Command::new("gsettings")
|
||||||
|
.args(["get", "org.gnome.system.proxy.http", "port"])
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let (Ok(host_output), Ok(port_output)) = (host_result, port_result) {
|
||||||
|
if host_output.status.success() && port_output.status.success() {
|
||||||
|
let host = String::from_utf8_lossy(&host_output.stdout)
|
||||||
|
.trim()
|
||||||
|
.trim_matches('\'')
|
||||||
|
.trim_matches('"')
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let port = String::from_utf8_lossy(&port_output.stdout)
|
||||||
|
.trim()
|
||||||
|
.parse::<u16>()
|
||||||
|
.unwrap_or(8080);
|
||||||
|
|
||||||
|
if !host.is_empty() {
|
||||||
|
return Ok(AsyncSysproxy {
|
||||||
|
enable: true,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
bypass: String::new(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(AsyncSysproxy::default())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn parse_proxy_url(proxy_url: &str) -> Result<AsyncSysproxy> {
|
||||||
|
// 解析形如 "http://proxy.example.com:8080" 的URL
|
||||||
|
let url = proxy_url.trim();
|
||||||
|
|
||||||
|
// 移除协议前缀
|
||||||
|
let url = if let Some(stripped) = url.strip_prefix("http://") {
|
||||||
|
stripped
|
||||||
|
} else if let Some(stripped) = url.strip_prefix("https://") {
|
||||||
|
stripped
|
||||||
|
} else {
|
||||||
|
url
|
||||||
|
};
|
||||||
|
|
||||||
|
// 解析主机和端口
|
||||||
|
let (host, port) = if let Some(colon_pos) = url.rfind(':') {
|
||||||
|
let host = url[..colon_pos].to_string();
|
||||||
|
let port = url[colon_pos + 1..].parse::<u16>().unwrap_or(8080);
|
||||||
|
(host, port)
|
||||||
|
} else {
|
||||||
|
(url.to_string(), 8080)
|
||||||
|
};
|
||||||
|
|
||||||
|
if host.is_empty() {
|
||||||
|
return Err(anyhow!("无效的代理URL"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(AsyncSysproxy {
|
||||||
|
enable: true,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
bypass: std::env::var("no_proxy").unwrap_or_default(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,23 @@
|
|||||||
use crate::config::Config;
|
use crate::{config::Config, utils::dirs};
|
||||||
use crate::utils::dirs;
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use reqwest_dav::list_cmd::{ListEntity, ListFile};
|
use reqwest_dav::list_cmd::{ListEntity, ListFile};
|
||||||
use std::collections::HashMap;
|
use std::{
|
||||||
use std::env::{consts::OS, temp_dir};
|
collections::HashMap,
|
||||||
use std::fs;
|
env::{consts::OS, temp_dir},
|
||||||
use std::io::Write;
|
fs,
|
||||||
use std::path::PathBuf;
|
io::Write,
|
||||||
use std::sync::Arc;
|
path::PathBuf,
|
||||||
use std::time::Duration;
|
sync::Arc,
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
use tokio::time::timeout;
|
use tokio::time::timeout;
|
||||||
use zip::write::SimpleFileOptions;
|
use zip::write::SimpleFileOptions;
|
||||||
|
|
||||||
|
// 应用版本常量,来自 tauri.conf.json
|
||||||
|
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
const TIMEOUT_UPLOAD: u64 = 300; // 上传超时 5 分钟
|
const TIMEOUT_UPLOAD: u64 = 300; // 上传超时 5 分钟
|
||||||
const TIMEOUT_DOWNLOAD: u64 = 300; // 下载超时 5 分钟
|
const TIMEOUT_DOWNLOAD: u64 = 300; // 下载超时 5 分钟
|
||||||
const TIMEOUT_LIST: u64 = 3; // 列表超时 30 秒
|
const TIMEOUT_LIST: u64 = 3; // 列表超时 30 秒
|
||||||
@@ -104,6 +108,15 @@ impl WebDavClient {
|
|||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.danger_accept_invalid_certs(true)
|
.danger_accept_invalid_certs(true)
|
||||||
.timeout(Duration::from_secs(op.timeout()))
|
.timeout(Duration::from_secs(op.timeout()))
|
||||||
|
.user_agent(format!("clash-verge/{APP_VERSION} ({OS} WebDAV-Client)"))
|
||||||
|
.redirect(reqwest::redirect::Policy::custom(|attempt| {
|
||||||
|
// 允许所有请求类型的重定向,包括PUT
|
||||||
|
if attempt.previous().len() >= 5 {
|
||||||
|
attempt.error("重定向次数过多")
|
||||||
|
} else {
|
||||||
|
attempt.follow()
|
||||||
|
}
|
||||||
|
}))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
@@ -111,12 +124,13 @@ impl WebDavClient {
|
|||||||
.set_auth(reqwest_dav::Auth::Basic(config.username, config.password))
|
.set_auth(reqwest_dav::Auth::Basic(config.username, config.password))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
// 确保备份目录存在
|
// 尝试检查目录是否存在,如果不存在尝试创建,但创建失败不报错
|
||||||
let list_result = client
|
if client
|
||||||
.list(dirs::BACKUP_DIR, reqwest_dav::Depth::Number(0))
|
.list(dirs::BACKUP_DIR, reqwest_dav::Depth::Number(0))
|
||||||
.await;
|
.await
|
||||||
if list_result.is_err() {
|
.is_err()
|
||||||
client.mkcol(dirs::BACKUP_DIR).await?;
|
{
|
||||||
|
let _ = client.mkcol(dirs::BACKUP_DIR).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缓存客户端
|
// 缓存客户端
|
||||||
@@ -136,9 +150,41 @@ impl WebDavClient {
|
|||||||
pub async fn upload(&self, file_path: PathBuf, file_name: String) -> Result<(), Error> {
|
pub async fn upload(&self, file_path: PathBuf, file_name: String) -> Result<(), Error> {
|
||||||
let client = self.get_client(Operation::Upload).await?;
|
let client = self.get_client(Operation::Upload).await?;
|
||||||
let webdav_path: String = format!("{}/{}", dirs::BACKUP_DIR, file_name);
|
let webdav_path: String = format!("{}/{}", dirs::BACKUP_DIR, file_name);
|
||||||
let fut = client.put(webdav_path.as_ref(), fs::read(file_path)?);
|
|
||||||
timeout(Duration::from_secs(TIMEOUT_UPLOAD), fut).await??;
|
// 读取文件并上传,如果失败尝试一次重试
|
||||||
Ok(())
|
let file_content = fs::read(&file_path)?;
|
||||||
|
|
||||||
|
// 添加超时保护
|
||||||
|
let upload_result = timeout(
|
||||||
|
Duration::from_secs(TIMEOUT_UPLOAD),
|
||||||
|
client.put(&webdav_path, file_content.clone()),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match upload_result {
|
||||||
|
Err(_) => {
|
||||||
|
log::warn!("Upload timed out, retrying once");
|
||||||
|
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||||
|
timeout(
|
||||||
|
Duration::from_secs(TIMEOUT_UPLOAD),
|
||||||
|
client.put(&webdav_path, file_content),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Err(e)) => {
|
||||||
|
log::warn!("Upload failed, retrying once: {e}");
|
||||||
|
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||||
|
timeout(
|
||||||
|
Duration::from_secs(TIMEOUT_UPLOAD),
|
||||||
|
client.put(&webdav_path, file_content),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Ok(Ok(_)) => Ok(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn download(&self, filename: String, storage_path: PathBuf) -> Result<(), Error> {
|
pub async fn download(&self, filename: String, storage_path: PathBuf) -> Result<(), Error> {
|
||||||
@@ -188,7 +234,7 @@ impl WebDavClient {
|
|||||||
|
|
||||||
pub fn create_backup() -> Result<(String, PathBuf), Error> {
|
pub fn create_backup() -> Result<(String, PathBuf), Error> {
|
||||||
let now = chrono::Local::now().format("%Y-%m-%d_%H-%M-%S").to_string();
|
let now = chrono::Local::now().format("%Y-%m-%d_%H-%M-%S").to_string();
|
||||||
let zip_file_name = format!("{}-backup-{}.zip", OS, now);
|
let zip_file_name = format!("{OS}-backup-{now}.zip");
|
||||||
let zip_path = temp_dir().join(&zip_file_name);
|
let zip_path = temp_dir().join(&zip_file_name);
|
||||||
|
|
||||||
let file = fs::File::create(&zip_path)?;
|
let file = fs::File::create(&zip_path)?;
|
||||||
|
|||||||
571
src-tauri/src/core/event_driven_proxy.rs
Normal file
@@ -0,0 +1,571 @@
|
|||||||
|
use parking_lot::RwLock;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
use tokio::time::{sleep, timeout, Duration};
|
||||||
|
|
||||||
|
use crate::config::{Config, IVerge};
|
||||||
|
use crate::core::async_proxy_query::AsyncProxyQuery;
|
||||||
|
use crate::logging_error;
|
||||||
|
use crate::utils::logging::Type;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use sysproxy::{Autoproxy, Sysproxy};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum ProxyEvent {
|
||||||
|
/// 配置变更事件
|
||||||
|
ConfigChanged,
|
||||||
|
/// 强制检查代理状态
|
||||||
|
#[allow(dead_code)]
|
||||||
|
ForceCheck,
|
||||||
|
/// 启用系统代理
|
||||||
|
#[allow(dead_code)]
|
||||||
|
EnableProxy,
|
||||||
|
/// 禁用系统代理
|
||||||
|
#[allow(dead_code)]
|
||||||
|
DisableProxy,
|
||||||
|
/// 切换到PAC模式
|
||||||
|
#[allow(dead_code)]
|
||||||
|
SwitchToPac,
|
||||||
|
/// 切换到HTTP代理模式
|
||||||
|
#[allow(dead_code)]
|
||||||
|
SwitchToHttp,
|
||||||
|
/// 应用启动事件
|
||||||
|
AppStarted,
|
||||||
|
/// 应用关闭事件
|
||||||
|
#[allow(dead_code)]
|
||||||
|
AppStopping,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct ProxyState {
|
||||||
|
pub sys_enabled: bool,
|
||||||
|
pub pac_enabled: bool,
|
||||||
|
pub auto_proxy: Autoproxy,
|
||||||
|
pub sys_proxy: Sysproxy,
|
||||||
|
pub last_updated: std::time::Instant,
|
||||||
|
pub is_healthy: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ProxyState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
sys_enabled: false,
|
||||||
|
pac_enabled: false,
|
||||||
|
auto_proxy: Autoproxy {
|
||||||
|
enable: false,
|
||||||
|
url: "".to_string(),
|
||||||
|
},
|
||||||
|
sys_proxy: Sysproxy {
|
||||||
|
enable: false,
|
||||||
|
host: "127.0.0.1".to_string(),
|
||||||
|
port: 7890,
|
||||||
|
bypass: "".to_string(),
|
||||||
|
},
|
||||||
|
last_updated: std::time::Instant::now(),
|
||||||
|
is_healthy: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EventDrivenProxyManager {
|
||||||
|
state: Arc<RwLock<ProxyState>>,
|
||||||
|
event_sender: mpsc::UnboundedSender<ProxyEvent>,
|
||||||
|
query_sender: mpsc::UnboundedSender<QueryRequest>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct QueryRequest {
|
||||||
|
response_tx: oneshot::Sender<Autoproxy>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置结构体移到外部
|
||||||
|
struct ProxyConfig {
|
||||||
|
sys_enabled: bool,
|
||||||
|
pac_enabled: bool,
|
||||||
|
guard_enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
static PROXY_MANAGER: Lazy<EventDrivenProxyManager> = Lazy::new(EventDrivenProxyManager::new);
|
||||||
|
|
||||||
|
impl EventDrivenProxyManager {
|
||||||
|
pub fn global() -> &'static EventDrivenProxyManager {
|
||||||
|
&PROXY_MANAGER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new() -> Self {
|
||||||
|
let state = Arc::new(RwLock::new(ProxyState::default()));
|
||||||
|
let (event_tx, event_rx) = mpsc::unbounded_channel();
|
||||||
|
let (query_tx, query_rx) = mpsc::unbounded_channel();
|
||||||
|
|
||||||
|
Self::start_event_loop(state.clone(), event_rx, query_rx);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
state,
|
||||||
|
event_sender: event_tx,
|
||||||
|
query_sender: query_tx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取自动代理配置(缓存)
|
||||||
|
pub fn get_auto_proxy_cached(&self) -> Autoproxy {
|
||||||
|
self.state.read().auto_proxy.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 异步获取最新的自动代理配置
|
||||||
|
pub async fn get_auto_proxy_async(&self) -> Autoproxy {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
let query = QueryRequest { response_tx: tx };
|
||||||
|
|
||||||
|
if self.query_sender.send(query).is_err() {
|
||||||
|
log::error!(target: "app", "发送查询请求失败,返回缓存数据");
|
||||||
|
return self.get_auto_proxy_cached();
|
||||||
|
}
|
||||||
|
|
||||||
|
match timeout(Duration::from_secs(5), rx).await {
|
||||||
|
Ok(Ok(result)) => result,
|
||||||
|
_ => {
|
||||||
|
log::warn!(target: "app", "查询超时,返回缓存数据");
|
||||||
|
self.get_auto_proxy_cached()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 通知配置变更
|
||||||
|
pub fn notify_config_changed(&self) {
|
||||||
|
self.send_event(ProxyEvent::ConfigChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 通知应用启动
|
||||||
|
pub fn notify_app_started(&self) {
|
||||||
|
self.send_event(ProxyEvent::AppStarted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 通知应用即将关闭
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn notify_app_stopping(&self) {
|
||||||
|
self.send_event(ProxyEvent::AppStopping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 启用系统代理
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn enable_proxy(&self) {
|
||||||
|
self.send_event(ProxyEvent::EnableProxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 禁用系统代理
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn disable_proxy(&self) {
|
||||||
|
self.send_event(ProxyEvent::DisableProxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 强制检查代理状态
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn force_check(&self) {
|
||||||
|
self.send_event(ProxyEvent::ForceCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_event(&self, event: ProxyEvent) {
|
||||||
|
if let Err(e) = self.event_sender.send(event) {
|
||||||
|
log::error!(target: "app", "发送代理事件失败: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_event_loop(
|
||||||
|
state: Arc<RwLock<ProxyState>>,
|
||||||
|
mut event_rx: mpsc::UnboundedReceiver<ProxyEvent>,
|
||||||
|
mut query_rx: mpsc::UnboundedReceiver<QueryRequest>,
|
||||||
|
) {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
log::info!(target: "app", "事件驱动代理管理器启动");
|
||||||
|
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
event = event_rx.recv() => {
|
||||||
|
match event {
|
||||||
|
Some(event) => {
|
||||||
|
log::debug!(target: "app", "处理代理事件: {event:?}");
|
||||||
|
Self::handle_event(&state, event).await;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::info!(target: "app", "事件通道关闭,代理管理器停止");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query = query_rx.recv() => {
|
||||||
|
match query {
|
||||||
|
Some(query) => {
|
||||||
|
let result = Self::handle_query(&state).await;
|
||||||
|
let _ = query.response_tx.send(result);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::info!(target: "app", "查询通道关闭");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_event(state: &Arc<RwLock<ProxyState>>, event: ProxyEvent) {
|
||||||
|
match event {
|
||||||
|
ProxyEvent::ConfigChanged | ProxyEvent::ForceCheck => {
|
||||||
|
Self::update_proxy_config(state).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::EnableProxy => {
|
||||||
|
Self::enable_system_proxy(state).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::DisableProxy => {
|
||||||
|
Self::disable_system_proxy(state).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::SwitchToPac => {
|
||||||
|
Self::switch_proxy_mode(state, true).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::SwitchToHttp => {
|
||||||
|
Self::switch_proxy_mode(state, false).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::AppStarted => {
|
||||||
|
Self::initialize_proxy_state(state).await;
|
||||||
|
}
|
||||||
|
ProxyEvent::AppStopping => {
|
||||||
|
log::info!(target: "app", "清理代理状态");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_query(state: &Arc<RwLock<ProxyState>>) -> Autoproxy {
|
||||||
|
let auto_proxy = Self::get_auto_proxy_with_timeout().await;
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.auto_proxy = auto_proxy.clone();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto_proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn initialize_proxy_state(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
log::info!(target: "app", "初始化代理状态");
|
||||||
|
|
||||||
|
let config = Self::get_proxy_config();
|
||||||
|
let auto_proxy = Self::get_auto_proxy_with_timeout().await;
|
||||||
|
let sys_proxy = Self::get_sys_proxy_with_timeout().await;
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.sys_enabled = config.sys_enabled;
|
||||||
|
s.pac_enabled = config.pac_enabled;
|
||||||
|
s.auto_proxy = auto_proxy;
|
||||||
|
s.sys_proxy = sys_proxy;
|
||||||
|
s.is_healthy = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
log::info!(target: "app", "代理状态初始化完成: sys={}, pac={}", config.sys_enabled, config.pac_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_proxy_config(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
log::debug!(target: "app", "更新代理配置");
|
||||||
|
|
||||||
|
let config = Self::get_proxy_config();
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.sys_enabled = config.sys_enabled;
|
||||||
|
s.pac_enabled = config.pac_enabled;
|
||||||
|
});
|
||||||
|
|
||||||
|
if config.guard_enabled && config.sys_enabled {
|
||||||
|
Self::check_and_restore_proxy(state).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_and_restore_proxy(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
let (sys_enabled, pac_enabled) = {
|
||||||
|
let s = state.read();
|
||||||
|
(s.sys_enabled, s.pac_enabled)
|
||||||
|
};
|
||||||
|
|
||||||
|
if !sys_enabled {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::debug!(target: "app", "检查代理状态");
|
||||||
|
|
||||||
|
if pac_enabled {
|
||||||
|
Self::check_and_restore_pac_proxy(state).await;
|
||||||
|
} else {
|
||||||
|
Self::check_and_restore_sys_proxy(state).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_and_restore_pac_proxy(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
let current = Self::get_auto_proxy_with_timeout().await;
|
||||||
|
let expected = Self::get_expected_pac_config();
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.auto_proxy = current.clone();
|
||||||
|
});
|
||||||
|
|
||||||
|
if !current.enable || current.url != expected.url {
|
||||||
|
log::info!(target: "app", "PAC代理设置异常,正在恢复...");
|
||||||
|
Self::restore_pac_proxy(&expected.url).await;
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(500)).await;
|
||||||
|
let restored = Self::get_auto_proxy_with_timeout().await;
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.is_healthy = restored.enable && restored.url == expected.url;
|
||||||
|
s.auto_proxy = restored;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_and_restore_sys_proxy(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
let current = Self::get_sys_proxy_with_timeout().await;
|
||||||
|
let expected = Self::get_expected_sys_proxy();
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.sys_proxy = current.clone();
|
||||||
|
});
|
||||||
|
|
||||||
|
if !current.enable || current.host != expected.host || current.port != expected.port {
|
||||||
|
log::info!(target: "app", "系统代理设置异常,正在恢复...");
|
||||||
|
Self::restore_sys_proxy(&expected).await;
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(500)).await;
|
||||||
|
let restored = Self::get_sys_proxy_with_timeout().await;
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| {
|
||||||
|
s.is_healthy = restored.enable
|
||||||
|
&& restored.host == expected.host
|
||||||
|
&& restored.port == expected.port;
|
||||||
|
s.sys_proxy = restored;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn enable_system_proxy(state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
log::info!(target: "app", "启用系统代理");
|
||||||
|
|
||||||
|
let pac_enabled = state.read().pac_enabled;
|
||||||
|
|
||||||
|
if pac_enabled {
|
||||||
|
let expected = Self::get_expected_pac_config();
|
||||||
|
Self::restore_pac_proxy(&expected.url).await;
|
||||||
|
} else {
|
||||||
|
let expected = Self::get_expected_sys_proxy();
|
||||||
|
Self::restore_sys_proxy(&expected).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::check_and_restore_proxy(state).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn disable_system_proxy(_state: &Arc<RwLock<ProxyState>>) {
|
||||||
|
log::info!(target: "app", "禁用系统代理");
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
let disabled_sys = Sysproxy::default();
|
||||||
|
let disabled_auto = Autoproxy::default();
|
||||||
|
|
||||||
|
logging_error!(Type::System, true, disabled_auto.set_auto_proxy());
|
||||||
|
logging_error!(Type::System, true, disabled_sys.set_system_proxy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn switch_proxy_mode(state: &Arc<RwLock<ProxyState>>, to_pac: bool) {
|
||||||
|
log::info!(target: "app", "切换到{}模式", if to_pac { "PAC" } else { "HTTP代理" });
|
||||||
|
|
||||||
|
if to_pac {
|
||||||
|
let disabled_sys = Sysproxy::default();
|
||||||
|
logging_error!(Type::System, true, disabled_sys.set_system_proxy());
|
||||||
|
|
||||||
|
let expected = Self::get_expected_pac_config();
|
||||||
|
Self::restore_pac_proxy(&expected.url).await;
|
||||||
|
} else {
|
||||||
|
let disabled_auto = Autoproxy::default();
|
||||||
|
logging_error!(Type::System, true, disabled_auto.set_auto_proxy());
|
||||||
|
|
||||||
|
let expected = Self::get_expected_sys_proxy();
|
||||||
|
Self::restore_sys_proxy(&expected).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::update_state_timestamp(state, |s| s.pac_enabled = to_pac);
|
||||||
|
Self::check_and_restore_proxy(state).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_auto_proxy_with_timeout() -> Autoproxy {
|
||||||
|
let async_proxy = AsyncProxyQuery::get_auto_proxy().await;
|
||||||
|
|
||||||
|
// 转换为兼容的结构
|
||||||
|
Autoproxy {
|
||||||
|
enable: async_proxy.enable,
|
||||||
|
url: async_proxy.url,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_sys_proxy_with_timeout() -> Sysproxy {
|
||||||
|
let async_proxy = AsyncProxyQuery::get_system_proxy().await;
|
||||||
|
|
||||||
|
// 转换为兼容的结构
|
||||||
|
Sysproxy {
|
||||||
|
enable: async_proxy.enable,
|
||||||
|
host: async_proxy.host,
|
||||||
|
port: async_proxy.port,
|
||||||
|
bypass: async_proxy.bypass,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统一的状态更新方法
|
||||||
|
fn update_state_timestamp<F>(state: &Arc<RwLock<ProxyState>>, update_fn: F)
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut ProxyState),
|
||||||
|
{
|
||||||
|
let mut state_guard = state.write();
|
||||||
|
update_fn(&mut state_guard);
|
||||||
|
state_guard.last_updated = std::time::Instant::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_proxy_config() -> ProxyConfig {
|
||||||
|
let verge_config = Config::verge();
|
||||||
|
let verge = verge_config.latest();
|
||||||
|
ProxyConfig {
|
||||||
|
sys_enabled: verge.enable_system_proxy.unwrap_or(false),
|
||||||
|
pac_enabled: verge.proxy_auto_config.unwrap_or(false),
|
||||||
|
guard_enabled: verge.enable_proxy_guard.unwrap_or(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_expected_pac_config() -> Autoproxy {
|
||||||
|
let verge_config = Config::verge();
|
||||||
|
let verge = verge_config.latest();
|
||||||
|
let (proxy_host, pac_port) = (
|
||||||
|
verge
|
||||||
|
.proxy_host
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| "127.0.0.1".to_string()),
|
||||||
|
IVerge::get_singleton_port(),
|
||||||
|
);
|
||||||
|
Autoproxy {
|
||||||
|
enable: true,
|
||||||
|
url: format!("http://{proxy_host}:{pac_port}/commands/pac"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_expected_sys_proxy() -> Sysproxy {
|
||||||
|
let verge_config = Config::verge();
|
||||||
|
let verge = verge_config.latest();
|
||||||
|
let port = verge
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
|
let proxy_host = verge
|
||||||
|
.proxy_host
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| "127.0.0.1".to_string());
|
||||||
|
|
||||||
|
Sysproxy {
|
||||||
|
enable: true,
|
||||||
|
host: proxy_host,
|
||||||
|
port,
|
||||||
|
bypass: Self::get_bypass_config(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_bypass_config() -> String {
|
||||||
|
let verge_config = Config::verge();
|
||||||
|
let verge = verge_config.latest();
|
||||||
|
let use_default = verge.use_default_bypass.unwrap_or(true);
|
||||||
|
let custom_bypass = verge.system_proxy_bypass.clone().unwrap_or_default();
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let default_bypass = "localhost;127.*;192.168.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;<local>";
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let default_bypass =
|
||||||
|
"localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,172.29.0.0/16,::1";
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let default_bypass = "127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,172.29.0.0/16,localhost,*.local,*.crashlytics.com,<local>";
|
||||||
|
|
||||||
|
if custom_bypass.is_empty() {
|
||||||
|
default_bypass.to_string()
|
||||||
|
} else if use_default {
|
||||||
|
format!("{default_bypass},{custom_bypass}")
|
||||||
|
} else {
|
||||||
|
custom_bypass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn restore_pac_proxy(expected_url: &str) {
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
let new_autoproxy = Autoproxy {
|
||||||
|
enable: true,
|
||||||
|
url: expected_url.to_string(),
|
||||||
|
};
|
||||||
|
logging_error!(Type::System, true, new_autoproxy.set_auto_proxy());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
Self::execute_sysproxy_command(&["pac", expected_url]).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn restore_sys_proxy(expected: &Sysproxy) {
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
logging_error!(Type::System, true, expected.set_system_proxy());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
let address = format!("{}:{}", expected.host, expected.port);
|
||||||
|
Self::execute_sysproxy_command(&["global", &address, &expected.bypass]).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn execute_sysproxy_command(args: &[&str]) {
|
||||||
|
use crate::utils::dirs;
|
||||||
|
#[allow(unused_imports)] // creation_flags必须
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
let binary_path = match dirs::service_path() {
|
||||||
|
Ok(path) => path,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(target: "app", "获取服务路径失败: {}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let sysproxy_exe = binary_path.with_file_name("sysproxy.exe");
|
||||||
|
if !sysproxy_exe.exists() {
|
||||||
|
log::error!(target: "app", "sysproxy.exe 不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = Command::new(sysproxy_exe)
|
||||||
|
.args(args)
|
||||||
|
.creation_flags(0x08000000) // CREATE_NO_WINDOW - 隐藏窗口
|
||||||
|
.output()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match output {
|
||||||
|
Ok(output) => {
|
||||||
|
if !output.status.success() {
|
||||||
|
log::error!(target: "app", "执行sysproxy命令失败: {:?}", args);
|
||||||
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
|
if !stderr.is_empty() {
|
||||||
|
log::error!(target: "app", "sysproxy错误输出: {}", stderr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::debug!(target: "app", "成功执行sysproxy命令: {:?}", args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(target: "app", "执行sysproxy命令出错: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,293 @@
|
|||||||
use crate::log_err;
|
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::{
|
||||||
|
sync::{
|
||||||
|
atomic::{AtomicU64, Ordering},
|
||||||
|
mpsc, Arc,
|
||||||
|
},
|
||||||
|
thread,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
use tauri::{AppHandle, Emitter, Manager, WebviewWindow};
|
use tauri::{AppHandle, Emitter, Manager, WebviewWindow};
|
||||||
use tauri_plugin_shell::process::CommandChild;
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
use crate::{logging, utils::logging::Type};
|
||||||
|
|
||||||
|
/// 不同类型的前端通知
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum FrontendEvent {
|
||||||
|
RefreshClash,
|
||||||
|
RefreshVerge,
|
||||||
|
NoticeMessage { status: String, message: String },
|
||||||
|
ProfileChanged { current_profile_id: String },
|
||||||
|
TimerUpdated { profile_index: String },
|
||||||
|
StartupCompleted,
|
||||||
|
ProfileUpdateStarted { uid: String },
|
||||||
|
ProfileUpdateCompleted { uid: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 事件发送统计和监控
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
struct EventStats {
|
||||||
|
total_sent: AtomicU64,
|
||||||
|
total_errors: AtomicU64,
|
||||||
|
last_error_time: RwLock<Option<Instant>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 存储启动期间的错误消息
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct ErrorMessage {
|
||||||
|
status: String,
|
||||||
|
message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 全局前端通知系统
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct NotificationSystem {
|
||||||
|
sender: Option<mpsc::Sender<FrontendEvent>>,
|
||||||
|
worker_handle: Option<thread::JoinHandle<()>>,
|
||||||
|
is_running: bool,
|
||||||
|
stats: EventStats,
|
||||||
|
last_emit_time: RwLock<Instant>,
|
||||||
|
/// 当通知系统失败超过阈值时,进入紧急模式
|
||||||
|
emergency_mode: RwLock<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for NotificationSystem {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NotificationSystem {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
sender: None,
|
||||||
|
worker_handle: None,
|
||||||
|
is_running: false,
|
||||||
|
stats: EventStats::default(),
|
||||||
|
last_emit_time: RwLock::new(Instant::now()),
|
||||||
|
emergency_mode: RwLock::new(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 启动通知处理线程
|
||||||
|
fn start(&mut self) {
|
||||||
|
if self.is_running {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (tx, rx) = mpsc::channel();
|
||||||
|
self.sender = Some(tx);
|
||||||
|
self.is_running = true;
|
||||||
|
|
||||||
|
*self.last_emit_time.write() = Instant::now();
|
||||||
|
|
||||||
|
self.worker_handle = Some(
|
||||||
|
thread::Builder::new()
|
||||||
|
.name("frontend-notifier".into())
|
||||||
|
.spawn(move || {
|
||||||
|
let handle = Handle::global();
|
||||||
|
|
||||||
|
while !handle.is_exiting() {
|
||||||
|
match rx.recv_timeout(Duration::from_millis(100)) {
|
||||||
|
Ok(event) => {
|
||||||
|
let system_guard = handle.notification_system.read();
|
||||||
|
if system_guard.as_ref().is_none() {
|
||||||
|
log::warn!("NotificationSystem not found in handle while processing event.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let system = system_guard.as_ref().unwrap();
|
||||||
|
|
||||||
|
let is_emergency = *system.emergency_mode.read();
|
||||||
|
|
||||||
|
if is_emergency {
|
||||||
|
if let FrontendEvent::NoticeMessage { ref status, .. } = event {
|
||||||
|
if status == "info" {
|
||||||
|
log::warn!(
|
||||||
|
"Emergency mode active, skipping info message"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(window) = handle.get_window() {
|
||||||
|
*system.last_emit_time.write() = Instant::now();
|
||||||
|
|
||||||
|
let (event_name_str, payload_result) = match event {
|
||||||
|
FrontendEvent::RefreshClash => {
|
||||||
|
("verge://refresh-clash-config", Ok(serde_json::json!("yes")))
|
||||||
|
}
|
||||||
|
FrontendEvent::RefreshVerge => {
|
||||||
|
("verge://refresh-verge-config", Ok(serde_json::json!("yes")))
|
||||||
|
}
|
||||||
|
FrontendEvent::NoticeMessage { status, message } => {
|
||||||
|
match serde_json::to_value((status, message)) {
|
||||||
|
Ok(p) => ("verge://notice-message", Ok(p)),
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to serialize NoticeMessage payload: {e}");
|
||||||
|
("verge://notice-message", Err(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FrontendEvent::ProfileChanged { current_profile_id } => {
|
||||||
|
("profile-changed", Ok(serde_json::json!(current_profile_id)))
|
||||||
|
}
|
||||||
|
FrontendEvent::TimerUpdated { profile_index } => {
|
||||||
|
("verge://timer-updated", Ok(serde_json::json!(profile_index)))
|
||||||
|
}
|
||||||
|
FrontendEvent::StartupCompleted => {
|
||||||
|
("verge://startup-completed", Ok(serde_json::json!(null)))
|
||||||
|
}
|
||||||
|
FrontendEvent::ProfileUpdateStarted { uid } => {
|
||||||
|
("profile-update-started", Ok(serde_json::json!({ "uid": uid })))
|
||||||
|
}
|
||||||
|
FrontendEvent::ProfileUpdateCompleted { uid } => {
|
||||||
|
("profile-update-completed", Ok(serde_json::json!({ "uid": uid })))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Ok(payload) = payload_result {
|
||||||
|
match window.emit(event_name_str, payload) {
|
||||||
|
Ok(_) => {
|
||||||
|
system.stats.total_sent.fetch_add(1, Ordering::SeqCst);
|
||||||
|
// 记录成功发送的事件
|
||||||
|
if log::log_enabled!(log::Level::Debug) {
|
||||||
|
log::debug!("Successfully emitted event: {event_name_str}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to emit event {event_name_str}: {e}");
|
||||||
|
system.stats.total_errors.fetch_add(1, Ordering::SeqCst);
|
||||||
|
*system.stats.last_error_time.write() = Some(Instant::now());
|
||||||
|
|
||||||
|
let errors = system.stats.total_errors.load(Ordering::SeqCst);
|
||||||
|
const EMIT_ERROR_THRESHOLD: u64 = 10;
|
||||||
|
if errors > EMIT_ERROR_THRESHOLD && !*system.emergency_mode.read() {
|
||||||
|
log::warn!(
|
||||||
|
"Reached {EMIT_ERROR_THRESHOLD} emit errors, entering emergency mode"
|
||||||
|
);
|
||||||
|
*system.emergency_mode.write() = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
system.stats.total_errors.fetch_add(1, Ordering::SeqCst);
|
||||||
|
*system.stats.last_error_time.write() = Some(Instant::now());
|
||||||
|
log::warn!("Skipped emitting event due to payload serialization error for {event_name_str}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("No window found, skipping event emit.");
|
||||||
|
}
|
||||||
|
thread::sleep(Duration::from_millis(20));
|
||||||
|
}
|
||||||
|
Err(mpsc::RecvTimeoutError::Timeout) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Err(mpsc::RecvTimeoutError::Disconnected) => {
|
||||||
|
log::info!(
|
||||||
|
"Notification channel disconnected, exiting worker thread"
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!("Notification worker thread exiting");
|
||||||
|
})
|
||||||
|
.expect("Failed to start notification worker thread"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 发送事件到队列
|
||||||
|
fn send_event(&self, event: FrontendEvent) -> bool {
|
||||||
|
if *self.emergency_mode.read() {
|
||||||
|
if let FrontendEvent::NoticeMessage { ref status, .. } = event {
|
||||||
|
if status == "info" {
|
||||||
|
log::info!("Skipping info message in emergency mode");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(sender) = &self.sender {
|
||||||
|
match sender.send(event) {
|
||||||
|
Ok(_) => true,
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to send event to notification queue: {e:?}");
|
||||||
|
self.stats.total_errors.fetch_add(1, Ordering::SeqCst);
|
||||||
|
*self.stats.last_error_time.write() = Some(Instant::now());
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("Notification system not started, can't send event");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shutdown(&mut self) {
|
||||||
|
log::info!("NotificationSystem shutdown initiated");
|
||||||
|
self.is_running = false;
|
||||||
|
|
||||||
|
// 先关闭发送端,让接收端知道不会再有新消息
|
||||||
|
if let Some(sender) = self.sender.take() {
|
||||||
|
drop(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置超时避免无限等待
|
||||||
|
if let Some(handle) = self.worker_handle.take() {
|
||||||
|
match handle.join() {
|
||||||
|
Ok(_) => {
|
||||||
|
log::info!("NotificationSystem worker thread joined successfully");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("NotificationSystem worker thread join failed: {e:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!("NotificationSystem shutdown completed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Handle {
|
pub struct Handle {
|
||||||
pub app_handle: Arc<RwLock<Option<AppHandle>>>,
|
pub app_handle: Arc<RwLock<Option<AppHandle>>>,
|
||||||
pub is_exiting: Arc<RwLock<bool>>,
|
pub is_exiting: Arc<RwLock<bool>>,
|
||||||
pub core_process: Arc<RwLock<Option<CommandChild>>>,
|
startup_errors: Arc<RwLock<Vec<ErrorMessage>>>,
|
||||||
|
startup_completed: Arc<RwLock<bool>>,
|
||||||
|
notification_system: Arc<RwLock<Option<NotificationSystem>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Handle {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
app_handle: Arc::new(RwLock::new(None)),
|
||||||
|
is_exiting: Arc::new(RwLock::new(false)),
|
||||||
|
startup_errors: Arc::new(RwLock::new(Vec::new())),
|
||||||
|
startup_completed: Arc::new(RwLock::new(false)),
|
||||||
|
notification_system: Arc::new(RwLock::new(Some(NotificationSystem::new()))),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handle {
|
impl Handle {
|
||||||
pub fn global() -> &'static Handle {
|
pub fn global() -> &'static Handle {
|
||||||
static HANDLE: OnceCell<Handle> = OnceCell::new();
|
static HANDLE: OnceCell<Handle> = OnceCell::new();
|
||||||
|
HANDLE.get_or_init(Handle::default)
|
||||||
HANDLE.get_or_init(|| Handle {
|
|
||||||
app_handle: Arc::new(RwLock::new(None)),
|
|
||||||
is_exiting: Arc::new(RwLock::new(false)),
|
|
||||||
core_process: Arc::new(RwLock::new(None)),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, app_handle: &AppHandle) {
|
pub fn init(&self, app_handle: &AppHandle) {
|
||||||
let mut handle = self.app_handle.write();
|
{
|
||||||
*handle = Some(app_handle.clone());
|
let mut handle = self.app_handle.write();
|
||||||
|
*handle = Some(app_handle.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut system_opt = self.notification_system.write();
|
||||||
|
if let Some(system) = system_opt.as_mut() {
|
||||||
|
system.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn app_handle(&self) -> Option<AppHandle> {
|
pub fn app_handle(&self) -> Option<AppHandle> {
|
||||||
@@ -33,7 +295,7 @@ impl Handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window(&self) -> Option<WebviewWindow> {
|
pub fn get_window(&self) -> Option<WebviewWindow> {
|
||||||
let app_handle = self.app_handle().unwrap();
|
let app_handle = self.app_handle()?;
|
||||||
let window: Option<WebviewWindow> = app_handle.get_webview_window("main");
|
let window: Option<WebviewWindow> = app_handle.get_webview_window("main");
|
||||||
if window.is_none() {
|
if window.is_none() {
|
||||||
log::debug!(target:"app", "main window not found");
|
log::debug!(target:"app", "main window not found");
|
||||||
@@ -42,48 +304,213 @@ impl Handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_clash() {
|
pub fn refresh_clash() {
|
||||||
if let Some(window) = Self::global().get_window() {
|
let handle = Self::global();
|
||||||
log_err!(window.emit("verge://refresh-clash-config", "yes"));
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::RefreshClash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_verge() {
|
pub fn refresh_verge() {
|
||||||
if let Some(window) = Self::global().get_window() {
|
let handle = Self::global();
|
||||||
log_err!(window.emit("verge://refresh-verge-config", "yes"));
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::RefreshVerge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
pub fn notify_profile_changed(profile_id: String) {
|
||||||
pub fn refresh_profiles() {
|
let handle = Self::global();
|
||||||
if let Some(window) = Self::global().get_window() {
|
if handle.is_exiting() {
|
||||||
log_err!(window.emit("verge://refresh-profiles-config", "yes"));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::ProfileChanged {
|
||||||
|
current_profile_id: profile_id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log::warn!(
|
||||||
|
"Notification system not initialized when trying to send ProfileChanged event."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn notify_timer_updated(profile_index: String) {
|
||||||
|
let handle = Self::global();
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::TimerUpdated { profile_index });
|
||||||
|
} else {
|
||||||
|
log::warn!(
|
||||||
|
"Notification system not initialized when trying to send TimerUpdated event."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn notify_startup_completed() {
|
||||||
|
let handle = Self::global();
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::StartupCompleted);
|
||||||
|
} else {
|
||||||
|
log::warn!(
|
||||||
|
"Notification system not initialized when trying to send StartupCompleted event."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn notify_profile_update_started(uid: String) {
|
||||||
|
let handle = Self::global();
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::ProfileUpdateStarted { uid });
|
||||||
|
} else {
|
||||||
|
log::warn!("Notification system not initialized when trying to send ProfileUpdateStarted event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn notify_profile_update_completed(uid: String) {
|
||||||
|
let handle = Self::global();
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::ProfileUpdateCompleted { uid });
|
||||||
|
} else {
|
||||||
|
log::warn!("Notification system not initialized when trying to send ProfileUpdateCompleted event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 通知前端显示消息队列
|
||||||
pub fn notice_message<S: Into<String>, M: Into<String>>(status: S, msg: M) {
|
pub fn notice_message<S: Into<String>, M: Into<String>>(status: S, msg: M) {
|
||||||
if let Some(window) = Self::global().get_window() {
|
let handle = Self::global();
|
||||||
log_err!(window.emit("verge://notice-message", (status.into(), msg.into())));
|
let status_str = status.into();
|
||||||
|
let msg_str = msg.into();
|
||||||
|
|
||||||
|
if !*handle.startup_completed.read() {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Frontend,
|
||||||
|
true,
|
||||||
|
"启动过程中发现错误,加入消息队列: {} - {}",
|
||||||
|
status_str,
|
||||||
|
msg_str
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut errors = handle.startup_errors.write();
|
||||||
|
errors.push(ErrorMessage {
|
||||||
|
status: status_str,
|
||||||
|
message: msg_str,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
system.send_event(FrontendEvent::NoticeMessage {
|
||||||
|
status: status_str,
|
||||||
|
message: msg_str,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mark_startup_completed(&self) {
|
||||||
|
{
|
||||||
|
let mut completed = self.startup_completed.write();
|
||||||
|
*completed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.send_startup_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 发送启动时累积的所有错误消息
|
||||||
|
fn send_startup_errors(&self) {
|
||||||
|
let errors = {
|
||||||
|
let mut errors = self.startup_errors.write();
|
||||||
|
std::mem::take(&mut *errors)
|
||||||
|
};
|
||||||
|
|
||||||
|
if errors.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Frontend,
|
||||||
|
true,
|
||||||
|
"发送{}条启动时累积的错误消息",
|
||||||
|
errors.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 启动单独线程处理启动错误,避免阻塞主线程
|
||||||
|
let thread_result = thread::Builder::new()
|
||||||
|
.name("startup-errors-sender".into())
|
||||||
|
.spawn(move || {
|
||||||
|
thread::sleep(Duration::from_secs(2));
|
||||||
|
|
||||||
|
let handle = Handle::global();
|
||||||
|
if handle.is_exiting() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let system_opt = handle.notification_system.read();
|
||||||
|
if let Some(system) = system_opt.as_ref() {
|
||||||
|
for error in errors {
|
||||||
|
if handle.is_exiting() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
system.send_event(FrontendEvent::NoticeMessage {
|
||||||
|
status: error.status,
|
||||||
|
message: error.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
thread::sleep(Duration::from_millis(300));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Err(e) = thread_result {
|
||||||
|
log::error!("Failed to spawn startup errors thread: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_is_exiting(&self) {
|
pub fn set_is_exiting(&self) {
|
||||||
let mut is_exiting = self.is_exiting.write();
|
let mut is_exiting = self.is_exiting.write();
|
||||||
*is_exiting = true;
|
*is_exiting = true;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_core_process(&self, process: CommandChild) {
|
let mut system_opt = self.notification_system.write();
|
||||||
let mut core_process = self.core_process.write();
|
if let Some(system) = system_opt.as_mut() {
|
||||||
*core_process = Some(process);
|
system.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_core_process(&self) -> Option<CommandChild> {
|
|
||||||
let mut core_process = self.core_process.write();
|
|
||||||
core_process.take()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 检查是否有运行中的核心进程
|
|
||||||
pub fn has_core_process(&self) -> bool {
|
|
||||||
self.core_process.read().is_some()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_exiting(&self) -> bool {
|
pub fn is_exiting(&self) -> bool {
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
use crate::core::handle;
|
use crate::utils::notification::{notify_event, NotificationEvent};
|
||||||
use crate::{config::Config, feat, log_err};
|
use crate::{
|
||||||
use crate::utils::resolve;
|
config::Config, core::handle, feat, logging, logging_error,
|
||||||
|
module::lightweight::entry_lightweight_mode, utils::logging::Type,
|
||||||
|
};
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, ShortcutState};
|
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, ShortcutState};
|
||||||
use tauri::async_runtime;
|
|
||||||
|
|
||||||
pub struct Hotkey {
|
pub struct Hotkey {
|
||||||
current: Arc<Mutex<Vec<String>>>, // 保存当前的热键设置
|
current: Arc<Mutex<Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hotkey {
|
impl Hotkey {
|
||||||
@@ -26,19 +27,26 @@ impl Hotkey {
|
|||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
let enable_global_hotkey = verge.latest().enable_global_hotkey.unwrap_or(true);
|
let enable_global_hotkey = verge.latest().enable_global_hotkey.unwrap_or(true);
|
||||||
|
|
||||||
println!("Initializing hotkeys, global hotkey enabled: {}", enable_global_hotkey);
|
logging!(
|
||||||
log::info!(target: "app", "Initializing hotkeys, global hotkey enabled: {}", enable_global_hotkey);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Initializing global hotkeys: {}",
|
||||||
|
enable_global_hotkey
|
||||||
|
);
|
||||||
|
|
||||||
// 如果全局热键被禁用,则不注册热键
|
|
||||||
if !enable_global_hotkey {
|
if !enable_global_hotkey {
|
||||||
println!("Global hotkey is disabled, skipping registration");
|
|
||||||
log::info!(target: "app", "Global hotkey is disabled, skipping registration");
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(hotkeys) = verge.latest().hotkeys.as_ref() {
|
if let Some(hotkeys) = verge.latest().hotkeys.as_ref() {
|
||||||
println!("Found {} hotkeys to register", hotkeys.len());
|
logging!(
|
||||||
log::info!(target: "app", "Found {} hotkeys to register", hotkeys.len());
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Has {} hotkeys need to register",
|
||||||
|
hotkeys.len()
|
||||||
|
);
|
||||||
|
|
||||||
for hotkey in hotkeys.iter() {
|
for hotkey in hotkeys.iter() {
|
||||||
let mut iter = hotkey.split(',');
|
let mut iter = hotkey.split(',');
|
||||||
@@ -47,28 +55,51 @@ impl Hotkey {
|
|||||||
|
|
||||||
match (key, func) {
|
match (key, func) {
|
||||||
(Some(key), Some(func)) => {
|
(Some(key), Some(func)) => {
|
||||||
println!("Registering hotkey: {} -> {}", key, func);
|
logging!(
|
||||||
log::info!(target: "app", "Registering hotkey: {} -> {}", key, func);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Registering hotkey: {} -> {}",
|
||||||
|
key,
|
||||||
|
func
|
||||||
|
);
|
||||||
if let Err(e) = self.register(key, func) {
|
if let Err(e) = self.register(key, func) {
|
||||||
println!("Failed to register hotkey {} -> {}: {:?}", key, func, e);
|
logging!(
|
||||||
log::error!(target: "app", "Failed to register hotkey {} -> {}: {:?}", key, func, e);
|
error,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Failed to register hotkey {} -> {}: {:?}",
|
||||||
|
key,
|
||||||
|
func,
|
||||||
|
e
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
println!("Successfully registered hotkey {} -> {}", key, func);
|
logging!(
|
||||||
log::info!(target: "app", "Successfully registered hotkey {} -> {}", key, func);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
"Successfully registered hotkey {} -> {}",
|
||||||
|
key,
|
||||||
|
func
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let key = key.unwrap_or("None");
|
let key = key.unwrap_or("None");
|
||||||
let func = func.unwrap_or("None");
|
let func = func.unwrap_or("None");
|
||||||
println!("Invalid hotkey configuration: `{key}`:`{func}`");
|
logging!(
|
||||||
log::error!(target: "app", "Invalid hotkey configuration: `{key}`:`{func}`");
|
error,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Invalid hotkey configuration: `{}`:`{}`",
|
||||||
|
key,
|
||||||
|
func
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.current.lock().clone_from(hotkeys);
|
self.current.lock().clone_from(hotkeys);
|
||||||
} else {
|
} else {
|
||||||
println!("No hotkeys configured");
|
logging!(debug, Type::Hotkey, "No hotkeys configured");
|
||||||
log::info!(target: "app", "No hotkeys configured");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -85,67 +116,121 @@ impl Hotkey {
|
|||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
let manager = app_handle.global_shortcut();
|
let manager = app_handle.global_shortcut();
|
||||||
|
|
||||||
println!("Attempting to register hotkey: {} for function: {}", hotkey, func);
|
logging!(
|
||||||
log::info!(target: "app", "Attempting to register hotkey: {} for function: {}", hotkey, func);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
"Attempting to register hotkey: {} for function: {}",
|
||||||
|
hotkey,
|
||||||
|
func
|
||||||
|
);
|
||||||
|
|
||||||
if manager.is_registered(hotkey) {
|
if manager.is_registered(hotkey) {
|
||||||
println!("Hotkey {} was already registered, unregistering first", hotkey);
|
logging!(
|
||||||
log::info!(target: "app", "Hotkey {} was already registered, unregistering first", hotkey);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
"Hotkey {} was already registered, unregistering first",
|
||||||
|
hotkey
|
||||||
|
);
|
||||||
manager.unregister(hotkey)?;
|
manager.unregister(hotkey)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let f = match func.trim() {
|
let app_handle_clone = app_handle.clone();
|
||||||
|
let f: Box<dyn Fn() + Send + Sync> = match func.trim() {
|
||||||
"open_or_close_dashboard" => {
|
"open_or_close_dashboard" => {
|
||||||
println!("Registering open_or_close_dashboard function");
|
let app_handle = app_handle_clone.clone();
|
||||||
log::info!(target: "app", "Registering open_or_close_dashboard function");
|
Box::new(move || {
|
||||||
|| {
|
logging!(
|
||||||
println!("=== Hotkey Dashboard Window Operation Start ===");
|
debug,
|
||||||
log::info!(target: "app", "=== Hotkey Dashboard Window Operation Start ===");
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"=== Hotkey Dashboard Window Operation Start ==="
|
||||||
|
);
|
||||||
|
|
||||||
// 使用 spawn_blocking 来确保在正确的线程上执行
|
logging!(
|
||||||
async_runtime::spawn_blocking(|| {
|
info,
|
||||||
println!("Toggle dashboard window visibility");
|
Type::Hotkey,
|
||||||
log::info!(target: "app", "Toggle dashboard window visibility");
|
true,
|
||||||
|
"Using unified WindowManager for hotkey operation (bypass debounce)"
|
||||||
|
);
|
||||||
|
|
||||||
// 检查窗口是否存在
|
crate::feat::open_or_close_dashboard_hotkey();
|
||||||
if let Some(window) = handle::Handle::global().get_window() {
|
|
||||||
// 如果窗口可见,则隐藏它
|
|
||||||
if window.is_visible().unwrap_or(false) {
|
|
||||||
println!("Window is visible, hiding it");
|
|
||||||
log::info!(target: "app", "Window is visible, hiding it");
|
|
||||||
let _ = window.hide();
|
|
||||||
} else {
|
|
||||||
// 如果窗口不可见,则显示它
|
|
||||||
println!("Window is hidden, showing it");
|
|
||||||
log::info!(target: "app", "Window is hidden, showing it");
|
|
||||||
if window.is_minimized().unwrap_or(false) {
|
|
||||||
let _ = window.unminimize();
|
|
||||||
}
|
|
||||||
let _ = window.show();
|
|
||||||
let _ = window.set_focus();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 如果窗口不存在,创建一个新窗口
|
|
||||||
println!("Window does not exist, creating a new one");
|
|
||||||
log::info!(target: "app", "Window does not exist, creating a new one");
|
|
||||||
resolve::create_window();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
println!("=== Hotkey Dashboard Window Operation End ===");
|
|
||||||
log::info!(target: "app", "=== Hotkey Dashboard Window Operation End ===");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"clash_mode_rule" => || feat::change_clash_mode("rule".into()),
|
|
||||||
"clash_mode_global" => || feat::change_clash_mode("global".into()),
|
|
||||||
"clash_mode_direct" => || feat::change_clash_mode("direct".into()),
|
|
||||||
"toggle_system_proxy" => || feat::toggle_system_proxy(),
|
|
||||||
"toggle_tun_mode" => || feat::toggle_tun_mode(None),
|
|
||||||
"quit" => || feat::quit(Some(0)),
|
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
"=== Hotkey Dashboard Window Operation End ==="
|
||||||
|
);
|
||||||
|
notify_event(&app_handle, NotificationEvent::DashboardToggled);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"clash_mode_rule" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::change_clash_mode("rule".into());
|
||||||
|
notify_event(
|
||||||
|
&app_handle,
|
||||||
|
NotificationEvent::ClashModeChanged { mode: "Rule" },
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"clash_mode_global" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::change_clash_mode("global".into());
|
||||||
|
notify_event(
|
||||||
|
&app_handle,
|
||||||
|
NotificationEvent::ClashModeChanged { mode: "Global" },
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"clash_mode_direct" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::change_clash_mode("direct".into());
|
||||||
|
notify_event(
|
||||||
|
&app_handle,
|
||||||
|
NotificationEvent::ClashModeChanged { mode: "Direct" },
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"toggle_system_proxy" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::toggle_system_proxy();
|
||||||
|
notify_event(&app_handle, NotificationEvent::SystemProxyToggled);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"toggle_tun_mode" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::toggle_tun_mode(None);
|
||||||
|
notify_event(&app_handle, NotificationEvent::TunModeToggled);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"entry_lightweight_mode" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
entry_lightweight_mode();
|
||||||
|
notify_event(&app_handle, NotificationEvent::LightweightModeEntered);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"quit" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::quit();
|
||||||
|
notify_event(&app_handle, NotificationEvent::AppQuit);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
"hide" => {
|
||||||
|
let app_handle = app_handle_clone.clone();
|
||||||
|
Box::new(move || {
|
||||||
|
feat::hide();
|
||||||
|
notify_event(&app_handle, NotificationEvent::AppHidden);
|
||||||
|
})
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("Invalid function: {}", func);
|
logging!(error, Type::Hotkey, "Invalid function: {}", func);
|
||||||
log::error!(target: "app", "Invalid function: {}", func);
|
|
||||||
bail!("invalid function \"{func}\"");
|
bail!("invalid function \"{func}\"");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -154,33 +239,29 @@ impl Hotkey {
|
|||||||
|
|
||||||
let _ = manager.on_shortcut(hotkey, move |app_handle, hotkey, event| {
|
let _ = manager.on_shortcut(hotkey, move |app_handle, hotkey, event| {
|
||||||
if event.state == ShortcutState::Pressed {
|
if event.state == ShortcutState::Pressed {
|
||||||
println!("Hotkey pressed: {:?}", hotkey);
|
logging!(debug, Type::Hotkey, "Hotkey pressed: {:?}", hotkey);
|
||||||
log::info!(target: "app", "Hotkey pressed: {:?}", hotkey);
|
|
||||||
|
|
||||||
if hotkey.key == Code::KeyQ && is_quit {
|
if hotkey.key == Code::KeyQ && is_quit {
|
||||||
if let Some(window) = app_handle.get_webview_window("main") {
|
if let Some(window) = app_handle.get_webview_window("main") {
|
||||||
if window.is_focused().unwrap_or(false) {
|
if window.is_focused().unwrap_or(false) {
|
||||||
println!("Executing quit function");
|
logging!(debug, Type::Hotkey, "Executing quit function");
|
||||||
log::info!(target: "app", "Executing quit function");
|
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 直接执行函数,不做任何状态检查
|
logging!(debug, Type::Hotkey, "Executing function directly");
|
||||||
println!("Executing function directly");
|
|
||||||
log::info!(target: "app", "Executing function directly");
|
|
||||||
|
|
||||||
// 获取轻量模式状态和全局热键状态
|
let is_enable_global_hotkey = Config::verge()
|
||||||
let is_lite_mode = Config::verge().latest().enable_lite_mode.unwrap_or(false);
|
.latest()
|
||||||
let is_enable_global_hotkey = Config::verge().latest().enable_global_hotkey.unwrap_or(true);
|
.enable_global_hotkey
|
||||||
|
.unwrap_or(true);
|
||||||
|
|
||||||
// 在轻量模式下或配置了全局热键时,始终执行热键功能
|
if is_enable_global_hotkey {
|
||||||
if is_lite_mode || is_enable_global_hotkey {
|
|
||||||
f();
|
f();
|
||||||
} else if let Some(window) = app_handle.get_webview_window("main") {
|
} else {
|
||||||
// 非轻量模式且未启用全局热键时,只在窗口可见且有焦点的情况下响应热键
|
use crate::utils::window_manager::WindowManager;
|
||||||
let is_visible = window.is_visible().unwrap_or(false);
|
let is_visible = WindowManager::is_main_window_visible();
|
||||||
let is_focused = window.is_focused().unwrap_or(false);
|
let is_focused = WindowManager::is_main_window_focused();
|
||||||
|
|
||||||
if is_focused && is_visible {
|
if is_focused && is_visible {
|
||||||
f();
|
f();
|
||||||
@@ -190,8 +271,13 @@ impl Hotkey {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
println!("Successfully registered hotkey {} for {}", hotkey, func);
|
logging!(
|
||||||
log::info!(target: "app", "Successfully registered hotkey {} for {}", hotkey, func);
|
debug,
|
||||||
|
Type::Hotkey,
|
||||||
|
"Successfully registered hotkey {} for {}",
|
||||||
|
hotkey,
|
||||||
|
func
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +285,7 @@ impl Hotkey {
|
|||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
let manager = app_handle.global_shortcut();
|
let manager = app_handle.global_shortcut();
|
||||||
manager.unregister(hotkey)?;
|
manager.unregister(hotkey)?;
|
||||||
log::debug!(target: "app", "unregister hotkey {hotkey}");
|
logging!(debug, Type::Hotkey, "Unregister hotkey {}", hotkey);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +301,7 @@ impl Hotkey {
|
|||||||
});
|
});
|
||||||
|
|
||||||
add.iter().for_each(|(key, func)| {
|
add.iter().for_each(|(key, func)| {
|
||||||
log_err!(self.register(key, func));
|
logging_error!(Type::Hotkey, self.register(key, func));
|
||||||
});
|
});
|
||||||
|
|
||||||
*current = new_hotkeys;
|
*current = new_hotkeys;
|
||||||
@@ -230,9 +316,9 @@ impl Hotkey {
|
|||||||
let func = iter.next();
|
let func = iter.next();
|
||||||
let key = iter.next();
|
let key = iter.next();
|
||||||
|
|
||||||
if func.is_some() && key.is_some() {
|
if let (Some(func), Some(key)) = (func, key) {
|
||||||
let func = func.unwrap().trim();
|
let func = func.trim();
|
||||||
let key = key.unwrap().trim();
|
let key = key.trim();
|
||||||
map.insert(key, func);
|
map.insert(key, func);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -272,7 +358,13 @@ impl Drop for Hotkey {
|
|||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
if let Err(e) = app_handle.global_shortcut().unregister_all() {
|
if let Err(e) = app_handle.global_shortcut().unregister_all() {
|
||||||
log::error!(target:"app", "Error unregistering all hotkeys: {:?}", e);
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Hotkey,
|
||||||
|
true,
|
||||||
|
"Error unregistering all hotkeys: {:?}",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
|
pub mod async_proxy_query;
|
||||||
pub mod backup;
|
pub mod backup;
|
||||||
#[allow(clippy::module_inception)]
|
#[allow(clippy::module_inception)]
|
||||||
mod core;
|
mod core;
|
||||||
|
pub mod event_driven_proxy;
|
||||||
pub mod handle;
|
pub mod handle;
|
||||||
pub mod hotkey;
|
pub mod hotkey;
|
||||||
pub mod service;
|
pub mod service;
|
||||||
|
pub mod service_ipc;
|
||||||
pub mod sysopt;
|
pub mod sysopt;
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
pub mod tray;
|
pub mod tray;
|
||||||
pub mod win_uwp;
|
pub mod win_uwp;
|
||||||
|
|
||||||
pub use self::core::*;
|
pub use self::{core::*, event_driven_proxy::EventDrivenProxyManager, timer::Timer};
|
||||||
|
|||||||
340
src-tauri/src/core/service_ipc.rs
Normal file
@@ -0,0 +1,340 @@
|
|||||||
|
use crate::{logging, utils::logging::Type};
|
||||||
|
use anyhow::{bail, Context, Result};
|
||||||
|
use hmac::{Hmac, Mac};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
|
const IPC_SOCKET_NAME: &str = if cfg!(windows) {
|
||||||
|
r"\\.\pipe\clash-verge-service"
|
||||||
|
} else {
|
||||||
|
"/tmp/clash-verge-service.sock"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 定义命令类型
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub enum IpcCommand {
|
||||||
|
GetClash,
|
||||||
|
GetVersion,
|
||||||
|
StartClash,
|
||||||
|
StopClash,
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPC消息格式
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct IpcRequest {
|
||||||
|
pub id: String,
|
||||||
|
pub timestamp: u64,
|
||||||
|
pub command: IpcCommand,
|
||||||
|
pub payload: serde_json::Value,
|
||||||
|
pub signature: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct IpcResponse {
|
||||||
|
pub id: String,
|
||||||
|
pub success: bool,
|
||||||
|
pub data: Option<serde_json::Value>,
|
||||||
|
pub error: Option<String>,
|
||||||
|
pub signature: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 密钥派生函数
|
||||||
|
fn derive_secret_key() -> Vec<u8> {
|
||||||
|
// to do
|
||||||
|
// 从系统安全存储中获取或从程序安装时生成的密钥文件中读取
|
||||||
|
let unique_app_id = "clash-verge-app-secret-fuck-me-until-daylight";
|
||||||
|
let mut hasher = Sha256::new();
|
||||||
|
hasher.update(unique_app_id.as_bytes());
|
||||||
|
hasher.finalize().to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建带签名的请求
|
||||||
|
pub fn create_signed_request(
|
||||||
|
command: IpcCommand,
|
||||||
|
payload: serde_json::Value,
|
||||||
|
) -> Result<IpcRequest> {
|
||||||
|
let id = nanoid::nanoid!(32);
|
||||||
|
let timestamp = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs();
|
||||||
|
|
||||||
|
let unsigned_request = IpcRequest {
|
||||||
|
id: id.clone(),
|
||||||
|
timestamp,
|
||||||
|
command: command.clone(),
|
||||||
|
payload: payload.clone(),
|
||||||
|
signature: String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let unsigned_json = serde_json::to_string(&unsigned_request)?;
|
||||||
|
let signature = sign_message(&unsigned_json)?;
|
||||||
|
|
||||||
|
Ok(IpcRequest {
|
||||||
|
id,
|
||||||
|
timestamp,
|
||||||
|
command,
|
||||||
|
payload,
|
||||||
|
signature,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 签名消息
|
||||||
|
fn sign_message(message: &str) -> Result<String> {
|
||||||
|
type HmacSha256 = Hmac<Sha256>;
|
||||||
|
|
||||||
|
let secret_key = derive_secret_key();
|
||||||
|
let mut mac = HmacSha256::new_from_slice(&secret_key).context("HMAC初始化失败")?;
|
||||||
|
|
||||||
|
mac.update(message.as_bytes());
|
||||||
|
let result = mac.finalize();
|
||||||
|
let signature = hex::encode(result.into_bytes());
|
||||||
|
|
||||||
|
Ok(signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证响应签名
|
||||||
|
pub fn verify_response_signature(response: &IpcResponse) -> Result<bool> {
|
||||||
|
let verification_response = IpcResponse {
|
||||||
|
id: response.id.clone(),
|
||||||
|
success: response.success,
|
||||||
|
data: response.data.clone(),
|
||||||
|
error: response.error.clone(),
|
||||||
|
signature: String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = serde_json::to_string(&verification_response)?;
|
||||||
|
let expected_signature = sign_message(&message)?;
|
||||||
|
|
||||||
|
Ok(expected_signature == response.signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPC连接管理-win
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
pub async fn send_ipc_request(
|
||||||
|
command: IpcCommand,
|
||||||
|
payload: serde_json::Value,
|
||||||
|
) -> Result<IpcResponse> {
|
||||||
|
use std::{
|
||||||
|
ffi::CString,
|
||||||
|
fs::File,
|
||||||
|
io::{Read, Write},
|
||||||
|
os::windows::io::{FromRawHandle, RawHandle},
|
||||||
|
ptr,
|
||||||
|
};
|
||||||
|
use winapi::um::{
|
||||||
|
fileapi::{CreateFileA, OPEN_EXISTING},
|
||||||
|
handleapi::INVALID_HANDLE_VALUE,
|
||||||
|
winnt::{FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_READ, GENERIC_WRITE},
|
||||||
|
};
|
||||||
|
|
||||||
|
logging!(info, Type::Service, true, "正在连接服务 (Windows)...");
|
||||||
|
|
||||||
|
let command_type = format!("{:?}", command);
|
||||||
|
|
||||||
|
let request = match create_signed_request(command, payload) {
|
||||||
|
Ok(req) => req,
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "创建签名请求失败: {}", e);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let request_json = serde_json::to_string(&request)?;
|
||||||
|
|
||||||
|
let result = tokio::task::spawn_blocking(move || -> Result<IpcResponse> {
|
||||||
|
let c_pipe_name = match CString::new(IPC_SOCKET_NAME) {
|
||||||
|
Ok(name) => name,
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "创建CString失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("创建CString失败: {}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let handle = unsafe {
|
||||||
|
CreateFileA(
|
||||||
|
c_pipe_name.as_ptr(),
|
||||||
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
ptr::null_mut(),
|
||||||
|
OPEN_EXISTING,
|
||||||
|
0,
|
||||||
|
ptr::null_mut(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if handle == INVALID_HANDLE_VALUE {
|
||||||
|
let error = std::io::Error::last_os_error();
|
||||||
|
logging!(
|
||||||
|
error,
|
||||||
|
Type::Service,
|
||||||
|
true,
|
||||||
|
"连接到服务命名管道失败: {}",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
return Err(anyhow::anyhow!("无法连接到服务命名管道: {}", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut pipe = unsafe { File::from_raw_handle(handle as RawHandle) };
|
||||||
|
logging!(info, Type::Service, true, "服务连接成功 (Windows)");
|
||||||
|
|
||||||
|
let request_bytes = request_json.as_bytes();
|
||||||
|
let len_bytes = (request_bytes.len() as u32).to_be_bytes();
|
||||||
|
|
||||||
|
if let Err(e) = pipe.write_all(&len_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "写入请求长度失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("写入请求长度失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(e) = pipe.write_all(request_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "写入请求内容失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("写入请求内容失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(e) = pipe.flush() {
|
||||||
|
logging!(error, Type::Service, true, "刷新管道失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("刷新管道失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut response_len_bytes = [0u8; 4];
|
||||||
|
if let Err(e) = pipe.read_exact(&mut response_len_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "读取响应长度失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("读取响应长度失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let response_len = u32::from_be_bytes(response_len_bytes) as usize;
|
||||||
|
|
||||||
|
let mut response_bytes = vec![0u8; response_len];
|
||||||
|
if let Err(e) = pipe.read_exact(&mut response_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "读取响应内容失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("读取响应内容失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let response: IpcResponse = match serde_json::from_slice::<IpcResponse>(&response_bytes) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "服务响应解析失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("解析响应失败: {}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match verify_response_signature(&response) {
|
||||||
|
Ok(valid) => {
|
||||||
|
if !valid {
|
||||||
|
logging!(error, Type::Service, true, "服务响应签名验证失败");
|
||||||
|
bail!("服务响应签名验证失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "验证响应签名时出错: {}", e);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Service,
|
||||||
|
true,
|
||||||
|
"IPC请求完成: 命令={}, 成功={}",
|
||||||
|
command_type,
|
||||||
|
response.success
|
||||||
|
);
|
||||||
|
Ok(response)
|
||||||
|
})
|
||||||
|
.await??;
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPC连接管理-unix
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
pub async fn send_ipc_request(
|
||||||
|
command: IpcCommand,
|
||||||
|
payload: serde_json::Value,
|
||||||
|
) -> Result<IpcResponse> {
|
||||||
|
use std::os::unix::net::UnixStream;
|
||||||
|
|
||||||
|
logging!(info, Type::Service, true, "正在连接服务 (Unix)...");
|
||||||
|
|
||||||
|
let command_type = format!("{command:?}");
|
||||||
|
|
||||||
|
let request = match create_signed_request(command, payload) {
|
||||||
|
Ok(req) => req,
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "创建签名请求失败: {}", e);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let request_json = serde_json::to_string(&request)?;
|
||||||
|
|
||||||
|
let mut stream = match UnixStream::connect(IPC_SOCKET_NAME) {
|
||||||
|
Ok(s) => {
|
||||||
|
logging!(info, Type::Service, true, "服务连接成功 (Unix)");
|
||||||
|
s
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "连接到Unix套接字失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("无法连接到服务Unix套接字: {}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let request_bytes = request_json.as_bytes();
|
||||||
|
let len_bytes = (request_bytes.len() as u32).to_be_bytes();
|
||||||
|
|
||||||
|
if let Err(e) = std::io::Write::write_all(&mut stream, &len_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "写入请求长度失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("写入请求长度失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(e) = std::io::Write::write_all(&mut stream, request_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "写入请求内容失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("写入请求内容失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut response_len_bytes = [0u8; 4];
|
||||||
|
if let Err(e) = std::io::Read::read_exact(&mut stream, &mut response_len_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "读取响应长度失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("读取响应长度失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let response_len = u32::from_be_bytes(response_len_bytes) as usize;
|
||||||
|
|
||||||
|
let mut response_bytes = vec![0u8; response_len];
|
||||||
|
if let Err(e) = std::io::Read::read_exact(&mut stream, &mut response_bytes) {
|
||||||
|
logging!(error, Type::Service, true, "读取响应内容失败: {}", e);
|
||||||
|
return Err(anyhow::anyhow!("读取响应内容失败: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let response: IpcResponse = match serde_json::from_slice::<IpcResponse>(&response_bytes) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "服务响应解析失败: {}", e,);
|
||||||
|
return Err(anyhow::anyhow!("解析响应失败: {}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match verify_response_signature(&response) {
|
||||||
|
Ok(valid) => {
|
||||||
|
if !valid {
|
||||||
|
logging!(error, Type::Service, true, "服务响应签名验证失败");
|
||||||
|
bail!("服务响应签名验证失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logging!(error, Type::Service, true, "验证响应签名时出错: {}", e);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Service,
|
||||||
|
true,
|
||||||
|
"IPC请求完成: 命令={}, 成功={}",
|
||||||
|
command_type,
|
||||||
|
response.success
|
||||||
|
);
|
||||||
|
Ok(response)
|
||||||
|
}
|
||||||
@@ -1,24 +1,22 @@
|
|||||||
use crate::core::handle::Handle;
|
#[cfg(target_os = "windows")]
|
||||||
|
use crate::utils::autostart as startup_shortcut;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, IVerge},
|
config::{Config, IVerge},
|
||||||
log_err,
|
core::{handle::Handle, EventDrivenProxyManager},
|
||||||
|
logging, logging_error,
|
||||||
|
utils::logging::Type,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
use sysproxy::{Autoproxy, Sysproxy};
|
use sysproxy::{Autoproxy, Sysproxy};
|
||||||
use tauri::async_runtime::Mutex as TokioMutex;
|
use tauri::async_runtime::Mutex as TokioMutex;
|
||||||
use tauri_plugin_autostart::ManagerExt;
|
use tauri_plugin_autostart::ManagerExt;
|
||||||
use tokio::time::{sleep, Duration};
|
|
||||||
|
|
||||||
pub struct Sysopt {
|
pub struct Sysopt {
|
||||||
update_sysproxy: Arc<TokioMutex<bool>>,
|
update_sysproxy: Arc<TokioMutex<bool>>,
|
||||||
reset_sysproxy: Arc<TokioMutex<bool>>,
|
reset_sysproxy: Arc<TokioMutex<bool>>,
|
||||||
/// helps to auto launch the app
|
|
||||||
auto_launch: Arc<Mutex<bool>>,
|
|
||||||
/// record whether the guard async is running or not
|
|
||||||
guard_state: Arc<Mutex<bool>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
@@ -45,7 +43,7 @@ fn get_bypass() -> String {
|
|||||||
if custom_bypass.is_empty() {
|
if custom_bypass.is_empty() {
|
||||||
DEFAULT_BYPASS.to_string()
|
DEFAULT_BYPASS.to_string()
|
||||||
} else if use_default {
|
} else if use_default {
|
||||||
format!("{},{}", DEFAULT_BYPASS, custom_bypass)
|
format!("{DEFAULT_BYPASS},{custom_bypass}")
|
||||||
} else {
|
} else {
|
||||||
custom_bypass
|
custom_bypass
|
||||||
}
|
}
|
||||||
@@ -57,13 +55,15 @@ impl Sysopt {
|
|||||||
SYSOPT.get_or_init(|| Sysopt {
|
SYSOPT.get_or_init(|| Sysopt {
|
||||||
update_sysproxy: Arc::new(TokioMutex::new(false)),
|
update_sysproxy: Arc::new(TokioMutex::new(false)),
|
||||||
reset_sysproxy: Arc::new(TokioMutex::new(false)),
|
reset_sysproxy: Arc::new(TokioMutex::new(false)),
|
||||||
auto_launch: Arc::new(Mutex::new(false)),
|
|
||||||
guard_state: Arc::new(false.into()),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_guard_sysproxy(&self) -> Result<()> {
|
pub fn init_guard_sysproxy(&self) -> Result<()> {
|
||||||
self.guard_proxy();
|
// 使用事件驱动代理管理器
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_app_started();
|
||||||
|
|
||||||
|
log::info!(target: "app", "已启用事件驱动代理守卫");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,12 +77,16 @@ impl Sysopt {
|
|||||||
.unwrap_or(Config::clash().data().get_mixed_port());
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
let pac_port = IVerge::get_singleton_port();
|
let pac_port = IVerge::get_singleton_port();
|
||||||
|
|
||||||
let (sys_enable, pac_enable) = {
|
let (sys_enable, pac_enable, proxy_host) = {
|
||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
let verge = verge.latest();
|
let verge = verge.latest();
|
||||||
(
|
(
|
||||||
verge.enable_system_proxy.unwrap_or(false),
|
verge.enable_system_proxy.unwrap_or(false),
|
||||||
verge.proxy_auto_config.unwrap_or(false),
|
verge.proxy_auto_config.unwrap_or(false),
|
||||||
|
verge
|
||||||
|
.proxy_host
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| String::from("127.0.0.1")),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,18 +94,20 @@ impl Sysopt {
|
|||||||
{
|
{
|
||||||
let mut sys = Sysproxy {
|
let mut sys = Sysproxy {
|
||||||
enable: false,
|
enable: false,
|
||||||
host: String::from("127.0.0.1"),
|
host: proxy_host.clone(),
|
||||||
port,
|
port,
|
||||||
bypass: get_bypass(),
|
bypass: get_bypass(),
|
||||||
};
|
};
|
||||||
let mut auto = Autoproxy {
|
let mut auto = Autoproxy {
|
||||||
enable: false,
|
enable: false,
|
||||||
url: format!("http://127.0.0.1:{pac_port}/commands/pac"),
|
url: format!("http://{proxy_host}:{pac_port}/commands/pac"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !sys_enable {
|
if !sys_enable {
|
||||||
sys.set_system_proxy()?;
|
sys.set_system_proxy()?;
|
||||||
auto.set_auto_proxy()?;
|
auto.set_auto_proxy()?;
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_config_changed();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +116,8 @@ impl Sysopt {
|
|||||||
auto.enable = true;
|
auto.enable = true;
|
||||||
sys.set_system_proxy()?;
|
sys.set_system_proxy()?;
|
||||||
auto.set_auto_proxy()?;
|
auto.set_auto_proxy()?;
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_config_changed();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,16 +126,20 @@ impl Sysopt {
|
|||||||
sys.enable = true;
|
sys.enable = true;
|
||||||
auto.set_auto_proxy()?;
|
auto.set_auto_proxy()?;
|
||||||
sys.set_system_proxy()?;
|
sys.set_system_proxy()?;
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_config_changed();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
if !sys_enable {
|
if !sys_enable {
|
||||||
return self.reset_sysproxy().await;
|
let result = self.reset_sysproxy().await;
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_config_changed();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
use crate::core::handle::Handle;
|
use crate::{core::handle::Handle, utils::dirs};
|
||||||
use crate::utils::dirs;
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use tauri_plugin_shell::ShellExt;
|
use tauri_plugin_shell::ShellExt;
|
||||||
|
|
||||||
@@ -141,7 +153,7 @@ impl Sysopt {
|
|||||||
|
|
||||||
let shell = app_handle.shell();
|
let shell = app_handle.shell();
|
||||||
let output = if pac_enable {
|
let output = if pac_enable {
|
||||||
let address = format!("http://{}:{}/commands/pac", "127.0.0.1", pac_port);
|
let address = format!("http://{}:{}/commands/pac", proxy_host, pac_port);
|
||||||
let output = shell
|
let output = shell
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["pac", address.as_str()])
|
.args(["pac", address.as_str()])
|
||||||
@@ -150,7 +162,7 @@ impl Sysopt {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
output
|
output
|
||||||
} else {
|
} else {
|
||||||
let address = format!("{}:{}", "127.0.0.1", port);
|
let address = format!("{}:{}", proxy_host, port);
|
||||||
let bypass = get_bypass();
|
let bypass = get_bypass();
|
||||||
let output = shell
|
let output = shell
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
@@ -165,6 +177,8 @@ impl Sysopt {
|
|||||||
bail!("sysproxy exe run failed");
|
bail!("sysproxy exe run failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let proxy_manager = EventDrivenProxyManager::global();
|
||||||
|
proxy_manager.notify_config_changed();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -176,7 +190,16 @@ impl Sysopt {
|
|||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
{
|
||||||
let mut sysproxy: Sysproxy = Sysproxy::get_system_proxy()?;
|
let mut sysproxy: Sysproxy = Sysproxy::get_system_proxy()?;
|
||||||
let mut autoproxy = Autoproxy::get_auto_proxy()?;
|
let mut autoproxy = match Autoproxy::get_auto_proxy() {
|
||||||
|
Ok(ap) => ap,
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!(target: "app", "重置代理时获取自动代理配置失败: {e}, 使用默认配置");
|
||||||
|
Autoproxy {
|
||||||
|
enable: false,
|
||||||
|
url: "".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
sysproxy.enable = false;
|
sysproxy.enable = false;
|
||||||
autoproxy.enable = false;
|
autoproxy.enable = false;
|
||||||
autoproxy.set_auto_proxy()?;
|
autoproxy.set_auto_proxy()?;
|
||||||
@@ -185,8 +208,7 @@ impl Sysopt {
|
|||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use crate::core::handle::Handle;
|
use crate::{core::handle::Handle, utils::dirs};
|
||||||
use crate::utils::dirs;
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use tauri_plugin_shell::ShellExt;
|
use tauri_plugin_shell::ShellExt;
|
||||||
|
|
||||||
@@ -217,132 +239,79 @@ impl Sysopt {
|
|||||||
|
|
||||||
/// update the startup
|
/// update the startup
|
||||||
pub fn update_launch(&self) -> Result<()> {
|
pub fn update_launch(&self) -> Result<()> {
|
||||||
let _lock = self.auto_launch.lock();
|
let enable_auto_launch = { Config::verge().latest().enable_auto_launch };
|
||||||
let enable = { Config::verge().latest().enable_auto_launch };
|
let is_enable = enable_auto_launch.unwrap_or(false);
|
||||||
let enable = enable.unwrap_or(false);
|
logging!(info, true, "Setting auto-launch state to: {:?}", is_enable);
|
||||||
let app_handle = Handle::global().app_handle().unwrap();
|
|
||||||
let autostart_manager = app_handle.autolaunch();
|
// 首先尝试使用快捷方式方法
|
||||||
println!("enable: {}", enable);
|
#[cfg(target_os = "windows")]
|
||||||
match enable {
|
{
|
||||||
true => log_err!(autostart_manager.enable()),
|
if is_enable {
|
||||||
false => log_err!(autostart_manager.disable()),
|
if let Err(e) = startup_shortcut::create_shortcut() {
|
||||||
};
|
log::error!(target: "app", "创建启动快捷方式失败: {}", e);
|
||||||
|
// 如果快捷方式创建失败,回退到原来的方法
|
||||||
|
self.try_original_autostart_method(is_enable);
|
||||||
|
} else {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
} else if let Err(e) = startup_shortcut::remove_shortcut() {
|
||||||
|
log::error!(target: "app", "删除启动快捷方式失败: {}", e);
|
||||||
|
self.try_original_autostart_method(is_enable);
|
||||||
|
} else {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
// 非Windows平台使用原来的方法
|
||||||
|
self.try_original_autostart_method(is_enable);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guard_proxy(&self) {
|
/// 尝试使用原来的自启动方法
|
||||||
let _lock = self.guard_state.lock();
|
fn try_original_autostart_method(&self, is_enable: bool) {
|
||||||
|
let app_handle = Handle::global().app_handle().unwrap();
|
||||||
|
let autostart_manager = app_handle.autolaunch();
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
if is_enable {
|
||||||
// default duration is 10s
|
logging_error!(Type::System, true, "{:?}", autostart_manager.enable());
|
||||||
let mut wait_secs = 10u64;
|
} else {
|
||||||
|
logging_error!(Type::System, true, "{:?}", autostart_manager.disable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
/// 获取当前自启动的实际状态
|
||||||
sleep(Duration::from_secs(wait_secs)).await;
|
pub fn get_launch_status(&self) -> Result<bool> {
|
||||||
|
// 首先尝试检查快捷方式是否存在
|
||||||
let (enable, guard, guard_duration, pac) = {
|
#[cfg(target_os = "windows")]
|
||||||
let verge = Config::verge();
|
{
|
||||||
let verge = verge.latest();
|
match startup_shortcut::is_shortcut_enabled() {
|
||||||
(
|
Ok(enabled) => {
|
||||||
verge.enable_system_proxy.unwrap_or(false),
|
log::info!(target: "app", "快捷方式自启动状态: {}", enabled);
|
||||||
verge.enable_proxy_guard.unwrap_or(false),
|
return Ok(enabled);
|
||||||
verge.proxy_guard_duration.unwrap_or(10),
|
|
||||||
verge.proxy_auto_config.unwrap_or(false),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
// stop loop
|
|
||||||
if !enable || !guard {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
// update duration
|
log::error!(target: "app", "检查快捷方式失败,尝试原来的方法: {}", e);
|
||||||
wait_secs = guard_duration;
|
|
||||||
|
|
||||||
log::debug!(target: "app", "try to guard the system proxy");
|
|
||||||
|
|
||||||
let sysproxy = Sysproxy::get_system_proxy();
|
|
||||||
let autoproxy = Autoproxy::get_auto_proxy();
|
|
||||||
if sysproxy.is_err() || autoproxy.is_err() {
|
|
||||||
log::error!(target: "app", "failed to get the system proxy");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let sysproxy_enable = sysproxy.ok().map(|s| s.enable).unwrap_or(false);
|
|
||||||
let autoproxy_enable = autoproxy.ok().map(|s| s.enable).unwrap_or(false);
|
|
||||||
|
|
||||||
if sysproxy_enable || autoproxy_enable {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let port = {
|
|
||||||
Config::verge()
|
|
||||||
.latest()
|
|
||||||
.verge_mixed_port
|
|
||||||
.unwrap_or(Config::clash().data().get_mixed_port())
|
|
||||||
};
|
|
||||||
let pac_port = IVerge::get_singleton_port();
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
{
|
|
||||||
if pac {
|
|
||||||
let autoproxy = Autoproxy {
|
|
||||||
enable: true,
|
|
||||||
url: format!("http://127.0.0.1:{pac_port}/commands/pac"),
|
|
||||||
};
|
|
||||||
log_err!(autoproxy.set_auto_proxy());
|
|
||||||
} else {
|
|
||||||
let sysproxy = Sysproxy {
|
|
||||||
enable: true,
|
|
||||||
host: "127.0.0.1".into(),
|
|
||||||
port,
|
|
||||||
bypass: get_bypass(),
|
|
||||||
};
|
|
||||||
|
|
||||||
log_err!(sysproxy.set_system_proxy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
{
|
|
||||||
use crate::core::handle::Handle;
|
|
||||||
use crate::utils::dirs;
|
|
||||||
use tauri_plugin_shell::ShellExt;
|
|
||||||
|
|
||||||
let app_handle = Handle::global().app_handle().unwrap();
|
|
||||||
|
|
||||||
let binary_path = dirs::service_path().unwrap();
|
|
||||||
let sysproxy_exe = binary_path.with_file_name("sysproxy.exe");
|
|
||||||
if !sysproxy_exe.exists() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let shell = app_handle.shell();
|
|
||||||
let output = if pac {
|
|
||||||
let address = format!("http://{}:{}/commands/pac", "127.0.0.1", pac_port);
|
|
||||||
|
|
||||||
shell
|
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
|
||||||
.args(["pac", address.as_str()])
|
|
||||||
.output()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
} else {
|
|
||||||
let address = format!("{}:{}", "127.0.0.1", port);
|
|
||||||
let bypass = get_bypass();
|
|
||||||
|
|
||||||
shell
|
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
|
||||||
.args(["global", address.as_str(), bypass.as_ref()])
|
|
||||||
.output()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
};
|
|
||||||
if !output.status.success() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// 回退到原来的方法
|
||||||
|
let app_handle = Handle::global().app_handle().unwrap();
|
||||||
|
let autostart_manager = app_handle.autolaunch();
|
||||||
|
|
||||||
|
match autostart_manager.is_enabled() {
|
||||||
|
Ok(status) => {
|
||||||
|
log::info!(target: "app", "Auto launch status: {status}");
|
||||||
|
Ok(status)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(target: "app", "Failed to get auto launch status: {e}");
|
||||||
|
Err(anyhow::anyhow!("Failed to get auto launch status: {}", e))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
use crate::config::Config;
|
use crate::{config::Config, feat, logging, logging_error, utils::logging::Type};
|
||||||
use crate::feat;
|
|
||||||
use crate::core::CoreManager;
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use delay_timer::prelude::{DelayTimer, DelayTimerBuilder, TaskBuilder};
|
use delay_timer::prelude::{DelayTimer, DelayTimerBuilder, TaskBuilder};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::{Mutex, RwLock};
|
||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
type TaskID = u64;
|
type TaskID = u64;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct TimerTask {
|
||||||
|
pub task_id: TaskID,
|
||||||
|
pub interval_minutes: u64,
|
||||||
|
#[allow(unused)]
|
||||||
|
pub last_run: i64, // Timestamp of last execution
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
/// cron manager
|
/// cron manager
|
||||||
delay_timer: Arc<Mutex<DelayTimer>>,
|
pub delay_timer: Arc<RwLock<DelayTimer>>,
|
||||||
|
|
||||||
/// save the current state
|
/// save the current state - using RwLock for better read concurrency
|
||||||
timer_map: Arc<Mutex<HashMap<String, (TaskID, u64)>>>,
|
pub timer_map: Arc<RwLock<HashMap<String, TimerTask>>>,
|
||||||
|
|
||||||
/// increment id
|
/// increment id - kept as mutex since it's just a counter
|
||||||
timer_count: Arc<Mutex<TaskID>>,
|
pub timer_count: Arc<Mutex<TaskID>>,
|
||||||
|
|
||||||
|
/// Flag to mark if timer is initialized - atomic for better performance
|
||||||
|
pub initialized: Arc<std::sync::atomic::AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Timer {
|
impl Timer {
|
||||||
@@ -26,68 +34,190 @@ impl Timer {
|
|||||||
static TIMER: OnceCell<Timer> = OnceCell::new();
|
static TIMER: OnceCell<Timer> = OnceCell::new();
|
||||||
|
|
||||||
TIMER.get_or_init(|| Timer {
|
TIMER.get_or_init(|| Timer {
|
||||||
delay_timer: Arc::new(Mutex::new(DelayTimerBuilder::default().build())),
|
delay_timer: Arc::new(RwLock::new(DelayTimerBuilder::default().build())),
|
||||||
timer_map: Arc::new(Mutex::new(HashMap::new())),
|
timer_map: Arc::new(RwLock::new(HashMap::new())),
|
||||||
timer_count: Arc::new(Mutex::new(1)),
|
timer_count: Arc::new(Mutex::new(1)),
|
||||||
|
initialized: Arc::new(std::sync::atomic::AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// restore timer
|
/// Initialize timer with better error handling and atomic operations
|
||||||
pub fn init(&self) -> Result<()> {
|
pub fn init(&self) -> Result<()> {
|
||||||
self.refresh()?;
|
// Use compare_exchange for thread-safe initialization check
|
||||||
|
if self
|
||||||
|
.initialized
|
||||||
|
.compare_exchange(
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
std::sync::atomic::Ordering::SeqCst,
|
||||||
|
std::sync::atomic::Ordering::SeqCst,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
logging!(debug, Type::Timer, "Timer already initialized, skipping...");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(info, Type::Timer, true, "Initializing timer...");
|
||||||
|
|
||||||
|
// Initialize timer tasks
|
||||||
|
if let Err(e) = self.refresh() {
|
||||||
|
// Reset initialization flag on error
|
||||||
|
self.initialized
|
||||||
|
.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||||
|
logging_error!(Type::Timer, false, "Failed to initialize timer: {}", e);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
let timer_map = self.timer_map.read();
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"已注册的定时任务数量: {}",
|
||||||
|
timer_map.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
for (uid, task) in timer_map.iter() {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"注册了定时任务 - uid={}, interval={}min, task_id={}",
|
||||||
|
uid,
|
||||||
|
task.interval_minutes,
|
||||||
|
task.task_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let cur_timestamp = chrono::Local::now().timestamp();
|
let cur_timestamp = chrono::Local::now().timestamp();
|
||||||
|
|
||||||
let timer_map = self.timer_map.lock();
|
// Collect profiles that need immediate update
|
||||||
let delay_timer = self.delay_timer.lock();
|
let profiles_to_update = if let Some(items) = Config::profiles().latest().get_items() {
|
||||||
|
|
||||||
if let Some(items) = Config::profiles().latest().get_items() {
|
|
||||||
items
|
items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|item| {
|
.filter_map(|item| {
|
||||||
// mins to seconds
|
let interval = item.option.as_ref()?.update_interval? as i64;
|
||||||
let interval = ((item.option.as_ref()?.update_interval?) as i64) * 60;
|
|
||||||
let updated = item.updated? as i64;
|
let updated = item.updated? as i64;
|
||||||
|
let uid = item.uid.as_ref()?;
|
||||||
|
|
||||||
if interval > 0 && cur_timestamp - updated >= interval {
|
if interval > 0 && cur_timestamp - updated >= interval * 60 {
|
||||||
Some(item)
|
logging!(info, Type::Timer, "需要立即更新的配置: uid={}", uid);
|
||||||
|
Some(uid.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.for_each(|item| {
|
.collect::<Vec<String>>()
|
||||||
if let Some(uid) = item.uid.as_ref() {
|
} else {
|
||||||
if let Some((task_id, _)) = timer_map.get(uid) {
|
Vec::new()
|
||||||
crate::log_err!(delay_timer.advance_task(*task_id));
|
};
|
||||||
}
|
|
||||||
|
// Advance tasks outside of locks to minimize lock contention
|
||||||
|
if !profiles_to_update.is_empty() {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"需要立即更新的配置数量: {}",
|
||||||
|
profiles_to_update.len()
|
||||||
|
);
|
||||||
|
let timer_map = self.timer_map.read();
|
||||||
|
let delay_timer = self.delay_timer.write();
|
||||||
|
|
||||||
|
for uid in profiles_to_update {
|
||||||
|
if let Some(task) = timer_map.get(&uid) {
|
||||||
|
logging!(info, Type::Timer, "立即执行任务: uid={}", uid);
|
||||||
|
if let Err(e) = delay_timer.advance_task(task.task_id) {
|
||||||
|
logging!(warn, Type::Timer, "Failed to advance task {}: {}", uid, e);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging!(info, Type::Timer, "Timer initialization completed");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Correctly update all cron tasks
|
/// Refresh timer tasks with better error handling
|
||||||
pub fn refresh(&self) -> Result<()> {
|
pub fn refresh(&self) -> Result<()> {
|
||||||
|
// Generate diff outside of lock to minimize lock contention
|
||||||
let diff_map = self.gen_diff();
|
let diff_map = self.gen_diff();
|
||||||
|
|
||||||
let mut timer_map = self.timer_map.lock();
|
if diff_map.is_empty() {
|
||||||
let mut delay_timer = self.delay_timer.lock();
|
logging!(debug, Type::Timer, "No timer changes needed");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
for (uid, diff) in diff_map.into_iter() {
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"Refreshing {} timer tasks",
|
||||||
|
diff_map.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Apply changes while holding locks
|
||||||
|
let mut timer_map = self.timer_map.write();
|
||||||
|
let mut delay_timer = self.delay_timer.write();
|
||||||
|
|
||||||
|
for (uid, diff) in diff_map {
|
||||||
match diff {
|
match diff {
|
||||||
DiffFlag::Del(tid) => {
|
DiffFlag::Del(tid) => {
|
||||||
let _ = timer_map.remove(&uid);
|
timer_map.remove(&uid);
|
||||||
crate::log_err!(delay_timer.remove_task(tid));
|
if let Err(e) = delay_timer.remove_task(tid) {
|
||||||
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Timer,
|
||||||
|
"Failed to remove task {} for uid {}: {}",
|
||||||
|
tid,
|
||||||
|
uid,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
logging!(debug, Type::Timer, "Removed task {} for uid {}", tid, uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DiffFlag::Add(tid, val) => {
|
DiffFlag::Add(tid, interval) => {
|
||||||
let _ = timer_map.insert(uid.clone(), (tid, val));
|
let task = TimerTask {
|
||||||
crate::log_err!(self.add_task(&mut delay_timer, uid, tid, val));
|
task_id: tid,
|
||||||
|
interval_minutes: interval,
|
||||||
|
last_run: chrono::Local::now().timestamp(),
|
||||||
|
};
|
||||||
|
|
||||||
|
timer_map.insert(uid.clone(), task);
|
||||||
|
|
||||||
|
if let Err(e) = self.add_task(&mut delay_timer, uid.clone(), tid, interval) {
|
||||||
|
logging_error!(Type::Timer, "Failed to add task for uid {}: {}", uid, e);
|
||||||
|
timer_map.remove(&uid); // Rollback on failure
|
||||||
|
} else {
|
||||||
|
logging!(debug, Type::Timer, "Added task {} for uid {}", tid, uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DiffFlag::Mod(tid, val) => {
|
DiffFlag::Mod(tid, interval) => {
|
||||||
let _ = timer_map.insert(uid.clone(), (tid, val));
|
// Remove old task first
|
||||||
crate::log_err!(delay_timer.remove_task(tid));
|
if let Err(e) = delay_timer.remove_task(tid) {
|
||||||
crate::log_err!(self.add_task(&mut delay_timer, uid, tid, val));
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Timer,
|
||||||
|
"Failed to remove old task {} for uid {}: {}",
|
||||||
|
tid,
|
||||||
|
uid,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then add the new one
|
||||||
|
let task = TimerTask {
|
||||||
|
task_id: tid,
|
||||||
|
interval_minutes: interval,
|
||||||
|
last_run: chrono::Local::now().timestamp(),
|
||||||
|
};
|
||||||
|
|
||||||
|
timer_map.insert(uid.clone(), task);
|
||||||
|
|
||||||
|
if let Err(e) = self.add_task(&mut delay_timer, uid.clone(), tid, interval) {
|
||||||
|
logging_error!(Type::Timer, "Failed to update task for uid {}: {}", uid, e);
|
||||||
|
timer_map.remove(&uid); // Rollback on failure
|
||||||
|
} else {
|
||||||
|
logging!(debug, Type::Timer, "Updated task {} for uid {}", tid, uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,59 +225,106 @@ impl Timer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generate a uid -> update_interval map
|
/// Generate map of profile UIDs to update intervals
|
||||||
fn gen_map(&self) -> HashMap<String, u64> {
|
fn gen_map(&self) -> HashMap<String, u64> {
|
||||||
let mut new_map = HashMap::new();
|
let mut new_map = HashMap::new();
|
||||||
|
|
||||||
if let Some(items) = Config::profiles().latest().get_items() {
|
if let Some(items) = Config::profiles().latest().get_items() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.option.is_some() {
|
if let Some(option) = item.option.as_ref() {
|
||||||
let option = item.option.as_ref().unwrap();
|
if let (Some(interval), Some(uid)) = (option.update_interval, &item.uid) {
|
||||||
let interval = option.update_interval.unwrap_or(0);
|
if interval > 0 {
|
||||||
|
logging!(
|
||||||
if interval > 0 {
|
debug,
|
||||||
new_map.insert(item.uid.clone().unwrap(), interval);
|
Type::Timer,
|
||||||
|
"找到定时更新配置: uid={}, interval={}min",
|
||||||
|
uid,
|
||||||
|
interval
|
||||||
|
);
|
||||||
|
new_map.insert(uid.clone(), interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging!(
|
||||||
|
debug,
|
||||||
|
Type::Timer,
|
||||||
|
"生成的定时更新配置数量: {}",
|
||||||
|
new_map.len()
|
||||||
|
);
|
||||||
new_map
|
new_map
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generate the diff map for refresh
|
/// Generate differences between current and new timer configuration
|
||||||
fn gen_diff(&self) -> HashMap<String, DiffFlag> {
|
fn gen_diff(&self) -> HashMap<String, DiffFlag> {
|
||||||
let mut diff_map = HashMap::new();
|
let mut diff_map = HashMap::new();
|
||||||
|
|
||||||
let timer_map = self.timer_map.lock();
|
|
||||||
|
|
||||||
let new_map = self.gen_map();
|
let new_map = self.gen_map();
|
||||||
let cur_map = &timer_map;
|
|
||||||
|
|
||||||
cur_map.iter().for_each(|(uid, (tid, val))| {
|
// Read lock for comparing current state
|
||||||
let new_val = new_map.get(uid).unwrap_or(&0);
|
let timer_map = self.timer_map.read();
|
||||||
|
logging!(
|
||||||
|
debug,
|
||||||
|
Type::Timer,
|
||||||
|
"当前 timer_map 大小: {}",
|
||||||
|
timer_map.len()
|
||||||
|
);
|
||||||
|
|
||||||
if *new_val == 0 {
|
// Find tasks to modify or delete
|
||||||
diff_map.insert(uid.clone(), DiffFlag::Del(*tid));
|
for (uid, task) in timer_map.iter() {
|
||||||
} else if new_val != val {
|
match new_map.get(uid) {
|
||||||
diff_map.insert(uid.clone(), DiffFlag::Mod(*tid, *new_val));
|
Some(&interval) if interval != task.interval_minutes => {
|
||||||
|
// Task exists but interval changed
|
||||||
|
logging!(
|
||||||
|
debug,
|
||||||
|
Type::Timer,
|
||||||
|
"定时任务间隔变更: uid={}, 旧={}, 新={}",
|
||||||
|
uid,
|
||||||
|
task.interval_minutes,
|
||||||
|
interval
|
||||||
|
);
|
||||||
|
diff_map.insert(uid.clone(), DiffFlag::Mod(task.task_id, interval));
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
// Task no longer needed
|
||||||
|
logging!(debug, Type::Timer, "定时任务已删除: uid={}", uid);
|
||||||
|
diff_map.insert(uid.clone(), DiffFlag::Del(task.task_id));
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// Task exists with same interval, no change needed
|
||||||
|
logging!(debug, Type::Timer, "定时任务保持不变: uid={}", uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
let mut count = self.timer_count.lock();
|
// Find new tasks to add
|
||||||
|
let mut next_id = *self.timer_count.lock();
|
||||||
|
|
||||||
new_map.iter().for_each(|(uid, val)| {
|
for (uid, &interval) in new_map.iter() {
|
||||||
if cur_map.get(uid).is_none() {
|
if !timer_map.contains_key(uid) {
|
||||||
diff_map.insert(uid.clone(), DiffFlag::Add(*count, *val));
|
logging!(
|
||||||
|
debug,
|
||||||
*count += 1;
|
Type::Timer,
|
||||||
|
"新增定时任务: uid={}, interval={}min",
|
||||||
|
uid,
|
||||||
|
interval
|
||||||
|
);
|
||||||
|
diff_map.insert(uid.clone(), DiffFlag::Add(next_id, interval));
|
||||||
|
next_id += 1;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Update counter only if we added new tasks
|
||||||
|
if next_id > *self.timer_count.lock() {
|
||||||
|
*self.timer_count.lock() = next_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
logging!(debug, Type::Timer, "定时任务变更数量: {}", diff_map.len());
|
||||||
diff_map
|
diff_map
|
||||||
}
|
}
|
||||||
|
|
||||||
/// add a cron task
|
/// Add a timer task with better error handling
|
||||||
fn add_task(
|
fn add_task(
|
||||||
&self,
|
&self,
|
||||||
delay_timer: &mut DelayTimer,
|
delay_timer: &mut DelayTimer,
|
||||||
@@ -155,12 +332,26 @@ impl Timer {
|
|||||||
tid: TaskID,
|
tid: TaskID,
|
||||||
minutes: u64,
|
minutes: u64,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"Adding task: uid={}, id={}, interval={}min",
|
||||||
|
uid,
|
||||||
|
tid,
|
||||||
|
minutes
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a task with reasonable retries and backoff
|
||||||
let task = TaskBuilder::default()
|
let task = TaskBuilder::default()
|
||||||
.set_task_id(tid)
|
.set_task_id(tid)
|
||||||
.set_maximum_parallel_runnable_num(1)
|
.set_maximum_parallel_runnable_num(1)
|
||||||
.set_frequency_repeated_by_minutes(minutes)
|
.set_frequency_repeated_by_minutes(minutes)
|
||||||
// .set_frequency_repeated_by_seconds(minutes) // for test
|
.spawn_async_routine(move || {
|
||||||
.spawn_async_routine(move || Self::async_task(uid.to_owned()))
|
let uid = uid.clone();
|
||||||
|
async move {
|
||||||
|
Self::async_task(uid).await;
|
||||||
|
}
|
||||||
|
})
|
||||||
.context("failed to create timer task")?;
|
.context("failed to create timer task")?;
|
||||||
|
|
||||||
delay_timer
|
delay_timer
|
||||||
@@ -170,20 +361,118 @@ impl Timer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the task runner
|
/// Get next update time for a profile
|
||||||
|
pub fn get_next_update_time(&self, uid: &str) -> Option<i64> {
|
||||||
|
logging!(info, Type::Timer, "获取下次更新时间,uid={}", uid);
|
||||||
|
|
||||||
|
let timer_map = self.timer_map.read();
|
||||||
|
let task = match timer_map.get(uid) {
|
||||||
|
Some(t) => t,
|
||||||
|
None => {
|
||||||
|
logging!(warn, Type::Timer, "找不到对应的定时任务,uid={}", uid);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get the profile updated timestamp
|
||||||
|
let profiles_config = Config::profiles();
|
||||||
|
let profiles = profiles_config.latest();
|
||||||
|
let items = match profiles.get_items() {
|
||||||
|
Some(i) => i,
|
||||||
|
None => {
|
||||||
|
logging!(warn, Type::Timer, "获取配置列表失败");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let profile = match items.iter().find(|item| item.uid.as_deref() == Some(uid)) {
|
||||||
|
Some(p) => p,
|
||||||
|
None => {
|
||||||
|
logging!(warn, Type::Timer, "找不到对应的配置,uid={}", uid);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let updated = profile.updated.unwrap_or(0) as i64;
|
||||||
|
|
||||||
|
// Calculate next update time
|
||||||
|
if updated > 0 && task.interval_minutes > 0 {
|
||||||
|
let next_time = updated + (task.interval_minutes as i64 * 60);
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"计算得到下次更新时间: {}, uid={}",
|
||||||
|
next_time,
|
||||||
|
uid
|
||||||
|
);
|
||||||
|
Some(next_time)
|
||||||
|
} else {
|
||||||
|
logging!(
|
||||||
|
warn,
|
||||||
|
Type::Timer,
|
||||||
|
"更新时间或间隔无效,updated={}, interval={}",
|
||||||
|
updated,
|
||||||
|
task.interval_minutes
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Emit update events for frontend notification
|
||||||
|
fn emit_update_event(_uid: &str, _is_start: bool) {
|
||||||
|
#[cfg(any(feature = "verge-dev", feature = "default"))]
|
||||||
|
{
|
||||||
|
if _is_start {
|
||||||
|
super::handle::Handle::notify_profile_update_started(_uid.to_string());
|
||||||
|
} else {
|
||||||
|
super::handle::Handle::notify_profile_update_completed(_uid.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Async task with better error handling and logging
|
||||||
async fn async_task(uid: String) {
|
async fn async_task(uid: String) {
|
||||||
log::info!(target: "app", "running timer task `{uid}`");
|
let task_start = std::time::Instant::now();
|
||||||
|
logging!(info, Type::Timer, "Running timer task for profile: {}", uid);
|
||||||
|
|
||||||
// 使用更轻量级的更新方式
|
match tokio::time::timeout(std::time::Duration::from_secs(40), async {
|
||||||
if let Err(e) = feat::update_profile(uid.clone(), None).await {
|
Self::emit_update_event(&uid, true);
|
||||||
log::error!(target: "app", "timer task update error: {}", e);
|
|
||||||
return;
|
let is_current = Config::profiles().latest().current.as_ref() == Some(&uid);
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"配置 {} 是否为当前激活配置: {}",
|
||||||
|
uid,
|
||||||
|
is_current
|
||||||
|
);
|
||||||
|
|
||||||
|
feat::update_profile(uid.clone(), None, Some(is_current)).await
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(result) => match result {
|
||||||
|
Ok(_) => {
|
||||||
|
let duration = task_start.elapsed().as_millis();
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Timer,
|
||||||
|
"Timer task completed successfully for uid: {} (took {}ms)",
|
||||||
|
uid,
|
||||||
|
duration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logging_error!(Type::Timer, "Failed to update profile uid {}: {}", uid, e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => {
|
||||||
|
logging_error!(Type::Timer, false, "Timer task timed out for uid: {}", uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有更新成功后才刷新配置
|
// Emit completed event
|
||||||
if let Err(e) = CoreManager::global().update_config().await {
|
Self::emit_update_event(&uid, false);
|
||||||
log::error!(target: "app", "timer task refresh error: {}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,171 @@
|
|||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
|
use tauri::tray::TrayIconBuilder;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub mod speed_rate;
|
pub mod speed_rate;
|
||||||
use crate::module::mihomo::Rate;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cmd,
|
cmd,
|
||||||
config::Config,
|
config::Config,
|
||||||
feat, resolve,
|
feat, logging,
|
||||||
utils::resolve::VERSION,
|
module::{lightweight::is_in_lightweight_mode, mihomo::Rate},
|
||||||
utils::{dirs, i18n::t},
|
utils::{dirs::find_target_icons, i18n::t, resolve::VERSION},
|
||||||
|
Type,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use futures::StreamExt;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
#[cfg(target_os = "macos")]
|
use std::{
|
||||||
use parking_lot::RwLock;
|
fs,
|
||||||
#[cfg(target_os = "macos")]
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
pub use speed_rate::{SpeedRate, Traffic};
|
time::{Duration, Instant},
|
||||||
#[cfg(target_os = "macos")]
|
};
|
||||||
use std::sync::Arc;
|
use tauri::{
|
||||||
use tauri::menu::{CheckMenuItem, IsMenuItem};
|
menu::{CheckMenuItem, IsMenuItem, MenuEvent, MenuItem, PredefinedMenuItem, Submenu},
|
||||||
use tauri::AppHandle;
|
tray::{MouseButton, MouseButtonState, TrayIconEvent},
|
||||||
use tauri::{
|
AppHandle, Wry,
|
||||||
menu::{MenuEvent, MenuItem, PredefinedMenuItem, Submenu},
|
|
||||||
tray::{MouseButton, MouseButtonState, TrayIconEvent, TrayIconId},
|
|
||||||
Wry,
|
|
||||||
};
|
};
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use tokio::sync::broadcast;
|
|
||||||
|
|
||||||
use super::handle;
|
use super::handle;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct TrayState {}
|
||||||
|
|
||||||
|
// 托盘点击防抖机制
|
||||||
|
static TRAY_CLICK_DEBOUNCE: OnceCell<Mutex<Instant>> = OnceCell::new();
|
||||||
|
const TRAY_CLICK_DEBOUNCE_MS: u64 = 300;
|
||||||
|
|
||||||
|
fn get_tray_click_debounce() -> &'static Mutex<Instant> {
|
||||||
|
TRAY_CLICK_DEBOUNCE.get_or_init(|| Mutex::new(Instant::now() - Duration::from_secs(1)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn should_handle_tray_click() -> bool {
|
||||||
|
let debounce_lock = get_tray_click_debounce();
|
||||||
|
let mut last_click = debounce_lock.lock();
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
|
if now.duration_since(*last_click) >= Duration::from_millis(TRAY_CLICK_DEBOUNCE_MS) {
|
||||||
|
*last_click = now;
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
log::debug!(target: "app", "托盘点击被防抖机制忽略,距离上次点击 {:?}ms",
|
||||||
|
now.duration_since(*last_click).as_millis());
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub struct Tray {
|
pub struct Tray {
|
||||||
pub speed_rate: Arc<Mutex<Option<SpeedRate>>>,
|
last_menu_update: Mutex<Option<Instant>>,
|
||||||
shutdown_tx: Arc<RwLock<Option<broadcast::Sender<()>>>>,
|
menu_updating: AtomicBool,
|
||||||
is_subscribed: Arc<RwLock<bool>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
pub struct Tray {}
|
pub struct Tray {
|
||||||
|
last_menu_update: Mutex<Option<Instant>>,
|
||||||
|
menu_updating: AtomicBool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TrayState {
|
||||||
|
pub fn get_common_tray_icon() -> (bool, Vec<u8>) {
|
||||||
|
let verge = Config::verge().latest().clone();
|
||||||
|
let is_common_tray_icon = verge.common_tray_icon.unwrap_or(false);
|
||||||
|
if is_common_tray_icon {
|
||||||
|
if let Some(common_icon_path) = find_target_icons("common").unwrap() {
|
||||||
|
let icon_data = fs::read(common_icon_path).unwrap();
|
||||||
|
return (true, icon_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
let tray_icon_colorful = verge.tray_icon.unwrap_or("monochrome".to_string());
|
||||||
|
if tray_icon_colorful == "monochrome" {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-mono.ico").to_vec(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_sysproxy_tray_icon() -> (bool, Vec<u8>) {
|
||||||
|
let verge = Config::verge().latest().clone();
|
||||||
|
let is_sysproxy_tray_icon = verge.sysproxy_tray_icon.unwrap_or(false);
|
||||||
|
if is_sysproxy_tray_icon {
|
||||||
|
if let Some(sysproxy_icon_path) = find_target_icons("sysproxy").unwrap() {
|
||||||
|
let icon_data = fs::read(sysproxy_icon_path).unwrap();
|
||||||
|
return (true, icon_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
let tray_icon_colorful = verge.tray_icon.clone().unwrap_or("monochrome".to_string());
|
||||||
|
if tray_icon_colorful == "monochrome" {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-sys-mono-new.ico").to_vec(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-sys.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-sys.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_tun_tray_icon() -> (bool, Vec<u8>) {
|
||||||
|
let verge = Config::verge().latest().clone();
|
||||||
|
let is_tun_tray_icon = verge.tun_tray_icon.unwrap_or(false);
|
||||||
|
if is_tun_tray_icon {
|
||||||
|
if let Some(tun_icon_path) = find_target_icons("tun").unwrap() {
|
||||||
|
let icon_data = fs::read(tun_icon_path).unwrap();
|
||||||
|
return (true, icon_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
let tray_icon_colorful = verge.tray_icon.clone().unwrap_or("monochrome".to_string());
|
||||||
|
if tray_icon_colorful == "monochrome" {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-tun-mono-new.ico").to_vec(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-tun.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
include_bytes!("../../../icons/tray-icon-tun.ico").to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Tray {
|
impl Tray {
|
||||||
pub fn global() -> &'static Tray {
|
pub fn global() -> &'static Tray {
|
||||||
@@ -48,73 +173,84 @@ impl Tray {
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
return TRAY.get_or_init(|| Tray {
|
return TRAY.get_or_init(|| Tray {
|
||||||
speed_rate: Arc::new(Mutex::new(None)),
|
last_menu_update: Mutex::new(None),
|
||||||
shutdown_tx: Arc::new(RwLock::new(None)),
|
menu_updating: AtomicBool::new(false),
|
||||||
is_subscribed: Arc::new(RwLock::new(false)),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
return TRAY.get_or_init(|| Tray {});
|
return TRAY.get_or_init(|| Tray {
|
||||||
|
last_menu_update: Mutex::new(None),
|
||||||
|
menu_updating: AtomicBool::new(false),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self) -> Result<()> {
|
pub fn init(&self) -> Result<()> {
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
let mut speed_rate = self.speed_rate.lock();
|
|
||||||
*speed_rate = Some(SpeedRate::new());
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_systray(&self) -> Result<()> {
|
/// 更新托盘点击行为
|
||||||
|
pub fn update_click_behavior(&self) -> Result<()> {
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
let tray_incon_id = TrayIconId::new("main");
|
let tray_event = { Config::verge().latest().tray_event.clone() };
|
||||||
let tray = app_handle.tray_by_id(&tray_incon_id).unwrap();
|
let tray_event: String = tray_event.unwrap_or("main_window".into());
|
||||||
|
let tray = app_handle.tray_by_id("main").unwrap();
|
||||||
#[cfg(target_os = "macos")]
|
match tray_event.as_str() {
|
||||||
tray.set_show_menu_on_left_click(false)?;
|
"tray_menu" => tray.set_show_menu_on_left_click(true)?,
|
||||||
|
_ => tray.set_show_menu_on_left_click(false)?,
|
||||||
tray.on_tray_icon_event(|_, event| {
|
}
|
||||||
let tray_event = { Config::verge().latest().tray_event.clone() };
|
|
||||||
let tray_event: String = tray_event.unwrap_or("main_window".into());
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
if let TrayIconEvent::Click {
|
|
||||||
button: MouseButton::Left,
|
|
||||||
button_state: MouseButtonState::Down,
|
|
||||||
..
|
|
||||||
} = event
|
|
||||||
{
|
|
||||||
match tray_event.as_str() {
|
|
||||||
"system_proxy" => feat::toggle_system_proxy(),
|
|
||||||
"tun_mode" => feat::toggle_tun_mode(None),
|
|
||||||
"main_window" => resolve::create_window(),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
if let TrayIconEvent::Click {
|
|
||||||
button: MouseButton::Left,
|
|
||||||
button_state: MouseButtonState::Down,
|
|
||||||
..
|
|
||||||
} = event
|
|
||||||
{
|
|
||||||
match tray_event.as_str() {
|
|
||||||
"system_proxy" => feat::toggle_system_proxy(),
|
|
||||||
"tun_mode" => feat::toggle_tun_mode(None),
|
|
||||||
"main_window" => resolve::create_window(),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tray.on_menu_event(on_menu_event);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新托盘菜单
|
/// 更新托盘菜单
|
||||||
pub fn update_menu(&self) -> Result<()> {
|
pub fn update_menu(&self) -> Result<()> {
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
// 调整最小更新间隔,确保状态及时刷新
|
||||||
|
const MIN_UPDATE_INTERVAL: Duration = Duration::from_millis(100);
|
||||||
|
|
||||||
|
// 检查是否正在更新
|
||||||
|
if self.menu_updating.load(Ordering::Acquire) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查更新频率,但允许重要事件跳过频率限制
|
||||||
|
let should_force_update = match std::thread::current().name() {
|
||||||
|
Some("main") => true,
|
||||||
|
_ => {
|
||||||
|
let last_update = self.last_menu_update.lock();
|
||||||
|
if let Some(last_time) = *last_update {
|
||||||
|
last_time.elapsed() >= MIN_UPDATE_INTERVAL
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if !should_force_update {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let app_handle = match handle::Handle::global().app_handle() {
|
||||||
|
Some(handle) => handle,
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘菜单失败: app_handle不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 设置更新状态
|
||||||
|
self.menu_updating.store(true, Ordering::Release);
|
||||||
|
|
||||||
|
let result = self.update_menu_internal(&app_handle);
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut last_update = self.last_menu_update.lock();
|
||||||
|
*last_update = Some(Instant::now());
|
||||||
|
}
|
||||||
|
self.menu_updating.store(false, Ordering::Release);
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_menu_internal(&self, app_handle: &AppHandle) -> Result<()> {
|
||||||
let verge = Config::verge().latest().clone();
|
let verge = Config::verge().latest().clone();
|
||||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||||
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||||
@@ -130,134 +266,128 @@ impl Tray {
|
|||||||
let profile_uid_and_name = Config::profiles()
|
let profile_uid_and_name = Config::profiles()
|
||||||
.data()
|
.data()
|
||||||
.all_profile_uid_and_name()
|
.all_profile_uid_and_name()
|
||||||
.unwrap_or(Vec::new());
|
.unwrap_or_default();
|
||||||
|
let is_lightweight_mode = is_in_lightweight_mode();
|
||||||
|
|
||||||
let tray = app_handle.tray_by_id("main").unwrap();
|
match app_handle.tray_by_id("main") {
|
||||||
let _ = tray.set_menu(Some(create_tray_menu(
|
Some(tray) => {
|
||||||
&app_handle,
|
let _ = tray.set_menu(Some(create_tray_menu(
|
||||||
Some(mode.as_str()),
|
app_handle,
|
||||||
*system_proxy,
|
Some(mode.as_str()),
|
||||||
*tun_mode,
|
*system_proxy,
|
||||||
profile_uid_and_name,
|
*tun_mode,
|
||||||
)?));
|
profile_uid_and_name,
|
||||||
Ok(())
|
is_lightweight_mode,
|
||||||
|
)?));
|
||||||
|
log::debug!(target: "app", "托盘菜单更新成功");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘菜单失败: 托盘不存在");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新托盘图标
|
/// 更新托盘图标
|
||||||
#[allow(unused_variables)]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn update_icon(&self, rate: Option<Rate>) -> Result<()> {
|
pub fn update_icon(&self, _rate: Option<Rate>) -> Result<()> {
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = match handle::Handle::global().app_handle() {
|
||||||
let verge = Config::verge().latest().clone();
|
Some(handle) => handle,
|
||||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
None => {
|
||||||
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
log::warn!(target: "app", "更新托盘图标失败: app_handle不存在");
|
||||||
|
return Ok(());
|
||||||
let common_tray_icon = verge.common_tray_icon.as_ref().unwrap_or(&false);
|
|
||||||
let sysproxy_tray_icon = verge.sysproxy_tray_icon.as_ref().unwrap_or(&false);
|
|
||||||
let tun_tray_icon = verge.tun_tray_icon.as_ref().unwrap_or(&false);
|
|
||||||
|
|
||||||
let tray = app_handle.tray_by_id("main").unwrap();
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let tray_icon = verge.tray_icon.clone().unwrap_or("monochrome".to_string());
|
|
||||||
|
|
||||||
let icon_bytes = if *system_proxy && !*tun_mode {
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let mut icon = match tray_icon.as_str() {
|
|
||||||
"colorful" => include_bytes!("../../../icons/tray-icon-sys.ico").to_vec(),
|
|
||||||
_ => include_bytes!("../../../icons/tray-icon-sys-mono.ico").to_vec(),
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
let mut icon = include_bytes!("../../../icons/tray-icon-sys.ico").to_vec();
|
|
||||||
if *sysproxy_tray_icon {
|
|
||||||
let icon_dir_path = dirs::app_home_dir()?.join("icons");
|
|
||||||
let png_path = icon_dir_path.join("sysproxy.png");
|
|
||||||
let ico_path = icon_dir_path.join("sysproxy.ico");
|
|
||||||
if ico_path.exists() {
|
|
||||||
icon = std::fs::read(ico_path).unwrap();
|
|
||||||
} else if png_path.exists() {
|
|
||||||
icon = std::fs::read(png_path).unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
icon
|
|
||||||
} else if *tun_mode {
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let mut icon = match tray_icon.as_str() {
|
|
||||||
"colorful" => include_bytes!("../../../icons/tray-icon-tun.ico").to_vec(),
|
|
||||||
_ => include_bytes!("../../../icons/tray-icon-tun-mono.ico").to_vec(),
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
let mut icon = include_bytes!("../../../icons/tray-icon-tun.ico").to_vec();
|
|
||||||
if *tun_tray_icon {
|
|
||||||
let icon_dir_path = dirs::app_home_dir()?.join("icons");
|
|
||||||
let png_path = icon_dir_path.join("tun.png");
|
|
||||||
let ico_path = icon_dir_path.join("tun.ico");
|
|
||||||
if ico_path.exists() {
|
|
||||||
icon = std::fs::read(ico_path).unwrap();
|
|
||||||
} else if png_path.exists() {
|
|
||||||
icon = std::fs::read(png_path).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icon
|
|
||||||
} else {
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let mut icon = match tray_icon.as_str() {
|
|
||||||
"colorful" => include_bytes!("../../../icons/tray-icon.ico").to_vec(),
|
|
||||||
_ => include_bytes!("../../../icons/tray-icon-mono.ico").to_vec(),
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
let mut icon = include_bytes!("../../../icons/tray-icon.ico").to_vec();
|
|
||||||
if *common_tray_icon {
|
|
||||||
let icon_dir_path = dirs::app_home_dir()?.join("icons");
|
|
||||||
let png_path = icon_dir_path.join("common.png");
|
|
||||||
let ico_path = icon_dir_path.join("common.ico");
|
|
||||||
if ico_path.exists() {
|
|
||||||
icon = std::fs::read(ico_path).unwrap();
|
|
||||||
} else if png_path.exists() {
|
|
||||||
icon = std::fs::read(png_path).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
let tray = match app_handle.tray_by_id("main") {
|
||||||
{
|
Some(tray) => tray,
|
||||||
let enable_tray_speed = Config::verge().latest().enable_tray_speed.unwrap_or(true);
|
None => {
|
||||||
let is_colorful = tray_icon == "colorful";
|
log::warn!(target: "app", "更新托盘图标失败: 托盘不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 处理图标和速率
|
let verge = Config::verge().latest().clone();
|
||||||
let final_icon_bytes = if enable_tray_speed {
|
let system_mode = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||||
let rate = rate.or_else(|| {
|
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||||
self.speed_rate
|
|
||||||
.lock()
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|speed_rate| speed_rate.get_curent_rate())
|
|
||||||
});
|
|
||||||
|
|
||||||
// 使用新的方法渲染图标和速率
|
let (_is_custom_icon, icon_bytes) = match (*system_mode, *tun_mode) {
|
||||||
SpeedRate::add_speed_text(icon_bytes, rate)?
|
(true, true) => TrayState::get_tun_tray_icon(),
|
||||||
} else {
|
(true, false) => TrayState::get_sysproxy_tray_icon(),
|
||||||
icon_bytes
|
(false, true) => TrayState::get_tun_tray_icon(),
|
||||||
};
|
(false, false) => TrayState::get_common_tray_icon(),
|
||||||
|
};
|
||||||
|
|
||||||
// 设置系统托盘图标
|
let colorful = verge.tray_icon.clone().unwrap_or("monochrome".to_string());
|
||||||
let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&final_icon_bytes)?));
|
let is_colorful = colorful == "colorful";
|
||||||
// 只对单色图标使用 template 模式
|
|
||||||
let _ = tray.set_icon_as_template(!is_colorful);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&icon_bytes)?));
|
let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&icon_bytes)?));
|
||||||
|
let _ = tray.set_icon_as_template(!is_colorful);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
pub fn update_icon(&self, _rate: Option<Rate>) -> Result<()> {
|
||||||
|
let app_handle = match handle::Handle::global().app_handle() {
|
||||||
|
Some(handle) => handle,
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘图标失败: app_handle不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let tray = match app_handle.tray_by_id("main") {
|
||||||
|
Some(tray) => tray,
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘图标失败: 托盘不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let verge = Config::verge().latest().clone();
|
||||||
|
let system_mode = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||||
|
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||||
|
|
||||||
|
let (_is_custom_icon, icon_bytes) = match (*system_mode, *tun_mode) {
|
||||||
|
(true, true) => TrayState::get_tun_tray_icon(),
|
||||||
|
(true, false) => TrayState::get_sysproxy_tray_icon(),
|
||||||
|
(false, true) => TrayState::get_tun_tray_icon(),
|
||||||
|
(false, false) => TrayState::get_common_tray_icon(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&icon_bytes)?));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 更新托盘显示状态的函数
|
||||||
|
pub fn update_tray_display(&self) -> Result<()> {
|
||||||
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
|
let _tray = app_handle.tray_by_id("main").unwrap();
|
||||||
|
|
||||||
|
// 更新菜单
|
||||||
|
self.update_menu()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新托盘提示
|
/// 更新托盘提示
|
||||||
pub fn update_tooltip(&self) -> Result<()> {
|
pub fn update_tooltip(&self) -> Result<()> {
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = match handle::Handle::global().app_handle() {
|
||||||
let version = VERSION.get().unwrap();
|
Some(handle) => handle,
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘提示失败: app_handle不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let version = match VERSION.get() {
|
||||||
|
Some(v) => v,
|
||||||
|
None => {
|
||||||
|
log::warn!(target: "app", "更新托盘提示失败: 版本信息不存在");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let verge = Config::verge().latest().clone();
|
let verge = Config::verge().latest().clone();
|
||||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||||
@@ -274,23 +404,28 @@ impl Tray {
|
|||||||
let profiles = Config::profiles();
|
let profiles = Config::profiles();
|
||||||
let profiles = profiles.latest();
|
let profiles = profiles.latest();
|
||||||
if let Some(current_profile_uid) = profiles.get_current() {
|
if let Some(current_profile_uid) = profiles.get_current() {
|
||||||
let current_profile = profiles.get_item(¤t_profile_uid);
|
if let Ok(profile) = profiles.get_item(¤t_profile_uid) {
|
||||||
current_profile_name = match ¤t_profile.unwrap().name {
|
current_profile_name = match &profile.name {
|
||||||
Some(profile_name) => profile_name.to_string(),
|
Some(profile_name) => profile_name.to_string(),
|
||||||
None => current_profile_name,
|
None => current_profile_name,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let tray = app_handle.tray_by_id("main").unwrap();
|
if let Some(tray) = app_handle.tray_by_id("main") {
|
||||||
let _ = tray.set_tooltip(Some(&format!(
|
let _ = tray.set_tooltip(Some(&format!(
|
||||||
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
|
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
|
||||||
t("SysProxy"),
|
t("SysProxy"),
|
||||||
switch_map[system_proxy],
|
switch_map[system_proxy],
|
||||||
t("TUN"),
|
t("TUN"),
|
||||||
switch_map[tun_mode],
|
switch_map[tun_mode],
|
||||||
t("Profile"),
|
t("Profile"),
|
||||||
current_profile_name
|
current_profile_name
|
||||||
)));
|
)));
|
||||||
|
} else {
|
||||||
|
log::warn!(target: "app", "更新托盘提示失败: 托盘不存在");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,75 +433,90 @@ impl Tray {
|
|||||||
self.update_menu()?;
|
self.update_menu()?;
|
||||||
self.update_icon(None)?;
|
self.update_icon(None)?;
|
||||||
self.update_tooltip()?;
|
self.update_tooltip()?;
|
||||||
Ok(())
|
// 更新轻量模式显示状态
|
||||||
}
|
self.update_tray_display()?;
|
||||||
|
|
||||||
/// 订阅流量数据
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
pub async fn subscribe_traffic(&self) -> Result<()> {
|
|
||||||
log::info!(target: "app", "subscribe traffic");
|
|
||||||
|
|
||||||
// 如果已经订阅,先取消订阅
|
|
||||||
if *self.is_subscribed.read() {
|
|
||||||
self.unsubscribe_traffic();
|
|
||||||
}
|
|
||||||
|
|
||||||
let (shutdown_tx, shutdown_rx) = broadcast::channel(1);
|
|
||||||
*self.shutdown_tx.write() = Some(shutdown_tx);
|
|
||||||
*self.is_subscribed.write() = true;
|
|
||||||
|
|
||||||
let speed_rate = Arc::clone(&self.speed_rate);
|
|
||||||
let is_subscribed = Arc::clone(&self.is_subscribed);
|
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
|
||||||
let mut shutdown = shutdown_rx;
|
|
||||||
|
|
||||||
'outer: loop {
|
|
||||||
match Traffic::get_traffic_stream().await {
|
|
||||||
Ok(mut stream) => loop {
|
|
||||||
tokio::select! {
|
|
||||||
Some(traffic) = stream.next() => {
|
|
||||||
if let Ok(traffic) = traffic {
|
|
||||||
let guard = speed_rate.lock();
|
|
||||||
let enable_tray_speed: bool = Config::verge().latest().enable_tray_speed.unwrap_or(true);
|
|
||||||
if !enable_tray_speed {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if let Some(sr) = guard.as_ref() {
|
|
||||||
if let Some(rate) = sr.update_and_check_changed(traffic.up, traffic.down) {
|
|
||||||
let _ = Tray::global().update_icon(Some(rate));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ = shutdown.recv() => break 'outer,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
log::error!(target: "app", "Failed to get traffic stream: {}", e);
|
|
||||||
// 如果获取流失败,等待一段时间后重试
|
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
|
||||||
|
|
||||||
// 检查是否应该继续重试
|
|
||||||
if !*is_subscribed.read() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 取消订阅 traffic 数据
|
/// 取消订阅 traffic 数据
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn unsubscribe_traffic(&self) {
|
pub fn unsubscribe_traffic(&self) {}
|
||||||
log::info!(target: "app", "unsubscribe traffic");
|
|
||||||
*self.is_subscribed.write() = false;
|
pub fn create_tray_from_handle(&self, app_handle: &AppHandle) -> Result<()> {
|
||||||
if let Some(tx) = self.shutdown_tx.write().take() {
|
log::info!(target: "app", "正在从AppHandle创建系统托盘");
|
||||||
drop(tx);
|
|
||||||
|
// 获取图标
|
||||||
|
let icon_bytes = TrayState::get_common_tray_icon().1;
|
||||||
|
let icon = tauri::image::Image::from_bytes(&icon_bytes)?;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let builder = TrayIconBuilder::with_id("main")
|
||||||
|
.icon(icon)
|
||||||
|
.icon_as_template(false);
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
let mut builder = TrayIconBuilder::with_id("main")
|
||||||
|
.icon(icon)
|
||||||
|
.icon_as_template(false);
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||||
|
{
|
||||||
|
let tray_event = { Config::verge().latest().tray_event.clone() };
|
||||||
|
let tray_event: String = tray_event.unwrap_or("main_window".into());
|
||||||
|
if tray_event.as_str() != "tray_menu" {
|
||||||
|
builder = builder.show_menu_on_left_click(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tray = builder.build(app_handle)?;
|
||||||
|
|
||||||
|
tray.on_tray_icon_event(|_, event| {
|
||||||
|
let tray_event = { Config::verge().latest().tray_event.clone() };
|
||||||
|
let tray_event: String = tray_event.unwrap_or("main_window".into());
|
||||||
|
log::debug!(target: "app","tray event: {tray_event:?}");
|
||||||
|
|
||||||
|
if let TrayIconEvent::Click {
|
||||||
|
button: MouseButton::Left,
|
||||||
|
button_state: MouseButtonState::Down,
|
||||||
|
..
|
||||||
|
} = event
|
||||||
|
{
|
||||||
|
// 添加防抖检查,防止快速连击
|
||||||
|
if !should_handle_tray_click() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
match tray_event.as_str() {
|
||||||
|
"system_proxy" => feat::toggle_system_proxy(),
|
||||||
|
"tun_mode" => feat::toggle_tun_mode(None),
|
||||||
|
"main_window" => {
|
||||||
|
use crate::utils::window_manager::WindowManager;
|
||||||
|
log::info!(target: "app", "Tray点击事件: 显示主窗口");
|
||||||
|
if crate::module::lightweight::is_in_lightweight_mode() {
|
||||||
|
log::info!(target: "app", "当前在轻量模式,正在退出轻量模式");
|
||||||
|
crate::module::lightweight::exit_lightweight_mode();
|
||||||
|
}
|
||||||
|
let result = WindowManager::show_main_window();
|
||||||
|
log::info!(target: "app", "窗口显示结果: {result:?}");
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tray.on_menu_event(on_menu_event);
|
||||||
|
log::info!(target: "app", "系统托盘创建成功");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 托盘统一的状态更新函数
|
||||||
|
pub fn update_all_states(&self) -> Result<()> {
|
||||||
|
// 确保所有状态更新完成
|
||||||
|
self.update_menu()?;
|
||||||
|
self.update_icon(None)?;
|
||||||
|
self.update_tooltip()?;
|
||||||
|
self.update_tray_display()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,9 +526,13 @@ fn create_tray_menu(
|
|||||||
system_proxy_enabled: bool,
|
system_proxy_enabled: bool,
|
||||||
tun_mode_enabled: bool,
|
tun_mode_enabled: bool,
|
||||||
profile_uid_and_name: Vec<(String, String)>,
|
profile_uid_and_name: Vec<(String, String)>,
|
||||||
|
is_lightweight_mode: bool,
|
||||||
) -> Result<tauri::menu::Menu<Wry>> {
|
) -> Result<tauri::menu::Menu<Wry>> {
|
||||||
let mode = mode.unwrap_or("");
|
let mode = mode.unwrap_or("");
|
||||||
let version = VERSION.get().unwrap();
|
|
||||||
|
let unknown_version = String::from("unknown");
|
||||||
|
let version = VERSION.get().unwrap_or(&unknown_version);
|
||||||
|
|
||||||
let hotkeys = Config::verge()
|
let hotkeys = Config::verge()
|
||||||
.latest()
|
.latest()
|
||||||
.hotkeys
|
.hotkeys
|
||||||
@@ -399,17 +553,20 @@ fn create_tray_menu(
|
|||||||
let profile_menu_items: Vec<CheckMenuItem<Wry>> = profile_uid_and_name
|
let profile_menu_items: Vec<CheckMenuItem<Wry>> = profile_uid_and_name
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(profile_uid, profile_name)| {
|
.map(|(profile_uid, profile_name)| {
|
||||||
let is_current_profile = Config::profiles().data().is_current_profile_index(profile_uid.to_string());
|
let is_current_profile = Config::profiles()
|
||||||
CheckMenuItem::with_id(
|
.data()
|
||||||
app_handle,
|
.is_current_profile_index(profile_uid.to_string());
|
||||||
&format!("profiles_{}", profile_uid),
|
CheckMenuItem::with_id(
|
||||||
t(&profile_name),
|
app_handle,
|
||||||
true,
|
format!("profiles_{profile_uid}"),
|
||||||
is_current_profile,
|
t(profile_name),
|
||||||
None::<&str>,
|
true,
|
||||||
)
|
is_current_profile,
|
||||||
.unwrap()
|
None::<&str>,
|
||||||
}).collect();
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let profile_menu_items: Vec<&dyn IsMenuItem<Wry>> = profile_menu_items
|
let profile_menu_items: Vec<&dyn IsMenuItem<Wry>> = profile_menu_items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| item as &dyn IsMenuItem<Wry>)
|
.map(|item| item as &dyn IsMenuItem<Wry>)
|
||||||
@@ -460,7 +617,8 @@ fn create_tray_menu(
|
|||||||
t("Profiles"),
|
t("Profiles"),
|
||||||
true,
|
true,
|
||||||
&profile_menu_items,
|
&profile_menu_items,
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let system_proxy = &CheckMenuItem::with_id(
|
let system_proxy = &CheckMenuItem::with_id(
|
||||||
app_handle,
|
app_handle,
|
||||||
@@ -482,6 +640,16 @@ fn create_tray_menu(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let lighteweight_mode = &CheckMenuItem::with_id(
|
||||||
|
app_handle,
|
||||||
|
"entry_lightweight_mode",
|
||||||
|
t("LightWeight Mode"),
|
||||||
|
true,
|
||||||
|
is_lightweight_mode,
|
||||||
|
hotkeys.get("entry_lightweight_mode").map(|s| s.as_str()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let copy_env =
|
let copy_env =
|
||||||
&MenuItem::with_id(app_handle, "copy_env", t("Copy Env"), true, None::<&str>).unwrap();
|
&MenuItem::with_id(app_handle, "copy_env", t("Copy Env"), true, None::<&str>).unwrap();
|
||||||
|
|
||||||
@@ -574,6 +742,8 @@ fn create_tray_menu(
|
|||||||
separator,
|
separator,
|
||||||
system_proxy,
|
system_proxy,
|
||||||
tun_mode,
|
tun_mode,
|
||||||
|
separator,
|
||||||
|
lighteweight_mode,
|
||||||
copy_env,
|
copy_env,
|
||||||
open_dir,
|
open_dir,
|
||||||
more,
|
more,
|
||||||
@@ -589,26 +759,77 @@ fn on_menu_event(_: &AppHandle, event: MenuEvent) {
|
|||||||
match event.id.as_ref() {
|
match event.id.as_ref() {
|
||||||
mode @ ("rule_mode" | "global_mode" | "direct_mode") => {
|
mode @ ("rule_mode" | "global_mode" | "direct_mode") => {
|
||||||
let mode = &mode[0..mode.len() - 5];
|
let mode = &mode[0..mode.len() - 5];
|
||||||
println!("change mode to: {}", mode);
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::ProxyMode,
|
||||||
|
true,
|
||||||
|
"Switch Proxy Mode To: {}",
|
||||||
|
mode
|
||||||
|
);
|
||||||
feat::change_clash_mode(mode.into());
|
feat::change_clash_mode(mode.into());
|
||||||
}
|
}
|
||||||
"open_window" => resolve::create_window(),
|
"open_window" => {
|
||||||
"system_proxy" => feat::toggle_system_proxy(),
|
use crate::utils::window_manager::WindowManager;
|
||||||
"tun_mode" => feat::toggle_tun_mode(None),
|
log::info!(target: "app", "托盘菜单点击: 打开窗口");
|
||||||
|
|
||||||
|
if !should_handle_tray_click() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if crate::module::lightweight::is_in_lightweight_mode() {
|
||||||
|
log::info!(target: "app", "当前在轻量模式,正在退出");
|
||||||
|
crate::module::lightweight::exit_lightweight_mode();
|
||||||
|
}
|
||||||
|
let result = WindowManager::show_main_window();
|
||||||
|
log::info!(target: "app", "窗口显示结果: {result:?}");
|
||||||
|
}
|
||||||
|
"system_proxy" => {
|
||||||
|
feat::toggle_system_proxy();
|
||||||
|
}
|
||||||
|
"tun_mode" => {
|
||||||
|
feat::toggle_tun_mode(None);
|
||||||
|
}
|
||||||
"copy_env" => feat::copy_clash_env(),
|
"copy_env" => feat::copy_clash_env(),
|
||||||
"open_app_dir" => crate::log_err!(cmd::open_app_dir()),
|
"open_app_dir" => {
|
||||||
"open_core_dir" => crate::log_err!(cmd::open_core_dir()),
|
let _ = cmd::open_app_dir();
|
||||||
"open_logs_dir" => crate::log_err!(cmd::open_logs_dir()),
|
}
|
||||||
|
"open_core_dir" => {
|
||||||
|
let _ = cmd::open_core_dir();
|
||||||
|
}
|
||||||
|
"open_logs_dir" => {
|
||||||
|
let _ = cmd::open_logs_dir();
|
||||||
|
}
|
||||||
"restart_clash" => feat::restart_clash_core(),
|
"restart_clash" => feat::restart_clash_core(),
|
||||||
"restart_app" => feat::restart_app(),
|
"restart_app" => feat::restart_app(),
|
||||||
|
"entry_lightweight_mode" => {
|
||||||
|
if !should_handle_tray_click() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let was_lightweight = crate::module::lightweight::is_in_lightweight_mode();
|
||||||
|
if was_lightweight {
|
||||||
|
crate::module::lightweight::exit_lightweight_mode();
|
||||||
|
} else {
|
||||||
|
crate::module::lightweight::entry_lightweight_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if was_lightweight {
|
||||||
|
use crate::utils::window_manager::WindowManager;
|
||||||
|
let result = WindowManager::show_main_window();
|
||||||
|
log::info!(target: "app", "退出轻量模式后显示主窗口: {result:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
println!("quit");
|
feat::quit();
|
||||||
feat::quit(Some(0));
|
}
|
||||||
},
|
|
||||||
id if id.starts_with("profiles_") => {
|
id if id.starts_with("profiles_") => {
|
||||||
let profile_index = &id["profiles_".len()..];
|
let profile_index = &id["profiles_".len()..];
|
||||||
feat::toggle_proxy_profile(profile_index.into());
|
feat::toggle_proxy_profile(profile_index.into());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(e) = Tray::global().update_all_states() {
|
||||||
|
log::warn!(target: "app", "更新托盘状态失败: {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,239 +1 @@
|
|||||||
use crate::module::mihomo::Rate;
|
|
||||||
use crate::module::mihomo::MihomoManager;
|
|
||||||
use crate::utils::help::format_bytes_speed;
|
|
||||||
use ab_glyph::FontArc;
|
|
||||||
use anyhow::Result;
|
|
||||||
use futures::Stream;
|
|
||||||
use image::{GenericImageView, Rgba, RgbaImage};
|
|
||||||
use imageproc::drawing::draw_text_mut;
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use std::io::Cursor;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use tokio_tungstenite::tungstenite::http;
|
|
||||||
use tokio_tungstenite::tungstenite::Message;
|
|
||||||
use tungstenite::client::IntoClientRequest;
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct SpeedRate {
|
|
||||||
rate: Arc<Mutex<(Rate, Rate)>>,
|
|
||||||
last_update: Arc<Mutex<std::time::Instant>>,
|
|
||||||
// 移除 base_image,不再缓存原始图像
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SpeedRate {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
rate: Arc::new(Mutex::new((Rate::default(), Rate::default()))),
|
|
||||||
last_update: Arc::new(Mutex::new(std::time::Instant::now())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update_and_check_changed(&self, up: u64, down: u64) -> Option<Rate> {
|
|
||||||
let mut rates = self.rate.lock();
|
|
||||||
let mut last_update = self.last_update.lock();
|
|
||||||
let now = std::time::Instant::now();
|
|
||||||
|
|
||||||
// 限制更新频率为每秒最多2次(500ms)
|
|
||||||
if now.duration_since(*last_update).as_millis() < 500 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let (current, previous) = &mut *rates;
|
|
||||||
|
|
||||||
// 如果速率变化不大(小于10%),则不更新
|
|
||||||
let should_update = {
|
|
||||||
let up_change = (current.up as f64 - up as f64).abs() / (current.up as f64 + 1.0);
|
|
||||||
let down_change =
|
|
||||||
(current.down as f64 - down as f64).abs() / (current.down as f64 + 1.0);
|
|
||||||
up_change > 0.1 || down_change > 0.1
|
|
||||||
};
|
|
||||||
|
|
||||||
if !should_update {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
*previous = current.clone();
|
|
||||||
current.up = up;
|
|
||||||
current.down = down;
|
|
||||||
*last_update = now;
|
|
||||||
|
|
||||||
if previous != current {
|
|
||||||
Some(current.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_curent_rate(&self) -> Option<Rate> {
|
|
||||||
let rates = self.rate.lock();
|
|
||||||
let (current, _) = &*rates;
|
|
||||||
Some(current.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分离图标加载和速率渲染
|
|
||||||
pub fn add_speed_text(icon_bytes: Vec<u8>, rate: Option<Rate>) -> Result<Vec<u8>> {
|
|
||||||
let rate = rate.unwrap_or(Rate { up: 0, down: 0 });
|
|
||||||
|
|
||||||
// 加载原始图标
|
|
||||||
let icon_image = image::load_from_memory(&icon_bytes)?;
|
|
||||||
let (icon_width, icon_height) = (icon_image.width(), icon_image.height());
|
|
||||||
|
|
||||||
// 判断是否为彩色图标
|
|
||||||
let is_colorful =
|
|
||||||
!crate::utils::help::is_monochrome_image_from_bytes(&icon_bytes).unwrap_or(false);
|
|
||||||
|
|
||||||
// 增加文本宽度和间距
|
|
||||||
let text_width = 580; // 文本区域宽度
|
|
||||||
let total_width = icon_width + text_width;
|
|
||||||
|
|
||||||
// 创建新的透明画布
|
|
||||||
let mut combined_image = RgbaImage::new(total_width, icon_height);
|
|
||||||
|
|
||||||
// 将原始图标绘制到新画布的左侧
|
|
||||||
for y in 0..icon_height {
|
|
||||||
for x in 0..icon_width {
|
|
||||||
let pixel = icon_image.get_pixel(x, y);
|
|
||||||
combined_image.put_pixel(x, y, pixel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选择文本颜色
|
|
||||||
let (text_color, shadow_color) = if is_colorful {
|
|
||||||
// 彩色图标使用黑色文本和轻微白色阴影
|
|
||||||
(
|
|
||||||
Rgba([255u8, 255u8, 255u8, 255u8]),
|
|
||||||
Rgba([0u8, 0u8, 0u8, 160u8]),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// 单色图标使用白色文本和轻微黑色阴影
|
|
||||||
(
|
|
||||||
Rgba([255u8, 255u8, 255u8, 255u8]),
|
|
||||||
Rgba([0u8, 0u8, 0u8, 120u8]),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
// 减小字体大小以适应文本区域
|
|
||||||
let font_data = include_bytes!("../../../assets/fonts/SF-Pro.ttf");
|
|
||||||
let font = FontArc::try_from_vec(font_data.to_vec()).unwrap();
|
|
||||||
let font_size = icon_height as f32 * 0.6; // 稍微减小字体
|
|
||||||
let scale = ab_glyph::PxScale::from(font_size);
|
|
||||||
|
|
||||||
// 使用更简洁的速率格式
|
|
||||||
let up_text = format_bytes_speed(rate.up);
|
|
||||||
let down_text = format_bytes_speed(rate.down);
|
|
||||||
|
|
||||||
// 计算文本位置,确保垂直间距合适
|
|
||||||
// 修改文本位置为居右显示
|
|
||||||
let up_text_width = imageproc::drawing::text_size(scale, &font, &up_text).0 as u32;
|
|
||||||
let down_text_width = imageproc::drawing::text_size(scale, &font, &down_text).0 as u32;
|
|
||||||
|
|
||||||
// 计算右对齐的文本位置
|
|
||||||
let up_text_x = total_width - up_text_width;
|
|
||||||
let down_text_x = total_width - down_text_width;
|
|
||||||
|
|
||||||
// 优化垂直位置,使速率显示的高度和上下间距正好等于图标大小
|
|
||||||
let text_height = font_size as i32;
|
|
||||||
let total_text_height = text_height * 2;
|
|
||||||
let up_y = (icon_height as i32 - total_text_height) / 2;
|
|
||||||
let down_y = up_y + text_height;
|
|
||||||
|
|
||||||
// 绘制速率文本(先阴影后文字)
|
|
||||||
let shadow_offset = 1;
|
|
||||||
|
|
||||||
// 绘制上行速率
|
|
||||||
draw_text_mut(
|
|
||||||
&mut combined_image,
|
|
||||||
shadow_color,
|
|
||||||
up_text_x as i32 + shadow_offset,
|
|
||||||
up_y + shadow_offset,
|
|
||||||
scale,
|
|
||||||
&font,
|
|
||||||
&up_text,
|
|
||||||
);
|
|
||||||
draw_text_mut(
|
|
||||||
&mut combined_image,
|
|
||||||
text_color,
|
|
||||||
up_text_x as i32,
|
|
||||||
up_y,
|
|
||||||
scale,
|
|
||||||
&font,
|
|
||||||
&up_text,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 绘制下行速率
|
|
||||||
draw_text_mut(
|
|
||||||
&mut combined_image,
|
|
||||||
shadow_color,
|
|
||||||
down_text_x as i32 + shadow_offset,
|
|
||||||
down_y + shadow_offset,
|
|
||||||
scale,
|
|
||||||
&font,
|
|
||||||
&down_text,
|
|
||||||
);
|
|
||||||
draw_text_mut(
|
|
||||||
&mut combined_image,
|
|
||||||
text_color,
|
|
||||||
down_text_x as i32,
|
|
||||||
down_y,
|
|
||||||
scale,
|
|
||||||
&font,
|
|
||||||
&down_text,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 将结果转换为 PNG 数据
|
|
||||||
let mut bytes = Vec::new();
|
|
||||||
combined_image.write_to(&mut Cursor::new(&mut bytes), image::ImageFormat::Png)?;
|
|
||||||
Ok(bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct Traffic {
|
|
||||||
pub up: u64,
|
|
||||||
pub down: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Traffic {
|
|
||||||
pub async fn get_traffic_stream() -> Result<impl Stream<Item = Result<Traffic, anyhow::Error>>>
|
|
||||||
{
|
|
||||||
use futures::stream::{self, StreamExt};
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
let stream = Box::pin(
|
|
||||||
stream::unfold((), |_| async {
|
|
||||||
loop {
|
|
||||||
let (url, token) = MihomoManager::get_traffic_ws_url();
|
|
||||||
let mut request = url.into_client_request().unwrap();
|
|
||||||
request
|
|
||||||
.headers_mut()
|
|
||||||
.insert(http::header::AUTHORIZATION, token);
|
|
||||||
|
|
||||||
match tokio_tungstenite::connect_async(request).await {
|
|
||||||
Ok((ws_stream, _)) => {
|
|
||||||
log::info!(target: "app", "traffic ws connection established");
|
|
||||||
return Some((
|
|
||||||
ws_stream.map(|msg| {
|
|
||||||
msg.map_err(anyhow::Error::from).and_then(|msg: Message| {
|
|
||||||
let data = msg.into_text()?;
|
|
||||||
let json: serde_json::Value = serde_json::from_str(&data)?;
|
|
||||||
Ok(Traffic {
|
|
||||||
up: json["up"].as_u64().unwrap_or(0),
|
|
||||||
down: json["down"].as_u64().unwrap_or(0),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!(target: "app", "traffic ws connection failed: {e}");
|
|
||||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.flatten(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(stream)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "mihomo_api"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
debug = []
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
reqwest = { version = "0.12.12", features = ["json"] }
|
|
||||||
serde = { version = "1.0.218", features = ["derive"] }
|
|
||||||
serde_json = "1.0.140"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
tokio = { version = "1.43.0", features = ["rt", "macros"] }
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
use reqwest::header::HeaderMap;
|
|
||||||
use serde_json::json;
|
|
||||||
use std::{
|
|
||||||
sync::{Arc, Mutex},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
pub mod model;
|
|
||||||
pub use model::{MihomoData, MihomoManager};
|
|
||||||
|
|
||||||
impl MihomoManager {
|
|
||||||
pub fn new(mihomo_server: String, headers: HeaderMap) -> Self {
|
|
||||||
Self {
|
|
||||||
mihomo_server,
|
|
||||||
data: Arc::new(Mutex::new(MihomoData {
|
|
||||||
proxies: serde_json::Value::Null,
|
|
||||||
providers_proxies: serde_json::Value::Null,
|
|
||||||
})),
|
|
||||||
headers: headers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_proxies(&self, proxies: serde_json::Value) {
|
|
||||||
let mut data = self.data.lock().unwrap();
|
|
||||||
data.proxies = proxies;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_providers_proxies(&self, providers_proxies: serde_json::Value) {
|
|
||||||
let mut data = self.data.lock().unwrap();
|
|
||||||
data.providers_proxies = providers_proxies;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_mihomo_server(&self) -> String {
|
|
||||||
self.mihomo_server.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_proxies(&self) -> serde_json::Value {
|
|
||||||
let data = self.data.lock().unwrap();
|
|
||||||
data.proxies.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_providers_proxies(&self) -> serde_json::Value {
|
|
||||||
let data = self.data.lock().unwrap();
|
|
||||||
data.providers_proxies.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn send_request(
|
|
||||||
&self,
|
|
||||||
method: &str,
|
|
||||||
url: String,
|
|
||||||
data: Option<serde_json::Value>,
|
|
||||||
) -> Result<serde_json::Value, String> {
|
|
||||||
let client_response = reqwest::ClientBuilder::new()
|
|
||||||
.default_headers(self.headers.clone())
|
|
||||||
.no_proxy()
|
|
||||||
.timeout(Duration::from_secs(2))
|
|
||||||
.build()
|
|
||||||
.map_err(|e| e.to_string())?
|
|
||||||
.request(
|
|
||||||
match method {
|
|
||||||
"GET" => reqwest::Method::GET,
|
|
||||||
"PUT" => reqwest::Method::PUT,
|
|
||||||
"POST" => reqwest::Method::POST,
|
|
||||||
"PATCH" => reqwest::Method::PATCH,
|
|
||||||
_ => reqwest::Method::GET,
|
|
||||||
},
|
|
||||||
&url,
|
|
||||||
)
|
|
||||||
.json(&data.unwrap_or(json!({})))
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
|
|
||||||
let response = if method != "PUT" {
|
|
||||||
client_response.json::<serde_json::Value>().await
|
|
||||||
} else {
|
|
||||||
client_response.text().await.map(|text| json!(text))
|
|
||||||
}
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn refresh_proxies(&self) -> Result<&Self, String> {
|
|
||||||
let url = format!("{}/proxies", self.mihomo_server);
|
|
||||||
let proxies = self.send_request("GET", url, None).await?;
|
|
||||||
self.update_proxies(proxies);
|
|
||||||
Ok(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn refresh_providers_proxies(&self) -> Result<&Self, String> {
|
|
||||||
let url = format!("{}/providers/proxies", self.mihomo_server);
|
|
||||||
let providers_proxies = self.send_request("GET", url, None).await?;
|
|
||||||
self.update_providers_proxies(providers_proxies);
|
|
||||||
Ok(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MihomoManager {
|
|
||||||
pub async fn put_configs_force(&self, clash_config_path: &str) -> Result<(), String> {
|
|
||||||
let url = format!("{}/configs?force=true", self.mihomo_server);
|
|
||||||
let payload = serde_json::json!({
|
|
||||||
"path": clash_config_path,
|
|
||||||
});
|
|
||||||
let _response = self.send_request("PUT", url, Some(payload)).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn patch_configs(&self, config: serde_json::Value) -> Result<(), String> {
|
|
||||||
let url = format!("{}/configs", self.mihomo_server);
|
|
||||||
let response = self.send_request("PATCH", url, Some(config)).await?;
|
|
||||||
if response["code"] == 204 {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(response["message"]
|
|
||||||
.as_str()
|
|
||||||
.unwrap_or("unknown error")
|
|
||||||
.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn test_proxy_delay(
|
|
||||||
&self,
|
|
||||||
name: &str,
|
|
||||||
test_url: Option<String>,
|
|
||||||
timeout: i32,
|
|
||||||
) -> Result<serde_json::Value, String> {
|
|
||||||
let test_url = test_url.unwrap_or("http://cp.cloudflare.com/generate_204".to_string());
|
|
||||||
let url = format!(
|
|
||||||
"{}/proxies/{}/delay?url={}&timeout={}",
|
|
||||||
self.mihomo_server, name, test_url, timeout
|
|
||||||
);
|
|
||||||
let response = self.send_request("GET", url, None).await?;
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use reqwest::header::HeaderMap;
|
|
||||||
|
|
||||||
pub struct MihomoData {
|
|
||||||
pub(crate) proxies: serde_json::Value,
|
|
||||||
pub(crate) providers_proxies: serde_json::Value,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct MihomoManager {
|
|
||||||
pub(crate) mihomo_server: String,
|
|
||||||
pub(crate) data: Arc<Mutex<MihomoData>>,
|
|
||||||
pub(crate) headers: HeaderMap,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
impl Drop for MihomoData {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
println!("Dropping MihomoData");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
impl Drop for MihomoManager {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
println!("Dropping MihomoManager");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
use mihomo_api;
|
|
||||||
use reqwest::header::HeaderMap;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_mihomo_manager_init() {
|
|
||||||
let manager = mihomo_api::MihomoManager::new("url".into(), HeaderMap::new());
|
|
||||||
assert_eq!(manager.get_proxies(), serde_json::Value::Null);
|
|
||||||
assert_eq!(manager.get_providers_proxies(), serde_json::Value::Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_refresh_proxies() {
|
|
||||||
let manager = mihomo_api::MihomoManager::new("http://127.0.0.1:9097".into(), HeaderMap::new());
|
|
||||||
let manager = manager.refresh_proxies().await.unwrap();
|
|
||||||
let proxies = manager.get_proxies();
|
|
||||||
let providers = manager.get_providers_proxies();
|
|
||||||
assert_ne!(proxies, serde_json::Value::Null);
|
|
||||||
assert_eq!(providers, serde_json::Value::Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_refresh_providers_proxies() {
|
|
||||||
let manager = mihomo_api::MihomoManager::new("http://127.0.0.1:9097".into(), HeaderMap::new());
|
|
||||||
let manager = manager.refresh_providers_proxies().await.unwrap();
|
|
||||||
let proxies = manager.get_proxies();
|
|
||||||
let providers = manager.get_providers_proxies();
|
|
||||||
assert_eq!(proxies, serde_json::Value::Null);
|
|
||||||
assert_ne!(providers, serde_json::Value::Null);
|
|
||||||
}
|
|
||||||
@@ -5,17 +5,10 @@ mod script;
|
|||||||
pub mod seq;
|
pub mod seq;
|
||||||
mod tun;
|
mod tun;
|
||||||
|
|
||||||
use self::chain::*;
|
use self::{chain::*, field::*, merge::*, script::*, seq::*, tun::*};
|
||||||
use self::field::*;
|
use crate::{config::Config, utils::tmpl};
|
||||||
use self::merge::*;
|
|
||||||
use self::script::*;
|
|
||||||
use self::seq::*;
|
|
||||||
use self::tun::*;
|
|
||||||
use crate::config::Config;
|
|
||||||
use crate::utils::tmpl;
|
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
type ResultLog = Vec<(String, String)>;
|
type ResultLog = Vec<(String, String)>;
|
||||||
|
|
||||||
@@ -29,7 +22,7 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
|||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
let verge = verge.latest();
|
let verge = verge.latest();
|
||||||
(
|
(
|
||||||
verge.clash_core.clone(),
|
Some(verge.get_valid_clash_core()),
|
||||||
verge.enable_tun_mode.unwrap_or(false),
|
verge.enable_tun_mode.unwrap_or(false),
|
||||||
verge.enable_builtin_enhanced.unwrap_or(true),
|
verge.enable_builtin_enhanced.unwrap_or(true),
|
||||||
verge.verge_socks_enabled.unwrap_or(false),
|
verge.verge_socks_enabled.unwrap_or(false),
|
||||||
@@ -268,16 +261,29 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
|||||||
use crate::utils::dirs;
|
use crate::utils::dirs;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
// 尝试读取dns_config.yaml
|
|
||||||
if let Ok(app_dir) = dirs::app_home_dir() {
|
if let Ok(app_dir) = dirs::app_home_dir() {
|
||||||
let dns_path = app_dir.join("dns_config.yaml");
|
let dns_path = app_dir.join("dns_config.yaml");
|
||||||
|
|
||||||
if dns_path.exists() {
|
if dns_path.exists() {
|
||||||
if let Ok(dns_yaml) = fs::read_to_string(&dns_path) {
|
if let Ok(dns_yaml) = fs::read_to_string(&dns_path) {
|
||||||
if let Ok(dns_config) = serde_yaml::from_str::<serde_yaml::Mapping>(&dns_yaml) {
|
if let Ok(dns_config) = serde_yaml::from_str::<serde_yaml::Mapping>(&dns_yaml) {
|
||||||
// 将DNS配置合并到最终配置中
|
// 处理hosts配置
|
||||||
config.insert("dns".into(), dns_config.into());
|
if let Some(hosts_value) = dns_config.get("hosts") {
|
||||||
log::info!(target: "app", "apply dns_config.yaml");
|
if hosts_value.is_mapping() {
|
||||||
|
config.insert("hosts".into(), hosts_value.clone());
|
||||||
|
log::info!(target: "app", "apply hosts configuration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(dns_value) = dns_config.get("dns") {
|
||||||
|
if let Some(dns_mapping) = dns_value.as_mapping() {
|
||||||
|
config.insert("dns".into(), dns_mapping.clone().into());
|
||||||
|
log::info!(target: "app", "apply dns_config.yaml (dns section)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
config.insert("dns".into(), dns_config.into());
|
||||||
|
log::info!(target: "app", "apply dns_config.yaml");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,37 +33,40 @@ pub fn use_script(
|
|||||||
}
|
}
|
||||||
let _ = context.eval(Source::from_bytes(
|
let _ = context.eval(Source::from_bytes(
|
||||||
r#"var console = Object.freeze({
|
r#"var console = Object.freeze({
|
||||||
log(data){__verge_log__("log",JSON.stringify(data))},
|
log(data){__verge_log__("log",JSON.stringify(data, null, 2))},
|
||||||
info(data){__verge_log__("info",JSON.stringify(data))},
|
info(data){__verge_log__("info",JSON.stringify(data, null, 2))},
|
||||||
error(data){__verge_log__("error",JSON.stringify(data))},
|
error(data){__verge_log__("error",JSON.stringify(data, null, 2))},
|
||||||
debug(data){__verge_log__("debug",JSON.stringify(data))},
|
debug(data){__verge_log__("debug",JSON.stringify(data, null, 2))},
|
||||||
|
warn(data){__verge_log__("warn",JSON.stringify(data, null, 2))},
|
||||||
|
table(data){__verge_log__("table",JSON.stringify(data, null, 2))},
|
||||||
});"#,
|
});"#,
|
||||||
));
|
));
|
||||||
|
|
||||||
let config = use_lowercase(config.clone());
|
let config = use_lowercase(config.clone());
|
||||||
let config_str = serde_json::to_string(&config)?;
|
let config_str = serde_json::to_string(&config)?;
|
||||||
|
|
||||||
|
// 仅处理 name 参数中的特殊字符
|
||||||
|
let safe_name = escape_js_string_for_single_quote(&name);
|
||||||
|
|
||||||
let code = format!(
|
let code = format!(
|
||||||
r#"try{{
|
r#"try{{
|
||||||
{script};
|
{script};
|
||||||
JSON.stringify(main({config_str},'{name}')||'')
|
JSON.stringify(main({config_str},'{safe_name}')||'')
|
||||||
}} catch(err) {{
|
}} catch(err) {{
|
||||||
`__error_flag__ ${{err.toString()}}`
|
`__error_flag__ ${{err.toString()}}`
|
||||||
}}"#
|
}}"#
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(result) = context.eval(Source::from_bytes(code.as_str())) {
|
if let Ok(result) = context.eval(Source::from_bytes(code.as_str())) {
|
||||||
if !result.is_string() {
|
if !result.is_string() {
|
||||||
anyhow::bail!("main function should return object");
|
anyhow::bail!("main function should return object");
|
||||||
}
|
}
|
||||||
let result = result.to_string(&mut context).unwrap();
|
let result = result.to_string(&mut context).unwrap();
|
||||||
let result = result.to_std_string().unwrap();
|
let result = result.to_std_string().unwrap();
|
||||||
if result.starts_with("__error_flag__") {
|
|
||||||
anyhow::bail!(result[15..].to_owned());
|
// 直接解析JSON结果,不做其他解析
|
||||||
}
|
let res: Result<Mapping, Error> = parse_json_safely(&result);
|
||||||
if result == "\"\"" {
|
|
||||||
anyhow::bail!("main function should return object");
|
|
||||||
}
|
|
||||||
let res: Result<Mapping, Error> = Ok(serde_json::from_str::<Mapping>(result.as_str())?);
|
|
||||||
let mut out = outputs.lock().unwrap();
|
let mut out = outputs.lock().unwrap();
|
||||||
match res {
|
match res {
|
||||||
Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
||||||
@@ -77,6 +80,27 @@ pub fn use_script(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_json_safely(json_str: &str) -> Result<Mapping, Error> {
|
||||||
|
let json_str = strip_outer_quotes(json_str);
|
||||||
|
|
||||||
|
Ok(serde_json::from_str::<Mapping>(json_str)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除字符串外层的引号
|
||||||
|
fn strip_outer_quotes(s: &str) -> &str {
|
||||||
|
let s = s.trim();
|
||||||
|
if (s.starts_with('"') && s.ends_with('"')) || (s.starts_with('\'') && s.ends_with('\'')) {
|
||||||
|
&s[1..s.len() - 1]
|
||||||
|
} else {
|
||||||
|
s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转义单引号和反斜杠,用于单引号包裹的JavaScript字符串
|
||||||
|
fn escape_js_string_for_single_quote(s: &str) -> String {
|
||||||
|
s.replace('\\', "\\\\").replace('\'', "\\'")
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_script() {
|
fn test_script() {
|
||||||
let script = r#"
|
let script = r#"
|
||||||
@@ -104,6 +128,31 @@ fn test_script() {
|
|||||||
let (config, results) = use_script(script.into(), config, "".to_string()).unwrap();
|
let (config, results) = use_script(script.into(), config, "".to_string()).unwrap();
|
||||||
|
|
||||||
let _ = serde_yaml::to_string(&config).unwrap();
|
let _ = serde_yaml::to_string(&config).unwrap();
|
||||||
|
let yaml_config_size = std::mem::size_of_val(&config);
|
||||||
|
dbg!(yaml_config_size);
|
||||||
|
let box_yaml_config_size = std::mem::size_of_val(&Box::new(config));
|
||||||
|
dbg!(box_yaml_config_size);
|
||||||
dbg!(results);
|
dbg!(results);
|
||||||
|
assert!(box_yaml_config_size < yaml_config_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试特殊字符转义功能
|
||||||
|
#[test]
|
||||||
|
fn test_escape_unescape() {
|
||||||
|
let test_string = r#"Hello "World"!\nThis is a test with \u00A9 copyright symbol."#;
|
||||||
|
let escaped = escape_js_string_for_single_quote(test_string);
|
||||||
|
println!("Original: {}", test_string);
|
||||||
|
println!("Escaped: {}", escaped);
|
||||||
|
|
||||||
|
let json_str = r#"{"key":"value","nested":{"key":"value"}}"#;
|
||||||
|
let parsed = parse_json_safely(json_str).unwrap();
|
||||||
|
|
||||||
|
assert!(parsed.contains_key("key"));
|
||||||
|
assert!(parsed.contains_key("nested"));
|
||||||
|
|
||||||
|
let quoted_json_str = r#""{"key":"value","nested":{"key":"value"}}""#;
|
||||||
|
let parsed_quoted = parse_json_safely(quoted_json_str).unwrap();
|
||||||
|
|
||||||
|
assert!(parsed_quoted.contains_key("key"));
|
||||||
|
assert!(parsed_quoted.contains_key("nested"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,16 +121,32 @@ proxy-groups:
|
|||||||
let proxies = config.get("proxies").unwrap().as_sequence().unwrap();
|
let proxies = config.get("proxies").unwrap().as_sequence().unwrap();
|
||||||
assert_eq!(proxies.len(), 1);
|
assert_eq!(proxies.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
proxies[0].as_mapping().unwrap().get("name").unwrap().as_str().unwrap(),
|
proxies[0]
|
||||||
|
.as_mapping()
|
||||||
|
.unwrap()
|
||||||
|
.get("name")
|
||||||
|
.unwrap()
|
||||||
|
.as_str()
|
||||||
|
.unwrap(),
|
||||||
"proxy2"
|
"proxy2"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if proxy1 is removed from all groups
|
// Check if proxy1 is removed from all groups
|
||||||
let groups = config.get("proxy-groups").unwrap().as_sequence().unwrap();
|
let groups = config.get("proxy-groups").unwrap().as_sequence().unwrap();
|
||||||
let group1_proxies = groups[0].as_mapping().unwrap()
|
let group1_proxies = groups[0]
|
||||||
.get("proxies").unwrap().as_sequence().unwrap();
|
.as_mapping()
|
||||||
let group2_proxies = groups[1].as_mapping().unwrap()
|
.unwrap()
|
||||||
.get("proxies").unwrap().as_sequence().unwrap();
|
.get("proxies")
|
||||||
|
.unwrap()
|
||||||
|
.as_sequence()
|
||||||
|
.unwrap();
|
||||||
|
let group2_proxies = groups[1]
|
||||||
|
.as_mapping()
|
||||||
|
.unwrap()
|
||||||
|
.get("proxies")
|
||||||
|
.unwrap()
|
||||||
|
.as_sequence()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(group1_proxies.len(), 1);
|
assert_eq!(group1_proxies.len(), 1);
|
||||||
assert_eq!(group1_proxies[0].as_str().unwrap(), "proxy2");
|
assert_eq!(group1_proxies[0].as_str().unwrap(), "proxy2");
|
||||||
|
|||||||