mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 23:35:59 +00:00
save from electron menu
This commit is contained in:
@@ -10,6 +10,7 @@ import useTheme from './theme/useTheme';
|
||||
import usePropsCompare from './utility/usePropsCompare';
|
||||
import { useShowMenu } from './modals/showMenu';
|
||||
import { setSelectedTabFunc } from './utility/common';
|
||||
import getElectron from './utility/getElectron';
|
||||
|
||||
// const files = [
|
||||
// { name: 'app.js' },
|
||||
@@ -219,6 +220,16 @@ export default function TabsPanel() {
|
||||
);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
const electron = getElectron();
|
||||
if (electron) {
|
||||
const { ipcRenderer } = electron;
|
||||
const activeTab = tabs.find(x => x.selected);
|
||||
window['activeTabId'] = activeTab ? activeTab.tabid : null;
|
||||
ipcRenderer.send('update-menu');
|
||||
}
|
||||
}, [tabs]);
|
||||
|
||||
// console.log(
|
||||
// 't',
|
||||
// tabs.map(x => x.tooltip)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import _ from 'lodash';
|
||||
import './index.css';
|
||||
import '@mdi/font/css/materialdesignicons.css';
|
||||
import App from './App';
|
||||
@@ -22,6 +23,17 @@ 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_tabCommand'] = cmd => {
|
||||
const tabid = window['activeTabId'];
|
||||
const commands = window['tabExports'][tabid];
|
||||
const func = (commands || {})[cmd];
|
||||
if (func) func();
|
||||
};
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import axios from '../utility/axios';
|
||||
import { changeTab } from '../utility/common';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import { useOpenedTabs, useSetOpenedTabs } from '../utility/globalState';
|
||||
import keycodes from '../utility/keycodes';
|
||||
import SaveFileToolbarButton from '../utility/SaveFileToolbarButton';
|
||||
@@ -72,6 +73,23 @@ export default function SaveTabModal({
|
||||
}
|
||||
}, [tabVisible, handleKeyboard, canSave]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const electron = getElectron();
|
||||
if (electron) {
|
||||
const { ipcRenderer } = electron;
|
||||
window['tabExports'][tabid] = {
|
||||
save: handleSaveRef.current,
|
||||
saveAs: saveFileModalState.open,
|
||||
};
|
||||
ipcRenderer.send('update-menu');
|
||||
|
||||
return () => {
|
||||
delete window['tabExports'][tabid];
|
||||
ipcRenderer.send('update-menu');
|
||||
};
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SaveFileModal
|
||||
|
||||
Reference in New Issue
Block a user