mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 12:26:01 +00:00
bundled electron app starts without error
This commit is contained in:
@@ -15,15 +15,19 @@ const doDatabasePing = value => {
|
||||
};
|
||||
|
||||
let openedConnectionsHandle = null;
|
||||
openedConnections.subscribe(value => {
|
||||
doServerPing(value);
|
||||
if (openedConnectionsHandle) window.clearInterval(openedConnectionsHandle);
|
||||
openedConnectionsHandle = window.setInterval(() => doServerPing(value), 30 * 1000);
|
||||
});
|
||||
|
||||
let currentDatabaseHandle = null;
|
||||
currentDatabase.subscribe(value => {
|
||||
doDatabasePing(value);
|
||||
if (currentDatabaseHandle) window.clearInterval(currentDatabaseHandle);
|
||||
currentDatabaseHandle = window.setInterval(() => doDatabasePing(value), 30 * 1000);
|
||||
});
|
||||
|
||||
export function subscribeConnectionPingers() {
|
||||
openedConnections.subscribe(value => {
|
||||
doServerPing(value);
|
||||
if (openedConnectionsHandle) window.clearInterval(openedConnectionsHandle);
|
||||
openedConnectionsHandle = window.setInterval(() => doServerPing(value), 30 * 1000);
|
||||
});
|
||||
|
||||
currentDatabase.subscribe(value => {
|
||||
doDatabasePing(value);
|
||||
if (currentDatabaseHandle) window.clearInterval(currentDatabaseHandle);
|
||||
currentDatabaseHandle = window.setInterval(() => doDatabasePing(value), 30 * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ export async function exportElectronFile(dataName, reader, format) {
|
||||
|
||||
function handleRunnerDone() {
|
||||
closeSnackbar(snackId);
|
||||
socket.off(`runner-done-${runid}`, handleRunnerDone);
|
||||
socket().off(`runner-done-${runid}`, handleRunnerDone);
|
||||
if (isCanceled) showSnackbarError(`Export ${dataName} canceled`);
|
||||
else showSnackbarInfo(`Export ${dataName} finished`);
|
||||
}
|
||||
|
||||
socket.on(`runner-done-${runid}`, handleRunnerDone);
|
||||
socket().on(`runner-done-${runid}`, handleRunnerDone);
|
||||
}
|
||||
|
||||
export async function saveFileToDisk(
|
||||
|
||||
@@ -16,14 +16,13 @@ class ElectronApi {
|
||||
let apiInstance = null;
|
||||
|
||||
function initializeElectron(args) {
|
||||
// console.log('Initialize electron with args:', args);
|
||||
|
||||
apiInstance = new ElectronApi(args);
|
||||
if (window['dbgate_recreateAxiosInstance']) {
|
||||
// console.log('Recreating axios instance');
|
||||
|
||||
window['dbgate_recreateAxiosInstance']();
|
||||
}
|
||||
if (window['dbgate_recreateSocket']) {
|
||||
window['dbgate_recreateSocket']();
|
||||
}
|
||||
}
|
||||
|
||||
window['dbgate_initializeElectron'] = initializeElectron;
|
||||
|
||||
@@ -3,13 +3,14 @@ import { useConfig } from './metadataLoaders';
|
||||
|
||||
let compiled = null;
|
||||
|
||||
const config = useConfig();
|
||||
config.subscribe(value => {
|
||||
if (!value) return;
|
||||
const { permissions } = value;
|
||||
compiled = compilePermissions(permissions);
|
||||
});
|
||||
|
||||
export default function hasPermission(tested) {
|
||||
return testPermission(tested, compiled);
|
||||
}
|
||||
|
||||
export function subscribePermissionCompiler() {
|
||||
useConfig().subscribe(value => {
|
||||
if (!value) return;
|
||||
const { permissions } = value;
|
||||
compiled = compilePermissions(permissions);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,11 +208,11 @@ function useCore(loader, args) {
|
||||
handleReload();
|
||||
if (reloadTrigger && socket) {
|
||||
for (const item of getAsArray(reloadTrigger)) {
|
||||
socket.on(item, handleReload);
|
||||
socket().on(item, handleReload);
|
||||
}
|
||||
return () => {
|
||||
for (const item of getAsArray(reloadTrigger)) {
|
||||
socket.off(item, handleReload);
|
||||
socket().off(item, handleReload);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
import io from 'socket.io-client';
|
||||
import resolveApi from './resolveApi';
|
||||
import { cacheClean } from './cache';
|
||||
import { shouldWaitForElectronInitialize } from './getElectron';
|
||||
|
||||
const socket = io(resolveApi());
|
||||
socket.on('clean-cache', reloadTrigger => cacheClean(reloadTrigger));
|
||||
let socketInstance;
|
||||
|
||||
function recreateSocket() {
|
||||
if (shouldWaitForElectronInitialize()) return;
|
||||
|
||||
socketInstance = io(resolveApi());
|
||||
socketInstance.on('clean-cache', reloadTrigger => cacheClean(reloadTrigger));
|
||||
}
|
||||
|
||||
window['dbgate_recreateSocket'] = recreateSocket;
|
||||
|
||||
recreateSocket();
|
||||
|
||||
function socket() {
|
||||
return socketInstance;
|
||||
}
|
||||
|
||||
export default socket;
|
||||
|
||||
Reference in New Issue
Block a user