添加PWA支持,更新配置文件以集成next-pwa,新增相关文件到.gitignore,优化layout和page组件以支持PWA功能,提升用户体验。

This commit is contained in:
zihanjian
2025-06-23 15:44:00 +08:00
parent d79c2c4b88
commit f5ce1df803
19 changed files with 5227 additions and 214 deletions

33
scripts/generate-cert.js Normal file
View File

@@ -0,0 +1,33 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const certDir = path.join(__dirname, '..', 'certificates');
// 创建证书目录
if (!fs.existsSync(certDir)) {
fs.mkdirSync(certDir);
}
console.log('生成本地 HTTPS 证书...');
try {
// 生成私钥
execSync(`openssl genrsa -out ${certDir}/localhost-key.pem 2048`);
// 生成证书请求
execSync(`openssl req -new -key ${certDir}/localhost-key.pem -out ${certDir}/localhost.csr -subj "/C=CN/ST=Beijing/L=Beijing/O=Dev/CN=localhost"`);
// 生成自签名证书
execSync(`openssl x509 -req -in ${certDir}/localhost.csr -signkey ${certDir}/localhost-key.pem -out ${certDir}/localhost.pem -days 365`);
console.log('证书生成成功!');
console.log(`证书位置: ${certDir}/localhost.pem`);
console.log(`私钥位置: ${certDir}/localhost-key.pem`);
// 清理 CSR 文件
fs.unlinkSync(`${certDir}/localhost.csr`);
} catch (error) {
console.error('生成证书失败:', error.message);
process.exit(1);
}