diff --git a/package-lock.json b/package-lock.json index e9c6700..29c416e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "weather-bar-app", - "version": "0.6.0", + "version": "0.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bbb9495..a367b6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "weather-bar-app", - "version": "0.6.0", + "version": "0.7.0", "author": "Peter Schmalfeldt ", "description": "Weather Bar is a Weather Application that lives in your Menu Bar giving you beautiful access to real-time weather conditions and a generous 15-day forecast.", "keywords": [ diff --git a/src/main/index.js b/src/main/index.js index e097866..2304a8c 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -10,6 +10,8 @@ import autoUpdater from './auto-update' import util from './util' import { version as currentVersion } from '../../package.json' +import { i18n as $t } from '../translations/i18n' + const machineId = machineIdSync({ original: true }) let appSettings = {} @@ -49,6 +51,9 @@ app.on('web-contents-created', (event, contents) => { }) }) +// Setup Context Menu +let contextMenu = null + // Setup Main Weather Bar App const mb = menubar({ index: (process.env.NODE_ENV === 'development') ? 'http://localhost:9080' : `file://${__dirname}/index.html`, @@ -56,79 +61,25 @@ const mb = menubar({ width: 280, height: 480, alwaysOnTop: true, - title: 'Weather Bar', + title: $t(appSettings.app_language, 'app.title'), preloadWindow: true, resizable: false }) -mb.on('ready', function ready () { - autoUpdater() - - mb.setOption('title', 'Weather Bar') - - globalShortcut.register('CommandOrControl+Shift+W', () => { - if (mb.window.isVisible()) { - mb.window.hide() - } else { - mb.window.show() - } - }) - - ipcMain.on('save-settings', (event, settings) => { - appSettings = settings - }) - - ipcMain.on('get-uuid', (event) => { - mb.window.send('set-uuid', machineId) - }) - - ipcMain.on('set-weather', (event, weather, settings) => { - util.setWeather(mb, weather, settings) - }) - - ipcMain.on('set-always-on-top', (event, preference) => { - mb.setOption('alwaysOnTop', preference) - appSettings.app_always_on_top = preference - }) - - ipcMain.on('set-launch-at-startup', (event, preference) => { - console.log('set-launch-at-startup', preference) - }) - - ipcMain.on('set-icon-preference', (event, preference) => { - console.log('set-icon-preference', preference) - }) - - ipcMain.on('close', (event, args) => { - app.quit() - }) - - ipcMain.on('will-navigate', (event, args) => { - const url = args.url - shell.openExternal(url) - }) -}) - -mb.on('focus-lost', () => { - if (!appSettings.app_always_on_top) { - if (mb.window.isVisible()) { - mb.window.hide() - } - } -}) - -// Add Context Menu to Weather Bar App -mb.on('after-create-window', () => { - const contextMenu = Menu.buildFromTemplate([ +const makeMenu = () => { + return Menu.buildFromTemplate([ { - label: 'About Weather Bar', + label: $t(appSettings.app_language, 'context.menu.about'), click () { dialog.showMessageBox(null, { type: 'none', icon: path.join(__static, '/logo.png'), message: `Weather Bar v${currentVersion}`, - detail: 'Weather Bar is an Open Source Application created by Peter Schmalfeldt.', - buttons: ['Close', 'Website'], + detail: $t(appSettings.app_language, 'context.menu.dialog.detail'), + buttons: [ + $t(appSettings.app_language, 'context.menu.dialog.close'), + $t(appSettings.app_language, 'context.menu.dialog.website') + ], defaultId: 0, noLink: true }, (selected) => { @@ -139,26 +90,26 @@ mb.on('after-create-window', () => { } }, { - label: `Version ${currentVersion}`, + label: $t(appSettings.app_language, 'context.menu.version', { version: currentVersion }), enabled: false }, { type: 'separator' }, { - label: 'Weather Bar Website', + label: $t(appSettings.app_language, 'context.menu.website'), click () { shell.openExternal('https://weatherbarapp.com') } }, { - label: 'License Agreement', + label: $t(appSettings.app_language, 'context.menu.license'), click () { shell.openExternal('https://github.com/manifestinteractive/weather-bar-app/blob/master/LICENSE') } }, { - label: 'Contact Support', + label: $t(appSettings.app_language, 'context.menu.support'), click () { shell.openExternal('https://github.com/manifestinteractive/weather-bar-app/issues') } @@ -167,7 +118,7 @@ mb.on('after-create-window', () => { type: 'separator' }, { - label: 'Local Weather', + label: $t(appSettings.app_language, 'app.menu.localWeather'), click () { mb.window.send('go-to-local-weather') if (!mb.window.isVisible()) { @@ -176,7 +127,7 @@ mb.on('after-create-window', () => { } }, { - label: 'Saved Locations', + label: $t(appSettings.app_language, 'app.menu.savedLocations'), click () { mb.window.send('go-to-saved-locations') if (!mb.window.isVisible()) { @@ -185,7 +136,7 @@ mb.on('after-create-window', () => { } }, { - label: 'New Location', + label: $t(appSettings.app_language, 'app.menu.newLocation'), click () { mb.window.send('go-to-new-location') if (!mb.window.isVisible()) { @@ -194,7 +145,7 @@ mb.on('after-create-window', () => { } }, { - label: 'Preferences...', + label: $t(appSettings.app_language, 'app.menu.preferences'), click () { mb.window.send('go-to-preferences') if (!mb.window.isVisible()) { @@ -206,7 +157,7 @@ mb.on('after-create-window', () => { type: 'separator' }, { - label: 'Developer Tools', + label: $t(appSettings.app_language, 'context.menu.devTools'), click () { mb.window.webContents.openDevTools() } @@ -215,28 +166,93 @@ mb.on('after-create-window', () => { type: 'separator' }, { - label: 'Quit Weather Bar', + label: $t(appSettings.app_language, 'context.menu.quit'), click () { mb.app.quit() } } ]) +} + +mb.on('ready', function ready () { + autoUpdater() + + mb.setOption('title', $t(appSettings.app_language, 'app.title')) + + globalShortcut.register('CommandOrControl+Shift+W', () => { + if (mb.window.isVisible()) { + mb.window.hide() + } else { + mb.window.show() + } + }) + + ipcMain.on('save-settings', (event, settings) => { + appSettings = settings + contextMenu = makeMenu() + }) + + ipcMain.on('save-setting', (event, key, value) => { + appSettings[key] = value + contextMenu = makeMenu() + }) + + ipcMain.on('get-uuid', (event) => { + mb.window.send('set-uuid', machineId) + }) + + ipcMain.on('set-weather', (event, weather, settings) => { + util.setWeather(mb, weather, settings) + }) + + ipcMain.on('set-always-on-top', (event, preference) => { + mb.setOption('alwaysOnTop', preference) + appSettings.app_always_on_top = preference + }) + + ipcMain.on('set-launch-at-startup', (event, preference) => { + console.log('set-launch-at-startup', preference) + }) + + ipcMain.on('set-icon-preference', (event, preference) => { + console.log('set-icon-preference', preference) + }) + + ipcMain.on('close', (event, args) => { + app.quit() + }) + + ipcMain.on('will-navigate', (event, args) => { + const url = args.url + shell.openExternal(url) + }) +}) + +mb.on('focus-lost', () => { + if (!appSettings.app_always_on_top) { + if (mb.window.isVisible()) { + mb.window.hide() + } + } +}) + +// Add Context Menu to Weather Bar App +mb.on('after-create-window', () => { + contextMenu = makeMenu() if (process.platform !== 'linux') { mb.tray.on('right-click', () => { mb.tray.popUpContextMenu(contextMenu) }) } else { - mb.tray.setToolTip('Show Weather Bar') + mb.tray.setToolTip($t(appSettings.app_language, 'context.menu.toggle')) } mb.tray.on('click', () => { if (mb.window.isVisible()) { - mb.tray.setToolTip('Hide Weather Bar') mb.window.send('app-opened') mb.window.show() } else { - mb.tray.setToolTip('Show Weather Bar') mb.window.send('app-closed') mb.window.hide() } diff --git a/src/main/util.js b/src/main/util.js index 8326e50..cb7ff86 100644 --- a/src/main/util.js +++ b/src/main/util.js @@ -1,6 +1,6 @@ import path from 'path' -const setWeather = (mb, data) => { +const setWeather = (mb, data, settings) => { if (process.platform === 'darwin') { if (data.setting === 'condition') { mb.tray.setTitle('') @@ -26,12 +26,8 @@ const setWeather = (mb, data) => { } } - if (process.platform !== 'linux') { - if (data.tooltip) { - mb.tray.setToolTip(data.tooltip) - } else { - mb.tray.setToolTip(`${data.title}°`) - } + if (process.platform !== 'linux' && data.tooltip) { + mb.tray.setToolTip(data.tooltip) } } diff --git a/src/renderer/app.vue b/src/renderer/app.vue index 92fdc4c..01cb689 100644 --- a/src/renderer/app.vue +++ b/src/renderer/app.vue @@ -75,6 +75,12 @@ EventBus.$on('setClassNames', (classNames) => { this.classNames = classNames }) + + EventBus.$off('updatedSettings') + EventBus.$on('updatedSettings', () => { + this.getWeather() + this.getForecast() + }) }, bindElectronEvents () { if (typeof this.$electron !== 'undefined' && typeof this.$electron.ipcRenderer !== 'undefined') { @@ -182,6 +188,7 @@ if (response.data) { this.$store.dispatch('loadSettings', response.data) this.$electron.ipcRenderer.send('save-settings', response.data) + this.$i18n.locale = response.data.app_language this.updateStatus('settings') } else { @@ -195,7 +202,7 @@ } }, getWeather () { - const savedLocations = this.$store.getters.getSavedLocations || {} + const savedLocations = Object.assign({}, this.$store.getters.getSavedLocations) const total = Object.keys(savedLocations).length let current = 0 @@ -231,7 +238,7 @@ this.timers.current = setTimeout(this.getWeather, TIMER_CURRENT_WEATHER) }, getForecast () { - const savedLocations = this.$store.getters.getSavedLocations || {} + const savedLocations = Object.assign({}, this.$store.getters.getSavedLocations) const total = Object.keys(savedLocations).length let current = 0 @@ -244,7 +251,7 @@ api.getWeatherForecastByGeo(location, (forecast) => { if (typeof forecast.data !== 'undefined' && typeof forecast.data.list !== 'undefined') { - let saveForecast = util.parseWeatherForecast(location.hash_key, forecast.data, this.$store.state.settings) + let saveForecast = util.parseWeatherForecast(location.hash_key, forecast.data, this.$store.state.settings, this.$i18n.t('ui.today')) this.$store.dispatch('saveForecast', saveForecast) diff --git a/src/renderer/assets/css/app.css b/src/renderer/assets/css/app.css index 51293b6..6fbab93 100644 --- a/src/renderer/assets/css/app.css +++ b/src/renderer/assets/css/app.css @@ -79,17 +79,14 @@ body { } #app { - min-width: 280px; - min-height: 480px; - max-width: 480px; - max-height: 853px; - width: 100%; - height: 100%; + width: 280px; + height: 480px; margin: 0 auto; box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5); - background: #132936; + background: linear-gradient(to bottom, #2a3641 0%, #535f6a 100%); position: relative; overflow: hidden; + transform: translateZ(0); } ::selection { diff --git a/src/renderer/assets/scss/_animations.scss b/src/renderer/assets/scss/_animations.scss index f21ff53..723ed6e 100644 --- a/src/renderer/assets/scss/_animations.scss +++ b/src/renderer/assets/scss/_animations.scss @@ -38,21 +38,6 @@ } } -@keyframes stem { - 0% { - opacity: 1; - } - 65% { - opacity: 1; - } - 75% { - opacity: 0; - } - 100% { - opacity: 0; - } -} - @keyframes move-fog { from { background-position: 0 0;} to { background-position: 600px 0; } diff --git a/src/renderer/assets/scss/_scene.scss b/src/renderer/assets/scss/_scene.scss index 3adb670..16a44f0 100644 --- a/src/renderer/assets/scss/_scene.scss +++ b/src/renderer/assets/scss/_scene.scss @@ -10,6 +10,8 @@ @import 'scene/scene-10'; .scene { + transform: translateZ(0); + .menu-toggle { position: absolute; top: 20px; @@ -66,7 +68,8 @@ left: 0; width: 100vw; height: 100vh; - transition: all 3s ease; + z-index: 1; + transform: translateZ(0); } .starry-sky { position: absolute; @@ -75,10 +78,10 @@ width: 100vw; height: 100vh; z-index: 2; + background: transparent; + transform: translateZ(0); .stars { - will-change: opacity; - &.large { height: 2px; width: 2px; diff --git a/src/renderer/assets/scss/weather/_rain.scss b/src/renderer/assets/scss/weather/_rain.scss index d174ee6..e9fe8de 100644 --- a/src/renderer/assets/scss/weather/_rain.scss +++ b/src/renderer/assets/scss/weather/_rain.scss @@ -3,16 +3,17 @@ top: 0; left: 0; z-index: 15; - width: 100%; - height: 100%; + height: 480px; + width: 280px; .rain { position: absolute; left: 0; - left: 0; - width: 100%; - height: 100%; + top: 0; + width: 280px; + height: 480px; z-index: 15; + transform: translate3d(0, 0, 0); &.back-row { z-index: 15; @@ -21,13 +22,10 @@ } .stem { - width: 1px; + width: 2px; height: 60%; margin-left: 7px; background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.25)); - animation: stem 0.5s linear infinite; - transform: translate3d(0, 0, 0); - perspective: 1000; } .drop { @@ -37,7 +35,5 @@ height: 120px; pointer-events: none; animation: drop 0.5s linear infinite; - transform: translate3d(0, 0, 0); - perspective: 1000; } } diff --git a/src/renderer/components/page/new-location.vue b/src/renderer/components/page/new-location.vue index 1a60df1..e4caa45 100644 --- a/src/renderer/components/page/new-location.vue +++ b/src/renderer/components/page/new-location.vue @@ -10,7 +10,7 @@
@@ -27,17 +27,17 @@
- No Matching Cities + {{ $t('page.newLocation.noMatch') }}
@@ -51,8 +51,9 @@ .new-location { .page-content { z-index: 500; - position: relative; - height: 100%; + position: absolute; + height: 480px; + width: 280px; } .scene { @@ -240,7 +241,7 @@ weather: false, forecast: false }, - settings: this.$store.getters.getSettings + settings: Object.assign({}, this.$store.getters.getSettings) } }, watch: { @@ -338,7 +339,7 @@ api.getWeatherForecastByGeo(data, (weather) => { if (typeof weather.data !== 'undefined' && typeof weather.data.list !== 'undefined') { - let saveForecast = util.parseWeatherForecast(data.hash_key, weather.data, this.$store.state.settings) + let saveForecast = util.parseWeatherForecast(data.hash_key, weather.data, this.$store.state.settings, this.$i18n.t('ui.today')) this.$store.dispatch('saveForecast', saveForecast) this.goToNewLocation('forecast', data.hash_key) diff --git a/src/renderer/components/page/preferences.vue b/src/renderer/components/page/preferences.vue index 9d37899..71da8ba 100644 --- a/src/renderer/components/page/preferences.vue +++ b/src/renderer/components/page/preferences.vue @@ -5,27 +5,27 @@
-
+
-

Settings

+

{{ $t('page.preferences.settings') }}

- +