Compare commits

...

16 Commits

Author SHA1 Message Date
“zouyf” 2bdac6e2ea Merge branch 'main' into zouyf_dev 2024-12-18 10:31:46 +08:00
baigl 2b5b365e2f Merge pull request 'baigl' (#147) from baigl into main
Reviewed-on: #147
2024-12-18 09:54:29 +08:00
白了个白 90ac7a49c7 1 2024-12-18 09:53:39 +08:00
白了个白 75ddbf6f26 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into baigl 2024-12-18 09:52:08 +08:00
白了个白 de9235751f 作业管理:习题上传后,返回进入 个人题库界面 2024-12-18 09:51:44 +08:00
zhengdegang c33c0d923e Merge pull request 'zdg_dev' (#146) from zdg_dev into main
Reviewed-on: #146
2024-12-17 17:36:33 +08:00
zdg 94fa1a2457 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-17 17:35:57 +08:00
zdg abce344d42 ppt 动画 2024-12-17 17:35:48 +08:00
zdg 0d38a12094 ppt 2024-12-17 17:34:47 +08:00
白了个白 dfd53637be 作业管理:习题上传页面加上返回 2024-12-17 17:20:53 +08:00
白了个白 c01a29bf3f 习题上传:扫描识别url修改 2024-12-17 17:20:30 +08:00
zhangxuelin 436bdfe7c8 Merge pull request 'zxl' (#145) from zxl into main
Reviewed-on: #145
2024-12-17 10:28:58 +08:00
zhangxuelin 2d0be935bf Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zxl 2024-12-17 10:26:51 +08:00
zhangxuelin d6dfe966c0 pptist 比例修改 2024-12-17 10:26:41 +08:00
zdg cf7f985020 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev 2024-12-16 17:49:09 +08:00
zdg 5d6c946e08 更新 2024-12-16 17:49:04 +08:00
16 changed files with 304 additions and 150 deletions

View File

@ -0,0 +1,24 @@
/**
*
*/
import ChatWs from '@/plugins/socket' // 聊天socket
import { sessionStore } from '@/utils/store' // electron-store 状态管理
import * as API_classcourse from '@/api/teaching/classcourse' // 后端api
export default () => {
const classcourse = sessionStore.get('curr.classcourse') // 课堂信息
const timgroupid = classcourse?.timgroupid // 群组id
if (!ChatWs.ws) ChatWs.init()
// 下课消息
const exitCourse = async() => {
if(!timgroupid) throw new Error('未获取到群组ID')
await API_classcourse.updateClasscourse({ id: classcourse.id, status: 'closed' })
return ChatWs.closedCourse(timgroupid)
}
return {
exitCourse,
classcourse,
groupid: timgroupid,
}
}

View File

@ -7,13 +7,13 @@ import { sessionStore } from '@/utils/store' // electron-store 状态管理
import * as useStore from '../store' // pptist-状态管理 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' // 消息工具
import useExecPlay from '../views/Screen/hooks/useExecPlay' // 播放控制 import emitter from '@/utils/mitt' //mitt 事件总线
import { nextTick } from 'vue'
const slidesStore = useStore.useSlidesStore() // 幻灯片-状态管理 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') // 课堂信息
const execPlay = useExecPlay() // 播放控制
export class Classcourse { export class Classcourse {
msgObj:ElMessageBox = null // 提示消息对象 msgObj:ElMessageBox = null // 提示消息对象
@ -23,10 +23,12 @@ export class Classcourse {
constructor() { constructor() {
this.load() this.load()
} }
// 延时
sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
/** /**
* @description * @description
*/ */
load() { async load() {
console.log('classcourse-load', classcourse) console.log('classcourse-load', classcourse)
// 打开全屏 // 打开全屏
const isCourse = !!classcourse const isCourse = !!classcourse
@ -39,13 +41,19 @@ export class Classcourse {
this.classcourse = classcourse // 课堂信息 this.classcourse = classcourse // 课堂信息
this.id = classcourse.id // 课堂id this.id = classcourse.id // 课堂id
// 如果课堂信息有paging则更新当前页码 // 如果课堂信息有paging则更新当前页码
const isPaging = !!classcourse.paging const { paging } = classcourse
if (isPaging) slidesStore.updateSlideIndex(classcourse.paging) const isPaging = !!paging || paging === 0
if (isPaging) {
await this.sleep(200)
emitter.emit('useExecPlay', {key:'turnSlideToIndex', paging})
await this.sleep(1000)
// 如果课堂信息有paging则更新动画播放状态 // 如果课堂信息有paging则更新动画播放状态
const isAnim = !!classcourse.cartoonTimes const isAnim = !!classcourse.cartoonTimes
if (isAnim) { // 动画播放 if (isAnim) { // 动画播放
for (let i = 0; i <= classcourse.cartoonTimes; i++) { for (let i = 0; i < classcourse.cartoonTimes; i++) {
execPlay.runAnimation(true) // 异步执行动画 // 异步执行动画
emitter.emit('useExecPlay', {key:'execNext', isAsync:true})
}
} }
} }
// 课堂信息-状态管理 // 课堂信息-状态管理

View File

@ -258,6 +258,7 @@ export class PPTApi {
} }
export class Homework{ export class Homework{
static win: null // 作业弹窗
// 作业弹窗 // 作业弹窗
static async showHomework(id: any) { static async showHomework(id: any) {
let result = await getClassWorkList(id) let result = await getClassWorkList(id)
@ -265,7 +266,14 @@ export class Homework{
  localStorage.setItem('teachClassWorkItem', JSON.stringify(result[0]));   localStorage.setItem('teachClassWorkItem', JSON.stringify(result[0]));
  toolStore.isTaskWin=true; // 设置打开批改窗口   toolStore.isTaskWin=true; // 设置打开批改窗口
//   emit('closeActive') //   emit('closeActive')
  createWindow('open-taskwin',{url:'/teachClassTask'}); // 重复打开,先关闭弹窗
// if (this.win) this.win?.close?.()
this.win = await createWindow('open-taskwin',{url:'/teachClassTask'})
 return this.win;
}
static closeHomework() {
if (this.win) this.win?.close?.()
this.win = null
} }
} }
export default PPTApi export default PPTApi

View File

@ -23,7 +23,6 @@ export default () => {
const resource = sessionStore.get('curr.resource') // apt 资源 const resource = sessionStore.get('curr.resource') // apt 资源
const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源 const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源
const execPlay = useExecPlay() // 播放控制 const execPlay = useExecPlay() // 播放控制
// 监听幻灯片内容变化 // 监听幻灯片内容变化
watch(() => slidesStore.slides, (newVal, oldVal) => { watch(() => slidesStore.slides, (newVal, oldVal) => {
PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容 PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容
@ -37,7 +36,15 @@ export default () => {
// 监听幻灯片下标变化 // 监听幻灯片下标变化
watch(() => slidesStore.slideIndex, (newVal, oldVal) => { watch(() => slidesStore.slideIndex, (newVal, oldVal) => {
PPTApi.updateWorkList() if (!!Classcourse.id) return // 上课状态,不更新右侧作业列表
PPTApi.updateWorkList() // 更新作业列表
})
// 监听幻灯片下画布尺寸比例变化
watch(() => slidesStore.viewportRatio, (newVal, oldVal) => {
const width = slidesStore.viewportSize
const widthandration={width, ratio:newVal}
const data = { id: resource.id, parentContent: JSON.stringify(widthandration)}
PPTApi.updateSlide(data)
}) })
// 消息监听ws // 消息监听ws
@ -91,7 +98,8 @@ export default () => {
case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页 case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页
const slideIndex = content?.current || 0 const slideIndex = content?.current || 0
const type = content?.animation const type = content?.animation
if (type === 'Nextsteps') emitter.emit('useExecPlay', 'execNext') // 下一步 // if (type === 'Nextsteps') emitter.emit('useExecPlay', 'execNext') // 下一步
if (type === 'Nextsteps') emitter.emit('useExecPlay', {key:'execNext', isAsync:true}) // 下一步
else if (type === 'Previoustep') emitter.emit('useExecPlay', 'turnPrevSlide') // 上一步清空-动画 else if (type === 'Previoustep') emitter.emit('useExecPlay', 'turnPrevSlide') // 上一步清空-动画
else slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标 else slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标
break break

View File

@ -52,6 +52,7 @@
<IconOffScreenOne class="tool-btn" v-tooltip="'退出全屏'" v-if="fullscreenState" @click="manualExitFullscreen()" /> <IconOffScreenOne class="tool-btn" v-tooltip="'退出全屏'" v-if="fullscreenState" @click="manualExitFullscreen()" />
<IconFullScreenOne class="tool-btn" v-tooltip="'进入全屏'" v-else @click="enterFullscreen()" /> <IconFullScreenOne class="tool-btn" v-tooltip="'进入全屏'" v-else @click="enterFullscreen()" />
<IconPower class="tool-btn" v-tooltip="'结束放映'" @click="exitScreening()" /> <IconPower class="tool-btn" v-tooltip="'结束放映'" @click="exitScreening()" />
<IconPower class="tool-btn close" v-if="chat.groupid" v-tooltip="'结束课堂'" @click="exitCourse()" />
</div> </div>
</div> </div>
</div> </div>
@ -60,7 +61,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref , watchEffect} from 'vue' import { ref , watchEffect} from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useSlidesStore ,useScreenStore} from '../../store' import { useSlidesStore ,useScreenStore, useClasscourseStore} from '../../store'
import type { ContextmenuItem } from '../../components/Contextmenu/types' import type { ContextmenuItem } from '../../components/Contextmenu/types'
import { enterFullscreen } from '../../utils/fullscreen' import { enterFullscreen } from '../../utils/fullscreen'
import useScreening from '../../hooks/useScreening' import useScreening from '../../hooks/useScreening'
@ -74,12 +75,16 @@ import WritingBoardTool from './WritingBoardTool.vue'
import CountdownTimer from './CountdownTimer.vue' import CountdownTimer from './CountdownTimer.vue'
import upvoteVue from '@/views/tool/components/upvote.vue' // - import upvoteVue from '@/views/tool/components/upvote.vue' // -
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt';
import Chat from '../../api/chat' //
// import * as emits from './hooks/emitter'
// emits.init() //
const props = defineProps<{ const props = defineProps<{
changeViewMode: (mode: 'base' | 'presenter') => void changeViewMode: (mode: 'base' | 'presenter') => void
}>() }>()
const { slides, slideIndex } = storeToRefs(useSlidesStore()) const { slides, slideIndex } = storeToRefs(useSlidesStore())
const { classcourse } = storeToRefs(useClasscourseStore()) //
const { const {
autoPlayTimer, autoPlayTimer,
@ -100,9 +105,30 @@ const {
execNext, execNext,
animationIndex, animationIndex,
} = useExecPlay() } = useExecPlay()
// zdg: 使
const execPlay = {
autoPlayTimer,
autoPlay,
closeAutoPlay,
autoPlayInterval,
setAutoPlayInterval,
loopPlay,
setLoopPlay,
mousewheelListener,
touchStartListener,
touchEndListener,
turnPrevSlide,
turnNextSlide,
turnSlideToIndex,
turnSlideToId,
execPrev,
execNext,
animationIndex,
}
const { slideWidth, slideHeight } = useSlideSize() const { slideWidth, slideHeight } = useSlideSize()
const { exitScreening } = useScreening() const { exitScreening } = useScreening()
const { fullscreenState, manualExitFullscreen } = useFullscreen() const { fullscreenState, manualExitFullscreen } = useFullscreen()
const chat:any = Chat() //
const rightToolsVisible = ref(false) const rightToolsVisible = ref(false)
const writingBoardToolVisible = ref(false) const writingBoardToolVisible = ref(false)
@ -192,43 +218,33 @@ const contextmenus = (): ContextmenuItem[] => {
}, },
] ]
} }
//
const exitCourse = async () => {
// console.log('', chat)
await chat.exitCourse() //
exitScreening() //
}
// 1 2 // 1 2
emitter.on('upvoteTrigger', (type) => { emitter.on('upvoteTrigger', (type) => {
upvoteRef.value?.trigger(type) upvoteRef.value?.trigger(type)
}); });
// zdg: 使
const execPlay = { //
autoPlayTimer,
autoPlay,
closeAutoPlay,
autoPlayInterval,
setAutoPlayInterval,
loopPlay,
setLoopPlay,
mousewheelListener,
touchStartListener,
touchEndListener,
turnPrevSlide,
turnNextSlide,
turnSlideToIndex,
turnSlideToId,
execPrev,
execNext,
animationIndex,
}
emitter.on('useExecPlay', (data: string|any) => { emitter.on('useExecPlay', (data: string|any) => {
console.log('useExecPlay', data)
if (!data) throw new Error('参数错误') if (!data) throw new Error('参数错误')
if (typeof data === 'string') { // if (typeof data === 'string') { //
if (execPlay[data]) execPlay[data]() if (execPlay[data]) execPlay[data]()
else throw new Error('方法不存在') else throw new Error('方法不存在')
} else { // } else { //
const { method, ...params } = data || {} const { key, ...params } = data || {}
if (execPlay[method]) execPlay[method](...params) const paramsArray = Object.values(params)
if (execPlay[key]) execPlay[key](...paramsArray)
else throw new Error('方法不存在') else throw new Error('方法不存在')
} }
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -309,6 +325,9 @@ emitter.on('useExecPlay', (data: string|any) => {
& + .tool-btn { & + .tool-btn {
margin-left: 15px; margin-left: 15px;
} }
&.close{
color: #d14424;
}
} }
.page-number { .page-number {
font-size: 13px; font-size: 13px;

View File

@ -12,6 +12,7 @@
</div> </div>
<Divider class="divider" /> <Divider class="divider" />
<div class="tool-btn" @click="exitScreening()"><IconPower class="tool-icon" /><span>结束放映</span></div> <div class="tool-btn" @click="exitScreening()"><IconPower class="tool-icon" /><span>结束放映</span></div>
<div class="tool-btn close" @click="exitCourse()" v-if="chat.groupid"><IconPower class="tool-icon" /><span>结束课堂</span></div>
</div> </div>
<div class="content"> <div class="content">
@ -55,7 +56,7 @@
:class="{ 'active': index === slideIndex }" :class="{ 'active': index === slideIndex }"
v-for="(slide, index) in slides" v-for="(slide, index) in slides"
:key="slide.id" :key="slide.id"
@click="turnSlideToIndex(index)" @click="turnSlideTo(index, $event)"
> >
<ThumbnailSlide :slide="slide" :size="120 / viewportRatio" :visible="index < slidesLoadLimit" /> <ThumbnailSlide :slide="slide" :size="120 / viewportRatio" :visible="index < slidesLoadLimit" />
</div> </div>
@ -79,7 +80,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, nextTick, ref, watch } from 'vue' import { computed, nextTick, ref, watch } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useSlidesStore } from '../../store' import { useSlidesStore, useClasscourseStore } from '../../store'
import type { ContextmenuItem } from '../../components/Contextmenu/types' import type { ContextmenuItem } from '../../components/Contextmenu/types'
import { enterFullscreen } from '../../utils/fullscreen' import { enterFullscreen } from '../../utils/fullscreen'
import { parseText2Paragraphs } from '../../utils/textParser' import { parseText2Paragraphs } from '../../utils/textParser'
@ -94,12 +95,14 @@ import ScreenSlideList from './ScreenSlideList.vue'
import WritingBoardTool from './WritingBoardTool.vue' import WritingBoardTool from './WritingBoardTool.vue'
import CountdownTimer from './CountdownTimer.vue' import CountdownTimer from './CountdownTimer.vue'
import Divider from '../../components/Divider.vue' import Divider from '../../components/Divider.vue'
import Chat from '../../api/chat' //
const props = defineProps<{ const props = defineProps<{
changeViewMode: (mode: 'base' | 'presenter') => void changeViewMode: (mode: 'base' | 'presenter') => void
}>() }>()
const { slides, slideIndex, viewportRatio, currentSlide } = storeToRefs(useSlidesStore()) const { slides, slideIndex, viewportRatio, currentSlide } = storeToRefs(useSlidesStore())
const { classcourse } = storeToRefs(useClasscourseStore()) //
const slideListWrapRef = ref<HTMLElement>() const slideListWrapRef = ref<HTMLElement>()
const thumbnailsRef = ref<HTMLElement>() const thumbnailsRef = ref<HTMLElement>()
@ -122,12 +125,27 @@ const { slideWidth, slideHeight } = useSlideSize(slideListWrapRef)
const { exitScreening } = useScreening() const { exitScreening } = useScreening()
const { slidesLoadLimit } = useLoadSlides() const { slidesLoadLimit } = useLoadSlides()
const { fullscreenState, manualExitFullscreen } = useFullscreen() const { fullscreenState, manualExitFullscreen } = useFullscreen()
const chat:any = Chat() //
const remarkFontSize = ref(16) const remarkFontSize = ref(16)
const currentSlideRemark = computed(() => { const currentSlideRemark = computed(() => {
return parseText2Paragraphs(currentSlide.value.remark || '无备注') return parseText2Paragraphs(currentSlide.value.remark || '无备注')
}) })
//
const turnSlideTo = (index: number, e: PointerEvent) => {
//
console.log('课堂信息', classcourse, index)
if (!!classcourse.value) return
turnSlideToIndex(index)
}
//
const exitCourse = async () => {
// console.log('', chat)
await chat.exitCourse() //
exitScreening() //
}
const handleMousewheelThumbnails = (e: WheelEvent) => { const handleMousewheelThumbnails = (e: WheelEvent) => {
if (!thumbnailsRef.value) return if (!thumbnailsRef.value) return
thumbnailsRef.value.scrollBy(e.deltaY, 0) thumbnailsRef.value.scrollBy(e.deltaY, 0)
@ -208,7 +226,7 @@ const contextmenus = (): ContextmenuItem[] => {
background-color: #fff; background-color: #fff;
border-right: solid 1px #eee; border-right: solid 1px #eee;
font-size: 12px; font-size: 12px;
margin: 20px 0; padding: 20px 0;
.tool-btn { .tool-btn {
display: flex; display: flex;
@ -224,6 +242,9 @@ const contextmenus = (): ContextmenuItem[] => {
&:hover, &.active { &:hover, &.active {
color: $themeColor; color: $themeColor;
} }
&.close{
color: #d14424;
}
} }
.divider { .divider {

View File

@ -1,13 +1,14 @@
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import { throttle } from 'lodash' import { throttle } from 'lodash'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useSlidesStore } from '../../../store' import { useSlidesStore, useClasscourseStore } from '../../../store'
import { KEYS } from '../../../configs/hotkey' import { KEYS } from '../../../configs/hotkey'
import { ANIMATION_CLASS_PREFIX } from '../../../configs/animation' import { ANIMATION_CLASS_PREFIX } from '../../../configs/animation'
import message from '../../../utils/message' import message from '../../../utils/message'
export default () => { export default () => {
const slidesStore = useSlidesStore() const slidesStore = useSlidesStore()
const classcourseStore = useClasscourseStore() // 课堂信息-状态管理
const { slides, slideIndex, formatedAnimations } = storeToRefs(slidesStore) const { slides, slideIndex, formatedAnimations } = storeToRefs(slidesStore)
// 当前页的元素动画执行到的位置 // 当前页的元素动画执行到的位置
@ -121,9 +122,9 @@ export default () => {
// 遇到元素动画时,优先执行动画播放,无动画则执行翻页 // 遇到元素动画时,优先执行动画播放,无动画则执行翻页
// 向上播放遇到动画时,仅撤销到动画执行前的状态,不需要反向播放动画 // 向上播放遇到动画时,仅撤销到动画执行前的状态,不需要反向播放动画
// 撤回到上一页时,若该页从未播放过(意味着不存在动画状态),需要将动画索引置为最小值(初始状态),否则置为最大值(最终状态) // 撤回到上一页时,若该页从未播放过(意味着不存在动画状态),需要将动画索引置为最小值(初始状态),否则置为最大值(最终状态)
const execPrev = () => { const execPrev = (isAsync: boolean) => {
if (formatedAnimations.value.length && animationIndex.value > 0) { if (formatedAnimations.value.length && animationIndex.value > 0) {
revokeAnimation() revokeAnimation(isAsync)
} }
else if (slideIndex.value > 0) { else if (slideIndex.value > 0) {
slidesStore.updateSlideIndex(slideIndex.value - 1) slidesStore.updateSlideIndex(slideIndex.value - 1)
@ -139,9 +140,10 @@ export default () => {
} }
inAnimation.value = false inAnimation.value = false
} }
const execNext = () => { const execNext = (isAsync: boolean) => {
console.log('execNext', isAsync)
if (formatedAnimations.value.length && animationIndex.value < formatedAnimations.value.length) { if (formatedAnimations.value.length && animationIndex.value < formatedAnimations.value.length) {
runAnimation() runAnimation(isAsync)
} }
else if (slideIndex.value < slides.value.length - 1) { else if (slideIndex.value < slides.value.length - 1) {
slidesStore.updateSlideIndex(slideIndex.value + 1) slidesStore.updateSlideIndex(slideIndex.value + 1)
@ -173,7 +175,13 @@ export default () => {
} }
// 鼠标滚动翻页 // 鼠标滚动翻页
const mousewheelListener = throttle(function(e: WheelEvent) { const mousewheelListener = (e: WheelEvent) => {
// console.log('mousewheel', e)
// 课堂信息存在时,不允许翻页
if (!!classcourseStore.classcourse) e.preventDefault()
mousewheelListenerThrottle(e)
}
const mousewheelListenerThrottle = throttle(function(e: WheelEvent) {
if (e.deltaY < 0) turning(e, 'prev') if (e.deltaY < 0) turning(e, 'prev')
else if (e.deltaY > 0) turning(e, 'next') else if (e.deltaY > 0) turning(e, 'next')
}, 500, { leading: true, trailing: false }) }, 500, { leading: true, trailing: false })
@ -203,6 +211,8 @@ export default () => {
// 向上翻页/向下翻页 // 向上翻页/向下翻页
const turning = (e, type) => { const turning = (e, type) => {
e.preventDefault() // 阻止默认事件 e.preventDefault() // 阻止默认事件
// 课堂信息存在时,不允许翻页
if (!!classcourseStore.classcourse) return
if (type === 'prev') execPrev() if (type === 'prev') execPrev()
else if (type === 'next') execNext() else if (type === 'next') execNext()
} }

View File

@ -167,9 +167,6 @@ export class ChatWs {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.sendMsg('closed', '下课', null, 'group', id) this.sendMsg('closed', '下课', null, 'group', id)
resolve() resolve()
// setTimeout(() => {
// this.close() // 关闭链接
// }, 1000);
}) })
} }
// 延时 ms 毫秒 // 延时 ms 毫秒

View File

@ -83,7 +83,7 @@ export const constantRoutes = [
path: 'questionUpload', path: 'questionUpload',
component: () => import('@/views/classTask/newClassTaskAssign/questionUpload/index.vue'), component: () => import('@/views/classTask/newClassTaskAssign/questionUpload/index.vue'),
name: 'questionUpload', name: 'questionUpload',
meta: { title: '习题上传' } meta: { title: '习题上传', showBread: true }
}, },
{ {
path: 'aiKolors', path: 'aiKolors',

View File

@ -5,6 +5,7 @@ import { JYApiListCT, JYApiListOriginYear, JYApiListSO} from "@/utils/examQuesti
const useClassTaskStore = defineStore('classTask',{ const useClassTaskStore = defineStore('classTask',{
state: () => ({ state: () => ({
isOpenQuestUploadView: false, // 是否打开习题上传的页面
classListIds: [], classListIds: [],
entpCourseWorkTypeList: [ entpCourseWorkTypeList: [
{value: 0, label: "不限"}, {value: 0, label: "不限"},

View File

@ -225,7 +225,7 @@ export const createWindow = async (type, data) => {
.filter(k => typeof data[k] === 'function') .filter(k => typeof data[k] === 'function')
.forEach(k => events[k] = data[k]) .forEach(k => events[k] = data[k])
eventHandles(type, win, events) // 事件监听处理 eventHandles(type, win, events) // 事件监听处理
break return win
} }
default: default:
break break

View File

@ -23,7 +23,8 @@
</div> </div>
<div class="class-reserv-item-tool" style="width: 50px;"> <div class="class-reserv-item-tool" style="width: 50px;">
<!-- <el-button v-if="item.status!='open'" size="small" type="danger" @click="deleteReserv">删除</el-button>--> <!-- <el-button v-if="item.status!='open'" size="small" type="danger" @click="deleteReserv">删除</el-button>-->
<el-tag>APT</el-tag> <!-- <el-tag>APT</el-tag> -->
<el-tag>AIPPT</el-tag>
</div> </div>
<div style="min-width: 150px;"><span> 浏览25955 点赞26605</span></div> <div style="min-width: 150px;"><span> 浏览25955 点赞26605</span></div>
</div> </div>
@ -85,6 +86,7 @@ const chatSend = () => {
<style scoped lang="scss"> <style scoped lang="scss">
.class-reserv-item { .class-reserv-item {
display: flex; display: flex;
align-items: center;
background-color: white; background-color: white;
border-radius: 10px; border-radius: 10px;
padding: 5px; padding: 5px;
@ -110,7 +112,7 @@ const chatSend = () => {
} }
} }
.class-reserv-item-tool { .class-reserv-item-tool {
margin-left: 15px; margin: 0 7px;
display: flex; display: flex;
align-items: center; align-items: center;
} }

View File

@ -149,10 +149,14 @@ import { useGetHomework } from '@/hooks/useGetHomework'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import useClassTaskStore from '@/store/modules/classTask'
const userStore = useUserStore().user const userStore = useUserStore().user
const route = useRoute(); const route = useRoute();
const router = useRouter() const router = useRouter()
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const useClassTaskStores = useClassTaskStore();
const props = defineProps({ const props = defineProps({
currentCourse: Object, currentCourse: Object,
}) })
@ -189,6 +193,7 @@ const boardLoading = ref(false);
const fileLoading = ref(false); // loading const fileLoading = ref(false); // loading
onMounted(() => { onMounted(() => {
console.log("----onMounted-------")
currentRow.value = {id:0}; currentRow.value = {id:0};
if(propsQueryCourseObj){ if(propsQueryCourseObj){
if(JSON.parse(propsQueryCourseObj)){ if(JSON.parse(propsQueryCourseObj)){
@ -216,7 +221,28 @@ onMounted(() => {
} }
} }
initHomeWork(); initHomeWork();
isInToMyQuestion(); //
}) })
//
const isInToMyQuestion = () => {
console.log('isOpenQuestUploadView',useClassTaskStores.isOpenQuestUploadView);
if(useClassTaskStores.isOpenQuestUploadView){
useClassTaskStores.isOpenQuestUploadView = false;
currentRow.value = {id:1}; //
activeAptTab.value = "个人题库";
//
classWorkForm.id = 0;
classWorkForm.uniquekey = ""; //
classWorkForm.worktype = "习题训练"; //
classWorkForm.title = ""; //
classWorkForm.quizlist = []; //
classWorkForm.chooseWorkLists = []; // list
classWorkForm.fileHomeworkList = []; //
classWorkForm.whiteboardObj = ""; // -
classWorkForm.question = ""; // -
}
}
watch(() => props.currentCourse, (newVal, oldVal) => { watch(() => props.currentCourse, (newVal, oldVal) => {
if(newVal){ if(newVal){
courseObj.textbookId = newVal.textbookId // courseObj.textbookId = newVal.textbookId //

View File

@ -74,7 +74,7 @@
<script setup> <script setup>
import "vue-cropper/dist/index.css"; import "vue-cropper/dist/index.css";
import { VueCropper } from "vue-cropper"; import { VueCropper } from "vue-cropper";
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue' import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
@ -88,6 +88,8 @@ import { useRouter, useRoute } from 'vue-router'
import { ocrImg2ExamByManualUpl, ocrImg2ItemByManualUpl } from "@/views/classTask/newClassTaskAssign/questionUpload/ocrImg2ExamQues"; import { ocrImg2ExamByManualUpl, ocrImg2ItemByManualUpl } from "@/views/classTask/newClassTaskAssign/questionUpload/ocrImg2ExamQues";
import QuesItem from "@/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue"; import QuesItem from "@/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue";
import useClassTaskStore from '@/store/modules/classTask'
// const Remote = require('@electron/remote') // const Remote = require('@electron/remote')
// const fs = require('fs'); // const fs = require('fs');
@ -96,7 +98,9 @@ import useUserStore from '@/store/modules/user'
const userStore = useUserStore().user const userStore = useUserStore().user
const route = useRoute(); const route = useRoute();
const router = useRouter() const router = useRouter()
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance();
const useClassTaskStores = useClassTaskStore();
const props = defineProps({ const props = defineProps({
}) })
@ -151,6 +155,7 @@ const cropOption = reactive({
onMounted(() => { onMounted(() => {
useClassTaskStores.isOpenQuestUploadView = true; //
console.log('propsQueryCourseObj', JSON.parse(propsQueryCourseObj)); console.log('propsQueryCourseObj', JSON.parse(propsQueryCourseObj));
if(propsQueryCourseObj&&JSON.parse(propsQueryCourseObj)){ if(propsQueryCourseObj&&JSON.parse(propsQueryCourseObj)){
courseObj.textbookId = JSON.parse(propsQueryCourseObj).bookObj // courseObj.textbookId = JSON.parse(propsQueryCourseObj).bookObj //
@ -161,7 +166,13 @@ onMounted(() => {
} }
initHomeWork(); initHomeWork();
}) })
onUnmounted(()=>{
// 1s isOpenQuestUploadView
setTimeout(()=>{
useClassTaskStores.isOpenQuestUploadView = false; //
console.log('onUnmounted 习题上传');
}, 1000)
})
/** /**
* 获取 entpcourseid 获取作业列表 * 获取 entpcourseid 获取作业列表

View File

@ -1,6 +1,7 @@
import { ElMessageBox, ElMessage } from "element-plus"; import { ElMessageBox, ElMessage } from "element-plus";
import qs from "qs"; import qs from "qs";
import axios from 'axios' import axios from 'axios'
import request from '@/utils/request'
import { pyOCRAPI } from "@/api/education/entpcoursework"; import { pyOCRAPI } from "@/api/education/entpcoursework";
@ -9,13 +10,20 @@ const baidubceConfig = {
// Header // Header
'Content-Type': "application/x-www-form-urlencoded", 'Content-Type': "application/x-www-form-urlencoded",
// 格式 // 格式
'Accept' : 'application/json', 'Accept': 'application/json',
// id(临时测试) // id(临时测试)
'client_id': "U0DrGBE6X92IXgV6cJMNON8F", 'client_id': "U0DrGBE6X92IXgV6cJMNON8F",
// 密钥(临时测试) // 密钥(临时测试)
'client_secret': 'oWb0M0YWMmZPMQIhIUkJX99ddr7h61qf', 'client_secret': 'oWb0M0YWMmZPMQIhIUkJX99ddr7h61qf',
}; };
export function getOcrContent(data) {
return request({
url: '/ocr/exam',
method: 'post',
data: data
})
}
/** /**
@ -35,7 +43,7 @@ export const ocrImg2ItemByManualUpl = async (isLocalTest = false, imgBase64 = ''
// 识别内容拼接 // 识别内容拼接
let ocrTxt = '' let ocrTxt = ''
if(isLocalTest) { if (isLocalTest) {
// 临时本地测试json格式跟百度ocr一致 // 临时本地测试json格式跟百度ocr一致
const response = await fetch('/cropImgTest/single.json'); const response = await fetch('/cropImgTest/single.json');
const resOcr = await response.json(); const resOcr = await response.json();
@ -59,7 +67,7 @@ export const ocrImg2ItemByManualUpl = async (isLocalTest = false, imgBase64 = ''
} }
else { else {
const tmp = await ocrImg2Json(imgBase64); const tmp = await ocrImg2Json(imgBase64);
if(!tmp?.data) { if (!tmp?.data) {
return examItem; return examItem;
} }
ocrJson = tmp.data.results; ocrJson = tmp.data.results;
@ -69,12 +77,12 @@ export const ocrImg2ItemByManualUpl = async (isLocalTest = false, imgBase64 = ''
}); });
} }
if(ocrJson == '') { if (ocrJson == '') {
ElMessage.error('[人工录入-单项]识别的图片为空, 识别失败, 请检查重试!'); ElMessage.error('[人工录入-单项]识别的图片为空, 识别失败, 请检查重试!');
return examItem; return examItem;
} }
if(ocrTxt == '') { if (ocrTxt == '') {
ElMessage.error('[人工录入-单项]识别内容拼接失败, 请检查重试!'); ElMessage.error('[人工录入-单项]识别内容拼接失败, 请检查重试!');
return examItem; return examItem;
} }
@ -96,13 +104,13 @@ export const ocrImg2ItemByManualUpl = async (isLocalTest = false, imgBase64 = ''
worktype: '单选题', worktype: '单选题',
params: [], params: [],
} }
mutiParams.arrWorkDesc.forEach( item => { mutiParams.arrWorkDesc.forEach(item => {
const obj = { const obj = {
title: item.title, title: item.title,
workanswer: '', workanswer: '',
checkAnswer: [], checkAnswer: [],
type: item.type, type: item.type,
options: item.options.map(element => {return {text: element.replace(/<br \/>/g, '')}}), options: item.options.map(element => { return { text: element.replace(/<br \/>/g, '') } }),
} }
examItem.params.push(obj); examItem.params.push(obj);
}); });
@ -114,7 +122,7 @@ export const ocrImg2ItemByManualUpl = async (isLocalTest = false, imgBase64 = ''
// 先判断是否存在选项标识, 且存在2个及以上(A.---1.---(1)---1) // 先判断是否存在选项标识, 且存在2个及以上(A.---1.---(1)---1)
regex = /\s*[A-H][..。]/g; regex = /\s*[A-H][..。]/g;
const matches = ocrTxt.match(regex); const matches = ocrTxt.match(regex);
if (matches==null || matches.length < 2){ if (matches == null || matches.length < 2) {
ElMessage.error('[人工录入-单项]识别[选项]失败, 请检查重试!'); ElMessage.error('[人工录入-单项]识别[选项]失败, 请检查重试!');
return examItem; return examItem;
} }
@ -164,7 +172,7 @@ export const ocrImg2ExamByManualUpl = async (isLocalTest = false, imgBase64 = ''
// 识别内容拼接 // 识别内容拼接
let ocrTxt = ''; let ocrTxt = '';
if(isLocalTest) { if (isLocalTest) {
// 临时本地测试json格式跟百度ocr一致 // 临时本地测试json格式跟百度ocr一致
const response = await fetch('/cropImgTest/single.json'); const response = await fetch('/cropImgTest/single.json');
const resOcr = await response.json(); const resOcr = await response.json();
@ -186,7 +194,7 @@ export const ocrImg2ExamByManualUpl = async (isLocalTest = false, imgBase64 = ''
// }); // });
} else { } else {
const tmp = await ocrImg2Json(imgBase64); const tmp = await ocrImg2Json(imgBase64);
if(!tmp?.data) { if (!tmp?.data) {
return examQues; return examQues;
} }
ocrJson = tmp.data.results; ocrJson = tmp.data.results;
@ -195,20 +203,20 @@ export const ocrImg2ExamByManualUpl = async (isLocalTest = false, imgBase64 = ''
}); });
} }
if(ocrJson == '') { if (ocrJson == '') {
ElMessage.error('[人工录入-整题]图片识别内容为空, 识别失败, 请重试!'); ElMessage.error('[人工录入-整题]图片识别内容为空, 识别失败, 请重试!');
return examQues; return examQues;
} }
if(ocrTxt == '') { if (ocrTxt == '') {
ElMessage.error('[人工录入-整题]识别内容拼接失败, 请重试!'); ElMessage.error('[人工录入-整题]识别内容拼接失败, 请重试!');
return examQues; return examQues;
} }
// 识别内容转为试题结构 // 识别内容转为试题结构
examQues = assembleExam(ocrTxt); examQues = assembleExam(ocrTxt);
if(examQues.err != '') { if (examQues.err != '') {
ElMessage.error(`[人工录入-整题]${examQues.err}, 请重试!`); ElMessage.error(`[人工录入-整题]${examQues.err}, 请重试!`);
examQues = {}; examQues = {};
} }
@ -226,30 +234,36 @@ const ocrImg2Json = async (urlBase64) => {
ElMessage.error("未检测到截图图片, 请截取图片后再识别"); ElMessage.error("未检测到截图图片, 请截取图片后再识别");
return null; return null;
} }
const resToken = await bdyAPI_getToken();
if (resToken.status !== 200) {
ElMessage.error("百度智能云用户标识有误");
return null;
}
const token = resToken.data?.access_token;
let base64Code = urlBase64.split(",")[1]; let base64Code = urlBase64.split(",")[1];
const query = { const resOcr = await getOcrContent({ base64Code: base64Code });
image: base64Code, //图片地址(base64) if (resOcr.code !== 200) {
line_probability: false, //是否返回每行识别结果的置信度。默认为false ElMessage.error("图片识别错误");
disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only手写文字识别 = handprint_mix 手写印刷混排识别
layout_analysis: false, //是否分析文档版面包括layout图、表、标题、段落、目录attribute栏、页眉、页脚、页码、脚注的分析输出
recg_long_division: false, //是否检测并识别手写竖式
recg_formula: true, //控制是否检测并识别公式默认为false
}
const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
if (resOcr.status !== 200) {
ElMessage.error("百度智能云图片识别错误");
return null; return null;
} }
// const resToken = await bdyAPI_getToken();
// if (resToken.status !== 200) {
// ElMessage.error("百度智能云用户标识有误");
// return null;
// }
// const token = resToken.data?.access_token;
// let base64Code = urlBase64.split(",")[1];
// const query = {
// image: base64Code, //图片地址(base64)
// line_probability: false, //是否返回每行识别结果的置信度。默认为false
// disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
// words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only手写文字识别 = handprint_mix 手写印刷混排识别
// layout_analysis: false, //是否分析文档版面包括layout图、表、标题、段落、目录attribute栏、页眉、页脚、页码、脚注的分析输出
// recg_long_division: false, //是否检测并识别手写竖式
// recg_formula: true, //控制是否检测并识别公式默认为false
// }
// const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
// if (resOcr.status !== 200) {
// ElMessage.error("百度智能云图片识别错误");
// return null;
// }
return resOcr; return resOcr;
} }
@ -370,7 +384,7 @@ const assembleExam = (eachSub) => {
if (!hasAnswer) { if (!hasAnswer) {
// 不存在答案, 仅处理[题干+选项] // 不存在答案, 仅处理[题干+选项]
titleAndWorkDesc = eachSub; titleAndWorkDesc = eachSub;
}else { } else {
// 存在答案, 需处理[题干+选项]和[答案+解析] // 存在答案, 需处理[题干+选项]和[答案+解析]
regex = /(<br \/>?\s*[【\[].*?[】\]])/g; regex = /(<br \/>?\s*[【\[].*?[】\]])/g;
let tmpList = eachSub.split(regex); let tmpList = eachSub.split(regex);
@ -386,10 +400,10 @@ const assembleExam = (eachSub) => {
// 第二部分[分析-答案] 处理 // 第二部分[分析-答案] 处理
let answerAndAnswer = {}; let answerAndAnswer = {};
// 将第二部分的内容做key-value绑定 - 键为【分析】、【讨论】、【方法】等. 值为随之分隔的内容 // 将第二部分的内容做key-value绑定 - 键为【分析】、【讨论】、【方法】等. 值为随之分隔的内容
for (let i=1; i<tmpList.length-1; i=i+2){ for (let i = 1; i < tmpList.length - 1; i = i + 2) {
let key = tmpList[i]; let key = tmpList[i];
key = key.replace(/<br \/>|【|】|\[|\]/g, ''); key = key.replace(/<br \/>|【|】|\[|\]/g, '');
let value = tmpList[i+1]; let value = tmpList[i + 1];
value = value.replace(/^<br \/>+|<br \/>+$/g, ''); value = value.replace(/^<br \/>+|<br \/>+$/g, '');
answerAndAnswer[key] = value; answerAndAnswer[key] = value;
} }
@ -430,12 +444,12 @@ const assembleExam = (eachSub) => {
// [答案] - 初步初始化 --- 根据答案判断试题大分类: 复合题(实际为大题) 或 其他基础题型(单选,多选,填空,判断) // [答案] - 初步初始化 --- 根据答案判断试题大分类: 复合题(实际为大题) 或 其他基础题型(单选,多选,填空,判断)
answer = answerAndAnswer['答案'].trim(); answer = answerAndAnswer['答案'].trim();
if(!answer) { if (!answer) {
answer = answerAndAnswer['答案及评分参考'].trim(); answer = answerAndAnswer['答案及评分参考'].trim();
answer = answer.replace(/^\d+[\u4e00-\u9fa5][..。]\s*<br \/>/, ''); // 去掉 - 有些开头会有[xx分。] answer = answer.replace(/^\d+[\u4e00-\u9fa5][..。]\s*<br \/>/, ''); // 去掉 - 有些开头会有[xx分。]
} }
// 将多余的空格替换为固定的4个空格 // 将多余的空格替换为固定的4个空格
answer = answer.replaceAll("\\s{3,}"," "); answer = answer.replaceAll("\\s{3,}", " ");
if (answer == null | answer == '') { if (answer == null | answer == '') {
subObj.err = '题目缺少[答案]'; subObj.err = '题目缺少[答案]';
return subObj; return subObj;
@ -455,7 +469,7 @@ const assembleExam = (eachSub) => {
let answerFind = regex.test(answer); let answerFind = regex.test(answer);
regex = /(\d+[..。]|\(\d+\)|\d+)/; regex = /(\d+[..。]|\(\d+\)|\d+)/;
let titleFind = regex.test(titleAndWorkDesc); let titleFind = regex.test(titleAndWorkDesc);
if(titleFind && answerFind){ if (titleFind && answerFind) {
/** /**
* [复合题] - 处理逻辑 * [复合题] - 处理逻辑
*/ */
@ -471,7 +485,7 @@ const assembleExam = (eachSub) => {
if (tmpExam) { if (tmpExam) {
// 错误信息 // 错误信息
if(tmpExam.errMsg !== '') { if (tmpExam.errMsg !== '') {
subObj.err = tmpExam.err; subObj.err = tmpExam.err;
return subObj; return subObj;
} }
@ -508,7 +522,7 @@ const processExamSingle = function (titleAndWorkDesc, answer) {
let matcher = null; let matcher = null;
/** [判断题]的处理逻辑, resp: -1-未找到 0-*为对应匹配的index */ /** [判断题]的处理逻辑, resp: -1-未找到 0-*为对应匹配的index */
let judgedStatus = answer!=='' ? containsExactMatch(answer) : -1; let judgedStatus = answer !== '' ? containsExactMatch(answer) : -1;
/** 其他基础题型(单选,多选,填空,判断)的处理逻辑 */ /** 其他基础题型(单选,多选,填空,判断)的处理逻辑 */
// 先去掉开头的试题序号 // 先去掉开头的试题序号
@ -524,7 +538,7 @@ const processExamSingle = function (titleAndWorkDesc, answer) {
answer = answer.replace("<br />", "").trim(); answer = answer.replace("<br />", "").trim();
// [题型] - 格式化 - 根据答案字符个数区分[单选]或[多选] // [题型] - 格式化 - 根据答案字符个数区分[单选]或[多选]
examSingle.workType = answer==='' ? '单选题' : answer.length == 1 ? "单选题" : "多选题"; examSingle.workType = answer === '' ? '单选题' : answer.length == 1 ? "单选题" : "多选题";
// 切分题干+选项 // 切分题干+选项
regex = /<br \/>*\s*[A-H][..。]/g; regex = /<br \/>*\s*[A-H][..。]/g;
@ -570,7 +584,7 @@ const processExamSingle = function (titleAndWorkDesc, answer) {
examSingle.arrWorkAnswer = answer.split(" "); examSingle.arrWorkAnswer = answer.split(" ");
} }
} }
else if( judgedStatus != -1 ) { else if (judgedStatus != -1) {
/** /**
* 判断题 * 判断题
*/ */
@ -635,12 +649,12 @@ const processExamMulti = function (titleAndWorkDesc, answer) {
// 先确定当前是以什么形式的小题序号来切分 --- 需要全部独立判断, 避免出现复合题中, 每小题内还包含小题的情况--- 1.回答以下问题 (1)***** (2)****** // 先确定当前是以什么形式的小题序号来切分 --- 需要全部独立判断, 避免出现复合题中, 每小题内还包含小题的情况--- 1.回答以下问题 (1)***** (2)******
let cliceSucc = false; let cliceSucc = false;
let arrAnswer = [] let arrAnswer = []
if(!cliceSucc){ if (!cliceSucc) {
regex = /<br \/>\s*\d+[..。]\s*/; regex = /<br \/>\s*\d+[..。]\s*/;
if (regex.test(titleAndWorkDesc)) { if (regex.test(titleAndWorkDesc)) {
// 再次以答案中的序号同步匹配一次 // 再次以答案中的序号同步匹配一次
regex = /^\s*\d+[..。]\s*/; regex = /^\s*\d+[..。]\s*/;
if(answer === '' || regex.test(answer)){ if (answer === '' || regex.test(answer)) {
regex = /<br \/>\s*\d+[..。]\s*/g; regex = /<br \/>\s*\d+[..。]\s*/g;
tmpSplit = titleAndWorkDesc.split(regex); tmpSplit = titleAndWorkDesc.split(regex);
if (answer !== '') { if (answer !== '') {
@ -653,12 +667,12 @@ const processExamMulti = function (titleAndWorkDesc, answer) {
} }
} }
} }
if (!cliceSucc){ if (!cliceSucc) {
regex = /<br \/>\s*\d+\s*/; regex = /<br \/>\s*\d+\s*/;
if (regex.test(titleAndWorkDesc)) { if (regex.test(titleAndWorkDesc)) {
// 再次以答案中的序号同步匹配一次 // 再次以答案中的序号同步匹配一次
regex = /\s*\d+\s*/; regex = /\s*\d+\s*/;
if(answer === '' || regex.test(answer)){ if (answer === '' || regex.test(answer)) {
regex = /<br \/>\s*\d+\s*/g; regex = /<br \/>\s*\d+\s*/g;
tmpSplit = titleAndWorkDesc.split(regex); tmpSplit = titleAndWorkDesc.split(regex);
if (answer !== '') { if (answer !== '') {
@ -671,12 +685,12 @@ const processExamMulti = function (titleAndWorkDesc, answer) {
} }
} }
} }
if (!cliceSucc){ if (!cliceSucc) {
regex = /<br \/>\s*\(\d+\)\s*/; regex = /<br \/>\s*\(\d+\)\s*/;
if (regex.test(titleAndWorkDesc)) { if (regex.test(titleAndWorkDesc)) {
// 再次以答案中的序号同步匹配一次 // 再次以答案中的序号同步匹配一次
regex = /^\s*\(\d+\)\s*/; regex = /^\s*\(\d+\)\s*/;
if(answer === '' || regex.test(answer)){ if (answer === '' || regex.test(answer)) {
regex = /<br \/>\s*\(\d+\)\s*/g; regex = /<br \/>\s*\(\d+\)\s*/g;
tmpSplit = titleAndWorkDesc.split(regex); tmpSplit = titleAndWorkDesc.split(regex);
if (answer !== '') { if (answer !== '') {
@ -689,19 +703,19 @@ const processExamMulti = function (titleAndWorkDesc, answer) {
} }
} }
} }
if (!cliceSucc){ if (!cliceSucc) {
examMulti.errMsg = '[复合题]小题与答案序号[不匹配]'; examMulti.errMsg = '[复合题]小题与答案序号[不匹配]';
return examMulti; return examMulti;
} }
if (tmpSplit.length < 2){ if (tmpSplit.length < 2) {
examMulti.errMsg = '[复合题]题干与小题[切分失败]'; examMulti.errMsg = '[复合题]题干与小题[切分失败]';
return examMulti; return examMulti;
} }
if (answer !== '' && arrAnswer.length < 2){ if (answer !== '' && arrAnswer.length < 2) {
examMulti.errMsg = '[复合题]答案切分小题失败'; examMulti.errMsg = '[复合题]答案切分小题失败';
return examMulti; return examMulti;
} }
if (answer !== '' && tmpSplit.length != arrAnswer.length){ if (answer !== '' && tmpSplit.length != arrAnswer.length) {
examMulti.errMsg = '[复合题]小题个数与答案个数[不一致]'; examMulti.errMsg = '[复合题]小题个数与答案个数[不一致]';
return examMulti; return examMulti;
} }
@ -710,13 +724,13 @@ const processExamMulti = function (titleAndWorkDesc, answer) {
examMulti.title = tmpSplit[0].trim(); examMulti.title = tmpSplit[0].trim();
// [选项]+[答案] - 逻辑处理 // [选项]+[答案] - 逻辑处理
for (let i=1; i<tmpSplit.length; i++){ for (let i = 1; i < tmpSplit.length; i++) {
const tmp = tmpSplit[i].trim(); const tmp = tmpSplit[i].trim();
// 因arrAnswer[0]对应为分隔出来的首位空数组, 故这里也可直接使用i=1作为下标获取答案 // 因arrAnswer[0]对应为分隔出来的首位空数组, 故这里也可直接使用i=1作为下标获取答案
const tmpAnswer = answer === '' ? '' : arrAnswer[i].trim(); const tmpAnswer = answer === '' ? '' : arrAnswer[i].trim();
// 单题处理 // 单题处理
const tmpExam = processExamSingle(tmp, tmpAnswer); const tmpExam = processExamSingle(tmp, tmpAnswer);
if(tmpExam.errMsg !== ''){ if (tmpExam.errMsg !== '') {
examMulti.errMsg = '[复合题]小题解析失败'; examMulti.errMsg = '[复合题]小题解析失败';
return examMulti; return examMulti;
} }

View File

@ -163,8 +163,10 @@ import quizStats from '@/views/classTask/container/quizStats.vue'
import ClassOverview from '@/views/classTask/container/classOverview.vue' import ClassOverview from '@/views/classTask/container/classOverview.vue'
import {sessionStore} from '@/utils/store' import {sessionStore} from '@/utils/store'
// import Chat from '@/utils/chat' // im // import Chat from '@/utils/chat' // im
import { Homework } from '@/AixPPTist/src/api/index'
import MsgEnum from '@/plugins/imChat/msgEnum' // im import MsgEnum from '@/plugins/imChat/msgEnum' // im
import ChatWs from '@/plugins/socket' // socket import ChatWs from '@/plugins/socket' // socket
import { set } from 'lodash'
if (!ChatWs.ws) ChatWs.init() if (!ChatWs.ws) ChatWs.init()
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const emit = defineEmits(['cle-click']) const emit = defineEmits(['cle-click'])
@ -719,14 +721,17 @@ const msgHandle = (msg) => {
const { head, content, ...other } = msg const { head, content, ...other } = msg
switch(head) { switch(head) {
case MsgEnum.HEADS.MSG_closed: // : case MsgEnum.HEADS.MSG_closed: // :
Homework.win = null
window.close() // window.close() //
break break
case MsgEnum.HEADS.MSG_finishHomework: // : case MsgEnum.HEADS.MSG_finishHomework: // :
console.log('更新作业', head, content)
const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
openDialog(data, false); openDialog(data, false);
break break
case MsgEnum.HEADS.MSG_slideFlapping: // case MsgEnum.HEADS.MSG_slideFlapping: //
console.log('切换页面-关闭窗口') console.log('切换页面-关闭窗口')
Homework.win = null
window.close() // window.close() //
break break
// case 'TIMAddRecvNewMsgCallback': // data=[] // case 'TIMAddRecvNewMsgCallback': // data=[]
@ -769,7 +774,7 @@ onMounted(() => {
console.log('socket监听消息') console.log('socket监听消息')
ChatWs.watch((msg, e) => { ChatWs.watch((msg, e) => {
try { try {
msgHandle(JSON.parse(msg)) msgHandle(JSON.parse(msg)?.msg)
} catch (error) { } catch (error) {
console.error('socket 解析异常 ', error, e) console.error('socket 解析异常 ', error, e)
msgHandle(msg) msgHandle(msg)