|
1 | 1 | window.runtime = {
|
2 | 2 | WindowSetSystemDefaultTheme() {},
|
3 |
| - EventsOnMultiple(id, fn) { |
4 |
| - console.log(id, fn) |
5 |
| - }, |
| 3 | + EventsOnMultiple(id, fn) {}, |
6 | 4 | WindowIsMaximised() {},
|
7 | 5 | WindowIsMinimised() {},
|
8 |
| -} |
9 |
| - |
10 |
| -const events = { |
11 |
| - data: [], |
12 |
| - on() {}, |
13 |
| -} |
| 6 | +}; |
14 | 7 |
|
15 | 8 | window.go = {
|
16 | 9 | bridge: {
|
17 | 10 | App: {
|
18 | 11 | UpdateTray() {},
|
19 | 12 | UpdateTrayMenus() {},
|
20 | 13 | GetEnv() {
|
21 |
| - return { os: 'darwin' } |
| 14 | + return { os: "darwin" }; |
22 | 15 | },
|
23 | 16 | Readdir() {
|
24 |
| - return { flag: true, data: '' } |
| 17 | + return { flag: true, data: "" }; |
25 | 18 | },
|
26 | 19 | IsStartup() {
|
27 |
| - return true |
| 20 | + return true; |
| 21 | + }, |
| 22 | + async Requests(method, url, headers, body, options) { |
| 23 | + const res = await fetch(url, { |
| 24 | + method, |
| 25 | + headers, |
| 26 | + body: ["HEAD", "GET"].includes(method) ? null : JSON.stringify(body), |
| 27 | + }); |
| 28 | + let respBody; |
| 29 | + if (res.headers["Content-Type"]?.includes("application/json")) { |
| 30 | + respBody = await res.json(); |
| 31 | + } else { |
| 32 | + respBody = await res.text(); |
| 33 | + } |
| 34 | + return { |
| 35 | + flag: true, |
| 36 | + status: res.status, |
| 37 | + headers: res.headers, |
| 38 | + body: respBody, |
| 39 | + }; |
28 | 40 | },
|
29 |
| - Requests() {}, |
30 | 41 | Writefile(path, content) {
|
31 |
| - localStorage.setItem(path, content) |
32 |
| - return { flag: true } |
| 42 | + path = window.location.pathname + path; |
| 43 | + localStorage.setItem(path, content); |
| 44 | + return { flag: true }; |
33 | 45 | },
|
34 | 46 | Readfile(path) {
|
35 |
| - return { flag: true, data: localStorage.getItem(path) } |
| 47 | + path = window.location.pathname + path; |
| 48 | + return { flag: true, data: localStorage.getItem(path) }; |
36 | 49 | },
|
37 | 50 | ExecBackground(path, args, out, end) {
|
38 |
| - return { flag: true, data: 999 } |
| 51 | + return { flag: true, data: 999 }; |
39 | 52 | },
|
40 | 53 | },
|
41 | 54 | },
|
42 |
| -} |
| 55 | +}; |
0 commit comments