News can now be opened inside KawAnime instead of opening the link in the installed browser. This will be set via configuration file.

This commit is contained in:
Kylart 2017-03-15 02:03:50 +01:00
parent 4adc9c8b8b
commit bfc572d9f3
2 changed files with 31 additions and 1 deletions

24
main.js
View File

@ -13,6 +13,7 @@ const os = require('os')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
let newsWindow
const BASE_PATH = os.userInfo().homedir
function createWindow() {
@ -84,3 +85,26 @@ app.on('activate', function () {
// In this file you can include the rest of your src's specific main process
// code. You can also put them in separate files and require them here.
exports.openANewsWindow = (uri) => {
// Create the browser window.
newsWindow = new BrowserWindow({
width: 720,
height: 480,
parent: mainWindow
})
// and load the index.html of the src.
newsWindow.loadURL(uri)
newsWindow.once('ready-to-show', () => {
newsWindow.show()
})
// Emitted when the window is closed.
newsWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your src supports multi windows, this is the time
// when you should delete the corresponding element.
newsWindow = null
})
}

View File

@ -8,9 +8,15 @@
const self = this
// Will be set via configuration file.
const inside = true
const path = require('path')
const shell = require('electron').shell
const remote = require('electron').remote
const malScraper = require('mal-scraper')
const index = require('./index.js')
const {openANewsWindow} = remote.require(path.join(__dirname, '..', '..', 'main.js'))
exports.getNews = (object) => {
let tmp = malScraper.getNewsNoDetails(() => {
@ -20,5 +26,5 @@ exports.getNews = (object) => {
}
exports.openLink = (link) => {
shell.openExternal(link)
inside ? openANewsWindow(link) : shell.openExternal(link)
}