mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-11 08:24:58 +01:00
refs #28 Catch menu and shortcut events
This commit is contained in:
parent
7326710d2a
commit
dc025d03ed
@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
import { app, ipcMain, BrowserWindow, shell } from 'electron'
|
||||
import { app, ipcMain, BrowserWindow, shell, Menu } from 'electron'
|
||||
import Datastore from 'nedb'
|
||||
import storage from 'electron-json-storage'
|
||||
import empty from 'is-empty'
|
||||
@ -28,6 +28,39 @@ let db = new Datastore({
|
||||
})
|
||||
|
||||
function createWindow () {
|
||||
/**
|
||||
* Set menu
|
||||
*/
|
||||
const template = [
|
||||
{
|
||||
label: 'Toot',
|
||||
submenu: [
|
||||
{
|
||||
label: 'New Toot',
|
||||
accelerator: 'CmdOrCtrl+N',
|
||||
role: 'toot',
|
||||
click: () => {
|
||||
mainWindow.webContents.send('CmdOrCtrl+N')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Reply',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
role: 'reply',
|
||||
click: () => {
|
||||
mainWindow.webContents.send('CmdOrCtrl+R')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
|
||||
/**
|
||||
* Initial window options
|
||||
*/
|
||||
|
@ -20,6 +20,7 @@ export default {
|
||||
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
|
||||
this.$store.dispatch('TimelineSpace/username', account)
|
||||
this.$store.dispatch('TimelineSpace/fetchNotifications', account)
|
||||
this.$store.dispatch('TimelineSpace/watchShortcutEvents', account)
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
|
@ -14,7 +14,8 @@ const TimelineSpace = {
|
||||
},
|
||||
username: '',
|
||||
homeTimeline: [],
|
||||
notifications: []
|
||||
notifications: [],
|
||||
newTootModal: false
|
||||
},
|
||||
mutations: {
|
||||
updateAccount (state, account) {
|
||||
@ -34,6 +35,9 @@ const TimelineSpace = {
|
||||
},
|
||||
insertNotifications (state, notifications) {
|
||||
state.notifications = state.notifications.concat(notifications)
|
||||
},
|
||||
changeNewTootModal (state, modal) {
|
||||
state.newTootModal = modal
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -82,6 +86,15 @@ const TimelineSpace = {
|
||||
stopUserStreaming ({ commit }) {
|
||||
ipcRenderer.send('stop-user-streaming')
|
||||
},
|
||||
watchShortcutEvents ({ commit }, account) {
|
||||
ipcRenderer.on('CmdOrCtrl+N', () => {
|
||||
console.log('new toot')
|
||||
commit('changeNewTootModal', true)
|
||||
})
|
||||
ipcRenderer.on('CmdOrCtrl+R', () => {
|
||||
console.log('reply')
|
||||
})
|
||||
},
|
||||
fetchHomeTimeline ({ commit }, account) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const client = new Mastodon(
|
||||
|
Loading…
Reference in New Issue
Block a user