Compare commits
No commits in common. "23c397e18a3a91243c3e8787b4dd35d1abf71bb0" and "78858111bb74e7465921ed813449d268e09c4877" have entirely different histories.
23c397e18a
...
78858111bb
|
@ -16,9 +16,4 @@ VITE_APP_RES_FILE_PATH = 'https://file.ysaix.com:7868/src/assets/textbook/booktx
|
|||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://file.ysaix.com:7868/'
|
||||
|
||||
# websocket 地址
|
||||
# VITE_APP_WS_URL = 'wss://file.ysaix.com:7868'
|
||||
VITE_APP_WS_URL = 'ws://192.168.2.16:7865'
|
||||
|
||||
# 是否显示开发工具
|
||||
VITE_SHOW_DEV_TOOLS = 'true'
|
||||
|
|
|
@ -18,8 +18,4 @@ VITE_APP_RES_FILE_PATH = 'https://prev.ysaix.com:7868/src/assets/textbook/booktx
|
|||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/'
|
||||
|
||||
# websocket 地址
|
||||
VITE_APP_WS_URL = 'wss://file.ysaix.com:7868'
|
||||
|
||||
# 是否显示开发工具
|
||||
VITE_SHOW_DEV_TOOLS = 'false'
|
||||
|
|
|
@ -28,7 +28,6 @@ import * as API_entpcoursefile from '@/api/education/entpcoursefile' // 相关ap
|
|||
import { PPTApi } from './api'
|
||||
import { sessionStore } from '@/utils/store' // electron-store 状态管理
|
||||
import './api/watcher' // 监听
|
||||
import './api/classcourse' // 课程相关
|
||||
|
||||
const loading = ref(true)
|
||||
const _isPC = isPC()
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
* @author zdg
|
||||
* @description 上课相关内容
|
||||
*/
|
||||
import type { Classcourse } from './types'
|
||||
import { sessionStore } from '@/utils/store' // electron-store 状态管理
|
||||
import * as useStore from '../store' // pptist-状态管理
|
||||
import { ChatWs } from '@/plugins/socket' // 聊天socket
|
||||
const screenStore = useStore.useScreenStore() // 全屏-状态管理
|
||||
const classcourseStore = useStore.useClasscourseStore() // 课堂信息-状态管理
|
||||
const classcourse: Classcourse = sessionStore.get('curr.classcourse') // 课堂信息
|
||||
|
||||
// 如果课堂信息有值,则连接socket
|
||||
if (!!classcourse) {
|
||||
// 连接socket
|
||||
const ws = new ChatWs()
|
||||
console.log('ws- ',ws)
|
||||
// ChatWs.connect(classcourse.id)
|
||||
classcourseStore.setClasscourse(classcourse)
|
||||
}
|
||||
// 打开全屏
|
||||
screenStore.setScreening(!!classcourse)
|
|
@ -136,7 +136,7 @@ export class PPTApi {
|
|||
id: currentSlide.id,
|
||||
datacontent: JSON.stringify(currentSlide),
|
||||
}
|
||||
Utils.mxThrottle(() => {this.updateSlide(params)}, 200, 2)
|
||||
Utils.mxThrottle(() => {this.updateSlide(params)}, 1000, 2)
|
||||
}
|
||||
}
|
||||
// 更新幻灯片
|
||||
|
|
|
@ -5,20 +5,4 @@ export interface Result {
|
|||
data?: any
|
||||
rows?: Array<any>,
|
||||
total?: number
|
||||
}
|
||||
|
||||
/** 课程信息 */
|
||||
export interface Classcourse {
|
||||
id?: number|string, // 课程id
|
||||
coursetitle?: string, // 课程名称
|
||||
coursetype?: string, // 课程类型
|
||||
courseverid?: string, // 课程版本id
|
||||
coursedesc?: string, // 课程描述
|
||||
status?: number, // 课程状态
|
||||
teacherid?: number|string, // 教师id
|
||||
entpcoursefileid?: number|string, // 课程文件id
|
||||
classid?: number|string, // 班级id
|
||||
entpcourseid?: number|string, // 章节中间表id
|
||||
plandate?: string, // 计划时间
|
||||
opendate?: string, // 开课时间
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
import { useScreenStore, useSlidesStore, useClasscourseStore } from '../store'
|
||||
import { useScreenStore, useSlidesStore } from '../store'
|
||||
import { enterFullscreen, exitFullscreen, isFullscreen } from '../utils/fullscreen'
|
||||
|
||||
export default () => {
|
||||
const screenStore = useScreenStore()
|
||||
const slidesStore = useSlidesStore()
|
||||
const classcourseStore = useClasscourseStore() // 课堂信息
|
||||
|
||||
// 进入放映状态(从当前页开始)
|
||||
const enterScreening = () => {
|
||||
|
@ -20,11 +19,7 @@ export default () => {
|
|||
|
||||
// 退出放映状态
|
||||
const exitScreening = () => {
|
||||
const classcourse = classcourseStore.classcourse
|
||||
if (!!classcourse) { //DOTO 有课堂,执行退相关操作
|
||||
console.log('退出放映状态')
|
||||
window.close()
|
||||
} else screenStore.setScreening(false)
|
||||
screenStore.setScreening(false)
|
||||
if (isFullscreen()) exitFullscreen()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import type { Classcourse } from '../api/types'
|
||||
|
||||
export interface ClasscourseState {
|
||||
classcourse: Classcourse
|
||||
}
|
||||
|
||||
export const useClasscourseStore = defineStore('classcourse', {
|
||||
state: (): ClasscourseState => ({
|
||||
classcourse: null, // 课堂信息
|
||||
}),
|
||||
|
||||
actions: {
|
||||
setClasscourse(classcourse: Classcourse) {
|
||||
this.classcourse = classcourse
|
||||
},
|
||||
},
|
||||
})
|
|
@ -3,7 +3,6 @@ import { useSlidesStore } from './slides'
|
|||
import { useSnapshotStore } from './snapshot'
|
||||
import { useKeyboardStore } from './keyboard'
|
||||
import { useScreenStore } from './screen'
|
||||
import { useClasscourseStore } from './classcourse'
|
||||
|
||||
export {
|
||||
useMainStore,
|
||||
|
@ -11,5 +10,4 @@ export {
|
|||
useSnapshotStore,
|
||||
useKeyboardStore,
|
||||
useScreenStore,
|
||||
useClasscourseStore,
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/**
|
||||
* websocket 工具类(im 自己实现)
|
||||
* 单例模式: 保证一个类仅有一个实例,并提供一个访问它的全局访问点。
|
||||
* 实现的方法为先判断实例存在与否,如果存在则直接返回,不存在就创建了再返回,这就确保了一个类只有一个实例对象。
|
||||
*/
|
||||
import useUserStore from '@/store/modules/user' // 用户信息
|
||||
|
||||
export class ChatWs {
|
||||
instance = null; // 实例
|
||||
id = null; // 群聊id || 单聊id-用户id(userId)
|
||||
closed = false; // 关闭状态
|
||||
onmessage = null; // 自定义处理
|
||||
errCount = 5; // 重连次数 (ms) 暂时不使用
|
||||
errTime = null; // 重连时间 (ms) 1秒内zhi间内不重连
|
||||
// 类型定义
|
||||
TYPES = {
|
||||
group: 'group', // 群发
|
||||
single: 'single', // 单发
|
||||
beat: 'heart_beat', // 心跳
|
||||
}
|
||||
static base = 'wss://file.ysaix.com:7868'
|
||||
constructor() {
|
||||
if (!ChatWs.instance) {
|
||||
const userStore = useUserStore() // 用户信息
|
||||
const wsBase = import.meta.env.VITE_APP_WS_URL; // ws地址
|
||||
const url = `${wsBase||ChatWs.base}/ws/websocket/${userStore.id}`;
|
||||
this.init(url);
|
||||
ChatWs.instance = this;
|
||||
}
|
||||
return ChatWs.instance;
|
||||
}
|
||||
|
||||
// 初始化
|
||||
init(url) {
|
||||
this.url = url;
|
||||
this.ws = null;
|
||||
const _this = this
|
||||
this.heartCheck = {
|
||||
timeout: 1000 * 10, // 60s
|
||||
timeoutObj: null,
|
||||
serverTimeoutObj: null,
|
||||
reset() {
|
||||
clearTimeout(this.timeoutObj);
|
||||
clearTimeout(this.serverTimeoutObj);
|
||||
return this;
|
||||
},
|
||||
start() {
|
||||
const self = this;
|
||||
this.timeoutObj = setTimeout(function () {
|
||||
// 这里发送一个心跳,后端收到后,返回一个心跳消息,
|
||||
// onmessage拿到返回的心跳就说明连接正常
|
||||
console.log("websocket-发送心跳")
|
||||
_this.sendMsgBeat();
|
||||
self.serverTimeoutObj = setTimeout(function () {
|
||||
console.log("websocket-心跳响应超时")
|
||||
// 如果超过一定时间还没重置,说明后端主动断开了
|
||||
_this.ws.close(); // 如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
||||
}, self.timeout);
|
||||
}, this.timeout);
|
||||
},
|
||||
};
|
||||
this.reconnect();
|
||||
}
|
||||
// 重连
|
||||
reconnect() {
|
||||
const self = this;
|
||||
if (!!this.ws) { // 关闭之前的链接
|
||||
this.ws.close()
|
||||
this.ws = null
|
||||
}
|
||||
this.ws = new WebSocket(this.url);
|
||||
this.ws.onopen = function () {
|
||||
console.log("websocket-连接成功")
|
||||
self.heartCheck.reset().start();
|
||||
};
|
||||
this.ws.onmessage = function (e) {
|
||||
// console.log("websocket-收到消息", e)
|
||||
// 拿到任何消息都说明当前连接是正常的
|
||||
const isBeat = e.data == 'pong'
|
||||
isBeat && self.heartCheck.reset().start();
|
||||
const exts = ['sessionId', 'pong'] // 不处理的消息头
|
||||
const isEmpty = !e.data
|
||||
const isExts = exts.some(item => e.data.includes(item))
|
||||
if (isEmpty && isExts) return;
|
||||
// 自定义处理
|
||||
self.onmessage && self.onmessage(e.data, e);
|
||||
};
|
||||
this.ws.onerror = function (e) {
|
||||
console.log("websocket-连接异常", e)
|
||||
self.connectSocket() // 重连
|
||||
};
|
||||
this.ws.onclose = function (e) {
|
||||
console.log("websocket-连接断开", e)
|
||||
self.connectSocket() // 重连
|
||||
};
|
||||
}
|
||||
connectSocket() {
|
||||
this.heartCheck.reset() // 重置心跳
|
||||
if (self.closed) return; // 关闭状态不重连
|
||||
// if(self.errCount <= 0) return; // 超过重连次数
|
||||
// self.errCount--; // 重连次数减1
|
||||
if (this.errTime) {
|
||||
const nowTime = Date.now();
|
||||
const bool = nowTime - this.errTime < 1000 // 1s内zhi间内不重连
|
||||
if (bool) return; // 1s内不重连
|
||||
}
|
||||
this.errTime = Date.now();
|
||||
// 延时5s 后重连
|
||||
console.log('重连中...')
|
||||
this.sleep(5000).then(_ => {this.reconnect()})
|
||||
}
|
||||
// 发送消息
|
||||
send(msg) {
|
||||
if (!msg) throw new Error("msg is not null")
|
||||
if (!this.ws) throw new Error("ws is not null")
|
||||
if (typeof msg === "object") msg = JSON.stringify(msg)
|
||||
if (!msg.includes('"msg":')) throw new Error("msg 格式错误请重试")
|
||||
this.ws.send(msg)
|
||||
}
|
||||
// 发送消息-带消息头(key)
|
||||
sendMsg(head, content, option = {}) {
|
||||
if (!head) throw new Error("head is not null")
|
||||
if (!content) throw new Error("content is not null")
|
||||
let msg = { head, content, ...option }
|
||||
// 发送消息
|
||||
this.send(this.getMsgObj(msg))
|
||||
}
|
||||
// 发送心跳
|
||||
sendMsgBeat() {
|
||||
// this.send(this.getMsgObj('ping', this.TYPES.beat))
|
||||
this.ws.send('ping')
|
||||
}
|
||||
/**
|
||||
* @description 获取消息对象
|
||||
* @param {*} msg 消息内容
|
||||
* @param {*} chatType 群发 group| 单发 single| 心态 heart_beat
|
||||
* @param {*} id 群聊id || 单聊id-用户id(userId)
|
||||
*/
|
||||
getMsgObj(msg, chatType = 'group', id) {
|
||||
if (typeof msg === "object") msg = JSON.stringify(msg)
|
||||
const res = {msg, chatType}
|
||||
// if (!id) throw new Error(`${type=='group'?'群ID':'用户ID'} is not null`)
|
||||
if (chatType == 'group') res.groupId = id || this.id || ''
|
||||
else if (chatType == 'single') res.to = id || this.id || ''
|
||||
return res
|
||||
}
|
||||
// 监听
|
||||
watch(callback) {
|
||||
callback && (this.onmessage = callback);
|
||||
}
|
||||
// 关闭链接
|
||||
close() {
|
||||
this.closed = true;
|
||||
this.ws.close();
|
||||
}
|
||||
// 延时 ms 毫秒
|
||||
sleep(ms){
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
}
|
||||
// 连接socket
|
||||
export const connect = () => new ChatWs()
|
||||
// 默认实例
|
||||
export default new ChatWs()
|
|
@ -61,6 +61,7 @@ import { sessionStore } from '@/utils/store' // 学科名字文生图
|
|||
// 组件引入
|
||||
import ChooseTextbook from '@/components/choose-textbook/index.vue'
|
||||
import { menusEvent } from '@/plugins/vue3-menus' // 右键菜单
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore() // 用户信息
|
||||
|
||||
|
@ -196,19 +197,6 @@ const getResourceList = async () => {
|
|||
// 统一HTTP处理
|
||||
const HTTP_SERVER_API = (type, params = {}) => {
|
||||
switch (type) {
|
||||
case 'addSmarttalk': { // 获取课程
|
||||
const def = {
|
||||
fileId: '', // 文件id - Entpcoursefile 对应id
|
||||
fileFlag: 'aptist',
|
||||
fileShowName: courseObj.coursetitle + '.aptist',
|
||||
textbookId: courseObj.textbookId,
|
||||
levelFirstId: courseObj.levelFirstId,
|
||||
levelSecondId: courseObj.levelSecondId,
|
||||
fileSource: '个人',
|
||||
fileRoot: '备课'
|
||||
}
|
||||
return API_smarttalk.creatAPT({...def, ...params})
|
||||
}
|
||||
case 'addEntpcourse': { // 添加课程
|
||||
const node = courseObj.node || {}
|
||||
if (!node) return msgUtils.msgWarning('请选择章节?')
|
||||
|
@ -291,8 +279,6 @@ const handleAll = async(type, row) =>{
|
|||
}
|
||||
// 生成ppt课件-子级(slide)
|
||||
await HTTP_SERVER_API('addEntpcoursefile', params)
|
||||
// 生成备课资源-Smarttalk
|
||||
await HTTP_SERVER_API('addSmarttalk',{fileId: id})
|
||||
// 刷新资源列表
|
||||
await getResourceList()
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</div>
|
||||
</el-dialog>
|
||||
<!-- im-chat 聊天组件 -->
|
||||
<!-- <im-chat ref="imChatRef" v-if="visible" @change="chatChange" /> -->
|
||||
<im-chat ref="imChatRef" v-if="visible" @change="chatChange" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
@ -90,7 +90,7 @@ import vueQr from 'vue-qr/src/packages/vue-qr.vue' // 插件: 二维码
|
|||
import imChat from '@/views/tool/components/imChat.vue' // im-chat-子组件
|
||||
import MsgEnum from '@/plugins/imChat/msgEnum' // 消息头-相关定义(nuem)
|
||||
import * as commUtil from '@/utils/comm' // 工具类-通用
|
||||
import { toLinkWeb, createWindow, getStaticUrl, sessionStore } from '@/utils/tool' // 工具类-主进程相关
|
||||
import { toLinkWeb, getStaticUrl } from '@/utils/tool' // 工具类-主进程相关
|
||||
|
||||
import * as Http_ClassManage from '@/api/classManage' // api接口
|
||||
import * as Http_Classcourse from '@/api/teaching/classcourse' // api接口
|
||||
|
@ -103,7 +103,7 @@ let baseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
|||
const userStore = useUserStore()
|
||||
const visible = ref(false) // 是否打开窗口
|
||||
const myClassActive = ref({}) // 我的课件:准备上课的APT课件
|
||||
// const imChatRef = ref(null) // im-chat ref
|
||||
const imChatRef = ref(null) // im-chat ref
|
||||
const emit = defineEmits(['close'])
|
||||
const classForm = reactive({ // 班级(左侧):表单数据 表单配置
|
||||
form: {}, itemOption: [], option: {}
|
||||
|
@ -177,7 +177,7 @@ const initData = () => {
|
|||
teacherForm.itemOption = [
|
||||
// { label: '班级', prop: 'classid' },
|
||||
// { label: '上课', prop: 'classcourseid' },
|
||||
// { label: '老师扫码', prop: 'qrUrl', show: false },
|
||||
{ label: '老师扫码', prop: 'qrUrl', show: false },
|
||||
{ label: '手机登录', prop: 'mobile', show: false },
|
||||
{ label: '故障备用', prop: 'backup', show: false },
|
||||
]
|
||||
|
@ -257,22 +257,18 @@ const createClasscourse = async () => {
|
|||
entpcourseid, evalid, coursetitle,
|
||||
plandate: curDate, opendate: curDate
|
||||
}
|
||||
// teacherForm.form.classcourseid = 100
|
||||
teacherForm.form.classcourseid = await Http_Classcourse.addClasscourseReturnId(params)
|
||||
dt.loading = false
|
||||
// getClasscourseList('update') // 更新列表
|
||||
let msgEl = ElMessage.success('创建课程-成功')
|
||||
ElMessage.success('创建课程-成功')
|
||||
// 新版-pptList 打开公屏
|
||||
if (myClassActive.value.filetype == 'aippt') {
|
||||
const msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0})
|
||||
setTimeout(() => {
|
||||
msgEl.close()
|
||||
msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0})
|
||||
setTimeout(() => {
|
||||
msgEl.close()
|
||||
const classcourse = {...params, id: teacherForm.form.classcourseid}
|
||||
openPublicScreen(classcourse)
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
const classcourse = {...params, id: teacherForm.form.classcourseid}
|
||||
openPublicScreen(classcourse)
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
// 删除课程
|
||||
|
@ -300,23 +296,14 @@ const removeClasscourse = async () => {
|
|||
const classTeachingStart = async () => {
|
||||
const { classcourseid:id } = teacherForm.form
|
||||
if (id) { // 开始上课
|
||||
// 新版-pptList 打开公屏
|
||||
if (myClassActive.value.filetype == 'aptist') {
|
||||
const msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0})
|
||||
setTimeout(() => {
|
||||
msgEl.close()
|
||||
openPublicScreen({id})
|
||||
}, 2000);
|
||||
}else {
|
||||
const url = `/teaching/classteaching?classcourseid=${id}&actor=classTeachingOnPublicScreen`
|
||||
toLinkWeb(url) // 跳转web-公屏
|
||||
visible.value = false // 关闭弹窗
|
||||
}
|
||||
const url = `/teaching/classteaching?classcourseid=${id}&actor=classTeachingOnPublicScreen`
|
||||
toLinkWeb(url) // 跳转web-公屏
|
||||
visible.value = false // 关闭弹窗
|
||||
handleClose() // 关闭im-chat
|
||||
}
|
||||
}
|
||||
// 获取二维码地址
|
||||
const getQrUrl = async() => {
|
||||
// console.log('获取二维码地址')
|
||||
const { classcourseid:id } = teacherForm.form
|
||||
const { userName, userId } = userStore.user
|
||||
if (!id||!userName) return
|
||||
|
@ -349,7 +336,6 @@ const getQrUrl = async() => {
|
|||
|
||||
// 打开公屏
|
||||
const openPublicScreen = (classcourse) => {
|
||||
console.log('打开公屏', classcourse)
|
||||
const resource = toRaw(myClassActive.value)
|
||||
sessionStore.set('curr.resource', resource) // 缓存当前资源信息
|
||||
sessionStore.set('curr.classcourse', classcourse) // 缓存当前当前上课
|
||||
|
@ -360,7 +346,6 @@ const openPublicScreen = (classcourse) => {
|
|||
sessionStore.set('curr.classcourse', null) // 清除缓存
|
||||
}
|
||||
})
|
||||
visible.value = false // 关闭弹窗
|
||||
}
|
||||
|
||||
// 定时器监听
|
||||
|
@ -401,14 +386,12 @@ watch(() => classForm.form.classid, (val)=> {
|
|||
// 监听-课程id
|
||||
watch(() => teacherForm.form.classcourseid, (val) => {
|
||||
const bool = !!val
|
||||
const isApt = myClassActive.filetype=='apt'
|
||||
// 获取选中课程-生成二维码地址
|
||||
isApt && bool && getQrUrl()
|
||||
bool && getQrUrl()
|
||||
// 监听课程id,是否显示功能
|
||||
teacherForm.itemOption.forEach(o => {
|
||||
// 有课程id,触发
|
||||
const arr = isApt ? ['qrUrl','backup'] : ['backup']
|
||||
if (arr.includes(o.prop)) o.show = bool
|
||||
if (['qrUrl','backup'].includes(o.prop)) o.show = bool
|
||||
// 课程id为空,触发
|
||||
if (['mobile'].includes(o.prop)) o.show = !bool
|
||||
})
|
||||
|
|
|
@ -192,11 +192,8 @@ import ClassReserv from '@/views/classManage/classReserv.vue'
|
|||
import TreeLog from '@/views/prepare/components/treeLog.vue'
|
||||
import classStart from './container/class-start.vue' // 预备上课
|
||||
import MsgEnum from '@/plugins/imChat/msgEnum' // im 消息枚举
|
||||
// import Chat from '@/utils/chat' // im 登录初始化
|
||||
// if (!Chat.imChat) Chat.init()
|
||||
// import ChatWs from '@/plugins/socket'
|
||||
// console.log('xxxx',ChatWs)
|
||||
// ChatWs.watch((data,e) => console.log('ws', data, e))
|
||||
import Chat from '@/utils/chat' // im 登录初始化
|
||||
if (!Chat.imChat) Chat.init()
|
||||
|
||||
const toolStore = useToolState()
|
||||
const fs = require('fs')
|
||||
|
|
Loading…
Reference in New Issue