Skip to content

Commit f79edb9

Browse files
committed
Add new methods and enhance Requests in fakeruntime.js for improved functionality
1 parent e325adf commit f79edb9

File tree

1 file changed

+62
-8
lines changed

1 file changed

+62
-8
lines changed

public/fakeruntime.js

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ window.runtime = {
33
EventsOnMultiple(id, fn) {},
44
WindowIsMaximised() {},
55
WindowIsMinimised() {},
6+
EventsOff() {},
67
WindowReloadApp() {
78
window.location.reload();
89
},
@@ -39,6 +40,7 @@ window.go = {
3940
GetEnv() {
4041
return {
4142
os: "darwin",
43+
arch: "arm64",
4244
basePath: window.location.pathname.slice(0, -1),
4345
};
4446
},
@@ -49,21 +51,33 @@ window.go = {
4951
return true;
5052
},
5153
async Requests(method, url, headers, body, options) {
54+
if (
55+
url ==
56+
"https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt"
57+
) {
58+
return {
59+
flag: true,
60+
status: 200,
61+
headers: {},
62+
body: "alpha-xxxxxxx",
63+
};
64+
}
5265
const res = await fetch(url, {
5366
method,
5467
headers,
5568
body: ["HEAD", "GET"].includes(method) ? null : JSON.stringify(body),
5669
});
57-
let respBody;
58-
if (res.headers["Content-Type"]?.includes("application/json")) {
59-
respBody = await res.json();
60-
} else {
61-
respBody = await res.text();
62-
}
70+
let respBody = await res.text();
71+
6372
return {
6473
flag: true,
6574
status: res.status,
66-
headers: res.headers,
75+
headers: {
76+
...res.headers,
77+
...(url.includes("api.github.com")
78+
? { "Content-Type": "application/json" }
79+
: {}),
80+
},
6781
body: respBody,
6882
};
6983
},
@@ -76,7 +90,44 @@ window.go = {
7690
path = window.location.pathname + path;
7791
return { flag: true, data: localStorage.getItem(path) };
7892
},
79-
Exec() {
93+
Removefile() {},
94+
Exec(path, args) {
95+
if (path == "bash") {
96+
return { flag: true, data: "" };
97+
}
98+
99+
if (path == "data/mihomo/mihomo-darwin-arm64" && args.includes("-v")) {
100+
return {
101+
flag: true,
102+
data: "Mihomo Meta v1.19.1 darwin arm64 with go1.23.4 Tue Dec 31 16:58:41 UTC 2024\nUse tags: with_gvisor",
103+
};
104+
}
105+
if (
106+
path == "data/mihomo/mihomo-darwin-arm64-alpha" &&
107+
args.includes("-v")
108+
) {
109+
return {
110+
flag: true,
111+
data: "Mihomo Meta alpha-xxxxxxx darwin arm64 with go1.23.4 Tue Jan 7 00:00:00 UTC 2025\nUse tags: with_gvisor",
112+
};
113+
}
114+
115+
if (path == "data/sing-box/sing-box" && args.includes("version")) {
116+
return {
117+
flag: true,
118+
data: "sing-box version 1.10.7\n\nEnvironment: go1.23.4 darwin/arm64\nTags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api\nRevision: 253b41936ecd6ae17948d49d9c510d7100830927\nCGO: disabled",
119+
};
120+
}
121+
122+
if (
123+
path == "data/sing-box/sing-box-latest" &&
124+
args.includes("version")
125+
) {
126+
return {
127+
flag: true,
128+
data: "sing-box version 1.11.0-beta.24\n\nEnvironment: go1.23.4 windows/amd64\nTags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api\nRevision: 8cc7734a921bf6c24d52d3b8dc40a553a88d7f5a\nCGO: disabled",
129+
};
130+
}
80131
return { flag: false, data: "Web端不支持" };
81132
},
82133
ExecBackground(path, args, out, end) {
@@ -88,6 +139,9 @@ window.go = {
88139
AddScheduledTask() {
89140
return { flag: false, data: "Web端不支持" };
90141
},
142+
AbsolutePath(path) {
143+
return { flag: true, data: path };
144+
},
91145
},
92146
},
93147
};

0 commit comments

Comments
 (0)