Skip to content

Commit cf62b36

Browse files
committed
feat: support to set the server arguments on desktop
1 parent 59e3ce9 commit cf62b36

File tree

3 files changed

+54
-14
lines changed

3 files changed

+54
-14
lines changed

console/atest-desktop/index.html

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,41 @@
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+
<table>
16+
<tr>
17+
<td>
18+
<label for="port">Port</label>
19+
</td>
20+
<td>
21+
<input name="port" id="port" type="text"/>
22+
</td>
23+
</tr>
24+
<tr>
25+
<td>
26+
<label for="extension-registry">Extension Registry</label>
27+
</td>
28+
<td>
29+
<input name="extension-registry" id="extension-registry" type="text"/>
30+
</td>
31+
</tr>
32+
<tr>
33+
<td>Log</td>
34+
<td>
35+
<button type="button" id="open-log-file">Open Log File</button>
36+
</td>
37+
</tr>
38+
<tr>
39+
<td>
40+
<button type="button" id="action">Start</button>
41+
</td>
42+
<td>
43+
<button type="button" id="open-server-page">Open Server Page</button>
44+
</td>
45+
</tr>
46+
</table>
2547
</div>
2648
</div>
2749

@@ -63,9 +85,11 @@
6385
window.setInterval(loadServerStatus, 2000)
6486

6587
const portInput = document.getElementById('port');
88+
const extensionRegistry = document.getElementById('extension-registry');
6689
(async function() {
6790
portInput.value = await window.electronAPI.getPort()
91+
extensionRegistry.value = await window.electronAPI.getExtensionRegistry()
6892
})();
6993
</script>
7094
</body>
71-
</html>
95+
</html>

console/atest-desktop/main.js

Lines changed: 15 additions & 2 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,6 +117,9 @@ menu.append(new MenuItem({
117117
Menu.setApplicationMenu(menu)
118118

119119
let serverProcess;
120+
let serverPort;
121+
let setExtensionRegistry = "ghcr.io";
122+
120123
// This method will be called when Electron has finished
121124
// initialization and is ready to create browser windows.
122125
// Some APIs can only be used after this event occurs.
@@ -129,6 +132,15 @@ app.whenReady().then(() => {
129132
ipcMain.on('control', (e, okCallback, errCallback) => {
130133
server.control(okCallback, errCallback)
131134
})
135+
ipcMain.handle('setPort', (port) => {
136+
serverPort = port;
137+
})
138+
ipcMain.handle('setExtensionRegistry', (registry) => {
139+
setExtensionRegistry = registry
140+
})
141+
ipcMain.handle('getExtensionRegistry', () => {
142+
return setExtensionRegistry
143+
})
132144
ipcMain.handle('getHomePage', server.getHomePage)
133145
ipcMain.handle('getPort', () => {
134146
return server.getPort()
@@ -181,6 +193,7 @@ const startServer = () => {
181193
"server",
182194
"--http-port", server.getPort(),
183195
"--port=0",
196+
`--extension-registry=${setExtensionRegistry}`,
184197
"--local-storage", path.join(homeData, "*.yaml")
185198
])
186199
serverProcess.stdout.on('data', (data) => {
@@ -222,4 +235,4 @@ function getLogLevel() {
222235
}
223236

224237
// 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.
238+
// code. You can also put them in separate files and require them here.

console/atest-desktop/preload.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
3636
control: (okCallback, errCallback) => ipcRenderer.send('control', okCallback, errCallback),
3737
getHomePage: () => ipcRenderer.invoke('getHomePage'),
3838
getPort: () => ipcRenderer.invoke('getPort'),
39+
setPort: (port) => ipcRenderer.send('setPort', port),
40+
setExtensionRegistry: (registry) => ipcRenderer.send('setExtensionRegistry', registry),
41+
getExtensionRegistry: () => ipcRenderer.invoke('getExtensionRegistry'),
3942
getHealthzUrl: () => ipcRenderer.invoke('getHealthzUrl'),
4043
})

0 commit comments

Comments
 (0)