Skip to content

Commit

Permalink
fix: handle spa fallback (regression)
Browse files Browse the repository at this point in the history
Resolves #21
  • Loading branch information
atinux committed Aug 4, 2020
1 parent 8ce7abb commit b92d64b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/templates/plugin.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ const cookieOptions = JSON.parse('<%= JSON.stringify(options.cookie.options) %>'
const colorMode = window['<%= options.globalName %>']

export default function (ctx, inject) {
let data = ctx.nuxtState.colorMode
// For SPA mode or fallback
if (!data) {
data = {
preference: colorMode.preference,
value: colorMode.value,
unknown: colorMode.preference === 'system'
}
}
const $colorMode = new Vue({
data: ctx.nuxtState.colorMode,
data,
watch: {
preference (preference) {
if (preference === 'system') {
Expand Down

0 comments on commit b92d64b

Please sign in to comment.