1 Star 1 Fork 2

李东平/rubick-suspension

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
suspend.js 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
muwoo 提交于 2023-10-23 15:37 . first commit
const fs = require('fs');
const { ipcRenderer } = require('electron')
let imgKey = window.location.hash.substring(1);
console.log(333, imgKey, localStorage.getItem(imgKey));
const mineMap = {
"image/bmp" : "bmp",
"image/gif" : "gif",
"image/heic" : "heic",
"image/jpeg" : "jpeg",
"image/jpeg" : "jpg",
"image/jpeg" : "jpe",
"image/png" : "png",
"image/svg+xml" : "svg",
"image/webp" : "webp",
"image/x-icon" : "ico"
}
// window.isMac = rubick.isMacOs();
let winId;
ipcRenderer.on('init', (event, args) => {
if (args && args.img) {
let img = document.querySelector("img")
img.src = args.img;
}
winId = event.senderId;
});
window.toEdit = () => {
ipcRenderer.sendTo(winId, 'toEdit');
}
window.resize = (changed, proportion) => {
ipcRenderer.sendTo(winId, 'resize', changed, proportion);
}
window.moveBounds = (x, y, width, height) => {
ipcRenderer.sendTo(winId, 'moveBounds', x, y, width, height);
}
/**
* 拷贝当前图片,借助窗口截图实现
*/
window.copyNowImage = () => {
ipcRenderer.sendTo(winId, 'copyNowImage');
}
/*
* 保存当前图片,借助窗口截图实现
*/
window.saveNowImage = () => {
ipcRenderer.sendTo(winId, 'saveNowImage');
}
ipcRenderer.on('reduction', (event) => {
document.body.className = "body-hover"
})
window.modifyOpacity = (op) => {
ipcRenderer.sendTo(winId, 'modifyOpacity',op);
}
ipcRenderer.on('will-resize', (event, newBounds) => {
//只能按比例缩放图片
let img = window.document.querySelector("img");
img.style.width = '100%';
img.style.height = '100%';
let scale = img.width / (img.height * 1.0)
let height = newBounds.width / scale;
// console.log(window, newBounds.width, newBounds.height);
window.resizeTo(newBounds.width, Math.min(newBounds.height, height));
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ibm317/rubick-suspension.git
git@gitee.com:ibm317/rubick-suspension.git
ibm317
rubick-suspension
rubick-suspension
main

搜索帮助