2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import TopNav from './components/top-nav/top-nav.vue'
|
|
|
|
import SideNav from './components/side-nav/side-nav.vue'
|
|
|
|
import $ from 'jquery'
|
|
|
|
import { shell } from 'electron'
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'App',
|
|
|
|
components: {
|
|
|
|
TopNav,
|
|
|
|
SideNav
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isOpen: function () {
|
|
|
|
return this.$store.getters.getIsSideNavOpen
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
2020-02-27 03:10:56 +00:00
|
|
|
this.$store.dispatch('grabUserSettings')
|
|
|
|
|
2020-03-01 03:37:02 +00:00
|
|
|
let baseTheme = localStorage.getItem('baseTheme')
|
|
|
|
let mainColor = localStorage.getItem('mainColor')
|
|
|
|
let secColor = localStorage.getItem('secColor')
|
2020-02-27 03:10:56 +00:00
|
|
|
|
2020-03-01 03:37:02 +00:00
|
|
|
if (baseTheme === null) {
|
|
|
|
baseTheme = 'light'
|
2020-02-27 03:10:56 +00:00
|
|
|
}
|
|
|
|
|
2020-03-01 03:37:02 +00:00
|
|
|
if (mainColor === null) {
|
|
|
|
mainColor = 'mainRed'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secColor === null) {
|
|
|
|
secColor = 'secBlue'
|
|
|
|
}
|
|
|
|
|
|
|
|
const theme = {
|
|
|
|
baseTheme: baseTheme,
|
|
|
|
mainColor: mainColor,
|
|
|
|
secColor: secColor
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateTheme(theme)
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
// Open links externally by default
|
|
|
|
$(document).on('click', 'a[href^="http"]', (event) => {
|
|
|
|
const el = event.currentTarget
|
|
|
|
console.log(el)
|
|
|
|
if (typeof (shell) !== 'undefined') {
|
|
|
|
event.preventDefault()
|
|
|
|
shell.openExternal(el.href)
|
|
|
|
}
|
|
|
|
})
|
2020-02-27 03:10:56 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateTheme: function (theme) {
|
|
|
|
console.log(theme)
|
2020-03-01 03:37:02 +00:00
|
|
|
const className = `${theme.baseTheme} ${theme.mainColor} ${theme.secColor}`
|
2020-02-27 03:10:56 +00:00
|
|
|
const body = document.getElementsByTagName('body')[0]
|
2020-03-01 03:37:02 +00:00
|
|
|
body.className = className
|
|
|
|
localStorage.setItem('baseTheme', theme.baseTheme)
|
|
|
|
localStorage.setItem('mainColor', theme.mainColor)
|
|
|
|
localStorage.setItem('secColor', theme.secColor)
|
2020-02-27 03:10:56 +00:00
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
})
|