diff --git a/.gitignore b/.gitignore index ec4bf75..39a853c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ skills/deps/ skills/*/.deps_installed *.log .DS_Store +app/server/version.json diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index b31231c..f6de75f 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -48,13 +48,6 @@ body { #files-panel .icon-btn, .files-panel-header .icon-btn { color: #555; } #files-panel .icon-btn:active { background: #eee; } -.version { - text-align: center; - font-size: 12px; - color: #aaa; - margin-top: 16px; -} - /* ---- 模型池条已随 2.0 任务页改版移除 ---- */ /* ---- 会话列表 ---- */ @@ -324,17 +317,10 @@ body { .model-card-state.busy { background: #fdecea; color: #b3382c; } /* 配置已加但还没重启进运行池 */ .model-card-state.pending { background: #fff4dc; color: #a06a00; } -.model-card-right { display: flex; align-items: center; gap: 4px; } -.model-edit-ico { - background: none; border: none; cursor: pointer; padding: 5px; border-radius: 8px; -} -.model-edit-ico svg { - width: 17px; height: 17px; stroke: #7f8db0; fill: none; - stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; -} -.model-edit-ico:active { background: #eef0f6; } +/* 点模型名打开编辑弹窗 */ +.model-card-name { cursor: pointer; } +.model-card-name:active { opacity: 0.55; } .model-card-meta { font-size: 12px; color: #888; margin-top: 4px; } -.model-card-foot { display: flex; justify-content: flex-end; gap: 14px; margin-top: 6px; } /* ---- 设置页行 ---- */ .settings-row { diff --git a/app/server/public/index.html b/app/server/public/index.html index b6fa9f9..dab9cf5 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -277,10 +277,10 @@ - - - - - + + + + + diff --git a/app/server/public/js/models.js b/app/server/public/js/models.js index c0aa9e4..a0cbadc 100644 --- a/app/server/public/js/models.js +++ b/app/server/public/js/models.js @@ -30,12 +30,8 @@ async function loadModelCards() { : '待重启'; return '
' + '
' + - '' + esc(m.display_name || m.id) + '' + - '' + stateHtml + - '' + - '' + + '' + esc(m.display_name || m.id) + '' + + stateHtml + '
' + '
' + esc(m.id) + (run && run.is_busy && run.current_session_id ? ' · 会话 ' + esc(run.current_session_id) : '') + '
' + diff --git a/app/server/public/js/settings.js b/app/server/public/js/settings.js index be352ec..e8b0bbe 100644 --- a/app/server/public/js/settings.js +++ b/app/server/public/js/settings.js @@ -60,7 +60,7 @@ function kvPlain(label, v) { function svcCard(st) { let html = '

服务状态' + (pendingKeys.size ? ' 待重启生效' : '') + '

'; - html += kvPlain('版本 / Node', st.version + ' / ' + st.node); + html += kvPlain('版本 / Node', st.version + (st.version_date ? '(' + st.version_date + ')' : '') + ' / ' + st.node); html += kvPlain('已运行', fmtUptime(st.uptime_ms) + '(启动于 ' + new Date(st.started_at).toLocaleString() + ')'); html += kvPlain('端口', st.port); html += kvPlain('配置文件', st.config_path); @@ -90,8 +90,8 @@ function formCard() { html += g.items.map(cfgInput).join(''); html += '
'; } - html += '' + - '
保存即写入 config.yml(注释保留);多数配置需重启服务后生效。' + + html += '' + + '
更新即写入 config.yml(注释保留);多数配置需重启服务后生效。' + '模型、账号、MCP 等请用右上角配置文件编辑。
'; return html; } @@ -221,6 +221,8 @@ async function saveCfgEditor() { cfgOrig = text; (r.changed || []).forEach(k => pendingKeys.add(k)); toast('配置已保存'); + $('cfg-editor').classList.add('hidden'); + loadSettings(); // 保存成功直接退出编辑页 } catch (e) { errEl.textContent = '校验失败:' + e.message; errEl.classList.remove('hidden'); diff --git a/app/server/public/js/skills.js b/app/server/public/js/skills.js index b15472c..82a932e 100644 --- a/app/server/public/js/skills.js +++ b/app/server/public/js/skills.js @@ -77,7 +77,7 @@ async function loadSkillDetail() { '' + esc(f.filename) + '' + '' + fmtSize(f.size) + '' + '' + - '' + + '' + '
'; }).join('') + '
' + newBtn; } catch (e) { @@ -163,6 +163,10 @@ async function saveSkillFile() { await req('PUT', '/api/skills/' + encodeURIComponent(curSkill) + '/file', { path: editorPath, content }); editorOrig = content; toast('已保存 ' + editorPath); + // 保存成功直接退出编辑页回文件列表 + editorPath = null; + setSkillsView('detail'); + loadSkillDetail(); } catch (e) { toast('保存失败:' + e.message); } } diff --git a/app/server/public/login.html b/app/server/public/login.html index 9e6c711..8cabac5 100644 --- a/app/server/public/login.html +++ b/app/server/public/login.html @@ -33,7 +33,6 @@ -
v1.0.1-260831

diff --git a/app/server/routes/system.js b/app/server/routes/system.js index 82b009d..398d7c5 100644 --- a/app/server/routes/system.js +++ b/app/server/routes/system.js @@ -5,12 +5,15 @@ const express = require('express'); const engine = require('../engine'); const { loadConfig } = require('../config'); +const versionInfo = require('../version'); const router = express.Router(); const STARTED_AT = Date.now(); let VERSION = '2.0.0'; try { VERSION = require('../../package.json').version || VERSION; } catch (_) {} +// 附带 git 提交号(post-commit 钩子自动生成),免去手动改版本号 +if (versionInfo.commit) VERSION += '+' + versionInfo.commit; function sendErr(res, err) { const code = err && err.status_code || 500; @@ -28,6 +31,7 @@ router.get('/status', wrap((req, res) => { res.json({ ok: true, version: VERSION, + version_date: versionInfo.date, pid: process.pid, node: process.version, started_at: STARTED_AT, diff --git a/app/server/version.js b/app/server/version.js new file mode 100644 index 0000000..f0841ce --- /dev/null +++ b/app/server/version.js @@ -0,0 +1,23 @@ +// 版本信息:package.json 版本 + git 提交号(提交时自动生成,免维护)。 +// 提交号来源:优先 .git/hooks/post-commit 写入的本目录 version.json +// (./app/server 为容器挂载卷,钩子写在宿主机、容器内直接可见); +// 宿主机直接跑 node 且无 json 时回退 git rev-parse。都拿不到则只显示 package 版本。 +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +function readVersionJson() { + try { return JSON.parse(fs.readFileSync(path.join(__dirname, 'version.json'), 'utf8')) || {}; } catch (_) { return {}; } +} +function gitInfo() { + const opts = { cwd: path.join(__dirname, '..', '..'), stdio: ['ignore', 'pipe', 'ignore'], timeout: 2000 }; + try { + return { + commit: execSync('git rev-parse --short HEAD', opts).toString().trim(), + date: execSync('git log -1 --format=%cd --date=format:%Y-%m-%d\\ %H:%M', opts).toString().trim(), + }; + } catch (_) { return {}; } // 容器内无 git/无 .git 属正常 +} + +const info = Object.assign(gitInfo(), readVersionJson()); +module.exports = { commit: String(info.commit || ''), date: String(info.date || '') };