diff --git a/public/index.html b/public/index.html
index 785ff15..59e181a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -100,7 +100,6 @@
}
async function setup() {
- // 检查是否已有 key
const savedKey = localStorage.getItem('myoss_api_key');
if (savedKey) {
apiKey = savedKey;
@@ -108,20 +107,19 @@
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', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ name })
+ body: JSON.stringify({ password, name })
});
const data = await res.json();
if (data.error) {
- // 已初始化过,提示用户输入已有 key
- const key = prompt('服务已初始化,请输入已有的 API Key:');
- if (key) {
- localStorage.setItem('myoss_api_key', key);
- location.reload();
- }
+ alert(data.error);
return;
}
apiKey = data.key;