Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
feat: create new tabs with cmd/ctrl+n
Browse files Browse the repository at this point in the history
  • Loading branch information
herteleo committed Jun 7, 2019
1 parent 836ad33 commit e8e02ec
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 deletions.
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -26,6 +26,7 @@
"postuninstall": "electron-builder install-app-deps"
},
"dependencies": {
"electron-localshortcut": "^3.1.0",
"electron-window-state": "^5.0.3",
"is-url-relative-without-domain": "^2.0.0",
"lodash-id": "^0.14.0",
Expand Down
6 changes: 5 additions & 1 deletion src/App.vue
Expand Up @@ -14,6 +14,7 @@
import AppLayout from '@/components/AppLayout.vue';
import TabsList from '@/components/TabsList.vue';
import WindowDimmer from '@/components/WindowDimmer.vue';
import Events from '@/utils/mixinEvents';
import NotificationSchedule from '@/utils/mixinNotificationSchedule';
export default {
Expand All @@ -22,6 +23,9 @@ export default {
TabsList,
WindowDimmer,
},
mixins: [NotificationSchedule],
mixins: [
Events,
NotificationSchedule,
],
};
</script>
16 changes: 15 additions & 1 deletion src/background.js
@@ -1,3 +1,4 @@
import electronLocalshortcut from 'electron-localshortcut';
import windowStateKeeper from 'electron-window-state';
import * as path from 'path';
import { format as formatUrl } from 'url';
Expand Down Expand Up @@ -114,6 +115,8 @@ app.on('ready', async () => {
}
mainWindow = createMainWindow();

electronLocalshortcut.register('CmdOrCtrl+T', () => app.emit('app-router-goto-tabs-create'));

Menu.setApplicationMenu(Menu.buildFromTemplate([
{
label: app.getName(),
Expand All @@ -127,7 +130,18 @@ app.on('ready', async () => {
{ type: 'separator' },
{ role: 'quit' },
],
}, {
},
{
label: 'File',
submenu: [
{
label: 'New Tab',
accelerator: 'CmdOrCtrl+N',
click: () => app.emit('app-router-goto-tabs-create'),
},
],
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
Expand Down
7 changes: 0 additions & 7 deletions src/components/TabsNav.vue
Expand Up @@ -60,13 +60,6 @@ export default {
return this.$store.getters['Settings/byKey']('navigation.displayTabLabels');
},
},
created() {
const { app } = this.$electron.remote;
const r = this.$router;
app.on('app-router-goto-settings', () => r.push({ name: 'settings' }));
app.on('app-router-goto-welcome', () => r.push({ name: 'welcome' }));
app.on('app-router-goto-changelog', () => r.push({ name: 'changelog' }));
},
};
</script>

Expand Down
11 changes: 11 additions & 0 deletions src/utils/mixinEvents.js
@@ -0,0 +1,11 @@
export default {
created() {
const { app } = this.$electron.remote;
const r = this.$router;

app.on('app-router-goto-tabs-create', () => r.push({ name: 'tabs-create' }));
app.on('app-router-goto-settings', () => r.push({ name: 'settings' }));
app.on('app-router-goto-welcome', () => r.push({ name: 'welcome' }));
app.on('app-router-goto-changelog', () => r.push({ name: 'changelog' }));
},
};

0 comments on commit e8e02ec

Please sign in to comment.