<script setup lang="ts">
import { onMounted, onUnmounted, provide, ref } from 'vue'
import { KkDaikan } from 'kankan-components'
const loading = ref(false)

onMounted(() => {
  const __win = window as any
  if (!__win.__sdk) {
    const __sdk = (__win.__sdk = new __win.KanKan({
      num: 'KJ-t-wOXfx2SDFy',
      server: '#DEMOSEVER#',
    }))
    provide('__sdk', __sdk)
    debugger
    __sdk.TagManager.on('ready', () => (loading.value = true))
    __sdk.mount('#scene').render()
  }
})
onUnmounted(() => {
  const __win = window as any
  if (__win.__sdk) {
    __win.__sdk = null
  }
})
const handleTagview = ({ id }) => {
  console.log('id', id)
}
</script>

<template>
  <div id="scene" class="scene">
    <Teleport v-if="loading" to=".kankan-plugins">
      <!-- <div xui_daikan_view>
        <kk-daikan />
      </div> -->
    </Teleport>
  </div>
</template>
<style>
html,
body,
#app {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}
.scene {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}
</style>
