|
@@ -424,15 +424,14 @@ async function convertToWebPAsync(base64Image) {
|
|
const ctx = canvas.getContext('2d');
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.drawImage(image, 0, 0);
|
|
ctx.drawImage(image, 0, 0);
|
|
|
|
|
|
- const webpData = canvas.toDataURL('image/webp');
|
|
|
|
- return webpData;
|
|
|
|
|
|
+ return canvas.toDataURL('image/webp');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeWindow() {
|
|
function closeWindow() {
|
|
const userAgent = navigator.userAgent;
|
|
const userAgent = navigator.userAgent;
|
|
- if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
|
|
|
|
|
|
+ if (userAgent.indexOf("Firefox") !== -1 || userAgent.indexOf("Chrome") !== -1) {
|
|
window.location.href = "about:blank";
|
|
window.location.href = "about:blank";
|
|
window.close();
|
|
window.close();
|
|
} else {
|
|
} else {
|
|
@@ -446,8 +445,7 @@ function closeWindow() {
|
|
function getTimeStamp() {
|
|
function getTimeStamp() {
|
|
const currentTimeStamp = Date.now();
|
|
const currentTimeStamp = Date.now();
|
|
const targetTimeStamp = new Date('2024-01-01').getTime();
|
|
const targetTimeStamp = new Date('2024-01-01').getTime();
|
|
- const difference = currentTimeStamp - targetTimeStamp;
|
|
|
|
- return difference;
|
|
|
|
|
|
+ return currentTimeStamp - targetTimeStamp;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -504,6 +502,19 @@ function showTextOnTopRight(text) {
|
|
function showBusyText() {
|
|
function showBusyText() {
|
|
showTextOnTopRight("同步中...");
|
|
showTextOnTopRight("同步中...");
|
|
}
|
|
}
|
|
|
|
+
|
|
function showDoneText() {
|
|
function showDoneText() {
|
|
showTextOnTopRight("✅");
|
|
showTextOnTopRight("✅");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// dispatchEventClick('.btn') 触发点击事件
|
|
|
|
+function dispatchEventClick(cssSelector) {
|
|
|
|
+ let dom = document.querySelector(cssSelector);
|
|
|
|
+ if (!dom) {
|
|
|
|
+ console.log('dom is null');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const event = new Event('click');
|
|
|
|
+ dom.dispatchEvent(event);
|
|
|
|
+}
|