Upload screenshotService.js
Browse files
backend/src/services/screenshotService.js
CHANGED
@@ -3,6 +3,7 @@ import playwright from 'playwright';
|
|
3 |
import fs from 'fs';
|
4 |
import path from 'path';
|
5 |
import { fileURLToPath } from 'url';
|
|
|
6 |
|
7 |
// 获取当前文件的目录路径
|
8 |
const __filename = fileURLToPath(import.meta.url);
|
@@ -474,7 +475,6 @@ class ScreenshotService {
|
|
474 |
generateCacheKey(htmlContent, options) {
|
475 |
const { format, quality, width, height } = options;
|
476 |
// 使用内容和选项的哈希作为缓存键
|
477 |
-
const crypto = require('crypto');
|
478 |
const contentHash = crypto.createHash('md5').update(htmlContent).digest('hex').substring(0, 8);
|
479 |
return `${contentHash}_${width}x${height}_${format}_${quality}`;
|
480 |
}
|
|
|
3 |
import fs from 'fs';
|
4 |
import path from 'path';
|
5 |
import { fileURLToPath } from 'url';
|
6 |
+
import crypto from 'crypto';
|
7 |
|
8 |
// 获取当前文件的目录路径
|
9 |
const __filename = fileURLToPath(import.meta.url);
|
|
|
475 |
generateCacheKey(htmlContent, options) {
|
476 |
const { format, quality, width, height } = options;
|
477 |
// 使用内容和选项的哈希作为缓存键
|
|
|
478 |
const contentHash = crypto.createHash('md5').update(htmlContent).digest('hex').substring(0, 8);
|
479 |
return `${contentHash}_${width}x${height}_${format}_${quality}`;
|
480 |
}
|