Skip to content

Commit f755642

Browse files
Merge branch 'LinuxSuRen:master' into master
2 parents 31a53bc + 7f9e6b1 commit f755642

File tree

15 files changed

+3898
-2890
lines changed

15 files changed

+3898
-2890
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ updates:
1313
directory: "/console/atest-ui" # Location of package manifests
1414
schedule:
1515
interval: "weekly"
16+
- package-ecosystem: "npm" # See documentation for possible values
17+
directory: "/console/atest-desktop" # Location of package manifests
18+
schedule:
19+
interval: "weekly"

console/atest-desktop/index.html

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,51 @@
99
</head>
1010
<body>
1111

12-
<div style="margin: 5px">
12+
<div style="margin: 5px; display: flex; justify-content: center">
1313
<div>
1414
<div>Server Status</div>
15-
<button type="button" id="action">Start</button>
16-
<button type="button" id="open-server-page">Open Server Page</button>
17-
<div>
18-
<span>Port:</span><input name="port" id="port" type="text"/>
19-
</div>
20-
</div>
21-
22-
<div>
23-
<div>Log</div>
24-
<button type="button" id="open-log-file">Open Log File</button>
15+
<div id="address"></div>
16+
<table>
17+
<tr>
18+
<td>
19+
<label for="port">Port</label>
20+
</td>
21+
<td>
22+
<input name="port" id="port" type="text"/>
23+
</td>
24+
</tr>
25+
<tr>
26+
<td>
27+
<label for="extension-registry">Extension Registry</label>
28+
</td>
29+
<td>
30+
<input name="extension-registry" id="extension-registry" type="text"/>
31+
</td>
32+
</tr>
33+
<tr>
34+
<td>
35+
<label for="download-timeout">Download timeout</label>
36+
</td>
37+
<td>
38+
<input name="download-timeout" id="download-timeout" type="text"/>
39+
</td>
40+
</tr>
41+
<tr>
42+
<td>Log</td>
43+
<td>
44+
<button type="button" id="open-log-file">Open Log File</button>
45+
</td>
46+
</tr>
47+
<tr>
48+
<td>
49+
<button type="button" id="action">Start</button>
50+
</td>
51+
<td>
52+
<button type="button" id="open-server-page">Open Server Page</button>
53+
<button type="button" id="open-from-browser">Open from Browser</button>
54+
</td>
55+
</tr>
56+
</table>
2557
</div>
2658
</div>
2759

@@ -39,6 +71,15 @@
3971
}
4072
})
4173

74+
document.getElementById('open-from-browser').addEventListener('click', async (e) => {
75+
const address = await window.electronAPI.getHomePage();
76+
if (address) {
77+
await window.electronAPI.openWithExternalBrowser(address);
78+
} else {
79+
alert('Please start the server first!');
80+
}
81+
})
82+
4283
const openServerBut = document.getElementById('open-server-page');
4384
openServerBut.addEventListener('click', async (e) => {
4485
window.location = await window.electronAPI.getHomePage()
@@ -63,9 +104,27 @@
63104
window.setInterval(loadServerStatus, 2000)
64105

65106
const portInput = document.getElementById('port');
107+
portInput.addEventListener("input", function(e) {
108+
window.electronAPI.setPort(portInput.value)
109+
});
110+
111+
const extensionRegistry = document.getElementById('extension-registry');
112+
extensionRegistry.addEventListener("input", function(e) {
113+
window.electronAPI.setExtensionRegistry(extensionRegistry.value)
114+
});
115+
116+
const downloadTimeout = document.getElementById('download-timeout');
117+
downloadTimeout.addEventListener("input", function(e) {
118+
window.electronAPI.setDownloadTimeout(downloadTimeout.value)
119+
});
120+
66121
(async function() {
67122
portInput.value = await window.electronAPI.getPort()
123+
extensionRegistry.value = await window.electronAPI.getExtensionRegistry()
124+
downloadTimeout.value = await window.electronAPI.getDownloadTimeout()
125+
126+
document.getElementById('address').innerText = await window.electronAPI.getHomePage();
68127
})();
69128
</script>
70129
</body>
71-
</html>
130+
</html>

console/atest-desktop/main.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2024 API Testing Authors.
2+
Copyright 2024-2025 API Testing Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -117,22 +117,44 @@ menu.append(new MenuItem({
117117
Menu.setApplicationMenu(menu)
118118

119119
let serverProcess;
120+
let serverPort = 7788;
121+
let extensionRegistry = "ghcr.io";
122+
let downloadTimeout = "1m";
123+
120124
// This method will be called when Electron has finished
121125
// initialization and is ready to create browser windows.
122126
// Some APIs can only be used after this event occurs.
123127
app.whenReady().then(() => {
124128
ipcMain.on('openLogDir', () => {
125129
shell.openExternal('file://' + server.getLogfile())
126130
})
131+
ipcMain.handle('openWithExternalBrowser', (e, address) => {
132+
shell.openExternal(address)
133+
})
127134
ipcMain.on('startServer', startServer)
128135
ipcMain.on('stopServer', stopServer)
129136
ipcMain.on('control', (e, okCallback, errCallback) => {
130137
server.control(okCallback, errCallback)
131138
})
132-
ipcMain.handle('getHomePage', server.getHomePage)
133139
ipcMain.handle('getPort', () => {
134-
return server.getPort()
140+
return serverPort
141+
})
142+
ipcMain.handle('setPort', (e, port) => {
143+
serverPort = port;
144+
})
145+
ipcMain.handle('getExtensionRegistry', () => {
146+
return extensionRegistry
135147
})
148+
ipcMain.handle('setExtensionRegistry', (e, registry) => {
149+
extensionRegistry = registry
150+
})
151+
ipcMain.handle('getDownloadTimeout', () => {
152+
return downloadTimeout
153+
})
154+
ipcMain.handle('setDownloadTimeout', (e, timeout) => {
155+
downloadTimeout = timeout
156+
})
157+
ipcMain.handle('getHomePage', server.getHomePage)
136158
ipcMain.handle('getHealthzUrl', server.getHealthzUrl)
137159

138160
startServer()
@@ -179,8 +201,10 @@ const startServer = () => {
179201

180202
serverProcess = spawn(atestFromHome, [
181203
"server",
182-
"--http-port", server.getPort(),
204+
`--http-port=${serverPort}`,
183205
"--port=0",
206+
`--download-timeout=${downloadTimeout}`,
207+
`--extension-registry=${extensionRegistry}`,
184208
"--local-storage", path.join(homeData, "*.yaml")
185209
])
186210
serverProcess.stdout.on('data', (data) => {
@@ -222,4 +246,4 @@ function getLogLevel() {
222246
}
223247

224248
// In this file you can include the rest of your app's specific main process
225-
// code. You can also put them in separate files and require them here.
249+
// code. You can also put them in separate files and require them here.

0 commit comments

Comments
 (0)