index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <transition mode="out-in">
  3. <div>
  4. <dialogIndex @closeDialog="closeDialog" @confirmDialog="confirmDialog" v-if="dialog == 'dialogIndex'"></dialogIndex>
  5. <dialogShare :shareLink="shareLink" @closeDialog="closeDialog" v-if="dialog == 'dialogShare'"></dialogShare>
  6. <createdRoom v-if="showCreated" @closeCreated="closeCreated" @createdConfirm="createdConfirm()"></createdRoom>
  7. <PageRtcLive @closeSocket="confirmDialog" @openDialog="openDialog" v-if="show"></PageRtcLive>
  8. </div>
  9. </transition>
  10. </template>
  11. <script setup>
  12. import PageRtcLive from "./PageRtcLive";
  13. // import Draw from "./paint/Draw";
  14. import createdRoom from "./dialog/createdRoom";
  15. import dialogIndex from "./dialog/index.vue";
  16. import dialogShare from "./dialog/share.vue";
  17. import browser from "@/utils/browser";
  18. import { onMounted, watch, computed, ref, nextTick } from "vue";
  19. import { useStore } from "vuex";
  20. import { useApp, getApp } from "@/app";
  21. const store = useStore();
  22. const shareLink = ref("");
  23. const dialog = ref("");
  24. const show = ref(false);
  25. const showPaint = ref(true);
  26. const showCreated = ref(false);
  27. const roomId = ref(browser.getURLParam("roomId"));
  28. const role = ref(browser.getURLParam("role"));
  29. const userName = ref(browser.getURLParam("name"));
  30. const socket = computed(() => store.getters["rtc/socket"]);
  31. const openDialog = (str, link) => {
  32. shareLink.value = link;
  33. dialog.value = str;
  34. };
  35. const closeDialog = (str, link) => {
  36. dialog.value = "";
  37. dialog.value = str;
  38. };
  39. const confirmDialog = async () => {
  40. await getApp().Connect.follow.exit();
  41. store.commit("rtc/setIsJoined", false);
  42. if (socket.value) {
  43. if(role.value == 'leader'){
  44. socket.value.emit("action", { type: "leader-dismiss" });
  45. }
  46. socket.value.close();
  47. store.commit("rtc/setSocket", null);
  48. }
  49. let tempUrl = window.location.href;
  50. ["mode", "name", "role", "roomId", "userId"].forEach((item) => {
  51. tempUrl = browser.replaceQueryString(tempUrl, item, "");
  52. });
  53. history.replaceState(null, null, tempUrl);
  54. store.commit("showShoppingguide", false);
  55. dialog.value = "";
  56. };
  57. const closeCreated = (str, link) => {
  58. store.commit("showShoppingguide", false);
  59. showCreated.value = false;
  60. };
  61. const createdConfirm = (str, link) => {
  62. showCreated.value = false;
  63. show.value = true;
  64. };
  65. onMounted(() => {
  66. useApp().then(async (sdk) => {
  67. await nextTick();
  68. if (userName.value) {
  69. createdConfirm();
  70. } else {
  71. showCreated.value = true;
  72. }
  73. });
  74. // showCreated.value = true;
  75. });
  76. </script>
  77. <style lang="scss" scoped></style>