diff --git a/src/main/index.js b/src/main/index.js index 92e3ec9d..c97b3b4c 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -65,21 +65,57 @@ if (!isDev) { }) app.on('ready', (event, commandLine, workingDirectory) => { - settingsDb.findOne({ - _id: 'disableSmoothScrolling' + settingsDb.find({ + $or: [ + { _id: 'disableSmoothScrolling' }, + { _id: 'useProxy' }, + { _id: 'proxyProtocol' }, + { _id: 'proxyHostname' }, + { _id: 'proxyPort' } + ] }, function (err, doc) { if (err) { app.exit(0) return } - if (doc !== null && doc.value) { + let disableSmoothScrolling = false + let useProxy = false + let proxyProtocol = 'socks5' + let proxyHostname = '127.0.0.1' + let proxyPort = '9050' + + if (typeof doc === 'object' && doc.length > 0) { + doc.forEach((dbItem) => { + switch (dbItem._id) { + case 'disableSmoothScrolling': + disableSmoothScrolling = dbItem.value + break + case 'useProxy': + useProxy = dbItem.value + break + case 'proxyProtocol': + proxyProtocol = dbItem.value + break + case 'proxyHostname': + proxyHostname = dbItem.value + break + case 'proxyPort': + proxyPort = dbItem.value + break + } + }) + } + + if (disableSmoothScrolling) { app.commandLine.appendSwitch('disable-smooth-scrolling') } else { app.commandLine.appendSwitch('enable-smooth-scrolling') } - createWindow() + const proxyUrl = `${proxyProtocol}://${proxyHostname}:${proxyPort}` + + createWindow(useProxy, proxyUrl) if (isDev) { installDevTools() @@ -99,21 +135,57 @@ if (!isDev) { }) app.on('ready', () => { - settingsDb.findOne({ - _id: 'disableSmoothScrolling' + settingsDb.find({ + $or: [ + { _id: 'disableSmoothScrolling' }, + { _id: 'useProxy' }, + { _id: 'proxyProtocol' }, + { _id: 'proxyHostname' }, + { _id: 'proxyPort' } + ] }, function (err, doc) { if (err) { app.exit(0) return } - if (doc !== null && doc.value) { + let disableSmoothScrolling = false + let useProxy = false + let proxyProtocol = 'socks5' + let proxyHostname = '127.0.0.1' + let proxyPort = '9050' + + if (typeof doc === 'object' && doc.length > 0) { + doc.forEach((dbItem) => { + switch (dbItem._id) { + case 'disableSmoothScrolling': + disableSmoothScrolling = dbItem.value + break + case 'useProxy': + useProxy = dbItem.value + break + case 'proxyProtocol': + proxyProtocol = dbItem.value + break + case 'proxyHostname': + proxyHostname = dbItem.value + break + case 'proxyPort': + proxyPort = dbItem.value + break + } + }) + } + + if (disableSmoothScrolling) { app.commandLine.appendSwitch('disable-smooth-scrolling') } else { app.commandLine.appendSwitch('enable-smooth-scrolling') } - createWindow() + const proxyUrl = `${proxyProtocol}://${proxyHostname}:${proxyPort}` + + createWindow(useProxy, proxyUrl) if (isDev) { installDevTools() @@ -137,7 +209,7 @@ async function installDevTools () { } } -function createWindow () { +function createWindow (useProxy = false, proxyUrl = '') { /** * Initial window options */ @@ -164,6 +236,12 @@ function createWindow () { height: 800 }) + if (useProxy) { + mainWindow.webContents.session.setProxy({ + proxyRules: proxyUrl + }) + } + settingsDb.findOne({ _id: 'bounds' }, function (err, doc) { @@ -264,6 +342,17 @@ function createWindow () { mainWindow.close() createWindow() }) + + ipcMain.on('enableProxy', (event, url) => { + console.log(url) + mainWindow.webContents.session.setProxy({ + proxyRules: url + }) + }) + + ipcMain.on('disableProxy', () => { + mainWindow.webContents.session.setProxy({}) + }) } app.on('window-all-closed', () => { diff --git a/src/renderer/components/data-settings/data-settings.js b/src/renderer/components/data-settings/data-settings.js index 020fc6e4..975543a3 100644 --- a/src/renderer/components/data-settings/data-settings.js +++ b/src/renderer/components/data-settings/data-settings.js @@ -78,6 +78,12 @@ export default Vue.extend({ } }, methods: { + openProfileSettings: function () { + this.$router.push({ + path: '/settings/profile/' + }) + }, + importSubscriptions: function (option) { this.showImportSubscriptionsPrompt = false diff --git a/src/renderer/components/data-settings/data-settings.vue b/src/renderer/components/data-settings/data-settings.vue index b0096c01..93bb8dc3 100644 --- a/src/renderer/components/data-settings/data-settings.vue +++ b/src/renderer/components/data-settings/data-settings.vue @@ -27,6 +27,22 @@ @click="exportHistory" /> + + +

+ {{ $t("Settings.Data Settings.How do I import my subscriptions?") }} +

+
+
+ + + { + console.log(response) + this.proxyIp = response.ip + this.proxyCountry = response.country_name + this.proxyRegion = response.region_name + this.proxyCity = response.city + this.dataAvailable = true + }).fail((xhr, textStatus, error) => { + console.log(xhr) + console.log(textStatus) + console.log(error) + this.showToast({ + message: this.$t('Settings.Proxy Settings["Error getting network information. Is your proxy configured properly?"]') + }) + this.dataAvailable = false + }).always(() => { + if (!this.useProxy) { + this.disableProxy() + } + this.isLoading = false + }) + }, + + ...mapActions([ + 'showToast', + 'updateUseProxy', + 'updateProxyProtocol', + 'updateProxyHostname', + 'updateProxyPort' + ]) + } +}) diff --git a/src/renderer/components/proxy-settings/proxy-settings.vue b/src/renderer/components/proxy-settings/proxy-settings.vue new file mode 100644 index 00000000..34c2194b --- /dev/null +++ b/src/renderer/components/proxy-settings/proxy-settings.vue @@ -0,0 +1,78 @@ + + +