diff --git a/src/index.js b/src/index.js index 24cf402..1898dd4 100644 --- a/src/index.js +++ b/src/index.js @@ -22,13 +22,15 @@ if (!app.requestSingleInstanceLock()) { // There's probably a better way to do this instead of a for loop and split[1][0] // but for now it works as a way to fix multiple OS's commandLine differences for (const line of commandLine) { - if (line.startsWith('miru://')) return sendToken(line) + if (line.startsWith('miru://auth')) return sendToken(line) + if (line.startsWith('miru://anime/')) return openAnime(line) } }) } app.on('open-url', (event, url) => { event.preventDefault() - if (url.startsWith('miru://')) sendToken(url) + if (url.startsWith('miru://auth')) sendToken(url) + if (url.startsWith('miru://anime/')) openAnime(url) }) function sendToken (line) { @@ -39,6 +41,13 @@ function sendToken (line) { } } +function openAnime (url) { + const animeId = url.split('anime/')[1] + if (animeId) { + mainWindow.webContents.send('open-anime', animeId) + } +} + ipcMain.on('open', (event, url) => { shell.openExternal(url) }) diff --git a/src/renderer/src/App.svelte b/src/renderer/src/App.svelte index 4f62a5d..90fe297 100644 --- a/src/renderer/src/App.svelte +++ b/src/renderer/src/App.svelte @@ -1,9 +1,14 @@ diff --git a/src/renderer/src/lib/Sidebar.svelte b/src/renderer/src/lib/Sidebar.svelte index ad801f3..1aa63e2 100644 --- a/src/renderer/src/lib/Sidebar.svelte +++ b/src/renderer/src/lib/Sidebar.svelte @@ -61,7 +61,7 @@ location.hash = '' location.reload() } else { - window.IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') + window.IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') //Change redirect_url to miru://auth if (platformMap[window.version.platform] === 'Linux') { addToast({ text: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.", diff --git a/src/renderer/src/lib/ViewAnime.svelte b/src/renderer/src/lib/ViewAnime.svelte index b19588e..3d4833a 100644 --- a/src/renderer/src/lib/ViewAnime.svelte +++ b/src/renderer/src/lib/ViewAnime.svelte @@ -5,6 +5,7 @@ import { getContext } from 'svelte' import { alToken } from '@/lib/pages/Settings.svelte' import { countdown } from '@/modules/util.js' + import { addToast } from './Toasts.svelte' const view = getContext('view') function close () { @@ -80,6 +81,18 @@ function viewTrailer (media) { $trailer = media.trailer.id } + function copyToClipboard(text) { + navigator.clipboard.writeText(text) + addToast({ + title: 'Copied to clipboard', + text: 'Copied share URL to clipboard', + type: 'primary', + duration: '5000' + }) + } + function openInBrowser(url) { + window.IPC.emit('open', url) + }