diff --git a/.env.production b/.env.production index a166cab..c3b1489 100644 --- a/.env.production +++ b/.env.production @@ -22,4 +22,4 @@ VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/' VITE_APP_WS_URL = 'wss://prev.ysaix.com:7868' # 是否显示开发工具 -VITE_SHOW_DEV_TOOLS = 'true' +VITE_SHOW_DEV_TOOLS = 'false' diff --git a/src/renderer/src/AixPPTist/src/api/index.ts b/src/renderer/src/AixPPTist/src/api/index.ts index 611efb6..ba0130e 100644 --- a/src/renderer/src/AixPPTist/src/api/index.ts +++ b/src/renderer/src/AixPPTist/src/api/index.ts @@ -55,26 +55,28 @@ export class PPTApi { // 变量 static isUpdate = true // 是否更新数据 - // 获取所有幻灯片列表 - static getSlideList(parentid: (Number | String)): Promise { + // 获取所有幻灯片列表 isUpdate为true不更新 + static getSlideList(parentid: (Number | String),isUpdate?:Boolean): Promise { return new Promise(async (resolve, reject) => { const params: object = { parentid, orderByColumn: 'fileidx', isAsc: 'asc', pageSize: 9999 } const res: Result = await API_entpcoursefile.listEntpcoursefileNew(params) - if (res.code === 200) { - const slides = (res.rows || []).map(o => { - if (!!o.datacontent) { - const json = JSON.parse(o.datacontent) - !!json && (json.id = o.id) - return json - } - // 如果没有数据,默认空白页 - return {id: o.id,elements:[],background:{type:"solid",color:"#fff"}} - }) + if (res.code === 200) { + if(!isUpdate){ + const slides = (res.rows || []).map(o => { + if (!!o.datacontent) { + const json = JSON.parse(o.datacontent) + !!json && (json.id = o.id) + return json + } + // 如果没有数据,默认空白页 + 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 workItem = [...res.rows] - // slidesStore.updateSlideIndex(0) // 下标0 为第一页 - slidesStore.setSlides(slides) // 写入数据 + const workItem = res.rows ? [...res.rows] : [] // 写入作业列表数据 slidesStore.setWorkList(workList) // 获取所有的pptlist的数据 @@ -111,7 +113,6 @@ export class PPTApi { data.id = rid slidesStore.updateSlide(data) // msgUtils.msgSuccess('新增成功') - PPTApi.getSlideList(resource.id) this.isUpdate = false // 新增后会触发监听,不再更新数据 resolve(true) } else msgUtils.msgError('新增失败');resolve(false) @@ -134,7 +135,9 @@ export class PPTApi { const isAdd = !/^\d+$/.test(currentSlide.id) // 是否新增 if (isAdd) { // 新增的幻灯片(id 为非数字,说明是新增的幻灯片) 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 { // 防抖-更新 if (!this.isUpdate) return this.isUpdate = true // 下次更新数据 const params = { diff --git a/src/renderer/src/AixPPTist/src/store/slides.ts b/src/renderer/src/AixPPTist/src/store/slides.ts index 37ba6b2..c86c7c7 100644 --- a/src/renderer/src/AixPPTist/src/store/slides.ts +++ b/src/renderer/src/AixPPTist/src/store/slides.ts @@ -145,21 +145,16 @@ export const useSlidesStore = defineStore('slides', { setWorkItem(list: Object[]) { 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[]) { const slides = Array.isArray(slide) ? slide : [slide] for (const slide of slides) { if (slide.sectionTag) delete slide.sectionTag } + // const addIndex = this.slideIndex + 1 this.slides.splice(this.slideIndex, 0, ...slides) + // this.slideIndex = addIndex }, - updateSlide(props: Partial, slideId?: string) { const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex this.slides[slideIndex] = { ...this.slides[slideIndex], ...props } diff --git a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue index 9ad6322..26c852e 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue @@ -19,7 +19,8 @@ import { ref, reactive, onMounted, computed } from 'vue'; import { sessionStore } from '@/utils/store' import { getSmarttalkPage } from '@/api/file' -import { getFileSuffix, urlToBase64 } from '@/utils/ruoyi.js' +import * as commUtils from '@/utils/comm.js' +import { getFileSuffix } from '@/utils/ruoyi.js' const emit = defineEmits(['insertMaterial', 'close']) @@ -62,12 +63,15 @@ const fileUrl = computed(() => (item) =>{ // 插入 const onInsert = async (item) =>{ + const res = await fetch(item.fileFullPath) + const bolb = await res.blob() + const file = commUtils.blobToFile(bolb, item.fileShowName) + if(videoSuffix.indexOf(getFileSuffix(item.fileShowName)) != -1){ - emit('insertMaterial',{ type: 'video', data: item.fileFullPath }) + emit('insertMaterial',{ type: 'video', file }) } else{ - const base64 = await urlToBase64(item.fileFullPath) - emit('insertMaterial',{ type: 'img', data: base64 }) + emit('insertMaterial',{ type: 'img', file }) } } diff --git a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue index 909f7fe..ad51dd9 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -132,7 +132,7 @@ - + @@ -165,6 +165,7 @@ import { PPTApi } from '../../../api' import TextCreateImg from '@/components/ai-kolors/index.vue' import { toPng } from 'html-to-image' // 引入html-to-image库 + const mainStore = useMainStore() const { creatingElement, creatingCustomShape, showSelectPanel, showSearchPanel, showNotesPanel } = storeToRefs(mainStore) const { canUndo, canRedo } = storeToRefs(useSnapshotStore()) @@ -280,21 +281,31 @@ const toggleNotesPanel = () => { // 插入素材 interface MaterialParams { type: string, - data: string + file: any } const insertMaterial = (item: MaterialParams) =>{ - const { type, data } = item - if(type == 'video'){ - createVideoElement(data) - } - else{ - createImageElement(data) - } - materiaVisible.value = false + const { type, file } = item + PPTApi.toRousrceUrl(file).then(data=>{ + if(type == 'video'){ + createVideoElement(data) + } + else{ + createImageElement(data) + } + materiaVisible.value = false + }) + } // 文生图 const imgVisible = ref(false) +const insertImg = async (file: any) =>{ + PPTApi.toRousrceUrl(file).then(data=>{ + createImageElement(data) + imgVisible.value = false + }) +} +