Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
b31e975efd
|
@ -5,7 +5,11 @@
|
||||||
<el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" >
|
<el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" >
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<el-image class="user-img" :src="img" />
|
<el-image class="user-img" :src="img">
|
||||||
|
<template #error>
|
||||||
|
<img :src="route_path + userStore.user.avatar">
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
<span>{{ userStore.user.nickName }}</span>
|
<span>{{ userStore.user.nickName }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -65,6 +69,7 @@ import {toLinkLeftWeb} from "@/utils/tool"
|
||||||
|
|
||||||
const { ipcRenderer } = window.electron || {}
|
const { ipcRenderer } = window.electron || {}
|
||||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||||
|
const route_path = ref(import.meta.env.VITE_APP_BUILD_BASE_PATH)
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const currentRoute = ref('')
|
const currentRoute = ref('')
|
||||||
|
|
|
@ -289,7 +289,8 @@ export default {
|
||||||
{ color: '#5cb87a', percentage: 100 }, // 绿色
|
{ color: '#5cb87a', percentage: 100 }, // 绿色
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
pptMedia: {} // ppt媒体数据
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -591,52 +592,76 @@ export default {
|
||||||
this.createAIPPTByFile(file, this.currentNode.itemtitle + '.aippt')
|
this.createAIPPTByFile(file, this.currentNode.itemtitle + '.aippt')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 将图片|音频|视频 转换为线上地址
|
||||||
|
getOnlineFileUrl(data, name){
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
let file
|
||||||
|
if (data instanceof Blob) { // blob类型判断
|
||||||
|
const fileName = Date.now() + `.${name||'png'}`
|
||||||
|
file = commUtils.blobToFile(data, fileName)
|
||||||
|
} else if (data instanceof File) { // file类型判断
|
||||||
|
file = data
|
||||||
|
} else { // 其他类型 base64
|
||||||
|
const blob = commUtils.base64ToBlob(data)
|
||||||
|
const fileName = Date.now() + `.${name||'png'}`
|
||||||
|
file = commUtils.blobToFile(blob, fileName)
|
||||||
|
}
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const res = await Api_server.Other.uploadFile(formData)
|
||||||
|
if (res && res.code == 200){
|
||||||
|
resolve(res?.url)
|
||||||
|
} else { // 失败
|
||||||
|
reject(res?.msg||'上传失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
async toRousrceUrl(o) {
|
async toRousrceUrl(o) {
|
||||||
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)
|
let onLineUrl = '' // 线上地址
|
||||||
if (isBase64) {
|
if (!!o.zipPath) onLineUrl = this.pptMedia[o.zipPath] || '' // 是否已上传过
|
||||||
const bolb = commUtils.base64ToBlob(o.src)
|
if (onLineUrl) o.src = onLineUrl // 已存在线上地址直接赋值
|
||||||
const fileName = Date.now() + '.png'
|
else { // 不存在重新上传
|
||||||
const file = commUtils.blobToFile(bolb, fileName)
|
if (isBase64) { // 相同资源处理
|
||||||
// o.src = fileName
|
const url = await this.getOnlineFileUrl(o.src)
|
||||||
// console.log('file', file)
|
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
||||||
const formData = new FormData()
|
} else if (isBlobUrl) { // 视频和音频
|
||||||
formData.append('file', file)
|
const res = await fetch(o.src)
|
||||||
const res = await Api_server.Other.uploadFile(formData)
|
const blob = await res.blob()
|
||||||
if (res && res.code == 200){
|
const url = await this.getOnlineFileUrl(blob, o.type=='video'?'mp4':'mp3')
|
||||||
const url = res?.url
|
URL.revokeObjectURL(o.src) // 释放内存
|
||||||
url &&(o.src = url)
|
|
||||||
}
|
|
||||||
} 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)
|
url &&(o.src = url)
|
||||||
|
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 处理元素为shape 可能存在背景图等
|
||||||
|
const isBg = o?.gradient?.type == 'image' && !!o?.gradient?.image
|
||||||
|
if (isBg) {
|
||||||
|
const {src, zipPath} = o.gradient.image || {}
|
||||||
|
let onLineUrl = '' // 线上地址
|
||||||
|
if (!!zipPath) onLineUrl = this.pptMedia[zipPath] || '' // 是否已上传过
|
||||||
|
if (onLineUrl) o.gradient.image.src = onLineUrl // 已存在线上地址直接赋值
|
||||||
|
else { // 重新上传
|
||||||
|
const url = await this.getOnlineFileUrl(src)
|
||||||
|
o.gradient.image.src = url
|
||||||
|
url && zipPath && (this.pptMedia[zipPath] = 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){
|
||||||
if(o?.elements){
|
for (let element of o.elements) {
|
||||||
for (let element of o.elements) {
|
await this.toRousrceUrl(element);
|
||||||
await this.toRousrceUrl(element);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async createAIPPTByFile(file,fileShowName) {
|
async createAIPPTByFile(file,fileShowName) {
|
||||||
this.pgDialog.visible = true
|
this.pgDialog.visible = true
|
||||||
this.pgDialog.pg.percentage = 0
|
this.pgDialog.pg.percentage = 0
|
||||||
|
this.pptMedia = {} // 清空媒体数据
|
||||||
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
||||||
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
||||||
this.pgDialog.visible = false
|
this.pgDialog.visible = false
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="user-info-head" @click="editCropper()">
|
<div class="user-info-head" @click="editCropper()">
|
||||||
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
<!-- <img :src="options.img" title="点击上传头像" class="img-circle img-lg" /> -->
|
||||||
|
<el-image class="user-img" :src="options.img" style="width: 120px;">
|
||||||
|
<template #error>
|
||||||
|
<img :src="route_path + userStore.user.avatar">
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="open"
|
v-model="open"
|
||||||
append-to-body
|
append-to-body
|
||||||
|
@ -31,6 +36,7 @@ const userStore = useUserStore()
|
||||||
const open = ref(false)
|
const open = ref(false)
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||||
|
const route_path = ref(import.meta.env.VITE_APP_BUILD_BASE_PATH)
|
||||||
const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/assets/images/img-avatar.png']
|
const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/assets/images/img-avatar.png']
|
||||||
|
|
||||||
//图片裁剪数据
|
//图片裁剪数据
|
||||||
|
|
Loading…
Reference in New Issue