This commit is contained in:
白了个白 2024-12-26 16:28:06 +08:00
commit bf39850d2f
9 changed files with 119 additions and 34 deletions

View File

@ -97,14 +97,30 @@ export class PPTApi {
})
}
/**
* @description slide
* @param slides
* @param slideAll
* @returns
*/
static async addSlideServer(slides: object[], slideAll: object[]) {
const resource = sessionStore.get('curr.resource')||{}
for(const slide of slides){
slide.id = resource.id // 覆盖默认随机id
await this.addSlide(slide)
}
await this.batchUpdateSlides(slideAll, true) // 批量更新-排序
return PPTApi.getSlideList(resource.id) // 更新幻灯片列表以及活动相关
}
// 新增幻灯片
static addSlide(data: object): Promise<Boolean> {
return new Promise(async (resolve, reject) => {
const enpt = sessionStore.get('curr.entp')||{}
const resource = sessionStore.get('curr.resource')||{}
// const resource = sessionStore.get('curr.resource')||{}
const {id, ...content} = data
const params = {
parentid: resource.id,
parentid: id,
entpid: userStore.user.deptId,
entpcourseid: enpt.id,
ppttype: 'file',
@ -126,7 +142,7 @@ export class PPTApi {
// msgUtils.msgSuccess('新增成功')
this.isUpdate = false // 新增后会触发监听,不再更新数据
resolve(true)
} else msgUtils.msgError('新增失败');resolve(false)
} else msgUtils.msgError('新增失败');reject(false)
})
}
/**
@ -147,22 +163,17 @@ export class PPTApi {
const currInd = toRaw(slidesStore.slideIndex) // 当前页索引-new
const oldInd = oldData.findIndex(o => o.id == currentSlide.id) // 当前页索引-old
const isBatch = oldVal && oldVal.length && currInd != oldInd // 是否批量更新-排序
if (isAdd) { // 新增的幻灯片(id 为非数字,说明是新增的幻灯片)
const bool = await this.addSlide(currentSlide)
bool && await this.batchUpdateSlides(newData, true) // 批量更新-排序
const resource = sessionStore.get('curr.resource')||{}
await PPTApi.getSlideList(resource.id)
} else { // 防抖-更新
if (!this.isUpdate) return this.isUpdate = true // 下次更新数据
if (isBatch) { // 批量更新-排序
this.batchUpdateSlides(newData, true)
} else { // 更新当前页幻灯片
const params = {
id: currentSlide.id,
datacontent: JSON.stringify(currentSlide),
}
Utils.mxThrottle(() => {this.updateSlide(params)}, 200, 2)
if (isAdd) return // 新增-这里不处理 状态管理-处理
// 防抖-更新
if (!this.isUpdate) return this.isUpdate = true // 下次更新数据
if (isBatch) { // 批量更新-排序
this.batchUpdateSlides(newData, true)
} else { // 更新当前页幻灯片
const params = {
id: currentSlide.id,
datacontent: JSON.stringify(currentSlide),
}
Utils.mxThrottle(() => {this.updateSlide(params)}, 200, 2)
}
}
// 更新幻灯片 isThum 是否更新缩略图

View File

@ -130,7 +130,7 @@ export default () => {
case MsgEnum.HEADS.MSG_yh: // 疑惑
hooksUpvote.trigger(2)
break
case MsgEnum.HEADS.MSG_pushSreen_ImgList: // 推图片上屏
case MsgEnum.HEADS.MSG_pushSreen_ImgList: // 推图片上屏
const imgArray = content.ImgList.map((obj) => obj.url);
emitter.emit('opengridPic',{arr:imgArray}) // 打开推图片上屏窗口
break

View File

@ -148,7 +148,8 @@ export const useSlidesStore = defineStore('slides', {
this.workItem = list
},
addSlide(slide: Slide | Slide[]) {
async addSlide(slide: Slide | Slide[]) {
const { PPTApi } = await import('../api/index')
const slides = Array.isArray(slide) ? slide : [slide]
for (const slide of slides) {
if (slide.sectionTag) delete slide.sectionTag
@ -156,6 +157,8 @@ export const useSlidesStore = defineStore('slides', {
const addIndex = this.slideIndex + 1
this.slides.splice(addIndex, 0, ...slides)
this.slideIndex = addIndex
// 添加到服务器
PPTApi.addSlideServer(slides, this.slides)
},
updateSlide(props: Partial<Slide>, slideId?: string) {
const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex

View File

@ -47,8 +47,9 @@
<IconListView class="tool-btn" v-tooltip="'演讲者视图'" @click="changeViewMode('presenter')" />
<IconOffScreenOne class="tool-btn" v-tooltip="'退出全屏'" v-if="fullscreenState" @click="manualExitFullscreen()" />
<IconFullScreenOne class="tool-btn" v-tooltip="'进入全屏'" v-else @click="enterFullscreen()" />
<IconPower class="tool-btn" v-tooltip="'结束放映'" @click="exitScreening()" />
<IconPower class="tool-btn close" v-if="chat.groupid" v-tooltip="'结束课堂'" @click="exitCourse()" />
<IconPower class="tool-btn" v-if="!classcourse" v-tooltip="'结束放映'" @click="exitScreening()" />
<IconPower class="tool-btn" v-else v-tooltip="'结束课堂'" @click="exitCourse()" size="30" fill="#d0021b" strokeLinecap="butt" />
<Share class="tool-btn" v-if="classcourse" v-tooltip="'分享'" @click="ShareCode()" />
</div>
<div :class="['tools-icon',{opacity:iconHide}]" @click.stop="toolTrigger('icon')">
<circle-double-down v-if="rightToolsVisible" theme="outline" size="30" fill="#409EFF"/>
@ -75,7 +76,8 @@ import WritingBoardTool from './WritingBoardTool.vue'
import CountdownTimer from './CountdownTimer.vue'
import emitter from '@/utils/mitt';
import Chat from '../../api/chat' //
import { CircleDoubleDown, CircleDoubleUp } from '@icon-park/vue-next' // icon-park
import { CircleDoubleDown, CircleDoubleUp, Share } from '@icon-park/vue-next' // icon-park
import { ShareCode } from '@/utils/ppt' // ppt
const props = defineProps<{
changeViewMode: (mode: 'base' | 'presenter') => void
@ -198,7 +200,7 @@ const contextmenus = (): ContextmenuItem[] => {
},
]
}
//
const toolTrigger = (type:string) => {
const curT = Date.now()
if (curT - timer.value < 200) return

View File

@ -10,9 +10,10 @@
<IconOffScreenOne class="tool-icon" v-else />
<span>{{ fullscreenState ? '退出全屏' : '全屏' }}</span>
</div>
<div class="tool-btn" @click="ShareCode()"><Share class="tool-icon" /><span>分享</span></div>
<Divider class="divider" />
<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 class="tool-btn" v-if="!classcourse" @click="exitScreening()"><IconPower class="tool-icon" /><span>结束放映</span></div>
<div class="tool-btn" v-else @click="exitCourse()" size="30" fill="#d0021b" strokeLinecap="butt"><IconPower class="tool-icon" /><span>结束课堂</span></div>
</div>
<div class="content">
@ -78,6 +79,7 @@
</template>
<script lang="ts" setup>
import { Share } from '@icon-park/vue-next' // icon-park
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { storeToRefs } from 'pinia'
import { useSlidesStore, useClasscourseStore } from '../../store'
@ -97,6 +99,7 @@ import CountdownTimer from './CountdownTimer.vue'
import Divider from '../../components/Divider.vue'
import emitter from '@/utils/mitt';
import Chat from '../../api/chat' //
import { ShareCode } from '@/utils/ppt' // ppt
const props = defineProps<{
changeViewMode: (mode: 'base' | 'presenter') => void
@ -125,7 +128,7 @@ const { slideWidth, slideHeight } = useSlideSize(slideListWrapRef)
const { exitScreening } = useScreening()
const { slidesLoadLimit } = useLoadSlides()
const { fullscreenState, manualExitFullscreen } = useFullscreen()
const chat:any = Chat() //
const chatApi:any = Chat() //
const remarkFontSize = ref(16)
const currentSlideRemark = computed(() => {
@ -134,15 +137,20 @@ const currentSlideRemark = computed(() => {
//
const turnSlideTo = (index: number, e: PointerEvent) => {
//
console.log('课堂信息', classcourse, index)
if (!!classcourse.value) return
const preInd = slideIndex.value
turnSlideToIndex(index)
if (!!classcourse.value) {//
if (preInd == index) return
const animationSteps = 0
const animation = index > preInd?'Nextsteps':'Previoustep'
const msg = { current:index, animation, animationSteps}
chatApi.slideFlapping(msg)
}
}
//
const exitCourse = async () => {
// console.log('', chat)
await chat.exitCourse() //
await chatApi.exitCourse() //
exitScreening() //
}

View File

@ -102,4 +102,16 @@ export function setPaging(data) {
data
})
}
/**
* 获取分享码(邀请码)
* @param {*} id 课堂id
* @returns
*/
export function getShareCode(id) {
return request({
url: '/education/classcourse/refresh/code',
method: 'post',
data: { id }
})
}

View File

@ -6,6 +6,10 @@ import { toPng, toJpeg } from 'html-to-image' // 引入html-to-image库
import { PPTXFileToJson } from "@/AixPPTist/src/hooks/useImport"
import ThumbnailSlide from '@/AixPPTist/src/views/components/ThumbnailSlide/index.vue'
import { useSlidesStore } from '@/AixPPTist/src/store'
import * as ElementPlus from 'element-plus'
import { sessionStore } from '@/utils/store' // electron-store 状态管理
import * as Http_Classcourse from '@/api/teaching/classcourse' // api接口
// 延时
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
@ -84,4 +88,44 @@ export const slidesToImg = (slides = [], options) => {
export const pptToImg = async(file, options) => {
const { slides } = await PPTXFileToJson(file)
return slidesToImg(slides, options)
}
/**
* 课堂-分享码
*/
export const ShareCode = async(code, cb) => {
let shareCode
if (typeof code =='string') shareCode = code
else { // 自动获取邀请码
const classcourse = sessionStore.get('curr.classcourse') // 课堂信息
if (!classcourse) return ElementPlus.ElMessage.warning('没有课堂信息')
const isRefresh = typeof code == 'boolean' && code // 是否刷新邀请码
shareCode = classcourse.shareCode
if (!shareCode || isRefresh) { // 获取邀请码
const res = await Http_Classcourse.getShareCode(classcourse.id)
shareCode = res.msg
// 更新邀请码
sessionStore.set('curr.classcourse.shareCode', shareCode)
}
}
const msg = h('div', [
h('h1', [`我的邀请码:`, h('b',{style:{color:'#F56C6C',fontSize:'1.5em'}}, shareCode)]),
h('div', {style:{color:'#E6A23C',fontSize:'13px'}}, `该邀请码1小时内有效请在学生端填写邀请码后即可进入课堂。`)
])
return ElementPlus.ElMessageBox.alert(msg, '分享课程', {
confirmButtonText: '更新',
cancelButtonText: '关闭',
showCancelButton: true,
beforeClose: (action, instance, done) => {
if (action =='confirm') { // 更新
if (!!cb) { // 回调
cb({ h, instance, action, done }, done) && done()
} else { // 默认更新
ShareCode(true)
done()
}
} else done()
}
}).catch(() => {})
}

View File

@ -60,8 +60,8 @@
<template #item_mobile>
<div>
<div v-if="myClassActive.filetype=='apt'">开始新的课堂需要点击先创建课堂才能显示手机二维码</div>
<div v-else>开始新的课堂需要点击先创建课堂</div>
<el-button type="warning" :loading="dt.loading" @click="createClasscourse()">创建课堂</el-button>
<div v-else>开始新的课堂</div>
<!-- <el-button type="warning" :loading="dt.loading" @click="createClasscourse()">创建课堂</el-button> -->
<el-button type="success" @click="createClasscourse(true)">公屏上课</el-button>
</div>
</template>
@ -139,6 +139,8 @@ onMounted(() => {
* @param classObj 课程对象-用于继续上课
*/
const open = async (id, classObj) => {
dt.loading = false
dt.loadingDel = false
visible.value = true
if (id) {
//
@ -167,6 +169,8 @@ const handleClose = async () => {
// await chat?.logout()
// chat = null
dt.ctCourse = null
dt.loading = false
dt.loadingDel = false
emit('close')
}
// -
@ -264,7 +268,7 @@ const createClasscourse = async (isPublic = false) => {
}
// teacherForm.form.classcourseid = 100
teacherForm.form.classcourseid = await Http_Classcourse.addClasscourseReturnId(params)
dt.loading = false
.finally(() => {dt.loading = false})
// getClasscourseList('update') //
let msgEl = ElMessage.success('创建课程-成功')
// -pptList

View File

@ -449,6 +449,7 @@ export default {
}
case 'click': { // --aippt
if (row.fileFlag === 'aippt' && !!row.fileId) {
sessionStore.delete('curr.classcourse') //
const res = await getEntpcoursefile(row.fileId)
if (res && res.code === 200) {
this.openPublicScreen('edit', res.data, row) // -