mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.7 KiB
107 lines
3.7 KiB
3 years ago
|
import isDev from '../helpers/xutils'
|
||
|
|
||
3 years ago
|
export default async({ store, $vuetify: { theme }, route }) => {
|
||
3 years ago
|
/**
|
||
|
*
|
||
|
*/
|
||
|
store.watch(
|
||
3 years ago
|
state => state.settings.theme,
|
||
3 years ago
|
(c) => {
|
||
3 years ago
|
theme.themes.dark = { ...theme.themes.dark, ...c }
|
||
|
theme.themes.light = { ...theme.themes.light, ...c }
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
store.watch(
|
||
3 years ago
|
state => state.settings.darkTheme,
|
||
3 years ago
|
(isDark) => {
|
||
|
theme.dark = isDark
|
||
|
document.body.classList.add(isDark ? 'dark' : 'light')
|
||
|
document.body.classList.remove(isDark ? 'light' : 'dark')
|
||
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
document.body.classList.add(store.state.settings.darkTheme ? 'dark' : 'light')
|
||
|
document.body.classList.remove(store.state.settings.darkTheme ? 'light' : 'dark')
|
||
3 years ago
|
|
||
|
// In case of HMR, mutation occurs before nuxReady, so previously saved state
|
||
|
// gets replaced with original state received from server. So, we've to skip HMR.
|
||
|
// Also nuxtReady event fires for HMR as well, which results multiple registration of
|
||
|
// vuex-persistedstate plugin
|
||
|
// if (isHMR) return
|
||
|
//
|
||
|
// if (process.client) {
|
||
|
//
|
||
|
// window.onNuxtReady(async (nuxt) => {
|
||
3 years ago
|
if (route && route.query && 'embed' in route.query) {
|
||
|
window.rehydrated = true
|
||
3 years ago
|
store.commit('mutEmbed', true)
|
||
3 years ago
|
} else {
|
||
3 years ago
|
const createPersistedState = (await import('vuex-persistedstate')).default
|
||
|
const SecureLS = (await import('secure-ls')).default
|
||
|
const ls = new SecureLS({ isCompression: false })
|
||
|
|
||
3 years ago
|
createPersistedState({
|
||
|
fetchBeforeUse: true,
|
||
|
async rehydrated(store) {
|
||
|
window.rehydrated = true
|
||
|
},
|
||
3 years ago
|
paths: ['users', 'sqlClient', 'apiClient', 'panelSize', 'settings', 'graphqlClient', 'apiClientSwagger', 'app'],
|
||
3 years ago
|
...(
|
||
|
isDev()
|
||
|
? {}
|
||
|
: {
|
||
|
storage: {
|
||
|
getItem: key => ls.get(key),
|
||
|
setItem: (key, value) => ls.set(key, value),
|
||
|
removeItem: key => ls.remove(key)
|
||
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
|
})(store) // vuex plugins can be connected to store, even after creation
|
||
|
}
|
||
3 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|