Browse Source

feat: save

gemercheung 1 year ago
parent
commit
4695061a92

+ 9 - 2
src/layout/header.vue

@@ -64,7 +64,11 @@
               </template>
             </a-avatar>
             <span>
-              {{ userStore.current.nickname }}
+              {{
+                userStore.current.nickname == 'base.tourist'
+                  ? t('base.tourist')
+                  : userStore.current.nickname
+              }}
               <DownOutlined />
             </span>
           </div>
@@ -137,7 +141,10 @@ const handlerMenuClick: MenuProps['onClick'] = async e => {
       location.href = `${mainURL}/#/information?lang=${currentLang.value.key}`
       break
     case e.key === 'guideLine':
-      window.open('https://docs.4dkankan.com/#/product/livestream/zh-cn/README', '_blank');
+      window.open(
+        'https://docs.4dkankan.com/#/product/livestream/zh-cn/README',
+        '_blank'
+      )
       break
   }
 }

+ 2 - 0
src/store/modules/room.ts

@@ -36,6 +36,7 @@ export interface ShareLinkType {
   userId?: string
   isTour?: string
   vlog?: string
+  platform?: string
 }
 
 export const createRoom = (room: Partial<Room>): Room => {
@@ -78,6 +79,7 @@ export const useRoomStore = defineStore('room', {
       param.lang && search.set('lang', param.lang)
       param.userId && search.set('vruserId', `${param.userId}`)
       param.isTour && search.set('isTour', `${param.isTour}`)
+      param.platform && search.set('platform', `${param.platform}`)
       if (Number(import.meta.env.VITE_SHOW_CONSOLE) == 1) {
         search.set('vlog', import.meta.env.VITE_SHOW_CONSOLE)
       }

+ 1 - 2
src/store/modules/user.ts

@@ -4,10 +4,9 @@ import { defineStore } from 'pinia'
 import type { User } from '@/api'
 import { useI18n } from '@/hook/useI18n'
 
-const { t } = useI18n()
 
 const defUser: User = {
-  nickname: t('base.tourist'),
+  nickname: 'base.tourist',
   phone: '',
   avatar: 'https://4dkk.4dage.com/head/18819272208/head_1662022947583.png',
   userId: 1,

+ 63 - 28
src/views/room/edit-room/index.vue

@@ -204,7 +204,11 @@
               @on-change="handlePsOnChange"
             />
           </a-form-item>
-          <a-form-item name="scenes" style="margin-bottom: 2px">
+          <a-form-item
+            name="scenes"
+            style="margin-bottom: 2px"
+            class="add-user-list"
+          >
             <div slot="label" style="margin: 10px 0">
               {{ t('room.authorize') }}
               <InfoCircleOutlined
@@ -227,26 +231,28 @@
                 "
               />
             </div>
-            <a-button
-              type="primary"
-              size="small"
-              ghost
-              :disabled="isRoomEnd"
-              @click="authvisible = true"
-            >
-              <template #icon><plus-outlined /></template
-              >{{ t('room.addUser') }}</a-button
-            >
-
-            <span
-              class="user-label"
-              :class="{ disabled: isRoomEnd }"
-              style="margin-left: 5px"
-              v-for="lab in current.userObjList"
-            >
-              {{ lab.userName }}
-              <CloseOutlined @click="handleAssistantUseDelete(lab.userName)" />
-            </span>
+            <div class="user_list">
+              <a-button
+                type="primary"
+                size="small"
+                ghost
+                :disabled="isRoomEnd"
+                @click="authvisible = true"
+              >
+                <template #icon><plus-outlined /></template
+                >{{ t('room.addUser') }}</a-button
+              >
+              <span
+                class="user-label"
+                :class="{ disabled: isRoomEnd }"
+                v-for="lab in current.userObjList"
+              >
+                {{ lab.userName }}
+                <CloseOutlined
+                  @click="handleAssistantUseDelete(lab.userName)"
+                />
+              </span>
+            </div>
           </a-form-item>
           <a-form-item
             :label="t('room.setRoomNumber')"
@@ -278,7 +284,7 @@
       @cancel="authformState.userName = ''"
       @ok="handleAuthConfirm"
     >
-      <a-form layout="inline" :model="authformState">
+      <a-form layout="inline" :model="authformState" ref="addFormRef">
         <a-form-item
           :label="t('room.userAccount')"
           name="userName"
@@ -318,7 +324,8 @@ import {
   computed,
   unref,
   createVNode,
-  shallowRef
+  shallowRef,
+  watch
 } from 'vue'
 
 import { createRoom, useRoomStore } from '@/store/modules/room'
@@ -414,12 +421,14 @@ export default defineComponent({
 
     const otpInput = ref('')
     const formRef = ref<FormInstance>()
+    const addFormRef = ref<FormInstance>()
+
     const current = reactive({
       ...createRoom(props.room || {})
     })
 
     watchEffect(async () => {
-      if(typeof current.head === 'undefined'){
+      if (typeof current.head === 'undefined') {
         current.head = ''
       }
       if (current.useTimeList?.length) {
@@ -443,9 +452,10 @@ export default defineComponent({
     if (!current.userObjList) {
       current.userObjList = []
     }
-    if (!current.userObjList) {
-      current.userObjList = []
-    }
+
+    // if (!current.userObjList) {
+    //   current.userObjList = []
+    // }
 
     const deleteScene = (scene: Scene) => {
       const index = current.scenes.indexOf(scene)
@@ -677,6 +687,17 @@ export default defineComponent({
 
     onMounted(() => {
       // initMap()
+      watch(
+        authvisible,
+        (newVal, oldVal) => {
+          if (oldVal && !newVal) {
+            clearForm()
+          }
+        },
+        {
+          immediate: true
+        }
+      )
     })
     onBeforeUnmount(() => {
       const editor = editorRef.value
@@ -760,6 +781,11 @@ export default defineComponent({
     const handlePsOnChange = (value: string) => {
       console.log('OTP changed: ', value)
     }
+    const clearForm = () => {
+      if (addFormRef.value) {
+        addFormRef.value.clearValidate()
+      }
+    }
 
     return {
       isLive,
@@ -800,7 +826,8 @@ export default defineComponent({
       handleVideoSync,
       editorRef,
       handleEditorCreated,
-      handlePsOnChange
+      handlePsOnChange,
+      addFormRef
     }
   }
 })
@@ -886,6 +913,14 @@ export default defineComponent({
     }
   }
 }
+.user_list {
+  display: flex;
+  align-items: center;
+  gap: 5px 10px;
+  width: 100%;
+  flex-wrap: wrap;
+  flex-direction: row;
+}
 </style>
 
 <style lang="scss">

+ 27 - 10
src/views/room/list.vue

@@ -233,16 +233,33 @@ const webSyncRoom = async (room: Room) => {
   const user = useUserStore().current
   console.log('scenes', scenes)
   const m = scenes.sceneData[0].num
-  const link = roomStore.getShareUrl({
-    roomId: room.id,
-    num: m,
-    role: 'leader',
-    name: encodeURIComponent(scenes.roomHostName),
-    avatar: encodeURIComponent(user.avatar) || '',
-    userId: String(user.userId || 1),
-    isTour: '0',
-    lang: unref(getLocale) || 'zh'
-  })
+  let link = ''
+  const isInternational = ref(import.meta.env.VITE_IS_INTERNATIONAL)
+  if (isInternational) {
+    link = roomStore.getShareUrl({
+      roomId: room.id,
+      num: m,
+      role: 'leader',
+      name: encodeURIComponent(scenes.roomHostName),
+      avatar: encodeURIComponent(user.avatar) || '',
+      userId: String(user.userId || 1),
+      isTour: '0',
+      lang: unref(getLocale) || 'zh',
+      platform: 'h5'
+    })
+  } else {
+    link = roomStore.getShareUrl({
+      roomId: room.id,
+      num: m,
+      role: 'leader',
+      name: encodeURIComponent(scenes.roomHostName),
+      avatar: encodeURIComponent(user.avatar) || '',
+      userId: String(user.userId || 1),
+      isTour: '0',
+      lang: unref(getLocale) || 'zh'
+    })
+  }
+
   console.log('带看link', link)
   window.open(link, '_blank')
 }