gemercheung hace 2 años
padre
commit
7f6ab182e8
Se han modificado 6 ficheros con 111 adiciones y 55 borrados
  1. 2 2
      src/App.vue
  2. 21 4
      src/components/basic/loading.vue
  3. 23 40
      src/hooks/userApp.ts
  4. 55 0
      src/store/modules/rtc.ts
  5. 9 9
      src/store/modules/scene.ts
  6. 1 0
      types/sdk.d.ts

+ 2 - 2
src/App.vue

@@ -1,12 +1,12 @@
 <script setup lang="ts">
 import { onMounted, ref, h } from "vue";
-import { useApp } from "/@/hooks/userApp";
+import { createApp } from "/@/hooks/userApp";
 import tagView from "/@/components/custom/tagView.vue";
 import LoadingLogo from "/@/components/basic/loading.vue";
 const scene$ = ref<HTMLElement | null>(null);
 const show = ref(false);
 onMounted(async () => {
-  const [app] = useApp({
+  const app =await createApp({
     dom: scene$.value as HTMLElement,
     num: "KK-t-KwmO6julDh",
     mobile: true,

+ 21 - 4
src/components/basic/loading.vue

@@ -44,7 +44,14 @@
   </transition>
 </template>
 <script lang="ts" setup>
-import { ref, computed, onMounted, defineProps, watchEffect } from "vue";
+import {
+  ref,
+  computed,
+  onMounted,
+  defineProps,
+  watchEffect,
+  nextTick,
+} from "vue";
 import { useApp } from "/@/hooks/userApp";
 import { useSceneStore } from "/@/store/modules/scene";
 
@@ -74,10 +81,20 @@ const loadingLogoFile = computed(() => sceneStore.loadingLogoFile);
 onMounted(() => {
   enter.value = true;
 });
-watchEffect(() => {
+
+watchEffect(async () => {
   if (props.thumb) {
-    // const [app] = useApp();
-    // console.log("app", app);
+    // debugger
+    onMounted(async () => {
+      await nextTick();
+      const [app] = useApp();
+      console.log("app22", app);
+      app().then(async (sdk: any) => {
+        console.log("hey", sdk);
+        debugger;
+      });
+    });
+
     //   console.log("app", app);
     //   useApp().then((app) => {
     //     app.Scene.on("ready", () => {

+ 23 - 40
src/hooks/userApp.ts

@@ -4,12 +4,8 @@ import { onMounted, ref, unref } from 'vue'
 import consola from 'consola'
 
 const instance = (window as any).KanKan
-
-interface AppInstance {
-
-}
-
-
+let app: KanKanInstance;
+const deferred = instance.Deferred()
 interface appOptions {
     region?: string
     resource?: string
@@ -23,41 +19,28 @@ interface appOptions {
 // })
 
 // let deferred = KanKan.Deferred()
-export function useApp(options?: appOptions): [
-    any,
-
-] {
-    let app = null;
-    const deferred = instance.Deferred()
-    function register() {
-        if (app) {
-            return app
-        }
-        consola.log(import.meta.env)
-        if (options) {
-            if (!options?.region) {
-                options.region = import.meta.env.VUE_APP_REGION_URL
-            }
-            if (!options?.resource) {
-                options.region = import.meta.env.VUE_APP_RESOURCE_URL
-            }
-            if (!options?.resource) {
-                options.server = '/'
-            }
-            console.log('options', options)
-            if (!instance) {
-                consola.error('kankan SDK 没有引入!')
-            }
-            const _app = new instance(options)
-            deferred.resolve(_app);
-            (window as any).__sdk = _app
-            app = _app
-            return app
-        }
-
-
+export function createApp(options: appOptions): Promise<KanKanInstance> {
+    if (!options?.region) {
+        options.region = import.meta.env.VUE_APP_REGION_URL
+    }
+    if (!options?.resource) {
+        options.region = import.meta.env.VUE_APP_RESOURCE_URL
+    }
+    if (!options?.resource) {
+        options.server = '/'
     }
+    console.log('options', options)
+    if (!instance) {
+        consola.error('kankan SDK 没有引入!')
+    }
+    const _app = new instance(options)
+    deferred.resolve(_app);
+    (window as any).__sdk = _app
+    app = _app
+    return Promise.resolve(app)
+}
+
+export function useApp(): Promise<KanKanInstance | null> {
 
-    return [register()];
 }
 

+ 55 - 0
src/store/modules/rtc.ts

@@ -0,0 +1,55 @@
+import { defineStore } from 'pinia';
+
+interface floorsType {
+    id: string,
+    subgroup: string,
+    name: string
+}
+interface RtcState {
+ 
+}
+
+export const useRtcStore = defineStore({
+    id: 'scene',
+    state: (): RtcState => ({
+        socket: null,
+        showdaogou: false,
+        sdkAppId: "1400685498",
+        userId: '',
+        roomId: '',
+        role: '',
+        secretKey: '7500f8938c46c5d3c64621ae7826905eec9723bf218fbcf121242e056a4ee14f',
+        userSig: 'eJwtzcsOgjAQBdB-6RaDU2jLI3EhsrHRBdGNK2Po0IyvNAWJxvjvEmA5597c*bLj7hD26FnOohDYYrzJ4LOjhkZ*tejPd7wY9EJwnsV8brXmdnGODMu5AEggExBNSUcPHFQpnkopIJkU34784ApECjBvkB1e8MLJfWyLOAis06Wut4b0tVdL77RVTb35dGXby6o6rVfs9wdhLDRy',
+        audioDeviceId: '',
+        videoDeviceId: '',
+        cameraList: [],
+        microphoneList: [],
+        logs: [],
+        isJoined: false,
+        isPublished: false,
+        isShared: false,
+        remoteStreams: [],
+        invitedRemoteStreams: [],
+        avatar: null,
+
+    }),
+    getters: {
+        // tags() {
+        //     return this.tags
+        // },
+        // floors() {
+        //     return this.floors
+        // },
+        // metadata() {
+        //     return this.metadata
+        // },
+        musicURL() {
+            return ''
+        },
+        loadingLogoFile() {
+            return ''
+        }
+
+    },
+
+})

+ 9 - 9
src/store/modules/scene.ts

@@ -23,15 +23,15 @@ export const useSceneStore = defineStore({
         }
     }),
     getters: {
-        tags() {
-            return this.tags
-        },
-        floors() {
-            return this.floors
-        },
-        metadata() {
-            return this.metadata
-        },
+        // tags() {
+        //     return this.tags
+        // },
+        // floors() {
+        //     return this.floors
+        // },
+        // metadata() {
+        //     return this.metadata
+        // },
         musicURL() {
             return ''
         },

+ 1 - 0
types/sdk.d.ts

@@ -8,6 +8,7 @@ declare interface CadCadManagerType {
 }
 
 declare interface KanKanInstance {
+  [x: string]: any
   CadCadManager: CadCadManagerType
 }