Merge branch 'development' of https://github.com/FreeTubeApp/FreeTube into development

Merge
This commit is contained in:
Luca 2020-10-15 19:58:33 +02:00
commit d214fe7d1e
4 changed files with 59 additions and 11 deletions

View File

@ -25,13 +25,25 @@ const path = require('path')
const isDev = process.env.NODE_ENV === 'development' const isDev = process.env.NODE_ENV === 'development'
const isDebug = process.argv.includes('--debug') const isDebug = process.argv.includes('--debug')
let mainWindow let mainWindow
let startupUrl
// CORS somehow gets re-enabled in Electron v9.0.4 // CORS somehow gets re-enabled in Electron v9.0.4
// This line disables it. // This line disables it.
// This line can possible be removed if the issue is fixed upstream // This line can possible be removed if the issue is fixed upstream
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors') app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
app.setAsDefaultProtocolClient('freetube') // See: https://stackoverflow.com/questions/45570589/electron-protocol-handler-not-working-on-windows
// remove so we can register each time as we run the app.
app.removeAsDefaultProtocolClient('freetube')
// If we are running a non-packaged version of the app && on windows
if (isDev && process.platform === 'win32') {
// Set the path of electron.exe and your app.
// These two additional parameters are only available on windows.
app.setAsDefaultProtocolClient('freetube', process.execPath, [path.resolve(process.argv[1])])
} else {
app.setAsDefaultProtocolClient('freetube')
}
// TODO: Uncomment if needed // TODO: Uncomment if needed
// only allow single instance of application // only allow single instance of application
@ -45,7 +57,10 @@ if (!isDev) {
if (mainWindow.isMinimized()) mainWindow.restore() if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus() mainWindow.focus()
mainWindow.webContents.send('ping', commandLine) const url = getLinkUrl(commandLine)
if (url) {
mainWindow.webContents.send('openUrl', url)
}
} }
}) })
@ -231,9 +246,8 @@ function createWindow () {
}) })
ipcMain.on('appReady', () => { ipcMain.on('appReady', () => {
const param = process.argv[1] if (startupUrl) {
if (typeof (param) !== 'undefined' && param !== null) { mainWindow.webContents.send('openUrl', startupUrl)
mainWindow.webContents.send('ping', process.argv)
} }
}) })
@ -276,6 +290,40 @@ app.on('activate', () => {
} }
}) })
/*
* Callback when processing a freetube:// link (macOS)
*/
app.on('open-url', (event, url) => {
event.preventDefault()
if (mainWindow && mainWindow.webContents) {
mainWindow.webContents.send('openUrl', baseUrl(url))
} else {
startupUrl = baseUrl(url)
}
})
/*
* Check if we were passed a freetube:// URL on process startup (linux/win)
*/
const url = getLinkUrl(process.argv)
if (url) {
startupUrl = url
}
function baseUrl(arg) {
return arg.replace('freetube://', '')
}
function getLinkUrl(argv) {
for (const arg of argv) {
if (arg.indexOf('freetube://') !== -1) {
return baseUrl(arg)
}
}
return null
}
/** /**
* Auto Updater * Auto Updater
* *

View File

@ -93,7 +93,7 @@ export default Vue.extend({
console.log('User is using Electron') console.log('User is using Electron')
this.activateKeyboardShortcuts() this.activateKeyboardShortcuts()
this.openAllLinksExternally() this.openAllLinksExternally()
this.enableCliPing() this.enableOpenUrl()
this.setBoundsOnClose() this.setBoundsOnClose()
} }
@ -262,12 +262,10 @@ export default Vue.extend({
}) })
}, },
enableCliPing: function () { enableOpenUrl: function () {
const v = this const v = this
electron.ipcRenderer.on('ping', function (event, message) { electron.ipcRenderer.on('openUrl', function (event, url) {
let url = message[message.length - 1]
if (url) { if (url) {
url = url.replace('freetube://', '')
v.$store.dispatch('getVideoIdFromUrl', url).then((result) => { v.$store.dispatch('getVideoIdFromUrl', url).then((result) => {
if (result) { if (result) {
v.$router.push({ v.$router.push({

View File

@ -918,7 +918,7 @@ body.vjs-full-window {
width: 1px; width: 1px;
height: 100%; height: 100%;
background-color: #000; background-color: #000;
z-index: 1; z-index: 4;
} }
.vjs-no-flex .vjs-progress-control .vjs-mouse-display { .vjs-no-flex .vjs-progress-control .vjs-mouse-display {
@ -2004,6 +2004,7 @@ video::-webkit-media-text-track-display {
bottom: 20px; bottom: 20px;
pointer-events: none; pointer-events: none;
box-shadow: 0 0 7px rgba(0,0,0,.6); box-shadow: 0 0 7px rgba(0,0,0,.6);
z-index: 3;
} }
.video-js .vjs-http-source-selector { .video-js .vjs-http-source-selector {

View File

@ -270,6 +270,7 @@ Settings:
Data Settings: Ustawienia danych Data Settings: Ustawienia danych
One or more subscriptions were unable to be imported: Nie można było zaimportować One or more subscriptions were unable to be imported: Nie można było zaimportować
conajmniej jednej subskrypcji conajmniej jednej subskrypcji
Check for Legacy Subscriptions: Sprawdź subskrypcje po starej wersji
Distraction Free Settings: Distraction Free Settings:
Distraction Free Settings: Ustawienia skupienia uwagi Distraction Free Settings: Ustawienia skupienia uwagi
Hide Live Chat: Schowaj czat na żywo Hide Live Chat: Schowaj czat na żywo