mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 06:06:00 +00:00
electron initialization without remote
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
import getElectron from './getElectron';
|
||||
|
||||
let apiUrl = null;
|
||||
try {
|
||||
apiUrl = process.env.API_URL;
|
||||
} catch {}
|
||||
|
||||
export default function resolveApi() {
|
||||
if (window['require']) {
|
||||
const electron = window['require']('electron');
|
||||
|
||||
if (electron) {
|
||||
const port = electron.remote.getGlobal('port');
|
||||
if (port) {
|
||||
return `http://localhost:${port}`;
|
||||
}
|
||||
}
|
||||
const electron = getElectron();
|
||||
if (electron?.port) {
|
||||
return `http://localhost:${electron.port}`;
|
||||
}
|
||||
|
||||
if (apiUrl) {
|
||||
@@ -22,14 +18,13 @@ export default function resolveApi() {
|
||||
}
|
||||
|
||||
export function resolveApiHeaders() {
|
||||
if (window['require']) {
|
||||
const electron = window['require']('electron');
|
||||
const electron = getElectron();
|
||||
|
||||
if (electron) {
|
||||
return {
|
||||
Authorization: electron.remote.getGlobal('authorization'),
|
||||
};
|
||||
}
|
||||
if (electron?.authorization) {
|
||||
return {
|
||||
Authorization: electron.authorization,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user