Upload public.js
Browse files- backend/src/routes/public.js +110 -189
backend/src/routes/public.js
CHANGED
|
@@ -155,19 +155,19 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 155 |
<html lang="zh-CN">
|
| 156 |
<head>
|
| 157 |
<meta charset="UTF-8">
|
| 158 |
-
<meta name="viewport" content="width=${pptDimensions.width}, height=${pptDimensions.height}, initial-scale=1.0,
|
| 159 |
<title>${title} - 第${slideIndex + 1}页</title>
|
| 160 |
<style>
|
| 161 |
-
/*
|
| 162 |
-
|
| 163 |
margin: 0 !important;
|
| 164 |
padding: 0 !important;
|
|
|
|
|
|
|
| 165 |
box-sizing: border-box !important;
|
| 166 |
-
border: none !important;
|
| 167 |
-
outline: none !important;
|
| 168 |
}
|
| 169 |
|
| 170 |
-
/* HTML
|
| 171 |
html {
|
| 172 |
width: ${pptDimensions.width}px !important;
|
| 173 |
height: ${pptDimensions.height}px !important;
|
|
@@ -175,18 +175,11 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 175 |
min-height: ${pptDimensions.height}px !important;
|
| 176 |
max-width: ${pptDimensions.width}px !important;
|
| 177 |
max-height: ${pptDimensions.height}px !important;
|
|
|
|
| 178 |
overflow: hidden !important;
|
| 179 |
-
background: ${slide.background?.color || theme.backgroundColor || '#ffffff'} !important;
|
| 180 |
-
position: fixed !important;
|
| 181 |
-
top: 0 !important;
|
| 182 |
-
left: 0 !important;
|
| 183 |
-
margin: 0 !important;
|
| 184 |
-
padding: 0 !important;
|
| 185 |
-
border: none !important;
|
| 186 |
-
outline: none !important;
|
| 187 |
}
|
| 188 |
|
| 189 |
-
/* Body
|
| 190 |
body {
|
| 191 |
width: ${pptDimensions.width}px !important;
|
| 192 |
height: ${pptDimensions.height}px !important;
|
|
@@ -194,37 +187,21 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 194 |
min-height: ${pptDimensions.height}px !important;
|
| 195 |
max-width: ${pptDimensions.width}px !important;
|
| 196 |
max-height: ${pptDimensions.height}px !important;
|
|
|
|
| 197 |
overflow: hidden !important;
|
| 198 |
font-family: 'Microsoft YaHei', Arial, sans-serif !important;
|
| 199 |
-
|
| 200 |
-
position: fixed !important;
|
| 201 |
-
top: 0 !important;
|
| 202 |
-
left: 0 !important;
|
| 203 |
-
margin: 0 !important;
|
| 204 |
-
padding: 0 !important;
|
| 205 |
-
border: none !important;
|
| 206 |
-
outline: none !important;
|
| 207 |
}
|
| 208 |
|
| 209 |
-
/* PPT容器 -
|
| 210 |
.slide-container {
|
| 211 |
width: ${pptDimensions.width}px !important;
|
| 212 |
height: ${pptDimensions.height}px !important;
|
| 213 |
-
min-width: ${pptDimensions.width}px !important;
|
| 214 |
-
min-height: ${pptDimensions.height}px !important;
|
| 215 |
-
max-width: ${pptDimensions.width}px !important;
|
| 216 |
-
max-height: ${pptDimensions.height}px !important;
|
| 217 |
background-color: ${slide.background?.color || theme.backgroundColor || '#ffffff'} !important;
|
| 218 |
-
position:
|
| 219 |
top: 0 !important;
|
| 220 |
left: 0 !important;
|
| 221 |
overflow: hidden !important;
|
| 222 |
-
transform: none !important;
|
| 223 |
-
transform-origin: top left !important;
|
| 224 |
-
margin: 0 !important;
|
| 225 |
-
padding: 0 !important;
|
| 226 |
-
border: none !important;
|
| 227 |
-
outline: none !important;
|
| 228 |
z-index: 1 !important;
|
| 229 |
}
|
| 230 |
|
|
@@ -246,20 +223,16 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 246 |
` : ''}
|
| 247 |
|
| 248 |
/* 隐藏所有滚动条 */
|
| 249 |
-
|
| 250 |
-
body::-webkit-scrollbar,
|
| 251 |
-
*::-webkit-scrollbar {
|
| 252 |
display: none !important;
|
| 253 |
-
width: 0 !important;
|
| 254 |
-
height: 0 !important;
|
| 255 |
}
|
| 256 |
|
| 257 |
-
/* Firefox滚动条���藏 */
|
| 258 |
html {
|
| 259 |
scrollbar-width: none !important;
|
|
|
|
| 260 |
}
|
| 261 |
|
| 262 |
-
/*
|
| 263 |
* {
|
| 264 |
-webkit-user-select: none !important;
|
| 265 |
-moz-user-select: none !important;
|
|
@@ -272,31 +245,15 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 272 |
user-drag: none !important;
|
| 273 |
}
|
| 274 |
|
| 275 |
-
/*
|
| 276 |
body {
|
| 277 |
zoom: 1 !important;
|
| 278 |
-webkit-text-size-adjust: 100% !important;
|
| 279 |
-ms-text-size-adjust: 100% !important;
|
|
|
|
|
|
|
| 280 |
}
|
| 281 |
</style>
|
| 282 |
-
<script>
|
| 283 |
-
// PPT尺寸信息 - 用于截图服务和JavaScript处理
|
| 284 |
-
window.PPT_DIMENSIONS = {
|
| 285 |
-
width: ${pptDimensions.width},
|
| 286 |
-
height: ${pptDimensions.height}
|
| 287 |
-
};
|
| 288 |
-
|
| 289 |
-
// 强制设置viewport尺寸
|
| 290 |
-
const viewportMeta = document.querySelector('meta[name="viewport"]');
|
| 291 |
-
if (viewportMeta) {
|
| 292 |
-
viewportMeta.setAttribute('content', \`width=\${window.PPT_DIMENSIONS.width}, height=\${window.PPT_DIMENSIONS.height}, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover\`);
|
| 293 |
-
}
|
| 294 |
-
|
| 295 |
-
console.log('PPT页面初始化 - 固定尺寸模式:', {
|
| 296 |
-
dimensions: window.PPT_DIMENSIONS,
|
| 297 |
-
userAgent: navigator.userAgent
|
| 298 |
-
});
|
| 299 |
-
</script>
|
| 300 |
</head>
|
| 301 |
<body>
|
| 302 |
<div class="slide-container" id="slideContainer">
|
|
@@ -304,88 +261,74 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 304 |
</div>
|
| 305 |
|
| 306 |
<script>
|
| 307 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
window.addEventListener('load', function() {
|
| 309 |
-
const container = document.getElementById('slideContainer');
|
| 310 |
const html = document.documentElement;
|
| 311 |
const body = document.body;
|
|
|
|
| 312 |
|
| 313 |
-
|
| 314 |
-
const
|
| 315 |
-
const exactHeight = ${pptDimensions.height};
|
| 316 |
-
const backgroundColor = '${slide.background?.color || theme.backgroundColor || '#ffffff'}';
|
| 317 |
|
| 318 |
-
console.log('
|
| 319 |
|
| 320 |
-
//
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
max-width: \${width}px !important;
|
| 330 |
-
max-height: \${height}px !important;
|
| 331 |
-
overflow: hidden !important;
|
| 332 |
-
margin: 0 !important;
|
| 333 |
-
padding: 0 !important;
|
| 334 |
-
border: none !important;
|
| 335 |
-
outline: none !important;
|
| 336 |
-
position: fixed !important;
|
| 337 |
-
top: 0 !important;
|
| 338 |
-
left: 0 !important;
|
| 339 |
-
transform: none !important;
|
| 340 |
-
transform-origin: top left !important;
|
| 341 |
-
background: \${backgroundColor} !important;
|
| 342 |
-
box-sizing: border-box !important;
|
| 343 |
-
\`;
|
| 344 |
-
};
|
| 345 |
|
| 346 |
-
//
|
| 347 |
-
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
|
| 350 |
-
//
|
| 351 |
if (container) {
|
| 352 |
-
container.style.
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
max-height: \${exactHeight}px !important;
|
| 359 |
-
position: fixed !important;
|
| 360 |
-
top: 0 !important;
|
| 361 |
-
left: 0 !important;
|
| 362 |
-
overflow: hidden !important;
|
| 363 |
-
margin: 0 !important;
|
| 364 |
-
padding: 0 !important;
|
| 365 |
-
border: none !important;
|
| 366 |
-
outline: none !important;
|
| 367 |
-
transform: none !important;
|
| 368 |
-
box-shadow: none !important;
|
| 369 |
-
z-index: 1 !important;
|
| 370 |
-
background-color: \${backgroundColor} !important;
|
| 371 |
-
\`;
|
| 372 |
}
|
| 373 |
|
| 374 |
-
//
|
| 375 |
document.addEventListener('wheel', function(e) {
|
| 376 |
-
if (e.ctrlKey)
|
| 377 |
-
e.preventDefault();
|
| 378 |
-
}
|
| 379 |
}, { passive: false });
|
| 380 |
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
if (e.
|
| 384 |
e.preventDefault();
|
| 385 |
}
|
| 386 |
-
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
|
| 388 |
-
//
|
| 389 |
let lastTouchEnd = 0;
|
| 390 |
document.addEventListener('touchend', function(e) {
|
| 391 |
const now = new Date().getTime();
|
|
@@ -395,84 +338,62 @@ const generateSlideHTML = (pptData, slideIndex, title) => {
|
|
| 395 |
lastTouchEnd = now;
|
| 396 |
}, false);
|
| 397 |
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
e.preventDefault();
|
| 401 |
-
}, false);
|
| 402 |
-
|
| 403 |
-
// 禁用F11全屏
|
| 404 |
-
document.addEventListener('keydown', function(e) {
|
| 405 |
-
if (e.key === 'F11') {
|
| 406 |
e.preventDefault();
|
| 407 |
}
|
| 408 |
-
}, false);
|
| 409 |
-
|
| 410 |
-
console.log('固定尺寸模式样式应用完成,精确尺寸:', exactWidth + 'x' + exactHeight);
|
| 411 |
|
| 412 |
-
//
|
| 413 |
setTimeout(() => {
|
| 414 |
const actualDimensions = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
html: {
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
clientWidth: html.clientWidth,
|
| 419 |
-
clientHeight: html.clientHeight
|
| 420 |
},
|
| 421 |
body: {
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
clientWidth: body.clientWidth,
|
| 425 |
-
clientHeight: body.clientHeight
|
| 426 |
-
},
|
| 427 |
-
container: {
|
| 428 |
-
width: container ? container.offsetWidth : 0,
|
| 429 |
-
height: container ? container.offsetHeight : 0,
|
| 430 |
-
clientWidth: container ? container.clientWidth : 0,
|
| 431 |
-
clientHeight: container ? container.clientHeight : 0
|
| 432 |
},
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
}
|
| 437 |
};
|
| 438 |
|
| 439 |
-
console.log('
|
| 440 |
-
console.log('
|
| 441 |
|
| 442 |
-
//
|
| 443 |
-
const
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
|
| 451 |
-
if (
|
| 452 |
-
console.
|
| 453 |
-
console.warn('HTML尺寸匹配:', htmlSizeMatch);
|
| 454 |
-
console.warn('Body尺寸匹配:', bodySizeMatch);
|
| 455 |
-
console.warn('容器尺寸匹配:', containerSizeMatch);
|
| 456 |
-
|
| 457 |
-
// 尝试强制修正
|
| 458 |
-
if (!htmlSizeMatch) {
|
| 459 |
-
html.style.width = window.PPT_DIMENSIONS.width + 'px';
|
| 460 |
-
html.style.height = window.PPT_DIMENSIONS.height + 'px';
|
| 461 |
-
}
|
| 462 |
-
if (!bodySizeMatch) {
|
| 463 |
-
body.style.width = window.PPT_DIMENSIONS.width + 'px';
|
| 464 |
-
body.style.height = window.PPT_DIMENSIONS.height + 'px';
|
| 465 |
-
}
|
| 466 |
-
if (container && !containerSizeMatch) {
|
| 467 |
-
container.style.width = window.PPT_DIMENSIONS.width + 'px';
|
| 468 |
-
container.style.height = window.PPT_DIMENSIONS.height + 'px';
|
| 469 |
-
}
|
| 470 |
-
|
| 471 |
-
console.log('已尝试强制修正尺寸不一致问题');
|
| 472 |
} else {
|
| 473 |
-
console.
|
| 474 |
}
|
| 475 |
-
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
});
|
| 477 |
</script>
|
| 478 |
</body>
|
|
|
|
| 155 |
<html lang="zh-CN">
|
| 156 |
<head>
|
| 157 |
<meta charset="UTF-8">
|
| 158 |
+
<meta name="viewport" content="width=${pptDimensions.width}, height=${pptDimensions.height}, initial-scale=1.0, user-scalable=no">
|
| 159 |
<title>${title} - 第${slideIndex + 1}页</title>
|
| 160 |
<style>
|
| 161 |
+
/* 完全重置所有默认样式 */
|
| 162 |
+
*, *::before, *::after {
|
| 163 |
margin: 0 !important;
|
| 164 |
padding: 0 !important;
|
| 165 |
+
border: 0 !important;
|
| 166 |
+
outline: 0 !important;
|
| 167 |
box-sizing: border-box !important;
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
+
/* HTML - 设置为PPT精确尺寸,黑色背景 */
|
| 171 |
html {
|
| 172 |
width: ${pptDimensions.width}px !important;
|
| 173 |
height: ${pptDimensions.height}px !important;
|
|
|
|
| 175 |
min-height: ${pptDimensions.height}px !important;
|
| 176 |
max-width: ${pptDimensions.width}px !important;
|
| 177 |
max-height: ${pptDimensions.height}px !important;
|
| 178 |
+
background: #000000 !important;
|
| 179 |
overflow: hidden !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
}
|
| 181 |
|
| 182 |
+
/* Body - 设置为PPT精确尺寸,黑色背景 */
|
| 183 |
body {
|
| 184 |
width: ${pptDimensions.width}px !important;
|
| 185 |
height: ${pptDimensions.height}px !important;
|
|
|
|
| 187 |
min-height: ${pptDimensions.height}px !important;
|
| 188 |
max-width: ${pptDimensions.width}px !important;
|
| 189 |
max-height: ${pptDimensions.height}px !important;
|
| 190 |
+
background: #000000 !important;
|
| 191 |
overflow: hidden !important;
|
| 192 |
font-family: 'Microsoft YaHei', Arial, sans-serif !important;
|
| 193 |
+
position: relative !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
}
|
| 195 |
|
| 196 |
+
/* PPT容器 - 完全填充整个页面 */
|
| 197 |
.slide-container {
|
| 198 |
width: ${pptDimensions.width}px !important;
|
| 199 |
height: ${pptDimensions.height}px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
background-color: ${slide.background?.color || theme.backgroundColor || '#ffffff'} !important;
|
| 201 |
+
position: absolute !important;
|
| 202 |
top: 0 !important;
|
| 203 |
left: 0 !important;
|
| 204 |
overflow: hidden !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
z-index: 1 !important;
|
| 206 |
}
|
| 207 |
|
|
|
|
| 223 |
` : ''}
|
| 224 |
|
| 225 |
/* 隐藏所有滚动条 */
|
| 226 |
+
::-webkit-scrollbar {
|
|
|
|
|
|
|
| 227 |
display: none !important;
|
|
|
|
|
|
|
| 228 |
}
|
| 229 |
|
|
|
|
| 230 |
html {
|
| 231 |
scrollbar-width: none !important;
|
| 232 |
+
-ms-overflow-style: none !important;
|
| 233 |
}
|
| 234 |
|
| 235 |
+
/* 禁用用户交互 */
|
| 236 |
* {
|
| 237 |
-webkit-user-select: none !important;
|
| 238 |
-moz-user-select: none !important;
|
|
|
|
| 245 |
user-drag: none !important;
|
| 246 |
}
|
| 247 |
|
| 248 |
+
/* 禁用缩放 */
|
| 249 |
body {
|
| 250 |
zoom: 1 !important;
|
| 251 |
-webkit-text-size-adjust: 100% !important;
|
| 252 |
-ms-text-size-adjust: 100% !important;
|
| 253 |
+
transform: none !important;
|
| 254 |
+
transform-origin: top left !important;
|
| 255 |
}
|
| 256 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
</head>
|
| 258 |
<body>
|
| 259 |
<div class="slide-container" id="slideContainer">
|
|
|
|
| 261 |
</div>
|
| 262 |
|
| 263 |
<script>
|
| 264 |
+
// PPT尺寸信息
|
| 265 |
+
window.PPT_DIMENSIONS = {
|
| 266 |
+
width: ${pptDimensions.width},
|
| 267 |
+
height: ${pptDimensions.height}
|
| 268 |
+
};
|
| 269 |
+
|
| 270 |
+
console.log('PPT页面初始化 - 精确尺寸模式:', window.PPT_DIMENSIONS);
|
| 271 |
+
|
| 272 |
+
// 确保页面加载完成后强制设置尺寸
|
| 273 |
window.addEventListener('load', function() {
|
|
|
|
| 274 |
const html = document.documentElement;
|
| 275 |
const body = document.body;
|
| 276 |
+
const container = document.getElementById('slideContainer');
|
| 277 |
|
| 278 |
+
const targetWidth = ${pptDimensions.width};
|
| 279 |
+
const targetHeight = ${pptDimensions.height};
|
|
|
|
|
|
|
| 280 |
|
| 281 |
+
console.log('强制设置精确尺寸:', targetWidth + 'x' + targetHeight);
|
| 282 |
|
| 283 |
+
// 强制设置HTML尺寸
|
| 284 |
+
html.style.width = targetWidth + 'px';
|
| 285 |
+
html.style.height = targetHeight + 'px';
|
| 286 |
+
html.style.minWidth = targetWidth + 'px';
|
| 287 |
+
html.style.minHeight = targetHeight + 'px';
|
| 288 |
+
html.style.maxWidth = targetWidth + 'px';
|
| 289 |
+
html.style.maxHeight = targetHeight + 'px';
|
| 290 |
+
html.style.overflow = 'hidden';
|
| 291 |
+
html.style.background = '#000000';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
|
| 293 |
+
// 强制设置Body尺寸
|
| 294 |
+
body.style.width = targetWidth + 'px';
|
| 295 |
+
body.style.height = targetHeight + 'px';
|
| 296 |
+
body.style.minWidth = targetWidth + 'px';
|
| 297 |
+
body.style.minHeight = targetHeight + 'px';
|
| 298 |
+
body.style.maxWidth = targetWidth + 'px';
|
| 299 |
+
body.style.maxHeight = targetHeight + 'px';
|
| 300 |
+
body.style.overflow = 'hidden';
|
| 301 |
+
body.style.background = '#000000';
|
| 302 |
+
body.style.margin = '0';
|
| 303 |
+
body.style.padding = '0';
|
| 304 |
|
| 305 |
+
// 强制设置容器尺寸
|
| 306 |
if (container) {
|
| 307 |
+
container.style.width = targetWidth + 'px';
|
| 308 |
+
container.style.height = targetHeight + 'px';
|
| 309 |
+
container.style.position = 'absolute';
|
| 310 |
+
container.style.top = '0';
|
| 311 |
+
container.style.left = '0';
|
| 312 |
+
container.style.overflow = 'hidden';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
}
|
| 314 |
|
| 315 |
+
// 禁用各种缩放和调整
|
| 316 |
document.addEventListener('wheel', function(e) {
|
| 317 |
+
if (e.ctrlKey) e.preventDefault();
|
|
|
|
|
|
|
| 318 |
}, { passive: false });
|
| 319 |
|
| 320 |
+
document.addEventListener('keydown', function(e) {
|
| 321 |
+
// 禁用Ctrl+滚轮缩放、F11全屏等
|
| 322 |
+
if ((e.ctrlKey && (e.key === '+' || e.key === '-' || e.key === '0')) || e.key === 'F11') {
|
| 323 |
e.preventDefault();
|
| 324 |
}
|
| 325 |
+
}, false);
|
| 326 |
+
|
| 327 |
+
document.addEventListener('contextmenu', function(e) {
|
| 328 |
+
e.preventDefault();
|
| 329 |
+
}, false);
|
| 330 |
|
| 331 |
+
// 禁用触摸缩放
|
| 332 |
let lastTouchEnd = 0;
|
| 333 |
document.addEventListener('touchend', function(e) {
|
| 334 |
const now = new Date().getTime();
|
|
|
|
| 338 |
lastTouchEnd = now;
|
| 339 |
}, false);
|
| 340 |
|
| 341 |
+
document.addEventListener('touchstart', function(e) {
|
| 342 |
+
if (e.touches.length > 1) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
e.preventDefault();
|
| 344 |
}
|
| 345 |
+
}, { passive: false });
|
|
|
|
|
|
|
| 346 |
|
| 347 |
+
// 验证最终尺寸
|
| 348 |
setTimeout(() => {
|
| 349 |
const actualDimensions = {
|
| 350 |
+
window: {
|
| 351 |
+
innerWidth: window.innerWidth,
|
| 352 |
+
innerHeight: window.innerHeight
|
| 353 |
+
},
|
| 354 |
html: {
|
| 355 |
+
offsetWidth: html.offsetWidth,
|
| 356 |
+
offsetHeight: html.offsetHeight
|
|
|
|
|
|
|
| 357 |
},
|
| 358 |
body: {
|
| 359 |
+
offsetWidth: body.offsetWidth,
|
| 360 |
+
offsetHeight: body.offsetHeight
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
},
|
| 362 |
+
container: container ? {
|
| 363 |
+
offsetWidth: container.offsetWidth,
|
| 364 |
+
offsetHeight: container.offsetHeight
|
| 365 |
+
} : null
|
| 366 |
};
|
| 367 |
|
| 368 |
+
console.log('最终尺寸验证:', actualDimensions);
|
| 369 |
+
console.log('目标尺寸:', window.PPT_DIMENSIONS);
|
| 370 |
|
| 371 |
+
// 检查是否达到目标尺寸
|
| 372 |
+
const isCorrectSize =
|
| 373 |
+
actualDimensions.window.innerWidth === targetWidth &&
|
| 374 |
+
actualDimensions.window.innerHeight === targetHeight &&
|
| 375 |
+
actualDimensions.html.offsetWidth === targetWidth &&
|
| 376 |
+
actualDimensions.html.offsetHeight === targetHeight &&
|
| 377 |
+
actualDimensions.body.offsetWidth === targetWidth &&
|
| 378 |
+
actualDimensions.body.offsetHeight === targetHeight;
|
| 379 |
|
| 380 |
+
if (isCorrectSize) {
|
| 381 |
+
console.log('✅ 页面尺寸完全正确,网页窗口与PPT尺寸一致');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
} else {
|
| 383 |
+
console.warn('⚠️ 页面尺寸不完全匹配,可能存在浏览器限制');
|
| 384 |
}
|
| 385 |
+
}, 200);
|
| 386 |
+
});
|
| 387 |
+
|
| 388 |
+
// 监听窗口大小变化,防止用户调整
|
| 389 |
+
window.addEventListener('resize', function() {
|
| 390 |
+
const targetWidth = ${pptDimensions.width};
|
| 391 |
+
const targetHeight = ${pptDimensions.height};
|
| 392 |
+
|
| 393 |
+
if (window.innerWidth !== targetWidth || window.innerHeight !== targetHeight) {
|
| 394 |
+
console.log('检测到窗口大小变化,尝试恢复原始尺寸');
|
| 395 |
+
// 注意:无法通过JavaScript强制调整浏览器窗口大小,只能设置内容尺寸
|
| 396 |
+
}
|
| 397 |
});
|
| 398 |
</script>
|
| 399 |
</body>
|