|
|
|
@ -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);
|
|
|
|
|