From 2926b4bd63829b4ddd1d89d4dd1f352f2e4c0d46 Mon Sep 17 00:00:00 2001 From: zhuhao <979263092@qq.com> Date: Tue, 23 Jul 2024 15:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=9C=9F=EF=BC=9A=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/api/file/index.js | 7 ++ src/renderer/src/utils/talkFile/index.js | 44 ++++++++ .../prepare/container/file-list-item.vue | 24 ++-- src/renderer/src/views/prepare/index.vue | 106 ++++-------------- 4 files changed, 83 insertions(+), 98 deletions(-) diff --git a/src/renderer/src/api/file/index.js b/src/renderer/src/api/file/index.js index d4394ac..5bfe721 100644 --- a/src/renderer/src/api/file/index.js +++ b/src/renderer/src/api/file/index.js @@ -9,6 +9,13 @@ export const getSmarttalkPage = (params) => { }) } +export const getPrepareById = (id) => { + return request({ + url: '/smarttalk/file/' + id, + method: 'get' + }) +} + export function deleteSmarttalk(id) { return request({ url: '/smarttalk/file/' + id, diff --git a/src/renderer/src/utils/talkFile/index.js b/src/renderer/src/utils/talkFile/index.js index f57ea36..6d4e746 100644 --- a/src/renderer/src/utils/talkFile/index.js +++ b/src/renderer/src/utils/talkFile/index.js @@ -1,5 +1,49 @@ const { ipcRenderer } = window.electron || {} +export const asyncLocalFile = (item) => { + return new Promise((resolve) => { + //判断是否需要从线上拿新的文件 + isAsyncLocalFile(item.fileNewName, item.lastModifyTime, item.fileMd5).then( + ({ isAsync, type }) => { + item.async = !isAsync + if (isAsync === true) { + item.async = 'on' + if (type === 'down') { + ipcRenderer.send('download-file-default', { + url: item.fileFullPath, + fileName: item.fileNewName + }) + ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => { + item.async = isSuccess + resolve() + }) + } + if (type === 'upload') { + let cookie = localStorage.getItem('Admin-Token') + ipcRenderer.send('upload-file-change', { + id: item.id, + fileNewName: item.fileNewName, + cookie, + fileType: item.fileType + }) + ipcRenderer.once( + 'upload-file-change-success' + item.fileNewName, + (e, { data, md5 }) => { + item.fileSize = data.fileSize + item.md5 = md5 + item.async = true + resolve() + } + ) + } + } else { + resolve() + } + } + ) + }) +} + export const isHaveLocalFile = async (fileNewName) => { return new Promise((resolve, reject) => { ipcRenderer.send('is-have-local-file', fileNewName) diff --git a/src/renderer/src/views/prepare/container/file-list-item.vue b/src/renderer/src/views/prepare/container/file-list-item.vue index 71deabf..794210e 100644 --- a/src/renderer/src/views/prepare/container/file-list-item.vue +++ b/src/renderer/src/views/prepare/container/file-list-item.vue @@ -100,10 +100,10 @@ import { Check, UploadFilled, Switch } from '@element-plus/icons-vue'