diff --git a/generate-encrypted.js b/generate-encrypted.js index 4c08870..30d4927 100644 --- a/generate-encrypted.js +++ b/generate-encrypted.js @@ -11,9 +11,11 @@ const encrypted = CryptoJS.AES.encrypt(originalHtml, password).toString(); // 读取模板 let template = fs.readFileSync('nav-home-encrypted.html', 'utf8'); -// 替换占位符 -template = template.replace('const ENCRYPTED_CONTENT = "ENCRYPTED_PLACEHOLDER";', - `const ENCRYPTED_CONTENT = "${encrypted}";`); +// 使用正则替换已有的加密内容(匹配 const ENCRYPTED_CONTENT = "..." 格式) +template = template.replace( + /const ENCRYPTED_CONTENT = "[^"]*";/, + `const ENCRYPTED_CONTENT = "${encrypted}";` +); // 写入最终文件 fs.writeFileSync('nav-home-encrypted.html', template); diff --git a/nav-home-encrypted.html b/nav-home-encrypted.html index 58eefeb..b9262dc 100644 --- a/nav-home-encrypted.html +++ b/nav-home-encrypted.html @@ -170,7 +170,7 @@