Files
PlantAI-rag-new/desktop/settings.html
T

77 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>后端地址设置</title>
<style>
:root { color-scheme: dark; }
body {
margin: 0;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
background: #0f1115;
color: #e6e8eb;
font-size: 14px;
user-select: none;
}
h1 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
p.desc { color: #9aa0a6; margin: 0 0 14px; font-size: 12px; line-height: 1.5; }
input {
width: 100%;
box-sizing: border-box;
padding: 9px 10px;
font-size: 13px;
color: #e6e8eb;
background: #1a1d23;
border: 1px solid #2a2f38;
border-radius: 6px;
outline: none;
}
input:focus { border-color: #3b82f6; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
button {
padding: 7px 16px;
font-size: 13px;
border-radius: 6px;
border: 1px solid #2a2f38;
cursor: pointer;
background: #1a1d23;
color: #e6e8eb;
}
button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
button:hover { filter: brightness(1.1); }
p.hint { color: #9aa0a6; font-size: 12px; margin: 10px 0 0; min-height: 16px; }
</style>
</head>
<body>
<h1>后端地址</h1>
<p class="desc">PlantAI 后端(BFF)地址,例如 http://127.0.0.1:8090。保存后立即重载页面。</p>
<input id="url" type="text" placeholder="http://127.0.0.1:8090" spellcheck="false">
<div class="actions">
<button id="cancel">取消</button>
<button id="save" class="primary">保存</button>
</div>
<p id="hint" class="hint"></p>
<script>
const input = document.getElementById('url');
const hint = document.getElementById('hint');
window.desktopApi.getBackendUrl().then((url) => { input.value = url || ''; });
document.getElementById('save').addEventListener('click', async () => {
const url = input.value.trim();
if (!url) { hint.textContent = '地址不能为空'; return; }
try {
await window.desktopApi.setBackendUrl(url);
window.close();
} catch (e) {
hint.textContent = '保存失败:' + (e && e.message ? e.message : e);
}
});
document.getElementById('cancel').addEventListener('click', () => window.close());
</script>
</body>
</html>