Changed external anilist token to be sent through IPC from main to renderer

This commit is contained in:
Muril-o 2022-04-12 03:44:38 -03:00
parent 2179c3b145
commit 34292c1fcc
3 changed files with 13 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "1.4.8",
"version": "1.4.9",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"main": "src/index.js",
"homepage": "https://github.com/ThaUnknown/miru#readme",

View file

@ -24,14 +24,14 @@ if (!gotTheLock) {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
}
if (commandLine.length === 3) {
let token = commandLine[2].slice(9)
if (token.endsWith('/')) token = token.slice(0, -1)
if (token) {
if (process.env.NODE_ENV !== 'development ') {
mainWindow.loadURL(path.join(__dirname, '/renderer/dist/index.html#' + token))
} else {
mainWindow.loadURL('http://localhost:3000#' + token)
// 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 (let i = 0; i < commandLine.length; i++) {
if (commandLine[i].startsWith('miru://')) {
let token = commandLine[i].split('access_token=')[1].split('&token_type')[0]
if (token.endsWith('/')) token = token.slice(0, -1)
if (token) {
mainWindow.webContents.send('altoken', token)
}
}
}

View file

@ -29,6 +29,10 @@
window.IPC.on('path', data => {
set.torrentPath = data
})
window.IPC.on('altoken', data => {
localStorage.setItem('ALtoken', data)
location.reload()
})
</script>
<script>