<script setup lang="ts">
import { onMounted, provide, ref } from 'vue'
import { UITag } from 'kankan-components'

const tags = ref<any>([])

onMounted(() => {
    const __win = window as any
    const __sdk = (__win.__sdk = new __win.KanKan({
        num: 'KJ-t-wOXfx2SDFy',
        // server: 'https://test.4dkankan.com',
        server: '/demoServer',
    }))
    provide('__sdk', __sdk)
    __sdk.TagManager.on('loaded', (data: any) => __sdk.TagManager.load((tags.value = data) && tags.value))
    __sdk.mount('#scene').render()
})
const handleTagview = ({ id }) => {
    console.log('id', id)
}
</script>

<template>
    <div id="scene">
        <Teleport v-if="tags.length > 0" to=".kankan-plugins">
            <div xui_tags_view>
                <UITag v-for="(item, index) in tags" :key="index" :tag="item" @click="handleTagview" />
            </div>
            <!-- <div xui_tags_view>
        <UITag v-for="(item, index) in tags" :key="index" :tag="item">
          <template #content="{ data, id, isClick, isShow, x, y }">
            <div>id:{{ id }}</div>
            <div>isClick:{{ isClick }}</div>
            <div>isShow:{{ isShow }}</div>
            <div>x:{{ x }}</div>
            <div>y:{{ y }}</div>
          </template>
        </UITag>
      </div> -->
        </Teleport>
    </div>
</template>
<style>
html,
body,
#app,
#scene {
    width: 100%;
    height: 600px;
    padding: 0;
    margin: 0;
}
</style>
