mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-18 15:12:04 +00:00
feat: external AL login
This commit is contained in:
parent
739c24745b
commit
aa16c10dcf
4 changed files with 41 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "1.3.1",
|
||||
"version": "1.4.0",
|
||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||
"main": "src/index.js",
|
||||
"homepage": "https://github.com/ThaUnknown/miru#readme",
|
||||
|
|
@ -33,6 +33,10 @@
|
|||
]
|
||||
},
|
||||
"build": {
|
||||
"protocols": {
|
||||
"name": "miru",
|
||||
"schemes": ["miru"]
|
||||
},
|
||||
"publish": [
|
||||
{
|
||||
"provider": "github",
|
||||
|
|
|
|||
34
src/index.js
34
src/index.js
|
|
@ -1,10 +1,42 @@
|
|||
const { app, BrowserWindow, protocol } = require('electron')
|
||||
const { app, BrowserWindow, protocol, shell, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const log = require('electron-log')
|
||||
const { autoUpdater } = require('electron-updater')
|
||||
require('./main/torrent.js')
|
||||
require('./main/misc.js')
|
||||
|
||||
if (process.defaultApp) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient('miru', process.execPath, [path.resolve(process.argv[1])])
|
||||
}
|
||||
} else {
|
||||
app.setAsDefaultProtocolClient('miru')
|
||||
}
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
}
|
||||
const token = commandLine[commandLine.length - 1].slice(7)
|
||||
if (process.env.NODE_ENV !== 'development ') {
|
||||
mainWindow.loadURL(path.join(__dirname, '/renderer/dist/index.html' + token))
|
||||
} else {
|
||||
mainWindow.loadURL('http://localhost:3000/' + token)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
ipcMain.on('open', (event, url) => {
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
autoUpdater.logger = log
|
||||
autoUpdater.logger.transports.file.level = 'info'
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ const server = http.createServer((request, response) => {
|
|||
pump(stream, response)
|
||||
})
|
||||
|
||||
server.on('error', console.log)
|
||||
|
||||
server.listen(41785)
|
||||
|
||||
let current = null
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
location.hash = ''
|
||||
location.reload()
|
||||
} else {
|
||||
location.href = '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')
|
||||
const searchParams = new URLSearchParams(location.href)
|
||||
if (searchParams.get('access_token')) {
|
||||
localStorage.setItem('ALtoken', searchParams.get('access_token'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue