Skip to content

Commit

Permalink
Merge branch 'cache'
Browse files Browse the repository at this point in the history
  • Loading branch information
Knkajfw committed Apr 24, 2020
2 parents a1544ab + a50b76a commit 95aabe9
Showing 1 changed file with 39 additions and 33 deletions.
72 changes: 39 additions & 33 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,25 @@ function createLoadingPageWindow() {
win.on('closed', () => {
win = null;
})
win.webContents.session.resolveProxy('https://www.indienost.com')
.then(str => {
let parts = str.split(' ');
if (parts[0] === 'PROXY') {
let resolvedProxyAddress = parts[1];
let resolvedProxyhref = 'http://' + resolvedProxyAddress;
https.globalAgent = new HttpsProxyAgent(resolvedProxyhref);
win.webContents.loadFile('assets/html/loading-page.html');
}
else {
win.webContents.session.clearCache()
.then(() => {
win.webContents.session.resolveProxy('https://www.indienost.com')
.then(str => {
let parts = str.split(' ');
if (parts[0] === 'PROXY') {
let resolvedProxyAddress = parts[1];
let resolvedProxyhref = 'http://' + resolvedProxyAddress;
https.globalAgent = new HttpsProxyAgent(resolvedProxyhref);
win.webContents.loadFile('assets/html/loading-page.html');
}
else {
win.webContents.loadFile('assets/html/loading-page.html');
}
})
.catch (err => {
console.error('resolveProxy error:', err.message);
win.webContents.loadFile('assets/html/loading-page.html');
}
})
.catch (err => {
console.error('resolveProxy error:', err.message);
win.webContents.loadFile('assets/html/loading-page.html');
})
})
}

Expand Down Expand Up @@ -184,25 +187,28 @@ function getGameTime() {
}

function winReload() {
win.webContents.session.resolveProxy('https://www.indienost.com')
.then(str => {
let parts = str.split(' ');
if (parts[0] === 'PROXY') {
let resolvedProxyAddress = parts[1];
let resolvedProxyhref = 'http://' + resolvedProxyAddress;
https.globalAgent = new HttpsProxyAgent(resolvedProxyhref);
socket.close();
win.webContents.loadFile('assets/html/loading-page.html');
}
else {
https.globalAgent = new https.Agent({});
socket.close();
win.webContents.session.clearCache()
.then(() => {
win.webContents.session.resolveProxy('https://www.indienost.com')
.then(str => {
let parts = str.split(' ');
if (parts[0] === 'PROXY') {
let resolvedProxyAddress = parts[1];
let resolvedProxyhref = 'http://' + resolvedProxyAddress;
https.globalAgent = new HttpsProxyAgent(resolvedProxyhref);
socket.close();
win.webContents.loadFile('assets/html/loading-page.html');
}
else {
https.globalAgent = new https.Agent({});
socket.close();
win.webContents.loadFile('assets/html/loading-page.html');
}
})
.catch (err => {
console.error('resolveProxy error:', err.message);
win.webContents.loadFile('assets/html/loading-page.html');
}
})
.catch (err => {
console.error('resolveProxy error:', err.message);
win.webContents.loadFile('assets/html/loading-page.html');
})
})
}

Expand Down

0 comments on commit 95aabe9

Please sign in to comment.