From 877c971415e2fc7a45a9c663aaae81b8cf359f75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com>
Date: Thu, 21 Nov 2024 16:15:14 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B9=A0=E9=A2=98=E4=B8=8A=E4=BC=A0=EF=BC=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/renderer/index.html | 2 +-
.../questionUpload/index.vue | 67 +++++--------------
2 files changed, 18 insertions(+), 51 deletions(-)
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 1de810c..f3672fb 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -8,7 +8,7 @@
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/> -->
-
+
diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue
index 4d5f6ec..503f76c 100644
--- a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue
+++ b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue
@@ -174,22 +174,22 @@ const initHomeWork = async()=> {
// taskList.value = res;
// tasklist_loading.value = false;
}
-const getBase64 = (file) =>{
- return new Promise(function (resolve, reject) {
- let reader = new FileReader();
- let imgResult = "";
- reader.readAsDataURL(file);
- reader.onload = function () {
- imgResult = reader.result;
- };
- reader.onerror = function (error) {
- reject(error);
- };
- reader.onloadend = function () {
- resolve(imgResult);
- };
- });
-}
+// const getBase64 = (file) =>{
+// return new Promise(function (resolve, reject) {
+// let reader = new FileReader();
+// let imgResult = "";
+// reader.readAsDataURL(file);
+// reader.onload = function () {
+// imgResult = reader.result;
+// };
+// reader.onerror = function (error) {
+// reject(error);
+// };
+// reader.onloadend = function () {
+// resolve(imgResult);
+// };
+// });
+// }
/**
* @desc: 上传本地图片
* @return: {*}
@@ -203,37 +203,7 @@ const handleImportImg = (uploadFile) => {
});
return;
}
- console.log('uploadFile', uploadFile);
- // 假设你在渲染进程中
- getBase64(uploadFile.raw).then(res => {
- // console.log('res-------', res);
-
-
- // 在 Electron 主进程中使用 URL.createObjectURL
- // const base64Data = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/...'; // Base64 编码的图片数据
- // const base64Data = res; // Base64 编码的图片数据
- // const buffer = Buffer.from(base64Data.split(',')[1], 'base64');
- // const filePath = path.join(Remote.app.getPath('userData'), 'image.jpg');
- // console.log(filePath,'???????????????????');
- // fs.writeFileSync(filePath, buffer);
- // const buf = fs.readFileSync(filePath)
- // console.log(buf);
- // const uint8Buffer = Uint8Array.from(buf)
- // cropOption.img = window.URL.createObjectURL(new Blob([uint8Buffer]));
- // cropOption.img = URL.createObjectURL(new Blob([fs.readFileSync(filePath)]));
- // cropOption.img = URL.createObjectURL(new Blob([buffer]));
- cropOption.img = res;
- // console.log(cropOption.img);
-
-
-
- // cropOption.img = window.URL.createObjectURL(new Blob([res]));
- // console.log(cropOption.img);
- })
- // cropOption.img = window.URL.createObjectURL(uploadFile.raw);
- // cropOption.img = window.URL.createObjectURL(new Blob([uploadFile.raw]));
- // cropOption.img = window.URL.createObjectURL(new Blob([uploadFile.raw]));
- // console.log(cropOption.img);
+ cropOption.img = window.URL.createObjectURL(uploadFile.raw);
ElMessage.success('上传成功');
};
/**
@@ -246,9 +216,6 @@ const getClipboardImg = async() => {
for (const item of clipboardItems) {
for (const type of item.types) {
if (type.includes('image/')) {
- console.log('剪贴板图片type', type);
- console.log('剪贴板图片item', item);
- console.log('剪贴板图片clipboardItems', clipboardItems);
const blob = await item.getType(type);
// blob 是图片的 Blob 对象
cropOption.img = URL.createObjectURL(blob);