auto-save 2026-05-11 16:03 (~5)

This commit is contained in:
2026-05-11 16:03:46 +08:00
parent 8f80417462
commit 0b4d811b2f
5 changed files with 37 additions and 24 deletions

View File

@@ -144,16 +144,28 @@ function ensureModelChoice(modelValue, labelValue = "") {
}
}
function syncModelPick(modelValue) {
function updateModelDisplay(modelValue, providerValue = "") {
const model = (modelValue || state.model || DEFAULT_MODEL_ID).trim();
const provider = (providerValue || "").trim();
const pick = document.getElementById("modelPick");
const option = pick ? Array.from(pick.options).find(item => item.value === model) : null;
const label = option?.textContent || model;
const stat = document.getElementById("statModel");
const statSub = document.getElementById("statModelSub");
const aboutModel = document.getElementById("aboutModelValue");
if (stat) stat.textContent = label;
if (statSub) statSub.textContent = provider ? "Provider: " + provider : "Provider 以设置为准";
if (aboutModel) aboutModel.textContent = provider ? model + " · " + provider : model;
}
function syncModelPick(modelValue, providerValue = "") {
const model = (modelValue || state.model || "").trim();
const pick = document.getElementById("modelPick");
if (!pick || !model) return;
ensureModelChoice(model);
let option = Array.from(pick.options).find(item => item.value === model);
pick.value = model;
state.model = model;
const stat = document.getElementById("statModel");
if (stat) stat.textContent = option.textContent || model;
updateModelDisplay(model, providerValue);
}
// ---------- 会话持久化 ----------
@@ -657,7 +669,8 @@ async function refreshHermesConfig(force = false) {
},
mcp_servers_yaml: config.mcp_servers_yaml || "",
};
if (model.default) syncModelPick(model.default);
if (model.default) syncModelPick(model.default, model.provider || "");
else updateModelDisplay(state.model, model.provider || "");
_hermesConfigLoaded = true;
const suffix = config.lxc ? " · " + config.lxc : "";
setHermesModelStatus("已读取模型配置" + suffix);
@@ -721,7 +734,7 @@ async function saveModelConfig() {
restart: true,
});
const savedModel = saved.model || {};
if (savedModel.default) syncModelPick(savedModel.default);
if (savedModel.default) syncModelPick(savedModel.default, savedModel.provider || model.provider || "");
_hermesConfigSnapshot = {
model: {
default: savedModel.default || model.default,
@@ -770,7 +783,7 @@ async function saveMcpConfig() {
restart: true,
});
const savedModel = saved.model || model;
if (savedModel.default) syncModelPick(savedModel.default);
if (savedModel.default) syncModelPick(savedModel.default, savedModel.provider || model.provider || "");
document.getElementById("mcpServersYaml").value = saved.mcp_servers_yaml || "";
_hermesConfigSnapshot = {
model: {
@@ -1041,7 +1054,7 @@ function renderChat(streaming = false) {
<span class="wh-mid">PARIS</span>
</div>
<div class="welcome-title">${greet},今天想聊点什么?</div>
<div class="welcome-sub">由 Gemini 3 Pro 驱动 · 你的私人 AI 助手</div>
<div class="welcome-sub">由当前 AI 模型驱动 · 你的私人 AI 助手</div>
<div class="welcome-chips">
<span class="chip" data-p="帮我规划今晚三道菜的晚餐">🍽 今晚吃什么</span>
<span class="chip" data-p="用通俗语言解释 MCP 协议">💡 解释一个概念</span>

View File

@@ -11,7 +11,7 @@
<link rel="icon" type="image/svg+xml" href="./icon.svg">
<link rel="apple-touch-icon" href="./icon.svg">
<title>爱马仕 · AI</title>
<link rel="stylesheet" href="./styles.css?v=20260511-settings-v29">
<link rel="stylesheet" href="./styles.css?v=20260511-settings-v30">
</head>
<body>
@@ -952,8 +952,8 @@ git push # Gitea kangwan/hermes-glass-ui-personal
</div>
<div class="stat-body">
<div class="stat-label">当前模型</div>
<div class="stat-value" id="statModel">Gemini 3 Pro</div>
<div class="stat-sub">Google AI Studio</div>
<div class="stat-value" id="statModel">google/gemini-3.1-pro-preview</div>
<div class="stat-sub" id="statModelSub">Provider 以设置为准</div>
</div>
</div>
<div class="stat stat-lg">
@@ -1385,7 +1385,7 @@ git push # Gitea kangwan/hermes-glass-ui-personal
</div>
<div class="about-item">
<div class="about-lbl">模型</div>
<div class="about-val">Gemini 3 Pro · Google AI Studio</div>
<div class="about-val" id="aboutModelValue">AI 模型接入配置为准</div>
</div>
<div class="about-item">
<div class="about-lbl">代理</div>
@@ -1408,6 +1408,6 @@ git push # Gitea kangwan/hermes-glass-ui-personal
</main>
</div>
<script src="./app.js?v=20260511-settings-v29"></script>
<script src="./app.js?v=20260511-settings-v30"></script>
</body>
</html>

View File

@@ -1,11 +1,11 @@
// 爱马仕 Hermes · 轻量 Service Worker
// 静态壳走 network-first拿不到再回退缓存API 直通
const CACHE = "hermes-ui-v29";
const CACHE = "hermes-ui-v30";
const ASSETS = [
"./",
"./index.html",
"./styles.css?v=20260511-settings-v29",
"./app.js?v=20260511-settings-v29",
"./styles.css?v=20260511-settings-v30",
"./app.js?v=20260511-settings-v30",
"./manifest.webmanifest",
"./icon.svg",
];