fix: 管理页面添加密码输入提示

This commit is contained in:
Cuishibing
2026-04-26 12:55:28 +08:00
parent e53a674bff
commit f8fbd290c7

View File

@@ -100,7 +100,6 @@
} }
async function setup() { async function setup() {
// 检查是否已有 key
const savedKey = localStorage.getItem('myoss_api_key'); const savedKey = localStorage.getItem('myoss_api_key');
if (savedKey) { if (savedKey) {
apiKey = savedKey; apiKey = savedKey;
@@ -108,20 +107,19 @@
return; return;
} }
const name = document.getElementById('setup-name').value; // 检查是否已有 key
const password = prompt('请输入管理员密码:');
if (!password) return;
const name = document.getElementById('setup-name').value || 'root';
const res = await fetch('/api/keys/bootstrap', { const res = await fetch('/api/keys/bootstrap', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name }) body: JSON.stringify({ password, name })
}); });
const data = await res.json(); const data = await res.json();
if (data.error) { if (data.error) {
// 已初始化过,提示用户输入已有 key alert(data.error);
const key = prompt('服务已初始化,请输入已有的 API Key:');
if (key) {
localStorage.setItem('myoss_api_key', key);
location.reload();
}
return; return;
} }
apiKey = data.key; apiKey = data.key;