@@ -22,6 +22,23 @@ const props = defineProps<{
const infoStore = useInfoStore()
const configStore = useConfigStore()
+const result = useAsyncState(
+ () => {
+ return configStore.calc()
+ },
+ {},
+ { resetOnExecute: false },
+)
+
+const stopWatch = watch
(
+ () => {
+ return JSON.stringify(configStore.config)
+ },
+ useDebounceFn(async () => {
+ await result.execute()
+ }, 800),
+)
+
onMounted(async () => {
await infoStore.createCharacter(props.alter, '0')
configStore.loadConfig()
@@ -29,6 +46,13 @@ onMounted(async () => {
configStore.saveConfig()
})
})
+
+onUnmounted(() => {
+ stopWatch()
+ window.removeEventListener('beforeunload', () => {
+ configStore.saveConfig()
+ })
+})