添加PWA支持,更新配置文件以集成next-pwa,新增相关文件到.gitignore,优化layout和page组件以支持PWA功能,提升用户体验。
This commit is contained in:
33
scripts/generate-cert.js
Normal file
33
scripts/generate-cert.js
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user