mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
small refactor
This commit is contained in:
@@ -225,7 +225,7 @@ export default function TabsPanel() {
|
||||
if (electron) {
|
||||
const { ipcRenderer } = electron;
|
||||
const activeTab = tabs.find(x => x.selected);
|
||||
window['activeTabId'] = activeTab ? activeTab.tabid : null;
|
||||
window['dbgate_activeTabId'] = activeTab ? activeTab.tabid : null;
|
||||
ipcRenderer.send('update-menu');
|
||||
}
|
||||
}, [tabs]);
|
||||
|
||||
@@ -23,14 +23,14 @@ import localStorageGarbageCollector from './utility/localStorageGarbageCollector
|
||||
// import 'ace-builds/src-noconflict/snippets/mysql';
|
||||
|
||||
localStorageGarbageCollector();
|
||||
window['tabExports'] = {};
|
||||
window['getCurrentTabCommands'] = () => {
|
||||
const tabid = window['activeTabId'];
|
||||
return _.mapValues(window['tabExports'][tabid] || {}, v => !!v);
|
||||
window['dbgate_tabExports'] = {};
|
||||
window['dbgate_getCurrentTabCommands'] = () => {
|
||||
const tabid = window['dbgate_activeTabId'];
|
||||
return _.mapValues(window['dbgate_tabExports'][tabid] || {}, v => !!v);
|
||||
};
|
||||
window['dbgate_tabCommand'] = cmd => {
|
||||
const tabid = window['activeTabId'];
|
||||
const commands = window['tabExports'][tabid];
|
||||
const tabid = window['dbgate_activeTabId'];
|
||||
const commands = window['dbgate_tabExports'][tabid];
|
||||
const func = (commands || {})[cmd];
|
||||
if (func) func();
|
||||
};
|
||||
|
||||
@@ -77,14 +77,14 @@ export default function SaveTabModal({
|
||||
const electron = getElectron();
|
||||
if (electron) {
|
||||
const { ipcRenderer } = electron;
|
||||
window['tabExports'][tabid] = {
|
||||
window['dbgate_tabExports'][tabid] = {
|
||||
save: handleSaveRef.current,
|
||||
saveAs: saveFileModalState.open,
|
||||
};
|
||||
ipcRenderer.send('update-menu');
|
||||
|
||||
return () => {
|
||||
delete window['tabExports'][tabid];
|
||||
delete window['dbgate_tabExports'][tabid];
|
||||
ipcRenderer.send('update-menu');
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user