Skip to content

Commit e325adf

Browse files
committed
Add new methods to fakeruntime.js for improved app functionality and error handling
1 parent e86129a commit e325adf

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

public/fakeruntime.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,44 @@ window.runtime = {
33
EventsOnMultiple(id, fn) {},
44
WindowIsMaximised() {},
55
WindowIsMinimised() {},
6+
WindowReloadApp() {
7+
window.location.reload();
8+
},
9+
WindowSetSize() {},
10+
BrowserOpenURL(url) {
11+
if (url.startsWith("http")) {
12+
window.open(url, "_blank");
13+
return;
14+
}
15+
url = url.replace(window.location.pathname, "");
16+
const { data } = window.go.bridge.App.Readfile(url);
17+
const link = URL.createObjectURL(
18+
new Blob([data], { type: "text/plain; charset=utf-8" })
19+
);
20+
window.open(link, "_blank");
21+
},
22+
ClipboardSetText(msg) {
23+
navigator.clipboard.writeText(msg);
24+
return { flag: true };
25+
},
626
};
727

828
window.go = {
929
bridge: {
1030
App: {
31+
RestartApp() {
32+
Plugins.message.info("Web端不支持");
33+
},
34+
GetInterfaces() {
35+
return { flag: true, data: "eth0|WLAN0" };
36+
},
1137
UpdateTray() {},
1238
UpdateTrayMenus() {},
1339
GetEnv() {
14-
return { os: "darwin" };
40+
return {
41+
os: "darwin",
42+
basePath: window.location.pathname.slice(0, -1),
43+
};
1544
},
1645
Readdir() {
1746
return { flag: true, data: "" };
@@ -47,8 +76,17 @@ window.go = {
4776
path = window.location.pathname + path;
4877
return { flag: true, data: localStorage.getItem(path) };
4978
},
79+
Exec() {
80+
return { flag: false, data: "Web端不支持" };
81+
},
5082
ExecBackground(path, args, out, end) {
51-
return { flag: true, data: 999 };
83+
return { flag: false, data: "Web端不支持" };
84+
},
85+
ValidateCron() {
86+
return { flag: true, data: "" };
87+
},
88+
AddScheduledTask() {
89+
return { flag: false, data: "Web端不支持" };
5290
},
5391
},
5492
},

0 commit comments

Comments
 (0)