Files
membank/.trae/skills/image-tools/scripts/convert-html-to-png.js
12600k-rog-d4 90d5c516c9 修复P0系统性价格错误:配件价格调整及SKU配置更新
1. 配件清单更新:
   - 新增3217U CPU价格定义:¥55(i3-2代)
   - 新增5005U CPU价格定义:¥150(i3-5代)
   - 确认3855U正确价格:¥80

2. SKU价格修正(D3-4G/8G、mSATA-32G/64G):
   - D3-4G: ¥38 → ¥25
   - D3-8G: ¥120 → ¥75
   - mSATA-32G: ¥25 → ¥20
   - mSATA-64G: ¥45 → ¥40

3. CPU价格修正:
   - 3217U: ¥65 → ¥55
   - 5005U: ¥80 → ¥150
   - 3855U: ¥75 → ¥80

4. Linux主机SKU更新:
   - 仅保留2G-16G配置
   - 3855U CPU价格修正

5. 修复文件统计:
   - fys亚克力-双:12个SKU
   - fjx金属3.5寸小:24个SKU
   - fjd金属3.5寸大:24个SKU
   - 龙虾盒子:6个SKU
   - 挂机宝:24个SKU
   - win10小主机:24个SKU
   - 总计:102+个文件
2026-04-23 00:23:11 +08:00

59 lines
1.8 KiB
JavaScript

const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
async function convertHtmlToPng() {
console.log('🚀 启动 HTML 转 PNG 转换工具...\n');
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 1000, height: 1000 });
const detailDir = 'G:\\stonelan-workspace\\membank\\产品\\Linux主机\\详情';
const htmlFiles = fs.readdirSync(detailDir)
.filter(file => file.endsWith('.html'));
console.log(`📁 找到 ${htmlFiles.length} 个 HTML 文件需要转换\n`);
for (const htmlFile of htmlFiles) {
try {
const htmlPath = path.join(detailDir, htmlFile);
const pngFile = htmlFile.replace('.html', '.png');
const pngPath = path.join(detailDir, pngFile);
console.log(`📄 正在转换: ${htmlFile}`);
const fileUrl = `file:///${htmlPath.replace(/\\/g, '/')}`;
await page.goto(fileUrl, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.screenshot({
path: pngPath,
fullPage: true,
type: 'png'
});
console.log(`✅ 已生成: ${pngFile}\n`);
} catch (error) {
console.error(`❌ 转换失败 ${htmlFile}: ${error.message}\n`);
}
}
await browser.close();
console.log('✨ 所有转换任务已完成!');
}
convertHtmlToPng().catch(error => {
console.error('💥 转换过程出错:', error);
process.exit(1);
});