bzkf3 2 yıl önce
ebeveyn
işleme
b3b85609fd

+ 34 - 7
src/components/rtc-dialog/index.vue

@@ -39,8 +39,9 @@ function handleClose() {
 }
 defineExpose({
   init(ws: WebSocket) {
-    console.log("init")
+    console.info("init")
     ws2 = ws
+    console.info("init end", ws2)
   },
   open(d: type_dyaw_xlfw_zxhd, _mode: 'audio' | 'video') {
     if (isOpen) return;
@@ -73,7 +74,7 @@ defineExpose({
         dxzl_id?: string
       }
   ) {
-    console.log('publisher: ', content);
+    console.info('[in publisher] start ', content);
     //
     const { operate } = content
     switch (operate) {
@@ -128,6 +129,7 @@ defineExpose({
 })
 
 function handleInfoAdd(tip: string) {
+  console.info('[in handleInfoAdd] start ');
   const _reqDate = Object.assign({
     dxzl_status: '1',
     dxzl_type: mode === 'audio' ? '3' : '4',
@@ -155,6 +157,7 @@ function handleInfoAdd(tip: string) {
 }
 
 function handleInfoEdit(data: Partial<type_dyaw_xlfw_zxhd_log>, tip?: string) {
+  console.info('[in handleInfoEdit] start ');
   const _reqDate = Object.assign({
     dxzl_last_msg_content: tip ? encodeURIComponent(`【${mode === 'audio' ? '语音通话' : '视频通话'}】 ${tip}`) : undefined,
   }, data)
@@ -202,6 +205,7 @@ type TRtcOptions = {
 let rtcOptions: TRtcOptions;
 
 function handleSwitchUse(v: boolean) {
+  // console.info('[in handleSwitchUse] start ');
   try {
     audioInUse = v
     videoInUse = v
@@ -218,12 +222,14 @@ function handleSwitchUse(v: boolean) {
 }
 
 function initRtcClient() {
+  console.info('[in initRtcClient] start')
+
   if (rtcInstance.client) {
     handleSwitchUse(true)
     return
   };
   const client = rtcInstance.client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" });
-
+  console.info("AgoraRTC client initialized", client);
   client.on("user-published", async (user, mediaType) => {
     await client.subscribe(user, mediaType);
     if (mediaType === "audio") {
@@ -237,6 +243,7 @@ function initRtcClient() {
 }
 
 async function getRtcOption() {
+  console.info('[in getRtcOption] start')
   try {
     await request({
       url: '/dyaw/xlfw_zxhd/get_rtc_token',
@@ -254,8 +261,12 @@ async function getRtcOption() {
           token: resp.rtc_token,
           // uid: user.user_id
         }
+      }else{
+        showFailToast('服务器繁忙,请稍后再试')
+        console.error(res);
       }
     })
+    console.info('rtcOptions', rtcOptions);
   } catch (error) {
     showFailToast('服务器繁忙,请稍后再试')
     console.error(error);
@@ -282,18 +293,34 @@ async function handleAudioChatStart() {
       currentChatStatus = CHAT_STATUS.WAITING_BUSY
       // ElMessage.warning('对方忙线中')
       showFailToast('对方忙线中')
+      console.info('对方忙线中');
       setTimeout(() => {
         handleClose()
-      }, 2000)
+      }, 5000)
       return
     };
-    await AgoraRTC.getMicrophones()
-    if (mode === 'video')
-      await AgoraRTC.getCameras()
+
+    console.info('验证相关权限')
+    // 手机版跳过验证
+    try {
+      console.info('验证麦克风权限')
+      const microInfo = await AgoraRTC.getMicrophones()
+      console.info('麦克风权限验证结束 : ', microInfo)
+      if (mode === 'video') {
+        console.info('验证摄像头权限')
+        const camerasInfo = await AgoraRTC.getCameras()
+        console.info('摄像头权限验证结束 : ', camerasInfo)
+      }
+    } catch (error) {
+      console.error(error)
+    }
+    console.info('相关权限验证结束')
+
     initRtcClient()
 
     await getRtcOption()
 
+    console.info('发送拨号信息')
     const fullSendData = await handleInfoAdd('拨号中')
 
 

+ 8 - 0
src/main.ts

@@ -23,3 +23,11 @@ import 'vant/es/notify/style';
 import 'vant/es/image-preview/style';
 
 createApp(App).use(router).mount('#appx')
+
+// console navagator property by group
+console.groupCollapsed('navigator');
+for (let key of ['appCodeName', 'appName', 'appVersion', 'platform', 'product', 'userAgent', 'vendor']) {
+  console.log(key, navigator[key]);
+}
+console.groupEnd();
+

+ 0 - 295
src/pages/student/consult copy.vue

@@ -1,295 +0,0 @@
-<script setup lang="ts">
-import type { type_dyaw_xlfw_zxhd, type_dyaw_xlfw_zxhd_log } from '~/types';
-import user from '~/store/user';
-import { createSocket, socketSend } from '~/utils/ws';
-import type { TSocketRes } from '~/utils/ws';
-import { formatTimestamp } from '~/utils/time'
-import { CHAT_STATUS, CHAT_OPERATION } from '~/types';
-
-const router = useRouter()
-let teacher
-const SessionConsultTeacher = sessionStorage.getItem('consult_teacher')
-if (SessionConsultTeacher !== null) {
-  teacher = JSON.parse(SessionConsultTeacher)
-} else {
-  router.back()
-}
-
-let teacherInfo = $ref<{
-  dxp_user_realname: string;
-  dxp_user_phone: string;
-  dxp_wx_qrcode: string;
-  dxp_jj: string;
-  dxp_user_avatar: string;
-}>()
-request({
-  url: '/dyaw/xlfw_pbgl/detail',
-  data: {
-    user_id: teacher.user_id
-  }
-}).then(res => {
-  if (res.code === '1') {
-    teacherInfo = res.data.one_info
-  }
-})
-
-const dyaw_xlfw_zxhd: type_dyaw_xlfw_zxhd = (await request({
-  url: '/dyaw/xlfw_zxhd/add',
-  data: {
-    dyaw_xlfw_zxhd: {
-      dxz_stu_user_id: user.user_id,
-      dxz_tea_user_id: teacher.user_id
-    }
-  }
-})).data.one_info
-
-
-
-let rateDialogVisible = $ref(false)
-let endTime = $ref<string>()
-let rateNum = $ref(5)
-function handleClickEnd() {
-  // ChatAudioRef && ChatAudioRef.open()
-  endTime = getDatabaseTime(new Date())
-  rateDialogVisible = true
-}
-function handleConfirmRate() {
-  request({
-    url: '/dyaw/xlfw_zxhd/edit',
-    data: {
-      dxz_id: dyaw_xlfw_zxhd.dxz_id,
-      dyaw_xlfw_zxhd: {
-        dxz_star: rateNum,
-        dxz_star_datetime: endTime,
-        // 下行代码【可能】导致使用问题
-        dxz_status: '1'
-      }
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      rateDialogVisible = false
-      router.back()
-    }
-  })
-}
-
-let infoList = $ref<Array<type_dyaw_xlfw_zxhd_log>>([])
-let inputValue = $ref('')
-let isSending = $ref(false)
-let TinyRef = $ref<typeof import('~/components/tinymce-area/index.vue')['default']>()
-async function handleClickSend() {
-  if (isSending) return;
-  isSending = true
-  const reqDate = {
-    dxz_id: dyaw_xlfw_zxhd.dxz_id,
-    dxzl_stu_user_id: dyaw_xlfw_zxhd.dxz_stu_user_id,
-    dxzl_stu_user_realname: dyaw_xlfw_zxhd.dxz_stu_user_realname,
-    dxzl_tea_user_id: dyaw_xlfw_zxhd.dxz_tea_user_id,
-    dxzl_tea_user_realname: dyaw_xlfw_zxhd.dxz_tea_user_realname,
-    dxzl_last_msg_content: encodeURIComponent(inputValue),
-    dxzl_type: inputValue.includes('><img') ? '2' : '1'
-  }
-
-  // infoList.push({
-  //   create_user_id: user.user_id,
-  //   create_dateline: Date.now().toString().slice(0, 10),
-
-  //   ...reqDate
-  // })
-  TinyRef?.clear()
-  // console.log('inputValue :>> ', inputValue);
-  request({
-    url: '/dyaw/xlfw_zxhd_log/add',
-    data: {
-      dyaw_xlfw_zxhd_log: reqDate
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      const fullSendData = {
-        create_user_id: user.user_id,
-        create_dateline: Date.now().toString().slice(0, 10),
-        ...reqDate,
-        dxzl_id: `${res.data.insert_id}`
-      }
-      infoList.push(fullSendData)
-      socketSend(ws, fullSendData)
-      isSending = false
-    }
-  })
-}
-
-request({
-  url: '/dyaw/xlfw_zxhd_log/index',
-  data: {
-    dxz_id: dyaw_xlfw_zxhd.dxz_id,
-    limit: 100
-  }
-}).then(res => {
-  if (res.code === '1') {
-    infoList = res.data.page_data.reverse()
-  }
-})
-const ws = createSocket(
-  { teacher: teacher.user_id, student: user.user_id },
-  {
-    message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log>) {
-      if (socketRes.from_client_name.endsWith('teacher')) {
-        infoList.push(socketRes.content)
-      }
-    }
-  }
-)
-// console.log('ws :>> ', ws);
-if (!dyaw_xlfw_zxhd.old_data) {
-
-  socketSend(ws, {
-    $: true,
-    dxz_stu_user_id: dyaw_xlfw_zxhd.dxz_stu_user_id,
-    dyaw_xlfw_zxhd
-  })
-}
-
-const scrollbarRef = $ref<HTMLElement>()
-function scrollToBottom() {
-  if (!scrollbarRef) return;
-  const scrollHeight = scrollbarRef!.scrollHeight;
-  scrollbarRef!.scrollTo(0, scrollHeight);
-}
-watch(
-  () => (infoList),
-  () => {
-    nextTick(() => {
-      scrollToBottom()
-    })
-  },
-  {
-    deep: true,
-  }
-)
-
-// ==========
-// chat audio/video
-// ==========
-
-let RtcDialogRef = $ref<typeof import("~/components/rtc-dialog/index.vue")['default']>()
-
-const ws2 = createSocket(
-  { teacher: teacher.user_id, student: '*' },
-  {
-    message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log & { operate: CHAT_OPERATION }>) {
-      console.log('enter', socketRes);
-      if (socketRes.from_client_name.endsWith('teacher')) {
-        if (socketRes.content.dxzl_stu_user_id === user.user_id) {
-          RtcDialogRef!.publisher(socketRes.content)
-        }
-      }
-    }
-  }
-)
-onMounted(() => {
-  RtcDialogRef!.init(ws2)
-})
-
-
-async function handleAudioChatStart() {
-  RtcDialogRef!.open(dyaw_xlfw_zxhd, 'audio')
-}
-
-async function handleVideoChatStart() {
-  RtcDialogRef!.open(dyaw_xlfw_zxhd, 'video')
-}
-
-function emitUpdateInfo(info: type_dyaw_xlfw_zxhd_log, isUpdate?: boolean) {
-  if (!isUpdate) {
-    if (info.dxz_id === dyaw_xlfw_zxhd?.dxz_id)
-      infoList.push(info)
-  }
-  else {
-    const target = infoList.find(item => item.dxzl_id === info.dxzl_id)
-    if (target)
-      target.dxzl_last_msg_content = info.dxzl_last_msg_content
-  }
-}
-
-// 从⼼灵氧吧/梦⾥寻芳/微⻛细⾬/花⾹⻦语获取随机昵称
-function getRandomName() {
-  const names = ['⼼灵氧吧', '梦⾥寻芳', '微⻛细⾬', '花⾹⻦语']
-  return names[Math.floor(Math.random() * names.length)]
-}
-const virtualName = getRandomName()
-</script>
-
-<template>
-  <div class="h-640px bg-hex-f2f2f295 flex justify-center divide-x">
-    <div class="w-1000px h-full divide-y">
-      <div class="bg-pink-300 flex justify-between h-48px items-center px-18px">
-        <span class="text-lg px-1 tracking-wider">{{ `${dyaw_xlfw_zxhd.dxz_tea_user_realname}老师正在为您服务` }}</span>
-        <div class="text-pink-300 text-sm bg-white w-100px h-32px flex_center rounded-2xl cursor-pointer"
-          @click="handleClickEnd">结束会话</div>
-      </div>
-      <div ref="scrollbarRef"
-        class="bg-hex-fff8fb space-y-2 h-410px py-2 px-6 scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
-        <div class="w-full text-center text-sm">{{ formatTimestamp(dyaw_xlfw_zxhd.create_dateline) }} 开始沟通</div>
-        <info-item v-for="item in infoList" :key="item.dxzl_id" :left="item.create_user_id !== user.user_id" :d="item"
-          :virtualName="virtualName" :w="780"></info-item>
-      </div>
-      <div class="bg-white h-180px p-5px flex flex-col justify-between">
-        <!-- <div class="h-48px"></div>
-            <el-input type="textarea"></el-input> -->
-        <tinymce-area v-model="inputValue" ref="TinyRef" @click:audio="handleAudioChatStart"
-          @click:video="handleVideoChatStart" @click:submit="handleClickSend"></tinymce-area>
-        <div class="flex justify-end">
-          <div class="bg-pink-300 text-sm text-white w-80px h-32px flex_center rounded-2xl cursor-pointer"
-            @click="handleClickSend">发送</div>
-        </div>
-      </div>
-    </div>
-    <div
-      class="w-400px h-full space-y-4 bg-white overflow-y-auto flex flex-col items-stretch px-30px py-4 divide-y scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
-
-      <template v-if="teacherInfo">
-        <div class="w-full">
-          <img :src="teacherInfo.dxp_wx_qrcode" alt="">
-        </div>
-        <div class="py-4">
-          <div class="text-lg font-bold max-w-24 truncate">{{ teacherInfo.dxp_user_realname }}</div>
-          <div class="text-hex-5B9FF0">联系电话:{{ teacherInfo.dxp_user_phone }}</div>
-          <div class=" text-hex-00000041 h-10 leading-5 mt-1">
-            {{ teacherInfo.dxp_jj }}
-          </div>
-        </div>
-      </template>
-    </div>
-  </div>
-
-  <el-dialog v-model="rateDialogVisible" title="请评价" align-center width="405px">
-    <p>于 {{ endTime }} 结束沟通</p>
-    <div class="flex items-center my-4">
-      <div>评价:</div>
-      <el-rate size="large" v-model="rateNum"></el-rate>
-    </div>
-    <template #footer>
-      <div class="flex_center">
-        <el-button round type="primary" @click="handleConfirmRate">
-          确认
-        </el-button>
-        <el-button round @click="rateDialogVisible = false">取消</el-button>
-      </div>
-    </template>
-
-  </el-dialog>
-
-
-  <rtc-dialog ref="RtcDialogRef" @update-info="emitUpdateInfo"></rtc-dialog>
-
-  <!-- <chat-dialog ref="ChatVideoRef">
-        <i:ant-design:audio-outlined />
-        <i:ant-design:audio-muted-outlined />
-
-        <i:material-symbols:video-camera-back-rounded />
-        <i:material-symbols:video-camera-front-off-rounded />
-      </chat-dialog> -->
-</template>
-
-<style scoped lang="scss">
-</style>

+ 2 - 12
src/pages/student/consult.vue

@@ -183,9 +183,10 @@ const ws2 = createSocket(
   { teacher: teacher.user_id, student: '*' },
   {
     message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log & { operate: CHAT_OPERATION }>) {
-      console.log('enter', socketRes);
+      console.info('enter message', socketRes);
       if (socketRes.from_client_name.endsWith('teacher')) {
         if (socketRes.content.dxzl_stu_user_id === user.user_id) {
+          console.info('start publisher ')
           RtcDialogRef!.publisher(socketRes.content)
         }
       }
@@ -290,17 +291,6 @@ const virtualName = getRandomName()
       </div>
     </div>
   </van-dialog>
-
-
-  <rtc-dialog ref="RtcDialogRef" @update-info="emitUpdateInfo"></rtc-dialog>
-
-  <!-- <chat-dialog ref="ChatVideoRef">
-                  <i:ant-design:audio-outlined />
-                  <i:ant-design:audio-muted-outlined />
-
-                  <i:material-symbols:video-camera-back-rounded />
-                  <i:material-symbols:video-camera-front-off-rounded />
-                </chat-dialog> -->
 </template>
 
 <style scoped lang="scss">

+ 0 - 383
src/pages/teacher/chat-list copy.vue

@@ -1,383 +0,0 @@
-<script setup lang="ts">
-import AgoraRTC from "agora-rtc-sdk-ng"
-import type { IAgoraRTCClient, IMicrophoneAudioTrack, ICameraVideoTrack } from "agora-rtc-sdk-ng"
-import type { type_dyaw_xlfw_zxhd, type_dyaw_xlfw_zxhd_log, type_archives_item } from '~/types';
-import { Search } from '@element-plus/icons-vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import user from '~/store/user';
-import { createSocket, socketSend } from '~/utils/ws';
-import type { TSocketRes } from '~/utils/ws';
-import { formatTimestamp2Date } from '~/utils/time';
-import { CHAT_STATUS, CHAT_OPERATION } from '~/types';
-let dyaw_xlfw_zxhd = $ref<type_dyaw_xlfw_zxhd | undefined>()
-let dyaw_xlfw_zxhd_list = $ref<type_dyaw_xlfw_zxhd[] | undefined>()
-
-
-
-const searchValue = $ref('搜索')
-watch(
-  () => searchValue,
-  async (val, oldVal) => {
-    if (oldVal === '搜索') return;
-    dyaw_xlfw_zxhd_list = (await request({
-      url: '/dyaw/xlfw_zxhd/index',
-      data: {
-        dxz_tea_user_id: user.user_id,
-        dxz_stu_user_realname: searchValue === '搜索' ? undefined : searchValue,
-        limit: 20,
-        last_msg: 1
-      }
-    })).data.page_data
-  }
-)
-
-
-let timer: NodeJS.Timeout;
-(async function loop() {
-  dyaw_xlfw_zxhd_list = (await request({
-    url: '/dyaw/xlfw_zxhd/index',
-    data: {
-      dxz_tea_user_id: user.user_id,
-      dxz_stu_user_realname: searchValue === '搜索' ? undefined : searchValue,
-      limit: 20,
-      last_msg: 1
-    }
-  })).data.page_data
-  if (dyaw_xlfw_zxhd !== undefined) {
-    const temp = dyaw_xlfw_zxhd_list!.find(item => item.dxz_stu_user_id === dyaw_xlfw_zxhd!.dxz_stu_user_id)
-    if (temp?.dxz_id !== dyaw_xlfw_zxhd?.dxz_id) {
-      dyaw_xlfw_zxhd = temp
-    }
-  }
-
-  timer = setTimeout(async () => {
-    await loop();
-  }, 60 * 1000);
-})();
-
-let infoList = $ref<Array<type_dyaw_xlfw_zxhd_log>>([])
-let inputValue = $ref('')
-let isSending = $ref(false)
-let TinyRef = $ref<typeof import('~/components/tinymce-area/index.vue')['default']>()
-async function handleClickSend() {
-  if (!dyaw_xlfw_zxhd) return;
-  if (isSending) return;
-  isSending = true
-  const reqDate = {
-    dxz_id: dyaw_xlfw_zxhd.dxz_id,
-    dxzl_stu_user_id: dyaw_xlfw_zxhd.dxz_stu_user_id,
-    dxzl_stu_user_realname: dyaw_xlfw_zxhd.dxz_stu_user_realname,
-    dxzl_tea_user_id: dyaw_xlfw_zxhd.dxz_tea_user_id,
-    dxzl_tea_user_realname: dyaw_xlfw_zxhd.dxz_tea_user_realname,
-    dxzl_last_msg_content: encodeURIComponent(inputValue),
-    dxzl_type: inputValue.includes('><img') ? '2' : '1'
-  }
-
-  // infoList.push({
-  //   create_user_id: user.user_id,
-  //   create_dateline: Date.now().toString().slice(0, 10),
-
-  //   ...reqDate
-  // })
-  TinyRef?.clear()
-  // console.log('inputValue :>> ', inputValue);
-  request({
-    url: '/dyaw/xlfw_zxhd_log/add',
-    data: {
-      dyaw_xlfw_zxhd_log: reqDate
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      const fullSendData = {
-        create_user_id: user.user_id,
-        create_dateline: Date.now().toString().slice(0, 10),
-        ...reqDate,
-        dxzl_id: `${res.data.insert_id}`
-      }
-      infoList.push(fullSendData)
-      socketSend(ws!, fullSendData)
-      isSending = false
-    }
-  })
-}
-
-let ws = $ref<WebSocket>()
-
-let cardLoading = $ref(false)
-let unreadNum = $ref(0)
-
-// function getAllUnreadMsg() {
-//   request({
-//     url: '/dyaw/xlfw_zxhd_log/index',
-//     data: {
-//       dxzl_stu_user_id: dyaw_xlfw_zxhd?.dxz_stu_user_id,
-//       dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
-//       limit: 1
-//     }
-//   }).then(res => {
-//     if (res.code === '1') {
-//       ifScroll = false
-//       infoList = (res.data.page_data.reverse())
-//       unreadNum = 0
-//     }
-//     nextTick(() => {
-//       ifScroll = true
-//       // scrollbarRef!.scrollTo(0, 0);
-//     })
-//   })
-// }
-
-function handleClickStuCard(stu: type_dyaw_xlfw_zxhd) {
-  cardLoading = true
-  dyaw_xlfw_zxhd = stu
-  unreadNum = parseInt(stu.dxz_unread_msg_num)
-  stu.dxz_unread_msg_num = "0"
-  archivesList = []
-
-  ws?.close()
-  request({
-    url: '/dyaw/xlfw_zxhd_log/index',
-    data: {
-      dxzl_stu_user_id: stu.dxz_stu_user_id,
-      dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      infoList = res.data.page_data.reverse()
-      cardLoading = false
-      ws = createSocket(
-        { teacher: user.user_id, student: stu.dxz_stu_user_id },
-        {
-          message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log & { $?: boolean, dxz_stu_user_id?: string, dyaw_xlfw_zxhd: type_dyaw_xlfw_zxhd }>) {
-            if (socketRes.from_client_name.endsWith('student')) {
-              if (socketRes.content.$) {
-                if (socketRes.content?.dxz_stu_user_id === dyaw_xlfw_zxhd?.dxz_stu_user_id) {
-                  dyaw_xlfw_zxhd = socketRes.content.dyaw_xlfw_zxhd
-                }
-                return;
-              }
-              infoList.push(socketRes.content)
-              request({
-                url: '/dyaw/xlfw_zxhd_log/index',
-                data: {
-                  dxzl_stu_user_id: stu.dxz_stu_user_id,
-                  dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
-                  limit: 0
-                }
-              })
-
-            }
-          }
-        }
-      )
-
-      handleQueryArchives()
-    }
-  })
-}
-
-let ifScroll = $ref(true)
-function handleLoadMoreInfo() {
-  request({
-    url: '/dyaw/xlfw_zxhd_log/index',
-    data: {
-      dxzl_stu_user_id: dyaw_xlfw_zxhd?.dxz_stu_user_id,
-      dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
-      zxhd_log_id: infoList[0].dxzl_id
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      ifScroll = false
-      if (res.data.page_data.length === 0) return ElMessage.info('暂无更多消息');
-      infoList.unshift(...res.data.page_data.reverse())
-    }
-  })
-}
-
-const scrollbarRef = $ref<HTMLElement>()
-function scrollToBottom() {
-  if (!scrollbarRef) return;
-  const scrollHeight = scrollbarRef!.scrollHeight;
-  scrollbarRef!.scrollTo(0, scrollHeight);
-}
-watch(
-  () => (infoList),
-  () => {
-    nextTick(() => {
-      ifScroll && scrollToBottom();
-      ifScroll = true
-    })
-  },
-  {
-    deep: true,
-  }
-)
-
-
-onBeforeUnmount(() => {
-  clearInterval(timer)
-})
-
-const ArchivesCardRef = $ref<typeof import('~/components/archives-card/index.vue')['default']>()
-function handleSubmitArchives() {
-  ElMessageBox.confirm('一次咨询只能提交一次档案,请确认完毕后点击提交', '提示')
-    .then(() => {
-      request({
-        url: '/dyaw/xlfw_xsda_dajl/add',
-        data: {
-          dyaw_xlfw_xsda_dajl: ArchivesCardRef!.form
-        }
-      }).then(res => {
-        if (res.code === '1') {
-
-          handleQueryArchives()
-        }
-      })
-    })
-    .catch(() => {
-      ElMessage({
-        type: 'info',
-        message: '取消提交',
-      })
-    })
-}
-
-let archivesList = $ref<type_archives_item[]>([])
-function handleQueryArchives() {
-  request({
-    url: '/dyaw/xlfw_xsda_dajl/index',
-    data: {
-      user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id
-    }
-  }).then(res => {
-    if (res.code === '1') {
-      archivesList = res.data.page_data
-    }
-  })
-}
-
-// ==========
-// chat audio/video
-// ==========
-
-let RtcDialogRef = $ref<typeof import("~/components/rtc-dialog/index.vue")['default']>()
-
-const ws2 = createSocket(
-  { teacher: user.user_id, student: '*' },
-  {
-    message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log & { operate: CHAT_OPERATION }>) {
-      if (socketRes.from_client_name.endsWith('student')) {
-        // infoList.push(socketRes.content)
-        if (socketRes.content.dxzl_tea_user_id === user.user_id) {
-          RtcDialogRef!.publisher(socketRes.content)
-        }
-      }
-    }
-  }
-)
-onMounted(() => {
-  RtcDialogRef!.init(ws2)
-})
-
-
-
-async function handleAudioChatStart() {
-  RtcDialogRef!.open(dyaw_xlfw_zxhd, 'audio')
-}
-
-async function handleVideoChatStart() {
-  RtcDialogRef!.open(dyaw_xlfw_zxhd, 'video')
-}
-
-function emitUpdateInfo(info: type_dyaw_xlfw_zxhd_log, isUpdate?: boolean) {
-  if (!isUpdate) {
-    if (info.dxz_id === dyaw_xlfw_zxhd?.dxz_id)
-      infoList.push(info)
-  }
-  else {
-    const target = infoList.find(item => (item.dxzl_id)?.toString() === info.dxzl_id?.toString())
-    if (target)
-      target.dxzl_last_msg_content = info.dxzl_last_msg_content
-  }
-}
-</script>
-
-<template>
-  <div class="h-590px bg-hex-f2f2f295 flex justify-center divide-x">
-    <div class="w-320px p-10px h-full flex flex-col justify-start bg-white space-y-4">
-      <el-input autocomplete="off" name="searchValue" v-model="searchValue" size="large" :prefix-icon="Search"
-        @focus="searchValue = ''" clearable placeholder="搜索"
-        :style="`${searchValue === '搜索' && '--ep-input-text-color:var(--ep-text-color-placeholder);'}`"></el-input>
-      <div
-        class="max-h-520px flex flex-col flex-none divide-y scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
-        <chat-stu-card v-for="item in dyaw_xlfw_zxhd_list" :d="item" @click="handleClickStuCard(item)"
-          class="h-68px"></chat-stu-card>
-      </div>
-    </div>
-    <div class="w-680px h-full divide-y flex flex-col relative">
-      <template v-if="dyaw_xlfw_zxhd">
-        <div class="bg-pink-300 flex justify-between h-48px items-center px-18px">
-          <span class="text-lg px-1 tracking-wider">{{ dyaw_xlfw_zxhd.dxz_stu_user_realname }}
-            {{ dyaw_xlfw_zxhd.dxz_stu_school_name }} {{ dyaw_xlfw_zxhd.dxz_class_name }}</span>
-        </div>
-        <div ref="scrollbarRef"
-          class="bg-hex-fff8fb space-y-2 h-410px py-2 px-6 scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent relative">
-          <div v-show="!cardLoading" @click="handleLoadMoreInfo"
-            class="w-full text-center text-sm text-blue-400 hover:underline underline-blue-400 cursor-pointer">查看更多
-          </div>
-          <info-item v-for="item in infoList" :key="item.dxzl_id" :left="item.create_user_id !== user.user_id" :d="item"
-            :w="500"></info-item>
-
-        </div>
-        <!--  -->
-        <!-- <div v-show="unreadNum > 10"
-                                    class="absolute bg-white right-2 bottom-200px text-blue-400 rounded-l-full cursor-pointer z-100 flex items-center space-x-1 p-2 text-sm"
-                                    @click="getAllUnreadMsg">
-                                    <i:material-symbols:keyboard-double-arrow-up />
-                                    <span>{{ unreadNum }}条消息</span>
-                                  </div> -->
-        <div class="bg-white h-180px p-5px flex flex-col justify-between">
-          <tinymce-area v-model="inputValue" ref="TinyRef" @click:audio="handleAudioChatStart"
-            @click:video="handleVideoChatStart" @click:submit="handleClickSend"></tinymce-area>
-          <div class="flex justify-end">
-            <div class="bg-pink-300 text-sm text-white w-80px h-32px flex_center rounded-2xl cursor-pointer"
-              @click="handleClickSend">发送</div>
-          </div>
-        </div>
-      </template>
-      <template v-else>
-        <div class="bg-pink-300 flex justify-between h-48px items-center px-18px"></div>
-        <div class="bg-hex-fff8fb flex-auto w-full flex_center">
-          <el-empty description="请先选择聊天的学生"></el-empty>
-        </div>
-      </template>
-
-    </div>
-    <div
-      class="w-400px h-full bg-white overflow-y-auto flex flex-col items-center px-2 py-2 divide-y scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
-      <div v-if="dyaw_xlfw_zxhd" :key="dyaw_xlfw_zxhd.dxz_stu_user_id">
-        <div class="w-full"
-          v-if="archivesList && (archivesList.length === 0 || dyaw_xlfw_zxhd.dxz_id !== archivesList[0].dxz_id)">
-          <archives-card storage ref="ArchivesCardRef"
-            :d="{ dxz_id: dyaw_xlfw_zxhd.dxz_id, user_id: dyaw_xlfw_zxhd.dxz_stu_user_id, dxxd_lfzxm: dyaw_xlfw_zxhd.dxz_stu_user_realname, dxxd_jfls: dyaw_xlfw_zxhd.dxz_tea_user_realname, dxxd_school_name: dyaw_xlfw_zxhd.dxz_stu_school_name, dxxd_class_name: dyaw_xlfw_zxhd.dxz_class_name, dxxd_date: formatTimestamp2Date(dyaw_xlfw_zxhd.create_dateline) }"></archives-card>
-          <div class="flex_center py-2">
-            <el-button @click="handleSubmitArchives" type="primary" size="small">提交</el-button>
-          </div>
-        </div>
-        <div class="bg-hex-FFF7FA py-2 space-y-1">
-          <div class="flex_center text-lg">历史档案</div>
-          <el-empty v-show="archivesList.length === 0" :image-size="60" description="暂无历史档案"></el-empty>
-          <archives-card disabled v-for="item in archivesList" :d="item" :key="item.dxxd_id"></archives-card>
-        </div>
-      </div>
-
-    </div>
-  </div>
-
-
-
-  <rtc-dialog ref="RtcDialogRef" @update-info="emitUpdateInfo"></rtc-dialog>
-</template>
-
-<style scoped lang="scss">
-</style>

+ 4 - 5
src/pages/teacher/consult.vue

@@ -2,7 +2,8 @@
 import type { type_dyaw_xlfw_zxhd, type_dyaw_xlfw_zxhd_log, type_archives_item } from '~/types';
 import user from '~/store/user';
 import type { TSocketRes } from '~/utils/ws';
-import { type } from 'os';
+import { CHAT_STATUS, CHAT_OPERATION } from '~/types';
+
 // ==========
 // chat audio/video
 // ==========
@@ -13,10 +14,11 @@ const ws2 = createSocket(
   { teacher: user.user_id, student: '*' },
   {
     message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log & { operate: CHAT_OPERATION }>) {
+      console.info('enter message', socketRes);
       if (socketRes.from_client_name.endsWith('student')) {
         // infoList.push(socketRes.content)
         if (socketRes.content.dxzl_tea_user_id === user.user_id) {
-          console.log('RtcDialogRef : ', RtcDialogRef)
+          console.info('start publisher ')
           RtcDialogRef!.publisher(socketRes.content)
         }
       }
@@ -32,9 +34,6 @@ function openRtcDialog(dyaw_xlfw_zxhd: type_dyaw_xlfw_zxhd, type: 'audio' | 'vid
 }
 
 
-
-
-
 const updateFnList = $ref<Function[]>([])
 function emitUpdateInfo(info: type_dyaw_xlfw_zxhd_log, isUpdate?: boolean) {
   updateFnList.forEach(fn => fn(info, isUpdate))

+ 1 - 1
src/pages/teacher/consult/chat-list.vue

@@ -224,7 +224,7 @@ const scrollContainRef = $ref<HTMLElement>()
 function scrollToBottom() {
   if (!scrollbarRef) return;
   const scrollHeight = scrollContainRef!.scrollHeight;
-  console.log('scrollHeight : ', scrollHeight)
+  // console.log('scrollHeight : ', scrollHeight)
   scrollbarRef!.scrollTo(0, scrollHeight + 200);
 }
 watch(

+ 1 - 3
src/pages/teacher/home.vue

@@ -31,14 +31,12 @@ async function routerPush(routename: string) {
     }
   }))?.data?.one_info
   const ifAuth = (!teacher?.dxp_user_name) && routename !== 'teacher_personal'
-  console.log('routerPush 1: ', ifAuth)
   if (ifAuth) {
-    console.log(true, ifAuth, (!teacher?.dxp_user_name) && routename !== 'teacher_personal')
+    // console.log(true, ifAuth, (!teacher?.dxp_user_name) && routename !== 'teacher_personal')
     showFailToast('请先去个人中心完善信息')
     return;
   }
   else {
-    console.log(false, ifAuth, (!teacher?.dxp_user_name) && routename !== 'teacher_personal')
     router.push({ name: routename })
   }
 }

+ 1 - 1
src/utils/ws.ts

@@ -23,7 +23,7 @@ export function createSocket(
       try {
         const data: TSocketRes<string> = JSON.parse(e.data)
         if (CLIENT_NAME === data.from_client_name) return
-        if (!['ping', 'login'].includes(data.type)) {
+        if (!['ping'].includes(data.type)) {
           console.groupCollapsed(`Socket : ${data.type}`)
           console.log(data);
           console.groupEnd();