Spaces:
Sleeping
Sleeping
Upload 5 files
#3
by e2dew32 - opened
app.py
CHANGED
|
@@ -279,6 +279,8 @@ HTML_CONTENT = '''<!DOCTYPE html>
|
|
| 279 |
}
|
| 280 |
|
| 281 |
let screenshotImgElement = null;
|
|
|
|
|
|
|
| 282 |
|
| 283 |
async function loadScreenshot() {
|
| 284 |
if (!selectedClient) return;
|
|
@@ -286,13 +288,21 @@ HTML_CONTENT = '''<!DOCTYPE html>
|
|
| 286 |
const container = document.getElementById('screenshotView');
|
| 287 |
|
| 288 |
// 保持容器大小,只更新图片
|
| 289 |
-
if (screenshotImgElement) {
|
| 290 |
screenshotImgElement.src = `/api/screenshots/${selectedClient.id}?t=${t}`;
|
| 291 |
} else {
|
| 292 |
-
container.innerHTML = `<img id="screenshotImg" style="
|
| 293 |
screenshotImgElement = document.getElementById('screenshotImg');
|
| 294 |
screenshotImgElement.src = `/api/screenshots/${selectedClient.id}?t=${t}`;
|
| 295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
screenshotImgElement.onclick = function(e) {
|
| 297 |
const rect = this.getBoundingClientRect();
|
| 298 |
const x = Math.round((e.clientX - rect.left) * (this.naturalWidth / rect.width));
|
|
|
|
| 279 |
}
|
| 280 |
|
| 281 |
let screenshotImgElement = null;
|
| 282 |
+
let originalWidth = 0;
|
| 283 |
+
let originalHeight = 0;
|
| 284 |
|
| 285 |
async function loadScreenshot() {
|
| 286 |
if (!selectedClient) return;
|
|
|
|
| 288 |
const container = document.getElementById('screenshotView');
|
| 289 |
|
| 290 |
// 保持容器大小,只更新图片
|
| 291 |
+
if (screenshotImgElement && originalWidth > 0) {
|
| 292 |
screenshotImgElement.src = `/api/screenshots/${selectedClient.id}?t=${t}`;
|
| 293 |
} else {
|
| 294 |
+
container.innerHTML = `<img id="screenshotImg" style="cursor:crosshair;">`;
|
| 295 |
screenshotImgElement = document.getElementById('screenshotImg');
|
| 296 |
screenshotImgElement.src = `/api/screenshots/${selectedClient.id}?t=${t}`;
|
| 297 |
|
| 298 |
+
screenshotImgElement.onload = function() {
|
| 299 |
+
// 记录原始尺寸,后续使用固定尺寸
|
| 300 |
+
originalWidth = this.naturalWidth;
|
| 301 |
+
originalHeight = this.naturalHeight;
|
| 302 |
+
this.style.width = originalWidth + 'px';
|
| 303 |
+
this.style.height = originalHeight + 'px';
|
| 304 |
+
};
|
| 305 |
+
|
| 306 |
screenshotImgElement.onclick = function(e) {
|
| 307 |
const rect = this.getBoundingClientRect();
|
| 308 |
const x = Math.round((e.clientX - rect.left) * (this.naturalWidth / rect.width));
|