customer.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { onMounted, onUnmounted, provide, ref } from 'vue'
  3. import { KkDaikan } from 'kankan-components'
  4. import type { DaikanUserInfoType } from 'kankan-components'
  5. const loading = ref(false)
  6. const userInfo = ref<DaikanUserInfoType>({
  7. userId: 'test-user-222',
  8. roomId: 'test-roomid-1',
  9. avatar: '',
  10. nickName: 'customer',
  11. role: 'customer',
  12. })
  13. const socketUrl = ref('wss://testws.4dkankan.com')
  14. const socketUrlLib = ref(
  15. 'https://cdn.bootcdn.net/ajax/libs/socket.io/4.5.4/socket.io.min.js'
  16. )
  17. onMounted(() => {
  18. const __win = window as any
  19. if (!__win.__sdk) {
  20. const __sdk = (__win.__sdk = new __win.KanKan({
  21. num: 'KJ-t-wOXfx2SDFy',
  22. server: '#DEMOSEVER#',
  23. }))
  24. provide('__sdk', __sdk)
  25. __sdk.Scene.on('ready', () => (loading.value = true))
  26. __sdk.mount('#scene').render()
  27. }
  28. })
  29. onUnmounted(() => {
  30. const __win = window as any
  31. if (__win.__sdk) {
  32. __win.__sdk = null
  33. }
  34. })
  35. </script>
  36. <template>
  37. <div id="scene" class="scene">
  38. <Teleport v-if="loading" to=".kankan-plugins">
  39. <div xui_daikan_view>
  40. <kk-daikan
  41. :socket-lib="socketUrlLib"
  42. :user-info="userInfo"
  43. :socket-url="socketUrl"
  44. />
  45. </div>
  46. </Teleport>
  47. </div>
  48. </template>
  49. <style>
  50. html,
  51. body,
  52. #app {
  53. width: 100%;
  54. height: 100%;
  55. padding: 0;
  56. margin: 0;
  57. }
  58. .scene {
  59. width: 100%;
  60. height: 100%;
  61. padding: 0;
  62. margin: 0;
  63. }
  64. </style>