Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export async function onRequest(context) {
}
html = html.replace('window.__ENV__.PASSWORD = "{{PASSWORD}}";',
`window.__ENV__.PASSWORD = "${passwordHash}";`);

// 移除 ADMINPASSWORD 占位符
html = html.replace('window.__ENV__.ADMINPASSWORD = "{{ADMINPASSWORD}}";',
'window.__ENV__.ADMINPASSWORD = "";');

return new Response(html, {
headers: response.headers,
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ <h2 class="text-2xl font-bold gradient-text mb-6 text-center">使用声明</h2>
// 注入服务器端环境变量 (将由服务器端替换)
// PASSWORD 变量将在这里被服务器端注入
window.__ENV__.PASSWORD = "{{PASSWORD}}";
window.__ENV__.ADMINPASSWORD = "{{ADMINPASSWORD}}";
</script>

<!-- 版本检测脚本 -->
Expand Down
13 changes: 4 additions & 9 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ export default async function middleware(request) {
}

// 替换密码占位符
let modifiedHtml = originalHtml
.replace(
'window.__ENV__.PASSWORD = "{{PASSWORD}}";',
`window.__ENV__.PASSWORD = "${passwordHash}"; // SHA-256 hash`
)
.replace(
'window.__ENV__.ADMINPASSWORD = "{{ADMINPASSWORD}}";',
'window.__ENV__.ADMINPASSWORD = ""; // ADMINPASSWORD 功能已移除'
);
let modifiedHtml = originalHtml.replace(
'window.__ENV__.PASSWORD = "{{PASSWORD}}";',
`window.__ENV__.PASSWORD = "${passwordHash}"; // SHA-256 hash`
);

// 修复Response构造
return new Response(modifiedHtml, {
Expand Down
13 changes: 4 additions & 9 deletions netlify/edge-functions/inject-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ export default async (request, context) => {
passwordHash = await sha256(password);
}

const modifiedHtml = originalHtml
.replace(
'window.__ENV__.PASSWORD = "{{PASSWORD}}";',
`window.__ENV__.PASSWORD = "${passwordHash}"; // SHA-256 hash`
)
.replace(
'window.__ENV__.ADMINPASSWORD = "{{ADMINPASSWORD}}";',
'window.__ENV__.ADMINPASSWORD = ""; // ADMINPASSWORD 功能已移除'
);
const modifiedHtml = originalHtml.replace(
'window.__ENV__.PASSWORD = "{{PASSWORD}}";',
`window.__ENV__.PASSWORD = "${passwordHash}"; // SHA-256 hash`
);

// Create a new response with the modified HTML
return new Response(modifiedHtml, {
Expand Down
1 change: 0 additions & 1 deletion player.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ <h2 id="modalTitle" class="text-2xl font-bold gradient-text break-words pr-4 max
// 注入服务器端环境变量 (将由服务器端替换)
// PASSWORD 变量将在这里被服务器端注入
window.__ENV__.PASSWORD = "{{PASSWORD}}";
window.__ENV__.ADMINPASSWORD = "{{ADMINPASSWORD}}";

// 修复 home 跳转
document.addEventListener('DOMContentLoaded', function() {
Expand Down
2 changes: 0 additions & 2 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ async function renderPage(filePath, password) {
} else {
content = content.replace('{{PASSWORD}}', '');
}
// 移除 ADMINPASSWORD 占位符
content = content.replace('{{ADMINPASSWORD}}', '');
return content;
}

Expand Down
Loading