1
0
forked from a/lifeto-shop
lifeto-shop/src/components/CharacterRoulette.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2022-07-03 10:25:12 +00:00
<template>
<div v-for="v in characters">
<CharacterCard :character="v" />
</div>
</template>
<script lang="ts" setup>
import CharacterCard from './CharacterCard.vue';
2022-07-06 07:48:11 +00:00
const { chars, accounts, invs, activeTable } = useStoreRef()
2022-07-03 10:25:12 +00:00
const characters = ref([] as string[])
2022-07-06 07:48:11 +00:00
watch(chars, () => {
2022-07-03 10:25:12 +00:00
characters.value = [...new Set([...characters.value, ...invs.value.keys()])]
}, { deep: true })
const session = storage.GetSession()
2022-07-03 15:50:41 +00:00
const api:LTOApi = getLTOState(LTOApiv0, session, useStoreRef())
2022-07-06 07:48:11 +00:00
2022-07-03 10:25:12 +00:00
api.GetAccounts().then(xs => {
xs.forEach(x => {
2022-07-06 07:48:11 +00:00
characters.value.push(...x.characters.map(x=>x.path))
2022-07-03 10:25:12 +00:00
})
2022-07-06 07:48:11 +00:00
characters.value = [...new Set([...characters.value])]
2022-07-03 10:25:12 +00:00
})
2022-07-03 15:50:41 +00:00
onMounted(()=>{
let val = invs.value.get(activeTable.value)
if(!val || Object.values(val.items).length == 0) {
api.GetInventory(activeTable.value)
}
})
2022-07-03 10:25:12 +00:00
</script>
<script lang="ts">
2022-07-03 15:50:41 +00:00
import { defineComponent, computed, PropType, defineProps, defineEmits, ref, watch, onMounted } from 'vue';
import { getLTOState, LTOApi, LTOApiv0 } from '../lib/lifeto';
2022-07-03 10:25:12 +00:00
import { LoginHelper, Session } from '../lib/session';
import { storage } from '../session_storage';
import { useStore, useStoreRef } from '../state/state';
import log from 'loglevel';
</script>