Add protocol to enable extension support
This commit is contained in:
parent
cbb1b853b5
commit
54a3810a53
|
@ -32,6 +32,14 @@ const config = {
|
|||
directories: {
|
||||
output: './build/',
|
||||
},
|
||||
protocols: [
|
||||
{
|
||||
name: "FreeTube",
|
||||
schemes: [
|
||||
"freetube"
|
||||
]
|
||||
}
|
||||
],
|
||||
files: ['_icons/iconColor.*', './dist/**/*', '!./dist/web/**/*'],
|
||||
dmg: {
|
||||
contents: [
|
||||
|
|
|
@ -21,8 +21,6 @@ app.setName(productName)
|
|||
|
||||
// disable electron warning
|
||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
|
||||
|
||||
// const gotTheLock = app.requestSingleInstanceLock()
|
||||
const path = require('path')
|
||||
const isDev = process.env.NODE_ENV === 'development'
|
||||
const isDebug = process.argv.includes('--debug')
|
||||
|
@ -33,26 +31,55 @@ let mainWindow
|
|||
// This line can possible be removed if the issue is fixed upstream
|
||||
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
|
||||
|
||||
app.setAsDefaultProtocolClient('freetube')
|
||||
|
||||
// TODO: Uncomment if needed
|
||||
// only allow single instance of application
|
||||
// if (!isDev) {
|
||||
// if (gotTheLock) {
|
||||
// app.on('second-instance', () => {
|
||||
// // Someone tried to run a second instance, we should focus our window.
|
||||
// if (mainWindow && mainWindow.isMinimized()) {
|
||||
// mainWindow.restore()
|
||||
// }
|
||||
// mainWindow.focus()
|
||||
// })
|
||||
// } else {
|
||||
// app.quit()
|
||||
// process.exit(0)
|
||||
// }
|
||||
// } else {
|
||||
// require('electron-debug')({
|
||||
// showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true')
|
||||
// })
|
||||
// }
|
||||
if (!isDev) {
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
if (gotTheLock) {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow && typeof (commandLine) !== 'undefined') {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
|
||||
mainWindow.webContents.send('ping', commandLine)
|
||||
}
|
||||
})
|
||||
|
||||
app.on('ready', (event, commandLine, workingDirectory) => {
|
||||
createWindow()
|
||||
|
||||
if (isDev) {
|
||||
installDevTools()
|
||||
}
|
||||
|
||||
if (isDebug) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.quit()
|
||||
}
|
||||
} else {
|
||||
require('electron-debug')({
|
||||
showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true')
|
||||
})
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
|
||||
if (isDev) {
|
||||
installDevTools()
|
||||
}
|
||||
|
||||
if (isDebug) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function installDevTools () {
|
||||
try {
|
||||
|
@ -172,20 +199,15 @@ function createWindow () {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('appReady', () => {
|
||||
const param = process.argv[1]
|
||||
if (typeof (param) !== 'undefined' && param !== null) {
|
||||
mainWindow.webContents.send('ping', process.argv)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
|
||||
if (isDev) {
|
||||
installDevTools()
|
||||
}
|
||||
|
||||
if (isDebug) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
|
@ -222,7 +244,6 @@ app.on('activate', () => {
|
|||
|
||||
/*
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Vue from 'vue'
|
||||
import { mapActions } from 'vuex'
|
||||
import { ObserveVisibility } from 'vue-observe-visibility'
|
||||
import FtFlexBox from './components/ft-flex-box/ft-flex-box.vue'
|
||||
import TopNav from './components/top-nav/top-nav.vue'
|
||||
|
@ -14,12 +15,14 @@ import Parser from 'rss-parser'
|
|||
|
||||
let useElectron
|
||||
let shell
|
||||
let electron
|
||||
|
||||
Vue.directive('observe-visibility', ObserveVisibility)
|
||||
|
||||
if (window && window.process && window.process.type === 'renderer') {
|
||||
/* eslint-disable-next-line */
|
||||
shell = require('electron').shell
|
||||
electron = require('electron')
|
||||
shell = electron.shell
|
||||
useElectron = true
|
||||
} else {
|
||||
useElectron = false
|
||||
|
@ -65,6 +68,9 @@ export default Vue.extend({
|
|||
},
|
||||
checkForBlogPosts: function () {
|
||||
return this.$store.getters.getCheckForBlogPosts
|
||||
},
|
||||
searchSettings: function () {
|
||||
return this.$store.getters.getSearchSettings
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
|
@ -79,6 +85,7 @@ export default Vue.extend({
|
|||
console.log('User is using Electron')
|
||||
this.activateKeyboardShortcuts()
|
||||
this.openAllLinksExternally()
|
||||
this.enableCliPing()
|
||||
this.setBoundsOnClose()
|
||||
}
|
||||
|
||||
|
@ -247,9 +254,39 @@ export default Vue.extend({
|
|||
})
|
||||
},
|
||||
|
||||
enableCliPing: function () {
|
||||
const v = this
|
||||
electron.ipcRenderer.on('ping', function (event, message) {
|
||||
console.log('ping!')
|
||||
console.log(message)
|
||||
let url = message[message.length - 1]
|
||||
if (url) {
|
||||
url = url.replace('freetube://', '')
|
||||
v.$store.dispatch('getVideoIdFromUrl', url).then((result) => {
|
||||
if (result) {
|
||||
v.$router.push({
|
||||
path: `/watch/${result}`
|
||||
})
|
||||
} else {
|
||||
v.$router.push({
|
||||
path: `/search/${encodeURIComponent(url)}`,
|
||||
query: {
|
||||
sortBy: v.searchSettings.sortBy,
|
||||
time: v.searchSettings.time,
|
||||
type: v.searchSettings.type,
|
||||
duration: v.searchSettings.duration
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
electron.ipcRenderer.send('appReady')
|
||||
},
|
||||
|
||||
setBoundsOnClose: function () {
|
||||
window.onbeforeunload = (e) => {
|
||||
const electron = require('electron')
|
||||
electron.ipcRenderer.send('setBounds')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue