mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-21 20:08:41 -05:00
fix(ui): darkMode lost on cache reset
This commit is contained in:
@@ -166,12 +166,6 @@ export default {
|
||||
|
||||
async applyDarkMode (enabled) {
|
||||
localStorage.setItem('vue-ui-dark-mode', enabled.toString())
|
||||
const el = document.getElementsByTagName('html')[0]
|
||||
if (enabled) {
|
||||
el.classList.add('vue-ui-dark-mode')
|
||||
} else {
|
||||
el.classList.remove('vue-ui-dark-mode')
|
||||
}
|
||||
await this.$apollo.mutate({
|
||||
mutation: DARK_MODE_SET,
|
||||
variables: {
|
||||
|
||||
@@ -22,6 +22,12 @@ export default {
|
||||
darkMode: enabled
|
||||
}
|
||||
cache.writeData({ data })
|
||||
const el = document.getElementsByTagName('html')[0]
|
||||
if (enabled) {
|
||||
el.classList.add('vue-ui-dark-mode')
|
||||
} else {
|
||||
el.classList.remove('vue-ui-dark-mode')
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import clientStateResolvers from './state/resolvers'
|
||||
// import CONNECTED from './graphql/connected.gql'
|
||||
import CONNECTED_SET from './graphql/connectedSet.gql'
|
||||
import LOADING_CHANGE from './graphql/loadingChange.gql'
|
||||
import DARK_MODE_SET from './graphql/darkModeSet.gql'
|
||||
|
||||
// Install the vue plugin
|
||||
Vue.use(VueApollo)
|
||||
@@ -67,6 +68,13 @@ export async function resetApollo () {
|
||||
} catch (e) {
|
||||
// Potential errors
|
||||
}
|
||||
const raw = localStorage.getItem('vue-ui-dark-mode')
|
||||
apolloClient.mutate({
|
||||
mutation: DARK_MODE_SET,
|
||||
variables: {
|
||||
enabled: raw === 'true'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Connected state */
|
||||
|
||||
Reference in New Issue
Block a user