zxl #107
|
@ -33,33 +33,7 @@ const { theme } = storeToRefs(useSlidesStore())
|
||||||
|
|
||||||
const { addSlidesFromData } = useAddSlidesOrElements()
|
const { addSlidesFromData } = useAddSlidesOrElements()
|
||||||
const { isEmptySlide } = useSlideHandler()
|
const { isEmptySlide } = useSlideHandler()
|
||||||
export default () => {
|
const parseLineElement = (el: Shape) => {
|
||||||
|
|
||||||
const exporting = ref(false)
|
|
||||||
|
|
||||||
// 导入pptist文件
|
|
||||||
const importSpecificFile = (files: FileList, cover = false) => {
|
|
||||||
const file = files[0]
|
|
||||||
|
|
||||||
const reader = new FileReader()
|
|
||||||
reader.addEventListener('load', () => {
|
|
||||||
try {
|
|
||||||
const slides = JSON.parse(decrypt(reader.result as string))
|
|
||||||
if (cover) {
|
|
||||||
slidesStore.updateSlideIndex(0)
|
|
||||||
slidesStore.setSlides(slides)
|
|
||||||
}
|
|
||||||
else if (isEmptySlide.value) slidesStore.setSlides(slides)
|
|
||||||
else addSlidesFromData(slides)
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
message.error('无法正确读取 / 解析该文件')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
reader.readAsText(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
const parseLineElement = (el: Shape) => {
|
|
||||||
let start: [number, number] = [0, 0]
|
let start: [number, number] = [0, 0]
|
||||||
let end: [number, number] = [0, 0]
|
let end: [number, number] = [0, 0]
|
||||||
|
|
||||||
|
@ -100,7 +74,34 @@ export default () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
}
|
||||||
|
export default () => {
|
||||||
|
|
||||||
|
const exporting = ref(false)
|
||||||
|
|
||||||
|
// 导入pptist文件
|
||||||
|
const importSpecificFile = (files: FileList, cover = false) => {
|
||||||
|
const file = files[0]
|
||||||
|
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.addEventListener('load', () => {
|
||||||
|
try {
|
||||||
|
const slides = JSON.parse(decrypt(reader.result as string))
|
||||||
|
if (cover) {
|
||||||
|
slidesStore.updateSlideIndex(0)
|
||||||
|
slidesStore.setSlides(slides)
|
||||||
}
|
}
|
||||||
|
else if (isEmptySlide.value) slidesStore.setSlides(slides)
|
||||||
|
else addSlidesFromData(slides)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
message.error('无法正确读取 / 解析该文件')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
reader.readAsText(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 导入PPTX文件
|
// 导入PPTX文件
|
||||||
const importPPTXFile = (files: FileList) => {
|
const importPPTXFile = (files: FileList) => {
|
||||||
|
@ -493,6 +494,7 @@ export default () => {
|
||||||
importPPTXFile,
|
importPPTXFile,
|
||||||
PPTXFileToJson,
|
PPTXFileToJson,
|
||||||
exporting,
|
exporting,
|
||||||
|
parseLineElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,6 +666,7 @@ export const PPTXFileToJson = (data: File|ArrayBuffer) => {
|
||||||
}
|
}
|
||||||
else if (el.type === 'shape') {
|
else if (el.type === 'shape') {
|
||||||
if (el.shapType === 'line' || /Connector/.test(el.shapType)) {
|
if (el.shapType === 'line' || /Connector/.test(el.shapType)) {
|
||||||
|
// 从返回对象中解构出 xx 函数并调用
|
||||||
const lineElement = parseLineElement(el)
|
const lineElement = parseLineElement(el)
|
||||||
slide.elements.push(lineElement)
|
slide.elements.push(lineElement)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,4 +56,5 @@ export class Other {
|
||||||
static baseUrl = "/common/upload"
|
static baseUrl = "/common/upload"
|
||||||
// 测试
|
// 测试
|
||||||
static uploadFile = data => ApiService.publicHttp(this.baseUrl, data, 'post', null, 'file')
|
static uploadFile = data => ApiService.publicHttp(this.baseUrl, data, 'post', null, 'file')
|
||||||
|
|
||||||
}
|
}
|
|
@ -524,7 +524,7 @@ export default {
|
||||||
if (!!o.src) { // 如果有src就转换
|
if (!!o.src) { // 如果有src就转换
|
||||||
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
||||||
const isBlobUrl = /^blob:/.test(o.src)
|
const isBlobUrl = /^blob:/.test(o.src)
|
||||||
console.log('isBase64', o, isBase64)
|
// console.log('isBase64', o, isBase64)
|
||||||
if (isBase64) {
|
if (isBase64) {
|
||||||
const bolb = commUtils.base64ToBlob(o.src)
|
const bolb = commUtils.base64ToBlob(o.src)
|
||||||
const fileName = Date.now() + '.png'
|
const fileName = Date.now() + '.png'
|
||||||
|
@ -539,11 +539,29 @@ export default {
|
||||||
url &&(o.src = url)
|
url &&(o.src = url)
|
||||||
}
|
}
|
||||||
} else if (isBlobUrl) { // 视频和音频
|
} else if (isBlobUrl) { // 视频和音频
|
||||||
|
const res = await fetch(o.src)
|
||||||
|
const blob = await res.blob()
|
||||||
|
const fileName = o.type=='video'? Date.now() + '.mp4':Date.now() + '.mp3'
|
||||||
|
const file = commUtils.blobToFile(blob, fileName)
|
||||||
|
// o.src = fileName
|
||||||
|
// console.log('file', file)
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const ress = await Api_server.Other.uploadFile(formData)
|
||||||
|
if (ress && ress.code == 200){
|
||||||
|
const url = ress?.url
|
||||||
|
url &&(o.src = url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (o?.background?.image) await this.toRousrceUrl(o.background.image)
|
if (o?.background?.image) await this.toRousrceUrl(o.background.image)
|
||||||
if (o?.elements) o.elements.forEach(async o => {await this.toRousrceUrl(o)})
|
// if (o?.elements) o.elements.forEach(async o => {await this.toRousrceUrl(o)})
|
||||||
|
if(o?.elements){
|
||||||
|
for (let element of o.elements) {
|
||||||
|
await this.toRousrceUrl(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async createAIPPTByFile(file) {
|
async createAIPPTByFile(file) {
|
||||||
this.pgDialog.visible = true
|
this.pgDialog.visible = true
|
||||||
|
@ -559,6 +577,8 @@ export default {
|
||||||
// 设置进度条
|
// 设置进度条
|
||||||
this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
|
this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
|
||||||
}
|
}
|
||||||
|
console.log('结束', slides)
|
||||||
|
return
|
||||||
this.pgDialog.pg.percentage = 0
|
this.pgDialog.pg.percentage = 0
|
||||||
this.pgDialog.visible = false
|
this.pgDialog.visible = false
|
||||||
listEntpcourse({
|
listEntpcourse({
|
||||||
|
@ -595,6 +615,8 @@ export default {
|
||||||
}).then(async (res) => {
|
}).then(async (res) => {
|
||||||
|
|
||||||
const resSlides = slides.map(({id, ...slide}) => JSON.stringify(slide))
|
const resSlides = slides.map(({id, ...slide}) => JSON.stringify(slide))
|
||||||
|
console.log(resSlides)
|
||||||
|
return
|
||||||
let params = {
|
let params = {
|
||||||
parentid: slideid,
|
parentid: slideid,
|
||||||
entpid: resCourse.entpid,
|
entpid: resCourse.entpid,
|
||||||
|
|
|
@ -330,11 +330,27 @@ const toRousrceUrl = async(o) => {
|
||||||
url &&(o.src = url)
|
url &&(o.src = url)
|
||||||
}
|
}
|
||||||
} else if (isBlobUrl) { // 视频和音频
|
} else if (isBlobUrl) { // 视频和音频
|
||||||
|
const res = await fetch(o.src)
|
||||||
|
const blob = await res.blob()
|
||||||
|
const fileName = o.type=='video'? Date.now() + '.mp4':Date.now() + '.mp3'
|
||||||
|
const file = commUtils.blobToFile(blob, fileName)
|
||||||
|
// o.src = fileName
|
||||||
|
// console.log('file', file)
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const ress = await Api_server.Other.uploadFile(formData)
|
||||||
|
if (ress && ress.code == 200){
|
||||||
|
const url = ress?.url
|
||||||
|
url &&(o.src = url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (o?.background?.image) await toRousrceUrl(o.background.image)
|
if (o?.background?.image) await toRousrceUrl(o.background.image)
|
||||||
if (o?.elements) o.elements.forEach(async o => {await toRousrceUrl(o)})
|
if(o?.elements){
|
||||||
|
for (let element of o.elements) {
|
||||||
|
await this.toRousrceUrl(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ======== zdg end ============
|
// ======== zdg end ============
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue