2.0阶段5调整5: 保存配置改称更新配置;技能文件删按钮改删除;编辑器保存成功即返回列表;模型名点击弹窗去编辑图标;login去版本号;版本号由post-commit钩子自动写入version.json(显示package版本+git提交号)
This commit is contained in:
@@ -10,3 +10,4 @@ skills/deps/
|
|||||||
skills/*/.deps_installed
|
skills/*/.deps_installed
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
app/server/version.json
|
||||||
|
|||||||
@@ -48,13 +48,6 @@ body {
|
|||||||
#files-panel .icon-btn, .files-panel-header .icon-btn { color: #555; }
|
#files-panel .icon-btn, .files-panel-header .icon-btn { color: #555; }
|
||||||
#files-panel .icon-btn:active { background: #eee; }
|
#files-panel .icon-btn:active { background: #eee; }
|
||||||
|
|
||||||
.version {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #aaa;
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---- 模型池条已随 2.0 任务页改版移除 ---- */
|
/* ---- 模型池条已随 2.0 任务页改版移除 ---- */
|
||||||
|
|
||||||
/* ---- 会话列表 ---- */
|
/* ---- 会话列表 ---- */
|
||||||
@@ -324,17 +317,10 @@ body {
|
|||||||
.model-card-state.busy { background: #fdecea; color: #b3382c; }
|
.model-card-state.busy { background: #fdecea; color: #b3382c; }
|
||||||
/* 配置已加但还没重启进运行池 */
|
/* 配置已加但还没重启进运行池 */
|
||||||
.model-card-state.pending { background: #fff4dc; color: #a06a00; }
|
.model-card-state.pending { background: #fff4dc; color: #a06a00; }
|
||||||
.model-card-right { display: flex; align-items: center; gap: 4px; }
|
/* 点模型名打开编辑弹窗 */
|
||||||
.model-edit-ico {
|
.model-card-name { cursor: pointer; }
|
||||||
background: none; border: none; cursor: pointer; padding: 5px; border-radius: 8px;
|
.model-card-name:active { opacity: 0.55; }
|
||||||
}
|
|
||||||
.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-meta { font-size: 12px; color: #888; margin-top: 4px; }
|
.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 {
|
.settings-row {
|
||||||
|
|||||||
@@ -277,10 +277,10 @@
|
|||||||
<div class="toast hidden" id="toast"></div>
|
<div class="toast hidden" id="toast"></div>
|
||||||
|
|
||||||
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
|
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
|
||||||
<script src="/js/core.js?v=20260901j"></script>
|
<script src="/js/core.js?v=20260901k"></script>
|
||||||
<script src="/js/tasks.js?v=20260901j"></script>
|
<script src="/js/tasks.js?v=20260901k"></script>
|
||||||
<script src="/js/skills.js?v=20260901j"></script>
|
<script src="/js/skills.js?v=20260901k"></script>
|
||||||
<script src="/js/models.js?v=20260901j"></script>
|
<script src="/js/models.js?v=20260901k"></script>
|
||||||
<script src="/js/settings.js?v=20260901j"></script>
|
<script src="/js/settings.js?v=20260901k"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -30,12 +30,8 @@ async function loadModelCards() {
|
|||||||
: '<span class="model-card-state pending">待重启</span>';
|
: '<span class="model-card-state pending">待重启</span>';
|
||||||
return '<div class="model-card">' +
|
return '<div class="model-card">' +
|
||||||
'<div class="model-card-head">' +
|
'<div class="model-card-head">' +
|
||||||
'<span class="model-card-name">' + esc(m.display_name || m.id) + '</span>' +
|
'<span class="model-card-name" title="点击编辑" onclick="modelsUI.openEdit(\'' + encodeURIComponent(m.id) + '\')">' + esc(m.display_name || m.id) + '</span>' +
|
||||||
'<span class="model-card-right">' + stateHtml +
|
stateHtml +
|
||||||
'<button class="model-edit-ico" title="编辑" onclick="modelsUI.openEdit(\'' + encodeURIComponent(m.id) + '\')">' +
|
|
||||||
'<svg viewBox="0 0 24 24"><path d="M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z"></path></svg>' +
|
|
||||||
'</button>' +
|
|
||||||
'</span>' +
|
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="model-card-meta">' + esc(m.id) +
|
'<div class="model-card-meta">' + esc(m.id) +
|
||||||
(run && run.is_busy && run.current_session_id ? ' · 会话 ' + esc(run.current_session_id) : '') + '</div>' +
|
(run && run.is_busy && run.current_session_id ? ' · 会话 ' + esc(run.current_session_id) : '') + '</div>' +
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function kvPlain(label, v) {
|
|||||||
function svcCard(st) {
|
function svcCard(st) {
|
||||||
let html = '<div class="settings-card"><h4>服务状态' +
|
let html = '<div class="settings-card"><h4>服务状态' +
|
||||||
(pendingKeys.size ? ' <span class="badge held">待重启生效</span>' : '') + '</h4>';
|
(pendingKeys.size ? ' <span class="badge held">待重启生效</span>' : '') + '</h4>';
|
||||||
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('已运行', fmtUptime(st.uptime_ms) + '(启动于 ' + new Date(st.started_at).toLocaleString() + ')');
|
||||||
html += kvPlain('端口', st.port);
|
html += kvPlain('端口', st.port);
|
||||||
html += kvPlain('配置文件', st.config_path);
|
html += kvPlain('配置文件', st.config_path);
|
||||||
@@ -90,8 +90,8 @@ function formCard() {
|
|||||||
html += g.items.map(cfgInput).join('');
|
html += g.items.map(cfgInput).join('');
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
html += '<button class="primary-btn" id="cfg-save-btn" style="width:100%" onclick="cfgUI.saveForm()">保存配置</button>' +
|
html += '<button class="primary-btn" id="cfg-save-btn" style="width:100%" onclick="cfgUI.saveForm()">更新配置</button>' +
|
||||||
'<div class="cfg-note" style="margin-bottom:12px">保存即写入 config.yml(注释保留);多数配置需重启服务后生效。' +
|
'<div class="cfg-note" style="margin-bottom:12px">更新即写入 config.yml(注释保留);多数配置需重启服务后生效。' +
|
||||||
'模型、账号、MCP 等请用右上角配置文件编辑。</div>';
|
'模型、账号、MCP 等请用右上角配置文件编辑。</div>';
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
@@ -221,6 +221,8 @@ async function saveCfgEditor() {
|
|||||||
cfgOrig = text;
|
cfgOrig = text;
|
||||||
(r.changed || []).forEach(k => pendingKeys.add(k));
|
(r.changed || []).forEach(k => pendingKeys.add(k));
|
||||||
toast('配置已保存');
|
toast('配置已保存');
|
||||||
|
$('cfg-editor').classList.add('hidden');
|
||||||
|
loadSettings(); // 保存成功直接退出编辑页
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errEl.textContent = '校验失败:' + e.message;
|
errEl.textContent = '校验失败:' + e.message;
|
||||||
errEl.classList.remove('hidden');
|
errEl.classList.remove('hidden');
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async function loadSkillDetail() {
|
|||||||
'<span class="file-name">' + esc(f.filename) + '</span>' +
|
'<span class="file-name">' + esc(f.filename) + '</span>' +
|
||||||
'<span class="file-size">' + fmtSize(f.size) + '</span>' +
|
'<span class="file-size">' + fmtSize(f.size) + '</span>' +
|
||||||
'<button class="file-act" onclick="event.stopPropagation();skillsUI.editFile(\'' + a + '\')">编辑</button>' +
|
'<button class="file-act" onclick="event.stopPropagation();skillsUI.editFile(\'' + a + '\')">编辑</button>' +
|
||||||
'<button class="file-act del" onclick="event.stopPropagation();skillsUI.deleteFile(\'' + a + '\')">删</button>' +
|
'<button class="file-act del" onclick="event.stopPropagation();skillsUI.deleteFile(\'' + a + '\')">删除</button>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
}).join('') + '</div>' + newBtn;
|
}).join('') + '</div>' + newBtn;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -163,6 +163,10 @@ async function saveSkillFile() {
|
|||||||
await req('PUT', '/api/skills/' + encodeURIComponent(curSkill) + '/file', { path: editorPath, content });
|
await req('PUT', '/api/skills/' + encodeURIComponent(curSkill) + '/file', { path: editorPath, content });
|
||||||
editorOrig = content;
|
editorOrig = content;
|
||||||
toast('已保存 ' + editorPath);
|
toast('已保存 ' + editorPath);
|
||||||
|
// 保存成功直接退出编辑页回文件列表
|
||||||
|
editorPath = null;
|
||||||
|
setSkillsView('detail');
|
||||||
|
loadSkillDetail();
|
||||||
} catch (e) { toast('保存失败:' + e.message); }
|
} catch (e) { toast('保存失败:' + e.message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
<input type="text" id="login-user" placeholder="用户名" autocomplete="username" autocapitalize="none" autocorrect="off">
|
<input type="text" id="login-user" placeholder="用户名" autocomplete="username" autocapitalize="none" autocorrect="off">
|
||||||
<input type="password" id="login-pass" placeholder="密码" autocomplete="current-password">
|
<input type="password" id="login-pass" placeholder="密码" autocomplete="current-password">
|
||||||
<button class="primary-btn" id="login-btn" type="submit" style="width:100%;">登录</button>
|
<button class="primary-btn" id="login-btn" type="submit" style="width:100%;">登录</button>
|
||||||
<div class="version" id="version-text">v1.0.1-260831</div>
|
|
||||||
<p class="login-error" id="login-error"></p>
|
<p class="login-error" id="login-error"></p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,12 +5,15 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const engine = require('../engine');
|
const engine = require('../engine');
|
||||||
const { loadConfig } = require('../config');
|
const { loadConfig } = require('../config');
|
||||||
|
const versionInfo = require('../version');
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const STARTED_AT = Date.now();
|
const STARTED_AT = Date.now();
|
||||||
let VERSION = '2.0.0';
|
let VERSION = '2.0.0';
|
||||||
try { VERSION = require('../../package.json').version || VERSION; } catch (_) {}
|
try { VERSION = require('../../package.json').version || VERSION; } catch (_) {}
|
||||||
|
// 附带 git 提交号(post-commit 钩子自动生成),免去手动改版本号
|
||||||
|
if (versionInfo.commit) VERSION += '+' + versionInfo.commit;
|
||||||
|
|
||||||
function sendErr(res, err) {
|
function sendErr(res, err) {
|
||||||
const code = err && err.status_code || 500;
|
const code = err && err.status_code || 500;
|
||||||
@@ -28,6 +31,7 @@ router.get('/status', wrap((req, res) => {
|
|||||||
res.json({
|
res.json({
|
||||||
ok: true,
|
ok: true,
|
||||||
version: VERSION,
|
version: VERSION,
|
||||||
|
version_date: versionInfo.date,
|
||||||
pid: process.pid,
|
pid: process.pid,
|
||||||
node: process.version,
|
node: process.version,
|
||||||
started_at: STARTED_AT,
|
started_at: STARTED_AT,
|
||||||
|
|||||||
@@ -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 || '') };
|
||||||
Reference in New Issue
Block a user