feat(api-server): Add HTTPS support and custom certificate configuration (#3874)

This commit is contained in:
MohanadAhmed
2025-12-19 09:10:12 +02:00
committed by GitHub
parent b1d2112bfc
commit 58a19cdaa2
5 changed files with 103 additions and 11 deletions

View File

@ -1,3 +1,4 @@
import { dialog } from 'electron';
import prompt from 'custom-electron-prompt';
import { t } from '@/i18n';
@ -93,5 +94,51 @@ export const onMenu = async ({
},
],
},
{
label: t('plugins.api-server.menu.https.label'),
type: 'submenu',
submenu: [
{
label: t('plugins.api-server.menu.https.submenu.enable-https.label'),
type: 'checkbox',
checked: config.useHttps,
click(menuItem) {
setConfig({ ...config, useHttps: menuItem.checked });
},
},
{
label: t('plugins.api-server.menu.https.submenu.cert.label'),
type: 'normal',
async click() {
const config = await getConfig();
const result = await dialog.showOpenDialog(window, {
title: t(
'plugins.api-server.menu.https.submenu.cert.dialogTitle',
),
filters: [{ name: 'Certificate', extensions: ['crt', 'pem'] }],
properties: ['openFile'],
});
if (!result.canceled && result.filePaths.length > 0) {
setConfig({ ...config, certPath: result.filePaths[0] });
}
},
},
{
label: t('plugins.api-server.menu.https.submenu.key.label'),
type: 'normal',
async click() {
const config = await getConfig();
const result = await dialog.showOpenDialog(window, {
title: t('plugins.api-server.menu.https.submenu.key.dialogTitle'),
filters: [{ name: 'Private Key', extensions: ['key', 'pem'] }],
properties: ['openFile'],
});
if (!result.canceled && result.filePaths.length > 0) {
setConfig({ ...config, keyPath: result.filePaths[0] });
}
},
},
],
},
];
};