diff --git a/package.json b/package.json index f27fc00..9ac8a1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aix-win-ws", - "version": "2.5.9", + "version": "2.5.10", "description": "", "main": "./out/main/index.js", "author": "上海交大重庆人工智能研究院", diff --git a/src/main/file.js b/src/main/file.js index 3de3333..5764d91 100644 --- a/src/main/file.js +++ b/src/main/file.js @@ -13,6 +13,34 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { const appTempFilePath = userDataPath + '\\tempFile\\' let Spark = new SparkMD5.ArrayBuffer() + ipcMain.on('remove-local-file-list', (e, list) => { + let filePath = appRootFilePath + for (let i = 0; i < list.length; i++) { + let item = list[i]; + if (!isAccess(filePath + item.fileNewName)) { + e.reply('remove-local-file-list-not', item) + continue + } + try { + fs.unlinkSync(filePath + item.fileNewName); + console.log(`${filePath} 已成功删除`); + } catch (err) { + console.error(`删除文件时出错:`, err); + e.reply('remove-local-file-list-error', item) + } + } + e.reply('remove-local-file-list-reply') + }) + + const isAccess = (filePath) => { + try { + fs.accessSync(filePath); + return true + } catch (err) { + return false + } + } + ipcMain.on('upload-file-change', (e, { id, fileNewName, cookie, fileType }) => { let filePath = appRootFilePath + fileNewName //执行更新,上传文件 @@ -58,7 +86,6 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { } //倒数十秒提交更改,十秒之内有继续修改则重置倒数 uploadId = setTimeout(() => { - console.log(223) //执行更新,上传文件 let formData = new FormData() formData.append('id', id) @@ -89,8 +116,12 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { function getFileMsg(path) { return new Promise((resolve, reject) => { - const stats = fs.statSync(path) - return resolve(stats.mtime.getTime()) + try { + const stats = fs.statSync(path) + resolve(stats.mtime.getTime()) + }catch (e) { + reject(e) + } }) } @@ -303,17 +334,20 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { }, onDownloadCancelled: async () => { console.log("取消") - reject({type:"取消了下载"}) + resolve({type:"取消了下载"}) }, onDownloadInterrupted: async () => { console.log('中断') - reject({type:"下载被中断"}) + resolve({type:"下载被中断"}) }, onError: (err, data) => { console.log(err.toString()) - reject({type:"下载出错",err}) + resolve({type:"下载出错",err}) } } + }).catch(err=>{ + console.log(err) + resolve({type:"下载出错",err}) }) }) } @@ -360,6 +394,7 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { }) }) .catch((error) => { + console.log(error) e.reply('download-file-default' + fileName, false) }) }) diff --git a/src/renderer/src/AixPPTist/src/api/index.ts b/src/renderer/src/AixPPTist/src/api/index.ts index 8e15fb7..d568d02 100644 --- a/src/renderer/src/AixPPTist/src/api/index.ts +++ b/src/renderer/src/AixPPTist/src/api/index.ts @@ -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 { 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 是否更新缩略图 diff --git a/src/renderer/src/AixPPTist/src/api/watcher.ts b/src/renderer/src/AixPPTist/src/api/watcher.ts index 5a9e731..4860a0e 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -2,7 +2,7 @@ * @description 公共监听器 */ -import { watch } from 'vue' +import { watch, render } from 'vue' import { PPTApi } from './index' import * as store from '../store' import { sessionStore } from '@/utils/store' // electron-store 状态管理 @@ -99,6 +99,7 @@ export default () => { } break case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页 + render(null, document.body) //移除弹窗 emitter.emit('closegridPic') //如果有推图片窗口 就关闭 const slideIndex = content?.current || 0 const type = content?.animation // 上下动作 @@ -130,7 +131,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 @@ -148,14 +149,4 @@ export default () => { window.close() // 关闭窗口 }, 1000) } - // setTimeout(async () => { - // emitter.emit('opengridPic',{arr:['https://prev.ysaix.com:7868/src/assets/images/homecard4.jpg']}) - // }, 3000) - - // setTimeout(async () => { - // emitter.emit('closegridPic') - // }, 6000) - // setTimeout(async () => { - // emitter.emit('opengridPic',{arr:['https://prev.ysaix.com:7868/src/assets/images/homecard4.jpg','https://prev.ysaix.com:7868/src/assets/images/homecard4.jpg']}) - // }, 9000) } \ No newline at end of file diff --git a/src/renderer/src/AixPPTist/src/store/slides.ts b/src/renderer/src/AixPPTist/src/store/slides.ts index f3a23fa..420bd84 100644 --- a/src/renderer/src/AixPPTist/src/store/slides.ts +++ b/src/renderer/src/AixPPTist/src/store/slides.ts @@ -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, slideId?: string) { const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex diff --git a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementAnimationPanel.vue b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementAnimationPanel.vue index d27f20f..ea8b59c 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementAnimationPanel.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementAnimationPanel.vue @@ -95,8 +95,8 @@ style="width: 65%;" :options="[ { label: '主动触发', value: 'click' }, - { label: '与上一动画同时', value: 'meantime' }, - { label: '上一动画之后', value: 'auto' }, + // { label: '与上一动画同时', value: 'meantime' }, + // { label: '上一动画之后', value: 'auto' }, ]" /> diff --git a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue index 7d24e8c..4b747bd 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue @@ -47,8 +47,9 @@ - - + + +
@@ -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 @@ -102,6 +104,7 @@ const { execPrev, execNext, animationIndex, + turning, } = useExecPlay() const { slideWidth, slideHeight } = useSlideSize() const { exitScreening } = useScreening() @@ -198,7 +201,7 @@ const contextmenus = (): ContextmenuItem[] => { }, ] } - +// 工具栏按钮触发 const toolTrigger = (type:string) => { const curT = Date.now() if (curT - timer.value < 200) return diff --git a/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue b/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue index a747a9c..5ece2f4 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue @@ -10,9 +10,10 @@ {{ fullscreenState ? '退出全屏' : '全屏' }}
+
分享
-
结束放映
-
结束课堂
+
结束放映
+
结束课堂
@@ -78,6 +79,7 @@