mirror of
https://github.com/kihashi/stardew_community_checklist.git
synced 2025-10-19 08:03:17 +00:00
Persist state on refresh
This commit is contained in:
parent
7eab79409c
commit
154d56a3f9
@ -21,6 +21,7 @@
|
|||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"mdi-vue": "^3.0.13",
|
"mdi-vue": "^3.0.13",
|
||||||
"pinia": "^2.1.3",
|
"pinia": "^2.1.3",
|
||||||
|
"pinia-plugin-persistedstate": "^3.1.0",
|
||||||
"sass": "^1.62.1",
|
"sass": "^1.62.1",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-router": "^4.2.2"
|
"vue-router": "^4.2.2"
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const props = defineProps<Props>()
|
|||||||
const bundle = store.getBundleById(props.bundleItem.bundle_id)
|
const bundle = store.getBundleById(props.bundleItem.bundle_id)
|
||||||
|
|
||||||
const itemInBundle = computed(() => store.isBundleItemStored(props.bundleItem.id))
|
const itemInBundle = computed(() => store.isBundleItemStored(props.bundleItem.id))
|
||||||
console.log(itemInBundle)
|
|
||||||
const buttonClass = computed(() => {
|
const buttonClass = computed(() => {
|
||||||
if (itemInBundle.value) {
|
if (itemInBundle.value) {
|
||||||
return 'is-success'
|
return 'is-success'
|
||||||
@ -30,7 +30,6 @@ const numberInBundle = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function toggleItemInBundle() {
|
function toggleItemInBundle() {
|
||||||
console.log(itemInBundle.value)
|
|
||||||
if (!itemInBundle.value) {
|
if (!itemInBundle.value) {
|
||||||
store.storeItem(props.bundleItem.id)
|
store.storeItem(props.bundleItem.id)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
12
src/main.ts
12
src/main.ts
@ -1,12 +1,13 @@
|
|||||||
import '../node_modules/bulma/bulma.sass'
|
import * as mdijs from '@mdi/js'
|
||||||
|
import mdiVue from 'mdi-vue/v3'
|
||||||
import { createApp } from 'vue'
|
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
import piniaPluginPersistedState from 'pinia-plugin-persistedstate'
|
||||||
|
import { createApp } from 'vue'
|
||||||
|
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import mdiVue from 'mdi-vue/v3'
|
|
||||||
import * as mdijs from '@mdi/js'
|
import '../node_modules/bulma/bulma.sass'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ app.use(mdiVue, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
pinia.use(piniaPluginPersistedState)
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@ -43,6 +43,7 @@ export const useGeneralStore = defineStore('general', {
|
|||||||
skills,
|
skills,
|
||||||
rooms
|
rooms
|
||||||
}),
|
}),
|
||||||
|
persist: true,
|
||||||
getters: {
|
getters: {
|
||||||
getItemById:
|
getItemById:
|
||||||
(state) =>
|
(state) =>
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import BundleNav from '@/components/bundles/BundleNav.vue'
|
|||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useGeneralStore } from '@/store'
|
import { useGeneralStore } from '@/store'
|
||||||
|
|
||||||
const bundle = useGeneralStore().getBundleById(Number(router.currentRoute.value.params.id))
|
const store = useGeneralStore()
|
||||||
|
const bundle = store.getBundleById(Number(router.currentRoute.value.params.id))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@ -1731,6 +1731,11 @@ pify@^2.3.0:
|
|||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
||||||
|
|
||||||
|
pinia-plugin-persistedstate@^3.1.0:
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.1.0.tgz#eada2b61ecd478fce88e490a685210415cd7a1b4"
|
||||||
|
integrity sha512-8UN+vYMEPBdgNLwceY08mi5olI0wkYaEb8b6hD6xW7SnBRuPydWHlEhZvUWgNb/ibuf4PvufpvtS+dmhYjJQOw==
|
||||||
|
|
||||||
pinia@^2.1.3:
|
pinia@^2.1.3:
|
||||||
version "2.1.3"
|
version "2.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.1.3.tgz#50c70c7b4c94c109fade0ed4122231cbba72f8c5"
|
resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.1.3.tgz#50c70c7b4c94c109fade0ed4122231cbba72f8c5"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user