Files
Electron_x64_x32/verify-icon.js
2025-12-02 17:41:15 +08:00

43 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const fs = require('fs');
const path = require('path');
console.log('========================================');
console.log('验证图标文件');
console.log('========================================\n');
const iconPath = path.join(__dirname, 'build', 'icon.ico');
// 检查文件是否存在
if (!fs.existsSync(iconPath)) {
console.error('[错误] 图标文件不存在:', iconPath);
console.log('\n请确保:');
console.log('1. build 文件夹存在');
console.log('2. icon.ico 文件在 build 文件夹中');
process.exit(1);
}
// 获取文件信息
const stats = fs.statSync(iconPath);
console.log('[OK] 图标文件存在');
console.log('路径:', iconPath);
console.log('大小:', stats.size, '字节');
// 检查文件内容ICO 文件头)
const buffer = Buffer.alloc(4);
const fd = fs.openSync(iconPath, 'r');
fs.readSync(fd, buffer, 0, 4, 0);
fs.closeSync(fd);
// ICO 文件头应该是 00 00 01 00
if (buffer[0] === 0x00 && buffer[1] === 0x00 &&
buffer[2] === 0x01 && buffer[3] === 0x00) {
console.log('[OK] 文件格式正确ICO');
} else {
console.error('[警告] 文件可能不是标准的 ICO 格式');
console.log('文件头:', buffer.toString('hex'));
}
console.log('\n========================================');
console.log('验证完成!');
console.log('========================================');