Compare commits

...

19 Commits

Author SHA1 Message Date
小杨 8f8016cb0b fix:添加默认头像以及pptlist的bug; 2024-12-13 11:18:33 +08:00
zhengdegang c2d5f2e99a Merge pull request 'zdg_dev' (#127) from zdg_dev into main
Reviewed-on: #127
2024-12-12 17:29:42 +08:00
zdg e7990dc175 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 17:02:31 +08:00
zdg 31de0da3c5 优化 2024-12-12 17:02:22 +08:00
baigl c3b975fee9 Merge pull request 'baigl' (#126) from baigl into main
Reviewed-on: #126
2024-12-12 16:45:29 +08:00
白了个白 ea2a8ebfda Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into baigl 2024-12-12 16:44:36 +08:00
白了个白 308465adb4 ppts: 64转file 提取到utils image中 2024-12-12 16:44:03 +08:00
yangws 469116701b Merge pull request 'fix:修改pptlist活动的bug;' (#125) from yws_dev into main
Reviewed-on: #125
2024-12-12 16:39:46 +08:00
zdg 80b66ffb28 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 16:38:44 +08:00
zdg 75b5884210 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 16:24:53 +08:00
zdg 03f160464c ppt上课 2024-12-12 16:24:47 +08:00
zdg 354e0b44c9 生产环境地址 2024-12-12 12:27:01 +08:00
zdg 5e04a4c2c2 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 12:21:53 +08:00
zdg ca93eb72ac 更新消息 2024-12-12 12:21:47 +08:00
zdg b15fa29ffa Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 11:02:22 +08:00
zdg 9ef4812acb Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-12 10:31:00 +08:00
zdg d313f901a3 去掉注释 2024-12-11 17:32:11 +08:00
zdg 8990ffdc58 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-11 17:17:01 +08:00
zdg 13b1a895a4 上课 socket 2024-12-11 17:16:55 +08:00
22 changed files with 283 additions and 210 deletions

View File

@ -19,7 +19,7 @@ VITE_APP_RES_FILE_PATH = 'https://prev.ysaix.com:7868/src/assets/textbook/booktx
VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/' VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/'
# websocket 地址 # websocket 地址
VITE_APP_WS_URL = 'wss://file.ysaix.com:7868' VITE_APP_WS_URL = 'wss://prev.ysaix.com:7868'
# 是否显示开发工具 # 是否显示开发工具
VITE_SHOW_DEV_TOOLS = 'true' VITE_SHOW_DEV_TOOLS = 'true'

View File

@ -28,8 +28,9 @@ import msgUtils from '@/plugins/modal' // 消息工具
import * as API_entpcoursefile from '@/api/education/entpcoursefile' // api import * as API_entpcoursefile from '@/api/education/entpcoursefile' // api
import { PPTApi } from './api' import { PPTApi } from './api'
import { sessionStore } from '@/utils/store' // electron-store import { sessionStore } from '@/utils/store' // electron-store
import './api/watcher' // // import './api/watcher' //
import watcher from './api/watcher' //
watcher() //
const loading = ref(true) const loading = ref(true)
const _isPC = isPC() const _isPC = isPC()

View File

@ -8,12 +8,15 @@ import * as useStore from '../store' // pptist-状态管理
import ChatWs from '@/plugins/socket' // 聊天socket import ChatWs from '@/plugins/socket' // 聊天socket
import msgUtils from '@/plugins/modal' // 消息工具 import msgUtils from '@/plugins/modal' // 消息工具
const slidesStore = useStore.useSlidesStore() // 幻灯片-状态管理
const screenStore = useStore.useScreenStore() // 全屏-状态管理 const screenStore = useStore.useScreenStore() // 全屏-状态管理
const classcourseStore = useStore.useClasscourseStore() // 课堂信息-状态管理 const classcourseStore = useStore.useClasscourseStore() // 课堂信息-状态管理
const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 const classcourse = sessionStore.get('curr.classcourse') // 课堂信息
export class Classcourse { export class Classcourse {
msgObj:ElMessageBox = null // 提示消息对象 msgObj:ElMessageBox = null // 提示消息对象
classcourse:any = null // 课堂信息
id: number|string = null // 课堂id
constructor() { constructor() {
this.load() this.load()
@ -22,6 +25,7 @@ export class Classcourse {
* @description * @description
*/ */
load() { load() {
console.log('classcourse-load', classcourse)
// 打开全屏 // 打开全屏
screenStore.setScreening(!!classcourse) screenStore.setScreening(!!classcourse)
// 如果课堂信息有值则连接socket // 如果课堂信息有值则连接socket
@ -29,14 +33,19 @@ export class Classcourse {
// 连接socket // 连接socket
if (!ChatWs.ws) ChatWs.init() if (!ChatWs.ws) ChatWs.init()
ChatWs.id = classcourse.timgroupid // 群组id ChatWs.id = classcourse.timgroupid // 群组id
console.log('ws- ', classcourse) this.classcourse = classcourse // 课堂信息
this.id = classcourse.id // 课堂id
// 如果课堂信息有paging则更新当前页码
const isPaging = !!classcourse.paging||classcourse.paging==0
if (isPaging) slidesStore.updateSlideIndex(classcourse.paging)
// 课堂信息-状态管理
classcourseStore.setClasscourse(classcourse) classcourseStore.setClasscourse(classcourse)
// 待上课提示 // 待上课提示
if (!classcourse.status) { if (!classcourse.status) {
this.msgObj = { this.msgObj = {
type: 'success', type: 'success',
title: '系统提示', title: '系统提示',
message: '公屏课堂已准备完毕,请等待老师开启课堂!', message: '公屏课堂已准备完毕,等待老师开启课堂...',
center: true, center: true,
showClose: false, showClose: false,
showCancelButton: false, showCancelButton: false,

View File

@ -55,26 +55,28 @@ export class PPTApi {
// 变量 // 变量
static isUpdate = true // 是否更新数据 static isUpdate = true // 是否更新数据
// 获取所有幻灯片列表 // 获取所有幻灯片列表 isUpdate为true不更新
static getSlideList(parentid: (Number | String)): Promise<Boolean> { static getSlideList(parentid: (Number | String),isUpdate?:Boolean): Promise<Boolean> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const params: object = { parentid, orderByColumn: 'fileidx', isAsc: 'asc', pageSize: 9999 } const params: object = { parentid, orderByColumn: 'fileidx', isAsc: 'asc', pageSize: 9999 }
const res: Result = await API_entpcoursefile.listEntpcoursefileNew(params) const res: Result = await API_entpcoursefile.listEntpcoursefileNew(params)
if (res.code === 200) { if (res.code === 200) {
const slides = (res.rows || []).map(o => { if(!isUpdate){
if (!!o.datacontent) { const slides = (res.rows || []).map(o => {
const json = JSON.parse(o.datacontent) if (!!o.datacontent) {
!!json && (json.id = o.id) const json = JSON.parse(o.datacontent)
return json !!json && (json.id = o.id)
} return json
// 如果没有数据,默认空白页 }
return {id: o.id,elements:[],background:{type:"solid",color:"#fff"}} // 如果没有数据,默认空白页
}) return {id: o.id,elements:[],background:{type:"solid",color:"#fff"}}
})
// slidesStore.updateSlideIndex(0) // 下标0 为第一页
slidesStore.setSlides(slides) // 写入数据
}
// 活动列表处理 // 活动列表处理
const workList = (res.rows || []).map(o => o.activityContent) const workList = (res.rows || []).map(o => o.activityContent)
const workItem = [...res.rows] const workItem = res.rows ? [...res.rows] : []
// slidesStore.updateSlideIndex(0) // 下标0 为第一页
slidesStore.setSlides(slides) // 写入数据
// 写入作业列表数据 // 写入作业列表数据
slidesStore.setWorkList(workList) slidesStore.setWorkList(workList)
// 获取所有的pptlist的数据 // 获取所有的pptlist的数据
@ -111,7 +113,6 @@ export class PPTApi {
data.id = rid data.id = rid
slidesStore.updateSlide(data) slidesStore.updateSlide(data)
// msgUtils.msgSuccess('新增成功') // msgUtils.msgSuccess('新增成功')
PPTApi.getSlideList(resource.id)
this.isUpdate = false // 新增后会触发监听,不再更新数据 this.isUpdate = false // 新增后会触发监听,不再更新数据
resolve(true) resolve(true)
} else msgUtils.msgError('新增失败');resolve(false) } else msgUtils.msgError('新增失败');resolve(false)
@ -134,7 +135,9 @@ export class PPTApi {
const isAdd = !/^\d+$/.test(currentSlide.id) // 是否新增 const isAdd = !/^\d+$/.test(currentSlide.id) // 是否新增
if (isAdd) { // 新增的幻灯片(id 为非数字,说明是新增的幻灯片) if (isAdd) { // 新增的幻灯片(id 为非数字,说明是新增的幻灯片)
const bool = await this.addSlide(currentSlide) const bool = await this.addSlide(currentSlide)
bool && this.batchUpdateSlides(newData, true) // 批量更新-排序 bool && await this.batchUpdateSlides(newData, true) // 批量更新-排序
const resource = sessionStore.get('curr.resource')||{}
await PPTApi.getSlideList(resource.id)
} else { // 防抖-更新 } else { // 防抖-更新
if (!this.isUpdate) return this.isUpdate = true // 下次更新数据 if (!this.isUpdate) return this.isUpdate = true // 下次更新数据
const params = { const params = {

View File

@ -106,6 +106,8 @@ export class MsgEnum {
MSG_anmationclick : 'anmationclick', MSG_anmationclick : 'anmationclick',
/** @desc: 群组创建成功 */ /** @desc: 群组创建成功 */
MSG_classcourseopen : 'classcourseopen', MSG_classcourseopen : 'classcourseopen',
/** @desc: 学生提交作业 */
MSG_finishHomework : 'finishHomework',
/** @desc: 学生的测练结果反馈 */ /** @desc: 学生的测练结果反馈 */
MSG_classquizfeedback : 'classquizfeedback', MSG_classquizfeedback : 'classquizfeedback',
/** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */ /** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */
@ -120,6 +122,12 @@ export class MsgEnum {
MSG_classWorkOfPresentDataUpdate : 'classWorkOfPresentDataUpdate', MSG_classWorkOfPresentDataUpdate : 'classWorkOfPresentDataUpdate',
/** @desc: 课堂讲授活动,选择不同的内容 */ /** @desc: 课堂讲授活动,选择不同的内容 */
MSG_classlecturePagesrc : 'classlecturePagesrc', MSG_classlecturePagesrc : 'classlecturePagesrc',
/** @desc: 课堂作业|活动 */
MSG_homework : 'HOMEWORK',
/** @desc: 点赞 */
MSG_dz : 'dz',
/** @desc: 疑惑 */
MSG_yh : 'yh',
// === 新定义-消息头 === // === 新定义-消息头 ===
/** @desc: 课程创建-待开课 */ /** @desc: 课程创建-待开课 */
MSG_0000: 0x0000, MSG_0000: 0x0000,

View File

@ -10,85 +10,106 @@ import { MsgEnum } from './types' // 消息枚举
import ChatWs from '@/plugins/socket' // 聊天socket import ChatWs from '@/plugins/socket' // 聊天socket
import Classcourse from './classcourse' // 课程相关 import Classcourse from './classcourse' // 课程相关
import msgUtils from '@/plugins/modal' // 消息工具 import msgUtils from '@/plugins/modal' // 消息工具
const slidesStore = store.useSlidesStore() import { Homework } from './index' // api-作业相关
const classcourseStore = store.useClasscourseStore() // 课堂信息-状态管理 import emitter from '@/utils/mitt' //mitt 事件总线
const resource = sessionStore.get('curr.resource') // apt 资源
const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源
/** /**
* @description * @description
*/ */
// 监听幻灯片内容变化 export default () => {
watch(() => slidesStore.slides, (newVal, oldVal) => { const slidesStore = store.useSlidesStore()
PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容 const classcourseStore = store.useClasscourseStore() // 课堂信息-状态管理
},{ deep: true }) const resource = sessionStore.get('curr.resource') // apt 资源
const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源
// 监听标题变化 // 监听幻灯片内容变化
watch(() => slidesStore.title, (newVal, oldVal) => { watch(() => slidesStore.slides, (newVal, oldVal) => {
if (oldVal == '未命名演示文稿') return // 初始加载,不需要更新数据 PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容
updatePPT({title: newVal}) },{ deep: true })
})
// 消息监听ws // 监听标题变化
console.log('监听器已开启', ChatWs) watch(() => slidesStore.title, (newVal, oldVal) => {
if (ChatWs.ws) { if (oldVal == '未命名演示文稿') return // 初始加载,不需要更新数据
ChatWs.watch((msg, e) => { updatePPT({title: newVal})
try {
handleMessage(JSON.parse(msg))
} catch (error) {
console.error('socket 解析异常 ', error, e)
handleMessage(msg)
}
}) })
}
// 更新ppt内容 // 消息监听ws
const updatePPT = async (data) => { // console.log('监听器已开启', ChatWs)
if (!resource) return if (!!ChatWs.ws) {
data.id = resource.id ChatWs.watch((data, e) => {
await PPTApi.updateSlide(data) // 更新ppt内容 try {
sessionStore.set('curr.resource.title', data.title) handleMessage(JSON.parse(data)?.msg)
// 更新smarttalk内容 } catch (error) {
if (!!smarttalk && !!data.title) { console.error('socket 解析异常 ', error, e)
const {id, fileFlag} = smarttalk handleMessage(data)
const params = { id, fileShowName: `${data.title}.${fileFlag}` } }
await PPTApi.updateSmarttalk(params) // 更新ppt内容 })
sessionStore.set('curr.smarttalk.fileShowName', params.fileShowName)
} }
}
// ws消息处理 // 更新ppt内容
const handleMessage = (msg) => { const updatePPT = async (data) => {
if (typeof msg === 'object'){ if (!resource) return
const { head, content, ...other } = msg data.id = resource.id
switch (head) { await PPTApi.updateSlide(data) // 更新ppt内容
case MsgEnum.HEADS.MSG_open: // 开课 sessionStore.set('curr.resource.title', data.title)
// 课堂信息不一致 // 更新smarttalk内容
if (Classcourse.id !== content.id) { if (!!smarttalk && !!data.title) {
msgUtils.alertError('老师开课信息异常,请重新进入公屏!') const {id, fileFlag} = smarttalk
.then(() => { // 点击确定按钮,关闭窗口 const params = { id, fileShowName: `${data.title}.${fileFlag}` }
window.close() await PPTApi.updateSmarttalk(params) // 更新ppt内容
}) sessionStore.set('curr.smarttalk.fileShowName', params.fileShowName)
} else { // 正常更新数据
classcourseStore.classcourse.status = 'open'
// 更新课堂信息-关闭警告框
Classcourse?.msgObj?.onVanish()
}
break
case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页
const slideIndex = content.current
slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标
break
case MsgEnum.HEADS.MSG_closed: // 下课:
window.close() // 关闭窗口
break
default:
break
} }
} }
// ws消息处理
const handleMessage = (msg) => {
console.log('ws消息处理', msg)
if (typeof msg === 'object'){
const { head, content, ...other } = msg
switch (head) {
case MsgEnum.HEADS.MSG_open: // 开课
// 课堂信息不一致
if (Classcourse.id !== content.id) {
msgUtils.alertError('老师开课信息异常,请重新进入公屏!')
.then(() => { // 点击确定按钮,关闭窗口
close()
})
} else { // 正常更新数据
classcourseStore.classcourse.status = 'open'
sessionStore.set('curr.classcourse.status', 'open')
// 更新课堂信息-关闭警告框
Classcourse?.msgObj?.onVanish()
}
break
case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页
const slideIndex = content.current
slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标
break
case MsgEnum.HEADS.MSG_homework: // 作业|活动-布置
if (!content.classWorkId) return
Homework.showHomework(content.classWorkId)
break
case MsgEnum.HEADS.MSG_closed: // 下课:
close()
break
case MsgEnum.HEADS.MSG_dz: // 点赞
emitter.emit('upvoteTrigger', 1)
break
case MsgEnum.HEADS.MSG_yh: // 疑惑
emitter.emit('upvoteTrigger', 2)
break
case MsgEnum.HEADS.MSG_0010: // 备用
break
default:
break
}
}
}
// 关闭窗口
const close = () => {
ChatWs?.close() // 关闭ws
setTimeout(() => {
window.close() // 关闭窗口
}, 1000)
}
} }
// console.log('监听器已开启', Classcourse)
// setTimeout(() => {
// console.log('关闭弹窗')
// // Classcourse.msgObj?.close()
// Classcourse?.msgObj?.onVanish()
// }, 10 * 1000)

View File

@ -1,5 +1,6 @@
import { useScreenStore, useSlidesStore, useClasscourseStore } from '../store' import { useScreenStore, useSlidesStore, useClasscourseStore } from '../store'
import { enterFullscreen, exitFullscreen, isFullscreen } from '../utils/fullscreen' import { enterFullscreen, exitFullscreen, isFullscreen } from '../utils/fullscreen'
import ChatWs from '@/plugins/socket' // 聊天socket
export default () => { export default () => {
const screenStore = useScreenStore() const screenStore = useScreenStore()
@ -23,7 +24,10 @@ export default () => {
const classcourse = classcourseStore.classcourse const classcourse = classcourseStore.classcourse
if (!!classcourse) { //DOTO 有课堂,执行退相关操作 if (!!classcourse) { //DOTO 有课堂,执行退相关操作
console.log('退出放映状态') console.log('退出放映状态')
window.close() ChatWs?.close() // 关闭ws
setTimeout(() => {
window.close() // 关闭窗口
}, 1000)
} else screenStore.setScreening(false) } else screenStore.setScreening(false)
if (isFullscreen()) exitFullscreen() if (isFullscreen()) exitFullscreen()
} }

View File

@ -145,21 +145,16 @@ export const useSlidesStore = defineStore('slides', {
setWorkItem(list: Object[]) { setWorkItem(list: Object[]) {
this.workItem = list this.workItem = list
}, },
addWorkItem(data: any) {
const id = data?.id
if (!id) return
this.workItem.splice(this.slideIndex + 1, 0, data)
this.slideIndex += 1
},
addSlide(slide: Slide | Slide[]) { addSlide(slide: Slide | Slide[]) {
const slides = Array.isArray(slide) ? slide : [slide] const slides = Array.isArray(slide) ? slide : [slide]
for (const slide of slides) { for (const slide of slides) {
if (slide.sectionTag) delete slide.sectionTag if (slide.sectionTag) delete slide.sectionTag
} }
// const addIndex = this.slideIndex + 1
this.slides.splice(this.slideIndex, 0, ...slides) this.slides.splice(this.slideIndex, 0, ...slides)
// this.slideIndex = addIndex
}, },
updateSlide(props: Partial<Slide>, slideId?: string) { updateSlide(props: Partial<Slide>, slideId?: string) {
const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex
this.slides[slideIndex] = { ...this.slides[slideIndex], ...props } this.slides[slideIndex] = { ...this.slides[slideIndex], ...props }

View File

@ -73,3 +73,54 @@ export const svg2File = (svg: string): File => {
const blob = new Blob([svg], { type: 'image/svg+xml' }) const blob = new Blob([svg], { type: 'image/svg+xml' })
return new File([blob], `${Date.now()}.svg`, { type: 'image/svg+xml' }) return new File([blob], `${Date.now()}.svg`, { type: 'image/svg+xml' })
} }
/**
*
* @returns
*/
export const getTime=()=>{
const now = new Date();
const year = now.getFullYear();
const month = ('0' + (now.getMonth() + 1)).slice(-2);
const day = ('0' + now.getDate()).slice(-2);
const hours = ('0' + now.getHours()).slice(-2);
const minutes = ('0' + now.getMinutes()).slice(-2);
const seconds = ('0' + now.getSeconds()).slice(-2);
return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`;
};
/**
* base64转图片File
* @param {String} base64 base64
* @param {String} fileName | myimg
* @returns File file数据类型
*/
export const base64ToFile = (base64: string, fileName = '试题图片') => {
// 将base64按照 , 进行分割 将前缀 与后续内容分隔开
let data = base64.split(','),
// 利用正则表达式 从前缀中获取图片的类型信息image/png、image/jpeg、image/webp等
type = data[0].match(/:(.*?);/)[1],
// 从图片的类型信息中 获取具体的文件格式后缀png、jpeg、webp
suffix = type.split('/')[1],
// 使用atob()对base64数据进行解码 结果是一个文件数据流 以字符串的格式输出
bstr = window.atob(data[1]),
// 获取解码结果字符串的长度
n = bstr.length,
// 根据解码结果字符串的长度创建一个等长的整形数字数组
// 但在创建时 所有元素初始值都为 0
u8arr = new Uint8Array(n)
// 将整形数组的每个元素填充为解码结果字符串对应位置字符的UTF-16 编码单元
while (n--) {
// charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元
u8arr[n] = bstr.charCodeAt(n)
}
const filename = fileName+getTime()
// 利用构造函数创建File文件对象
// new File(bits, name, options)
const file = new File([u8arr], `${filename}.${suffix}`, {
type: type
})
// 返回file
return file
}

View File

@ -141,7 +141,7 @@
import { ref } from 'vue' import { ref } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useMainStore, useSnapshotStore } from '../../../store' import { useMainStore, useSnapshotStore } from '../../../store'
import { getImageDataURL } from '../../../utils/image' import { getImageDataURL, base64ToFile } from '../../../utils/image'
import type { ShapePoolItem } from '../../../configs/shapes' import type { ShapePoolItem } from '../../../configs/shapes'
import type { LinePoolItem } from '../../../configs/lines' import type { LinePoolItem } from '../../../configs/lines'
import useScaleCanvas from '../../../hooks/useScaleCanvas' import useScaleCanvas from '../../../hooks/useScaleCanvas'
@ -208,57 +208,9 @@ const insertImageElement = (files: FileList) => {
// }) // })
} }
//
const getTime=()=>{
const now = new Date();
const year = now.getFullYear();
const month = ('0' + (now.getMonth() + 1)).slice(-2);
const day = ('0' + now.getDate()).slice(-2);
const hours = ('0' + now.getHours()).slice(-2);
const minutes = ('0' + now.getMinutes()).slice(-2);
const seconds = ('0' + now.getSeconds()).slice(-2);
return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`;
};
/**
* base64转图片File
* @param {String} base64 图片base64
* @param {String} fileName 图片名称| 默认 myimg
* @returns File 返回转换后的file数据类型
*/
const base64ToFile = (base64: string, fileName = '试题图片') => {
// base64 ,
let data = base64.split(','),
// image/pngimage/jpegimage/webp
type = data[0].match(/:(.*?);/)[1],
// pngjpegwebp
suffix = type.split('/')[1],
// 使atob()base64
bstr = window.atob(data[1]),
//
n = bstr.length,
//
// 0
u8arr = new Uint8Array(n)
// UTF-16
while (n--) {
// charCodeAt() UTF-16
u8arr[n] = bstr.charCodeAt(n)
}
const filename = fileName+getTime()
// File
// new File(bits, name, options)
const file = new File([u8arr], `${filename}.${suffix}`, {
type: type
})
// file
return file
}
const onhtml2canvas = async (html: HTMLElement) => { const onhtml2canvas = async (html: HTMLElement) => {
const base64Dta = await toPng(html); const base64Dta = await toPng(html);
// base64File
const toFile = base64ToFile(base64Dta) const toFile = base64ToFile(base64Dta)
// 线 // 线
PPTApi.toRousrceUrl(toFile).then(data=>{ PPTApi.toRousrceUrl(toFile).then(data=>{

View File

@ -302,9 +302,9 @@ const getData = async (data: WorkItem) => {
dialogVisible.value = false dialogVisible.value = false
} }
const upDateData = async () => { const upDateData = async () => {
// await PPTApi.updateSlide(paramData.value)
loadingActive.value = true loadingActive.value = true
await updateEntpcoursefileNew(paramData.value) await PPTApi.updateSlide(paramData.value)
// await updateEntpcoursefileNew(paramData.value)
const resource = sessionStore.get('curr.resource') const resource = sessionStore.get('curr.resource')
await PPTApi.getSlideList(resource.id) await PPTApi.getSlideList(resource.id)
const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 }) const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 })

View File

@ -5,7 +5,7 @@
<el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" > <el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" >
<template #reference> <template #reference>
<div class="user-info"> <div class="user-info">
<el-image class="user-img" :src="dev_api + userStore.user.avatar" /> <el-image class="user-img" :src="userStore.user.avatar ==='/img/avatar-default.jpg' ? defaultUserImg : dev_api + userStore.user.avatar" />
<span>{{ userStore.user.nickName }}</span> <span>{{ userStore.user.nickName }}</span>
</div> </div>
</template> </template>
@ -59,6 +59,7 @@ import { ElMessageBox, ElMessage } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import pkc from "../../../../../package.json" import pkc from "../../../../../package.json"
import defaultUserImg from '@/assets/images/img-avatar.png'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}

View File

@ -80,10 +80,10 @@ export class MsgEnum {
MSG_anmationclick : 'anmationclick', MSG_anmationclick : 'anmationclick',
/** @desc: 群组创建成功 */ /** @desc: 群组创建成功 */
MSG_classcourseopen : 'classcourseopen', MSG_classcourseopen : 'classcourseopen',
/** @desc: 学生的测练结果反馈 */
MSG_classquizfeedback : 'classquizfeedback',
/** @desc: 学生提交作业 */ /** @desc: 学生提交作业 */
MSG_finishHomework : 'finishHomework', MSG_finishHomework : 'finishHomework',
/** @desc: 学生的测练结果反馈 */
MSG_classquizfeedback : 'classquizfeedback',
/** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */ /** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */
MSG_classtaskfeedback : 'classtaskfeedback', MSG_classtaskfeedback : 'classtaskfeedback',
/** @desc: 老师端学生反馈的消息具体要看其中的feedbackkey类别较繁杂 */ /** @desc: 老师端学生反馈的消息具体要看其中的feedbackkey类别较繁杂 */
@ -96,6 +96,12 @@ export class MsgEnum {
MSG_classWorkOfPresentDataUpdate : 'classWorkOfPresentDataUpdate', MSG_classWorkOfPresentDataUpdate : 'classWorkOfPresentDataUpdate',
/** @desc: 课堂讲授活动,选择不同的内容 */ /** @desc: 课堂讲授活动,选择不同的内容 */
MSG_classlecturePagesrc : 'classlecturePagesrc', MSG_classlecturePagesrc : 'classlecturePagesrc',
/** @desc: 课堂作业|活动 */
MSG_homework : 'HOMEWORK',
/** @desc: 点赞 */
MSG_dz : 'dz',
/** @desc: 疑惑 */
MSG_yh : 'yh',
// === 新定义-消息头 === // === 新定义-消息头 ===
/** @desc: 课程创建-待开课 */ /** @desc: 课程创建-待开课 */
MSG_0000: 0x0000, MSG_0000: 0x0000,
@ -140,4 +146,4 @@ export class MsgEnum {
} }
} }
export { MsgEnum as default } export default MsgEnum;

View File

@ -28,6 +28,7 @@ export class ChatWs {
const userStore = useUserStore() // 用户信息 const userStore = useUserStore() // 用户信息
const wsBase = import.meta.env.VITE_APP_WS_URL; // ws地址 const wsBase = import.meta.env.VITE_APP_WS_URL; // ws地址
this.url = `${wsBase||ChatWs.base}/ws/websocket/${userStore.id}`; this.url = `${wsBase||ChatWs.base}/ws/websocket/${userStore.id}`;
this.closed = false; // 关闭状态 防止重连失败
// this.init(url); // this.init(url);
} }
ChatWs.instance = this; ChatWs.instance = this;
@ -38,6 +39,7 @@ export class ChatWs {
// 初始化 // 初始化
init(url) { init(url) {
!!url && (this.url = url); !!url && (this.url = url);
this.closed = false; // 关闭状态 防止重连失败
this.ws = null; this.ws = null;
const _this = this const _this = this
this.heartCheck = { this.heartCheck = {
@ -64,43 +66,46 @@ export class ChatWs {
}, this.timeout); }, this.timeout);
}, },
}; };
this.reconnect(); return this.reconnect();
} }
// 重连 // 重连
reconnect() { reconnect() {
const self = this; return new Promise((resolve, reject) => {
if (!!this.ws) { // 关闭之前的链接 const self = this;
this.ws.close() if (!!this.ws) { // 关闭之前的链接
this.ws = null this.ws.close()
} this.ws = null
this.ws = new WebSocket(this.url); }
this.ws.onopen = function () { this.ws = new WebSocket(this.url);
console.log("websocket-连接成功") this.ws.onopen = function () {
self.heartCheck.reset().start(); console.log("websocket-连接成功")
}; self.heartCheck.reset().start();
this.ws.onmessage = function (e) { resolve()
// console.log("websocket-收到消息", e) };
// 拿到任何消息都说明当前连接是正常的 this.ws.onmessage = function (e) {
const isBeat = e.data == 'pong' // console.log("websocket-收到消息", e)
isBeat && self.heartCheck.reset().start(); // 拿到任何消息都说明当前连接是正常的
const isEmpty = !e.data const isBeat = e.data == 'pong'
const isExts = e.data.includes('sessionId') || e.data == ('pong') isBeat && self.heartCheck.reset().start();
if (isEmpty || isExts) return; const isEmpty = !e.data
// 自定义处理 const isExts = e.data.includes('sessionId') || e.data == ('pong')
self.onmessage && self.onmessage(e.data, e); if (isEmpty || isExts) return;
}; // 自定义处理
this.ws.onerror = function (e) { self.onmessage && self.onmessage(e.data, e);
console.log("websocket-连接异常", e) };
self.connectSocket() // 重连 this.ws.onerror = function (e) {
}; console.log("websocket-连接异常", e)
this.ws.onclose = function (e) { self.connectSocket() // 重连
console.log("websocket-连接断开", e) };
self.connectSocket() // 重连 this.ws.onclose = function (e) {
}; console.log("websocket-连接断开", e)
self.connectSocket() // 重连
};
})
} }
connectSocket() { connectSocket() {
this.heartCheck.reset() // 重置心跳 this.heartCheck.reset() // 重置心跳
if (self.closed) return; // 关闭状态不重连 if (this.closed) return this.ws = null; // 关闭状态不重连
// if(self.errCount <= 0) return; // 超过重连次数 // if(self.errCount <= 0) return; // 超过重连次数
// self.errCount--; // 重连次数减1 // self.errCount--; // 重连次数减1
if (this.errTime) { if (this.errTime) {
@ -157,6 +162,16 @@ export class ChatWs {
this.closed = true; this.closed = true;
this.ws.close(); this.ws.close();
} }
// 下课
closedCourse(id) {
return new Promise((resolve, reject) => {
this.sendMsg('closed', '下课', null, 'group', id)
resolve()
// setTimeout(() => {
// this.close() // 关闭链接
// }, 1000);
})
}
// 延时 ms 毫秒 // 延时 ms 毫秒
sleep(ms){ sleep(ms){
return new Promise(resolve => setTimeout(resolve, ms)) return new Promise(resolve => setTimeout(resolve, ms))

View File

@ -15,8 +15,7 @@
</template> </template>
<template v-else-if="item.status === 'open'"> <template v-else-if="item.status === 'open'">
<el-button :disabled="toolStore.isToolWin" size="small" type="primary" @click="startClassR(item)" <el-button :disabled="toolStore.isToolWin" size="small" type="primary" @click="startClassR(item)"
>继续上课</el-button >继续上课</el-button>
>
<!--<el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>--> <!--<el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>-->
<el-button :loading="loading" size="small" type="info" @click="endClassR(item)" <el-button :loading="loading" size="small" type="info" @click="endClassR(item)"
>下课{{ loading?'中...':'' }}</el-button> >下课{{ loading?'中...':'' }}</el-button>

View File

@ -714,6 +714,7 @@ const closeDialog = () => {
// im // im
const msgHandle = (msg) => { const msgHandle = (msg) => {
console.log('socket消息回调', msg)
if (typeof msg === 'object'){ if (typeof msg === 'object'){
const { head, content, ...other } = msg const { head, content, ...other } = msg
switch(head) { switch(head) {

View File

@ -146,6 +146,7 @@ const open = async (id, classObj) => {
await getAptInfo(id) await getAptInfo(id)
// //
getClassList() getClassList()
console.log('classObj', classObj)
// //
if (!!classObj) { if (!!classObj) {
dt.ctCourse = classObj dt.ctCourse = classObj
@ -304,11 +305,11 @@ const classTeachingStart = async () => {
const { classcourseid:id } = teacherForm.form const { classcourseid:id } = teacherForm.form
if (id) { // if (id) { //
// -pptList // -pptList
if (myClassActive.value.filetype == 'aptist') { if (myClassActive.value.filetype == 'aippt') {
const msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0}) const msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0})
setTimeout(async () => { setTimeout(async () => {
msgEl.close() msgEl.close()
const res = await Http_Classcourse.getClasscourse(teacherForm.form.classcourseid) const res = await Http_Classcourse.getClasscourse(id)
openPublicScreen(res.data) openPublicScreen(res.data)
}, 2000); }, 2000);
}else { }else {
@ -316,6 +317,8 @@ const classTeachingStart = async () => {
toLinkWeb(url) // web- toLinkWeb(url) // web-
visible.value = false // visible.value = false //
} }
} else {
ElMessage.warning('请先创建课程')
} }
} }
// //
@ -354,9 +357,11 @@ const getQrUrl = async() => {
// //
const openPublicScreen = (classcourse) => { const openPublicScreen = (classcourse) => {
console.log('打开公屏', classcourse) console.log('打开公屏', classcourse)
// app if (!dt.ctCourse) { // -
const data = { id: classcourse.id } // app
ChatWs.sendMsg(MsgEnum.HEADS.MSG_0000, data, {}, ChatWs.TYPES.single, userStore.id) const data = { id: classcourse.id }
ChatWs.sendMsg(MsgEnum.HEADS.MSG_0000, data, {}, ChatWs.TYPES.single, userStore.id)
}
// //
const resource = toRaw(myClassActive.value) const resource = toRaw(myClassActive.value)
sessionStore.set('curr.resource', resource) // sessionStore.set('curr.resource', resource) //

View File

@ -196,7 +196,7 @@ export default {
} }
},*/ },*/
clickStartClass(item) { clickStartClass(item) {
const isApt = item.fileFlag === 'apt' const isApt = ['apt','aippt'].includes(item.fileFlag)
this.getOpenCourse(isApt).then(res => { this.getOpenCourse(isApt).then(res => {
console.log(res) console.log(res)
if(!res){ if(!res){

View File

@ -380,7 +380,7 @@ export default {
} }
case 'close': { // case 'close': { //
const head = MsgEnum.HEADS.MSG_closed // closed const head = MsgEnum.HEADS.MSG_closed // closed
const msgT = MsgEnum.TYPES.TEACHER // teacher // const msgT = MsgEnum.TYPES.TEACHER // teacher
const isApt = !row.bookImg // bookImg ppt Apt const isApt = !row.bookImg // bookImg ppt Apt
row.ex3 == 'undefined' && (row.ex3 = null) row.ex3 == 'undefined' && (row.ex3 = null)
const timgroupid = isApt ? row.timgroupid : row.ex3 // ex3 ppt Apt const timgroupid = isApt ? row.timgroupid : row.ex3 // ex3 ppt Apt
@ -392,12 +392,13 @@ export default {
} }
// - // -
if (!!timgroupid) { if (!!timgroupid) {
const msg = { msgKey: head, actor: msgT, classcourseid: row.id } // const msg = { msgKey: head, actor: msgT, classcourseid: row.id }
Chat.sendMsg(timgroupid, msg) // Chat.sendMsg(timgroupid, msg)
await ChatWs.closedCourse(timgroupid)
} }
if (isApt) { // Apt if (isApt) { // Apt
// - // -
await updateClasscourse({ id: row.id, status: head, timgroupid: '' }) await updateClasscourse({ id: row.id, status: head })
} else { // PPT } else { // PPT
const toolStore = useToolState() const toolStore = useToolState()
// //
@ -410,12 +411,12 @@ export default {
} }
// //
setTimeout(async() => { setTimeout(async() => {
if (!!timgroupid) await Chat.dismissGroup(timgroupid) // if (!!timgroupid) await Chat.dismissGroup(timgroupid)
if (other.type == 1) { // - if (other.type == 1) { // -
other.instance.confirmButtonLoading = false other.instance.confirmButtonLoading = false
other.instance.confirmButtonText = '下课' other.instance.confirmButtonText = '下课'
other.done() other.done()
} else { } else { // -
other.loading.value = false other.loading.value = false
row.status = isApt ? head : '已结束' row.status = isApt ? head : '已结束'
} }

View File

@ -11,7 +11,7 @@
<!-- 裁剪+效果 --> <!-- 裁剪+效果 -->
<div class="box"> <div class="box">
<div class="box_1"> <div class="box_1">
<img :src="dev_api + filePath" ref="image" /> <img :src="filePath" ref="image" />
</div> </div>
<!--裁剪完的图片--> <!--裁剪完的图片-->
@ -164,7 +164,7 @@ export default {
// //
onMounted(() => { onMounted(() => {
if (props.filePath) { if (props.filePath) {
dataFile.image.src = dev_api.value + props.filePath; dataFile.image.src = props.filePath;
copper(); copper();
} }
}); });

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="user-info-head" @click="editCropper()"> <div class="user-info-head" @click="editCropper()">
<img :src="dev_api + options.img" title="点击上传头像" class="img-circle img-lg" /> <img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
<el-dialog <el-dialog
v-model="open" v-model="open"
append-to-body append-to-body
@ -23,6 +23,7 @@ import { uploadAvatar } from '@/api/system/user'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import CropperImage from './cropperImage.vue' import CropperImage from './cropperImage.vue'
import defaultUserImg from '@/assets/images/img-avatar.png'
const userStore = useUserStore() const userStore = useUserStore()
@ -32,7 +33,7 @@ const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
// //
const options = reactive({ const options = reactive({
img: userStore.user.avatar, // img: userStore.user.avatar ==='/img/avatar-default.jpg' ? defaultUserImg : dev_api + userStore.user.avatar, //
autoCrop: true, // autoCrop: true, //
autoCropWidth: 400, // autoCropWidth: 400, //
autoCropHeight: 400, // autoCropHeight: 400, //

View File

@ -8,7 +8,7 @@
</el-form-item> </el-form-item>
<el-form-item label="所属学校" prop="identity"> <el-form-item label="所属学校" prop="identity">
<div style="display: flex;"> <div style="display: flex;">
<div>{{ userStore.DeptInfo.register.schoolName }}</div> <div>{{ userStore.DeptInfo.register ? userStore.DeptInfo.register.schoolName : '' }}</div>
<div> <div>
<el-button type="primary" link>更改学校</el-button> <el-button type="primary" link>更改学校</el-button>
</div> </div>