Electron 8.

This commit is contained in:
Daniel Scalzi 2020-03-18 19:54:46 -04:00
parent 8b5a7bb02e
commit 141a753893
No known key found for this signature in database
GPG Key ID: D18EA3FB4B142A57
5 changed files with 512 additions and 676 deletions

View File

@ -1076,56 +1076,54 @@ function loadNews(){
const distroData = DistroManager.getDistribution() const distroData = DistroManager.getDistribution()
const newsFeed = distroData.getRSS() const newsFeed = distroData.getRSS()
const newsHost = new URL(newsFeed).origin + '/' const newsHost = new URL(newsFeed).origin + '/'
$.ajax( $.ajax({
{ url: newsFeed,
url: newsFeed, success: (data) => {
success: (data) => { const items = $(data).find('item')
const items = $(data).find('item') const articles = []
const articles = []
for(let i=0; i<items.length; i++){ for(let i=0; i<items.length; i++){
// JQuery Element // JQuery Element
const el = $(items[i]) const el = $(items[i])
// Resolve date. // Resolve date.
const date = new Date(el.find('pubDate').text()).toLocaleDateString('en-US', {month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric'}) const date = new Date(el.find('pubDate').text()).toLocaleDateString('en-US', {month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric'})
// Resolve comments. // Resolve comments.
let comments = el.find('slash\\:comments').text() || '0' let comments = el.find('slash\\:comments').text() || '0'
comments = comments + ' Comment' + (comments === '1' ? '' : 's') comments = comments + ' Comment' + (comments === '1' ? '' : 's')
// Fix relative links in content. // Fix relative links in content.
let content = el.find('content\\:encoded').text() let content = el.find('content\\:encoded').text()
let regex = /src="(?!http:\/\/|https:\/\/)(.+?)"/g let regex = /src="(?!http:\/\/|https:\/\/)(.+?)"/g
let matches let matches
while((matches = regex.exec(content))){ while((matches = regex.exec(content))){
content = content.replace(`"${matches[1]}"`, `"${newsHost + matches[1]}"`) content = content.replace(`"${matches[1]}"`, `"${newsHost + matches[1]}"`)
}
let link = el.find('link').text()
let title = el.find('title').text()
let author = el.find('dc\\:creator').text()
// Generate article.
articles.push(
{
link,
title,
date,
author,
content,
comments,
commentsLink: link + '#comments'
}
)
} }
resolve({
articles let link = el.find('link').text()
}) let title = el.find('title').text()
}, let author = el.find('dc\\:creator').text()
timeout: 2500
} // Generate article.
).catch(err => { articles.push(
{
link,
title,
date,
author,
content,
comments,
commentsLink: link + '#comments'
}
)
}
resolve({
articles
})
},
timeout: 2500
}).catch(err => {
resolve({ resolve({
articles: null articles: null
}) })

View File

@ -34,7 +34,6 @@ remote.getCurrentWebContents().on('devtools-opened', () => {
// Disable zoom, needed for darwin. // Disable zoom, needed for darwin.
webFrame.setZoomLevel(0) webFrame.setZoomLevel(0)
webFrame.setVisualZoomLevelLimits(1, 1) webFrame.setVisualZoomLevelLimits(1, 1)
webFrame.setLayoutZoomLevelLimits(0, 0)
// Initialize auto updates in production environments. // Initialize auto updates in production environments.
let updateCheckListener let updateCheckListener

View File

@ -86,6 +86,9 @@ ipcMain.on('distributionIndexDone', (event, res) => {
// https://electronjs.org/docs/tutorial/offscreen-rendering // https://electronjs.org/docs/tutorial/offscreen-rendering
app.disableHardwareAcceleration() app.disableHardwareAcceleration()
// https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = true
// Keep a global reference of the window object, if you don't, the window will // 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. // be closed automatically when the JavaScript object is garbage collected.
let win let win

1094
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@
}, },
"devDependencies": { "devDependencies": {
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"electron": "^7.1.14", "electron": "^8.1.1",
"electron-builder": "^22.4.0", "electron-builder": "^22.4.0",
"eslint": "^6.8.0" "eslint": "^6.8.0"
}, },