代码拉取完成,页面将自动刷新
同步操作将从 rubickCenter/rubick-suspension 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!DOCTYPE html>
<html>
<style type="text/css">
body {
-webkit-app-region: drag;
-webkit-user-select: none;
margin: 0px;
width: 100%;
height: 100%;
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
opacity: 1;
}
.body-hover {
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.body-hover:hover {
opacity: 0.8;
}
img {
width: 100vw;
height: auto;
border-radius: 3%;
overflow: hidden !important;
}
</style>
<body scroll="no" class="body-hover">
<img draggable="false" />
</body>
<script type="application/javascript">
let lock = false;
let img = document.querySelector("img")
let imgKey = window.location.hash.substring(1);
img.src = localStorage[imgKey];
window.rotateX = 0;
window.rotateY = 0;
function rotate(degree) {
if (lock) {
return;
}
lock = true;
//获得图片大小
let { width, height } = img;
//计算改变后窗口位置和大小
let R = Math.sqrt(width * width + height * height);
let xOffset = (R - width) / 2;
let yOffset = (R - height) / 2;
img.src = rotateImage(degree);
img.onload = () => {
window.moveBounds(yOffset - xOffset, xOffset - yOffset, height, width);
lock = false;
}
}
let keyCounter = {
lastKey: undefined,
key: undefined,
count: 3,
time: 0
}
let dowingKey = {};
document.addEventListener("keyup", event => {
delete dowingKey[event.key]
})
document.addEventListener("keydown", event => {
console.log(event.key);
//长按操作将加速
if (keyCounter.key === event.key && new Date().getTime() - keyCounter.time < 200) {
keyCounter.count++
} else {
keyCounter.key = event.key
keyCounter.count = 3;
keyCounter.time = 0;
}
keyCounter.time = new Date().getTime();
switch (event.key) {
case "c":
case "C":
if (dowingKey["Control"] || dowingKey["Meta"]) {
document.body.className = ""
//等待透明关闭,再拷贝当前图片
setTimeout(() => window.copyNowImage(), 100)
}
break
case "s":
case "S":
if (dowingKey["Control"] || dowingKey["Meta"]) {
document.body.className = ""
//等待透明关闭,再保存当前图片
setTimeout(() => window.saveNowImage(), 100)
}
break
case "q":
case "Q":
document.body.className = ""
//等待透明关闭,再去编辑图片
setTimeout(() => window.toEdit(), 100)
break;
case "Escape":
window.close();
break;
case "ArrowUp":
window.moveBounds(0, -keyCounter.count / 3);
break;
case "ArrowDown":
window.moveBounds(0, keyCounter.count / 3);
break;
case "ArrowLeft":
window.moveBounds(-keyCounter.count / 3, 0);
break;
case "ArrowRight":
window.moveBounds(keyCounter.count / 3, 0);
break;
case "+":
case "=":
window.resize(keyCounter.count / 2, img.height / img.width);
break;
case "-":
case "_":
if (img.width > 100) {
window.resize(0 - keyCounter.count / 2, img.height / img.width);
}
break;
//旋转相关
case "【":
case "[": {
rotate(-90);
break;
}
case "】":
case "]": {
rotate(90);
break;
}
//左右反转
case "Home":
case "End":
window.rotateY += 180;
window.document.body.style.webkitTransform = `rotateX(${window.rotateX}deg) rotateY(${window.rotateY}deg)`
break;
//上下反转
case "PageUp":
case "PageDown":
window.rotateX -= 180;
window.document.body.style.webkitTransform = `rotateX(${window.rotateX}deg) rotateY(${window.rotateY}deg)`
break;
case ",":
if (dowingKey["Control"] || dowingKey["Meta"]) {
window.modifyOpacity(-0.1);
break;
}
case ".":
if (dowingKey["Control"] || dowingKey["Meta"]) {
window.modifyOpacity(0.1);
break;
}
}
dowingKey[event.key] = true
});
document.addEventListener("wheel", (e) => {
console.log(e);
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
if (delta < 0 && img.width <= 100) {
return false;
}
window.resize(delta * 7, img.height / img.width);
return false;
}, false);
//重画图片
function rotateImage(degree) {
degree = degree % 360;
let img = document.querySelector("img");
let tmpImg = new Image()
tmpImg.src = img.src;
let canvas = document.createElement('canvas');
let cContext = canvas.getContext('2d');
let height = tmpImg.height;
let width = tmpImg.width;
canvas.width = height;
canvas.height = width;
cContext.translate(canvas.width / 2, canvas.height / 2);
cContext.rotate(degree * Math.PI / 180);
cContext.drawImage(tmpImg, -width / 2, -height / 2);
return canvas.toDataURL();
}
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。