mirror of https://github.com/Kylart/KawAnime.git
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:
parent
4adc9c8b8b
commit
bfc572d9f3
24
main.js
24
main.js
|
@ -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
|
||||
})
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue