diff --git a/app/src/electron.js b/app/src/electron.js index 3cd48a2a..a8e85036 100644 --- a/app/src/electron.js +++ b/app/src/electron.js @@ -63,22 +63,7 @@ function buildMenu() { }, }, commandItem('group.save'), - // { - // label: 'Save', - // click() { - // mainWindow.webContents.executeJavaScript(`dbgate_tabCommand('save')`); - // }, - // accelerator: 'Ctrl+S', - // id: 'save', - // }, - { - label: 'Save As', - click() { - mainWindow.webContents.executeJavaScript(`dbgate_tabCommand('saveAs')`); - }, - accelerator: 'Ctrl+Shift+S', - id: 'saveAs', - }, + commandItem('group.saveAs'), { type: 'separator' }, { role: 'close' }, ], @@ -86,19 +71,10 @@ function buildMenu() { { label: 'Window', submenu: [ - { - label: 'New query', - click() { - mainWindow.webContents.executeJavaScript(`dbgate_newQuery()`); - }, - }, + commandItem('new.query'), { type: 'separator' }, - { - label: 'Close all tabs', - click() { - mainWindow.webContents.executeJavaScript('dbgate_closeAll()'); - }, - }, + + commandItem('tabs.closeAll'), { role: 'minimize' }, ], }, @@ -155,12 +131,7 @@ function buildMenu() { require('electron').shell.openExternal('https://github.com/dbgate/dbgate/issues/new'); }, }, - { - label: 'About', - click() { - mainWindow.webContents.executeJavaScript(`dbgate_showAbout()`); - }, - }, + commandItem('about.show'), ], }, ]; diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index f6ea157b..3e0b3083 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -3,6 +3,7 @@ import registerCommand from './registerCommand'; import { derived, get } from 'svelte/store'; import { ThemeDefinition } from 'dbgate-types'; import ConnectionModal from '../modals/ConnectionModal.svelte'; +import AboutModal from '../modals/AboutModal.svelte'; import { showModal } from '../modals/modalTools'; import newQuery from '../query/newQuery'; import saveTabFile from '../utility/saveTabFile'; @@ -45,6 +46,14 @@ registerCommand({ testEnabled: () => getVisibleToolbar(), }); +registerCommand({ + id: 'about.show', + category: 'About', + name: 'Show', + toolbarName: 'About', + onClick: () => showModal(AboutModal), +}); + registerCommand({ id: 'new.connection', toolbar: true, @@ -118,6 +127,15 @@ registerCommand({ group: 'save', }); +registerCommand({ + id: 'group.saveAs', + category: null, + isGroupCommand: true, + name: 'Save As', + keyText: 'Ctrl+Shift+S', + group: 'saveAs', +}); + export function registerFileCommands({ idPrefix, category, @@ -142,9 +160,9 @@ export function registerFileCommands({ }); registerCommand({ id: idPrefix + '.saveAs', + group: 'saveAs', category, name: 'Save As', - keyText: 'Ctrl+Shift+S', testEnabled: () => getCurrentEditor() != null, onClick: () => saveTabFile(getCurrentEditor(), true, folder, format, fileExtension), }); diff --git a/packages/web/src/elements/Link.svelte b/packages/web/src/elements/Link.svelte new file mode 100644 index 00000000..ec5a4905 --- /dev/null +++ b/packages/web/src/elements/Link.svelte @@ -0,0 +1,28 @@ + + +{#if electron} + electron.shell.openExternal(href)}> + + +{:else} + + + +{/if} + + diff --git a/packages/web/src/modals/AboutModal.svelte b/packages/web/src/modals/AboutModal.svelte new file mode 100644 index 00000000..5fa1612b --- /dev/null +++ b/packages/web/src/modals/AboutModal.svelte @@ -0,0 +1,53 @@ + + + + About DbGate + + + + + Version: {version} + + + Build date: {moment(buildTime).format('YYYY-MM-DD')} + + + Web: dbgate.org + + + Source codes: github + + + Docker container: docker hub + + + Online demo: demo.dbgate.org + + + Search plugins: npmjs.com + + + + + + + + + + diff --git a/packages/web/src/widgets/TabsPanel.svelte b/packages/web/src/widgets/TabsPanel.svelte index 326e6f73..10fd626d 100644 --- a/packages/web/src/widgets/TabsPanel.svelte +++ b/packages/web/src/widgets/TabsPanel.svelte @@ -1,69 +1,4 @@ - - + +