解决ppt生成失败的问题

This commit is contained in:
朱浩 2024-10-18 16:31:57 +08:00
parent 670c457a9f
commit 9552e75f18
3 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "aix-win",
"version": "2.1.9",
"version": "2.1.12",
"description": "",
"main": "./out/main/index.js",
"author": "example.com",

View File

@ -246,8 +246,10 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
/*创建新的ppt文件*/
ipcMain.on('creat-ai-file-default', (e, { name, url, uploadData, cookie }) => {
createFolder('tempFile').then(async () => {
let lastname = decodeURIComponent(url);
name = lastname.substring(lastname.lastIndexOf("/")+1)
let path = appTempFilePath + name.replace(/[\\/:*?"<>|]/, '')
let {type,item} = await downloadFile(url,name)
let {type,item} = await downloadFiles(url,name)
if (type==="成功") {
let fileType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
let formData = new FormData()
@ -279,7 +281,8 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
})
})
function downloadFile(url,fileName) {
function downloadFiles(url,fileName) {
console.log(url,fileName)
return new Promise((resolve, reject)=>{
const browserWindow = BrowserWindow.getFocusedWindow()
const id = manager.download({

View File

@ -247,14 +247,12 @@ const getAllSubject = async () => {
rows && rows.map(item => {
if(edustage === item.edustage && item.edusubject === edusubject){
bookInfo.value = {...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar,bookName: bookNameFormat(item.edustage,item.edusubject)}
if(item.itemgroup==="校本课程") {
bookInfo.value.avartar = item.avartar
if(item.fileurl !== ''){
bookList.value.push(bookInfo.value)
}
}
if(item.fileurl !== ''){
bookList.value.push(bookInfo.value)
}
})
console.log(bookList)
const textselidx = bookList.value.findIndex(item => item.edustage === edustage && item.edusubject === edusubject)
booksel.value = textselidx
const filePath = import.meta.env.VITE_APP_RES_FILE_PATH + bookList.value[textselidx].fileurl.replace('.txt','.pdf')