fix: 管理页面添加密码输入提示
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user