diff --git a/electron-builder.yml b/electron-builder.yml index 46e484d..4b26cd1 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -16,7 +16,7 @@ win: nsis: oneClick: false allowToChangeInstallationDirectory: true - artifactName: ${name}-${version}-setup.${ext} + artifactName: ${name}-${version}-test.${ext} shortcutName: ${productName} uninstallDisplayName: ${productName} createDesktopShortcut: always diff --git a/package.json b/package.json index b544cec..7e2e499 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aix-win", - "version": "2.1.5", + "version": "2.1.9", "description": "", "main": "./out/main/index.js", "author": "example.com", diff --git a/src/main/file.js b/src/main/file.js index 58ee5ec..7612bf4 100644 --- a/src/main/file.js +++ b/src/main/file.js @@ -243,6 +243,78 @@ 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 path = appTempFilePath + name.replace(/[\\/:*?"<>|]/, '') + let {type,item} = await downloadFile(url,name) + if (type==="成功") { + let fileType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation' + let formData = new FormData() + for (let key in uploadData) { + if (Object.prototype.hasOwnProperty.call(uploadData, key)) { + // 检查是否是对象自身的属性 + formData.append(key, uploadData[key]) + } + } + formData.append('fileFlag', '课件') + uploadFileByFS({ + url: uploadUrl, + path, + name, + cookie, + fileType, + formData, + success: (response) => { + e.reply('creat-ai-file-default-reply', response.data) + console.log('File uploaded successfully:', response.data) + }, + error: (err) => { + console.error('Error uploading file:', err) + } + }) + }else { + e.reply('creat-ai-file-default-reply', type) + } + }) + }) + + function downloadFile(url,fileName) { + return new Promise((resolve, reject)=>{ + const browserWindow = BrowserWindow.getFocusedWindow() + const id = manager.download({ + window: browserWindow, + url: url, + saveAsFilename: fileName, + directory: appTempFilePath, + callbacks: { + onDownloadStarted: async ({ id, item, webContents }) => { + // Do something with the download id + }, + onDownloadProgress: async ({ id, item, percentCompleted }) => { + // console.log(percentCompleted) + }, + onDownloadCompleted: async ({ id, item }) => { + console.log('完成') + resolve({type:"成功",item}) + }, + onDownloadCancelled: async () => { + console.log("取消") + reject({type:"取消了下载"}) + }, + onDownloadInterrupted: async () => { + console.log('中断') + reject({type:"下载被中断"}) + }, + onError: (err, data) => { + console.log(err.toString()) + reject({type:"下载出错",err}) + } + } + }) + }) + } + //获取应用文件目录 ipcMain.on('get-root-file-path', (e) => { e.reply('get-root-file-path-reply', appRootFilePath) diff --git a/src/renderer/src/utils/talkFile/index.js b/src/renderer/src/utils/talkFile/index.js index 08c9990..ae5dfbb 100644 --- a/src/renderer/src/utils/talkFile/index.js +++ b/src/renderer/src/utils/talkFile/index.js @@ -96,3 +96,19 @@ export const creatPPT = (name, uploadData) => { }) }) } + +export const creatAIPPT = (name, url, uploadData) => { + JSON.parse(JSON.stringify(uploadData)) + return new Promise((resolve, reject) => { + let cookie = localStorage.getItem('Admin-Token') + ipcRenderer.send('creat-ai-file-default', { + name, + url, + uploadData: JSON.parse(JSON.stringify(uploadData)), + cookie + }) + ipcRenderer.once('creat-ai-file-default-reply', (e, res) => { + resolve(res) + }) + }) +} diff --git a/src/renderer/src/views/classManage/reserv-item-apt.vue b/src/renderer/src/views/classManage/reserv-item-apt.vue index 57f2596..59c1137 100644 --- a/src/renderer/src/views/classManage/reserv-item-apt.vue +++ b/src/renderer/src/views/classManage/reserv-item-apt.vue @@ -27,11 +27,8 @@ \ No newline at end of file + diff --git a/src/renderer/src/views/prepare/container/reserv.vue b/src/renderer/src/views/prepare/container/reserv.vue index 99f660d..116b5e9 100644 --- a/src/renderer/src/views/prepare/container/reserv.vue +++ b/src/renderer/src/views/prepare/container/reserv.vue @@ -101,6 +101,12 @@ const props = defineProps({ default: () => { return {} } + }, + curFile: { + type: Object, + default: () => { + return {} + } } }) const ruleFormDialog = ref(null) @@ -292,7 +298,8 @@ const addClassReserv = (formData) => { classRoom: formData.classRoom, classSubject: props.currentNode.edusubject, ex1: props.bookId, - ex2: props.currentNode.id + ex2: props.currentNode.id, + ex4: props.curFile.id } addSmartClassReserv(param).then((res) => { if (res.msg) { diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 7a3729a..0f5645e 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -34,7 +34,7 @@ - @@ -132,19 +132,20 @@ ref="reservDialog" :current-node="currentNode" :book-id="uploadData.textbookId" + :cur-file="activeClass" @add-success="initReserv" @close="closeChange" > - - +