Merge pull request #191 from h3poteto/iss-190
closes #190 Sound a system sound when user favourite or reblog
This commit is contained in:
commit
b0d39770b3
|
@ -24,7 +24,7 @@ else if (process.env.BUILD_TARGET === 'web') web()
|
|||
else build()
|
||||
|
||||
function clean () {
|
||||
del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])
|
||||
del.sync(['build/*', '!build/icons', '!build/icons/icon.*', '!build/sounds', '!build/sounds/*'])
|
||||
console.log(`\n${doneLog}\n`)
|
||||
process.exit()
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -13699,6 +13699,11 @@
|
|||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
|
||||
"dev": true
|
||||
},
|
||||
"simplayer": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/simplayer/-/simplayer-0.0.8.tgz",
|
||||
"integrity": "sha1-8gzrIzFmrH84J0VmbSPzxIeSw8g="
|
||||
},
|
||||
"single-line-log": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-1.1.2.tgz",
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
"directories": {
|
||||
"output": "build"
|
||||
},
|
||||
"extraResources": [
|
||||
"build/sounds/"
|
||||
],
|
||||
"files": [
|
||||
"dist/electron/**/*",
|
||||
"build/icons/*"
|
||||
|
@ -87,6 +90,7 @@
|
|||
"mastodon-api": "^1.3.0",
|
||||
"moment": "^2.21.0",
|
||||
"nedb": "^1.8.0",
|
||||
"simplayer": "0.0.8",
|
||||
"vue": "^2.3.3",
|
||||
"vue-awesome": "^2.3.5",
|
||||
"vue-electron": "^1.0.6",
|
||||
|
|
|
@ -5,6 +5,8 @@ import Datastore from 'nedb'
|
|||
import empty from 'is-empty'
|
||||
import log from 'electron-log'
|
||||
import windowStateKeeper from 'electron-window-state'
|
||||
import simplayer from 'simplayer'
|
||||
import path from 'path'
|
||||
|
||||
import Authentication from './auth'
|
||||
import Account from './account'
|
||||
|
@ -21,7 +23,7 @@ log.transports.file.level = 'info'
|
|||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
||||
*/
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
|
||||
let mainWindow
|
||||
|
@ -192,7 +194,7 @@ function createWindow () {
|
|||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
useContentSize: true,
|
||||
icon: require('path').join(__dirname, '../../build/icons/256x256.png')
|
||||
icon: path.join(__dirname, '../../build/icons/256x256.png')
|
||||
})
|
||||
mainWindowState.manage(mainWindow)
|
||||
|
||||
|
@ -441,6 +443,25 @@ ipcMain.on('stop-public-streaming', (event, _) => {
|
|||
publicStreaming = null
|
||||
})
|
||||
|
||||
// sounds
|
||||
ipcMain.on('operation-sound01', (event, _) => {
|
||||
const sound = process.env.NODE_ENV === 'development'
|
||||
? path.join(__dirname, '../../build/sounds/operation_sound01.wav')
|
||||
: path.join(process.resourcesPath, 'build/sounds/operation_sound01.wav')
|
||||
simplayer(sound, (err) => {
|
||||
if (err) log.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('operation-sound02', (event, _) => {
|
||||
const sound = process.env.NODE_ENV === 'development'
|
||||
? path.join(__dirname, '../../build/sounds/operation_sound02.wav')
|
||||
: path.join(process.resourcesPath, 'build/sounds/operation_sound02.wav')
|
||||
simplayer(sound, (err) => {
|
||||
if (err) log.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Auto Updater
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Mastodon from 'mastodon-api'
|
||||
import { ipcRenderer } from 'electron'
|
||||
|
||||
const Toot = {
|
||||
namespaced: true,
|
||||
|
@ -19,6 +20,7 @@ const Toot = {
|
|||
// Reblog target status is in the data.reblog.
|
||||
// So I send data.reblog as status for update local timeline.
|
||||
commit('TimelineSpace/updateToot', data.reblog, { root: true })
|
||||
ipcRenderer.send('operation-sound01')
|
||||
resolve(data.reblog)
|
||||
})
|
||||
})
|
||||
|
@ -49,6 +51,7 @@ const Toot = {
|
|||
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
|
||||
if (err) return reject(err)
|
||||
commit('TimelineSpace/updateToot', data, { root: true })
|
||||
ipcRenderer.send('operation-sound01')
|
||||
resolve(data)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Mastodon from 'mastodon-api'
|
||||
import { ipcRenderer } from 'electron'
|
||||
import fs from 'fs'
|
||||
|
||||
const NewToot = {
|
||||
|
@ -47,6 +48,7 @@ const NewToot = {
|
|||
)
|
||||
client.post('/statuses', form, (err, data, res) => {
|
||||
if (err) return reject(err)
|
||||
ipcRenderer.send('operation-sound02')
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue