fde-console 0.0.0-stage → 2.9.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/README.zh-CN.md +130 -0
- package/assets/icon.svg +9 -0
- package/cordis.patch.yml +7 -0
- package/lib/agentActivity.js +1180 -0
- package/lib/agentContext.js +146 -0
- package/lib/agentTranscript.js +1398 -0
- package/lib/analyze.js +625 -0
- package/lib/attribute.js +205 -0
- package/lib/backup.js +366 -0
- package/lib/desktopAgents.js +123 -0
- package/lib/diary.js +333 -0
- package/lib/dingtalk.js +412 -0
- package/lib/feishu.js +580 -0
- package/lib/giteaClient.js +810 -0
- package/lib/giteeClient.js +372 -0
- package/lib/githubClient.js +361 -0
- package/lib/heatmap.js +99 -0
- package/lib/imNotify.js +378 -0
- package/lib/inbox.js +438 -0
- package/lib/instanceLock.js +122 -0
- package/lib/jobs.js +56 -0
- package/lib/learn.js +1388 -0
- package/lib/learnImport.js +283 -0
- package/lib/learnSeeds.js +97 -0
- package/lib/learnSeedsAiEng.js +77 -0
- package/lib/mcpCore.js +135 -0
- package/lib/members.js +160 -0
- package/lib/migration.js +403 -0
- package/lib/overview.js +376 -0
- package/lib/postmortem.js +148 -0
- package/lib/radarIgnore.js +134 -0
- package/lib/redact.js +76 -0
- package/lib/router.js +246 -0
- package/lib/routes-gitea.js +262 -0
- package/lib/routes-setup.js +40 -0
- package/lib/scorecard.js +111 -0
- package/lib/sessionRef.js +227 -0
- package/lib/sessionSnapshot.js +67 -0
- package/lib/sessionSuggest.js +186 -0
- package/lib/settings.js +783 -0
- package/lib/setupCheck.js +330 -0
- package/lib/ssrfGuard.js +145 -0
- package/lib/store.js +564 -0
- package/lib/storeDb.js +418 -0
- package/lib/taskEvents.js +243 -0
- package/lib/webhookOut.js +125 -0
- package/lib/weekly.js +439 -0
- package/lib/workSearch.js +220 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +46 -4
- package/plugin/adapter.js +157 -0
- package/plugin/client.js +282 -0
- package/plugin/index.mjs +116 -0
- package/plugin/static.js +99 -0
- package/scripts/backup-data.js +41 -0
- package/scripts/mcp-server.mjs +68 -0
- package/scripts/migrate-data.js +301 -0
- package/scripts/migrate-storage.js +47 -0
- package/scripts/seed-demo.js +200 -0
- package/scripts/write-agent-context.js +43 -0
- package/test/helpers/appAssembler.js +1078 -0
- package/web/client/fde-client.js +292 -0
- package/web/css/app.css +1510 -0
- package/web/index.html +69 -0
- package/web/js/api.js +72 -0
- package/web/js/app.js +313 -0
- package/web/js/icons.js +48 -0
- package/web/js/mock.js +1150 -0
- package/web/js/state.js +7 -0
- package/web/js/ui.js +276 -0
- package/web/js/views/activity.js +410 -0
- package/web/js/views/agents.js +892 -0
- package/web/js/views/board.js +1656 -0
- package/web/js/views/learn.js +530 -0
- package/web/js/views/members.js +344 -0
- package/web/js/views/onboarding.js +103 -0
- package/web/js/views/overview.js +508 -0
- package/web/js/views/radar.js +1359 -0
- package/web/js/views/search.js +149 -0
- package/web/js/views/settings.js +1351 -0
- package/web/js/views/topology.js +471 -0
- package/web/mock.json +2363 -0
package/web/index.html
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>超级工作台</title>
|
|
7
|
+
<link rel="icon" href="data:,">
|
|
8
|
+
<link rel="stylesheet" href="css/app.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app">
|
|
12
|
+
<aside class="side">
|
|
13
|
+
<div class="logo">
|
|
14
|
+
<i data-icon="bot"></i>
|
|
15
|
+
<div>超级工作台<small id="side-addr">127.0.0.1:7788</small></div>
|
|
16
|
+
</div>
|
|
17
|
+
<nav class="nav" id="nav" aria-label="主导航">
|
|
18
|
+
<button type="button" data-view="overview"><i data-icon="layout-dashboard"></i>总览</button>
|
|
19
|
+
<button type="button" data-view="radar"><i data-icon="radar"></i>任务雷达</button>
|
|
20
|
+
<button type="button" data-view="board"><i data-icon="kanban"></i>任务看板</button>
|
|
21
|
+
<button type="button" data-view="agents"><i data-icon="bot"></i>智能体</button>
|
|
22
|
+
<button type="button" data-view="members"><i data-icon="users"></i>成员进度</button>
|
|
23
|
+
<button type="button" data-view="activity"><i data-icon="activity"></i>团队动态</button>
|
|
24
|
+
<!-- v2.9.45 学习:仅在设置里配置了知识库后出现(app.js 按 /api/learn/status 控制 hidden) -->
|
|
25
|
+
<button type="button" data-view="learn" id="nav-learn" hidden><i data-icon="book-open"></i>学习</button>
|
|
26
|
+
<button type="button" data-view="settings"><i data-icon="settings"></i>设置</button>
|
|
27
|
+
</nav>
|
|
28
|
+
<div class="side-foot"><span class="dot" id="foot-dot"></span><span id="foot-text">连接中…</span></div>
|
|
29
|
+
</aside>
|
|
30
|
+
|
|
31
|
+
<div class="main">
|
|
32
|
+
<header class="topbar">
|
|
33
|
+
<h3 id="view-title">总览</h3>
|
|
34
|
+
<span class="pill pill-mock" id="pill-mock" hidden>MOCK · 零出网</span>
|
|
35
|
+
<span class="pill warn" id="pill-multi" hidden>多实例</span>
|
|
36
|
+
<span class="pill" id="pill-sessions"><span class="dot"></span><span id="pill-sessions-text">—</span></span>
|
|
37
|
+
<span class="pill" id="pill-gitea"><i data-icon="refresh-cw"></i><span id="pill-gitea-text">—</span></span>
|
|
38
|
+
<span class="spacer"></span>
|
|
39
|
+
<div class="attn-wrap">
|
|
40
|
+
<button type="button" class="btn ghost" id="btn-attn" title="待处理:逾期 / 待验收 / 收件箱待确认" aria-haspopup="true" aria-expanded="false">
|
|
41
|
+
<i data-icon="bell"></i>待办<span class="attn-badge" id="attn-count" hidden>0</span>
|
|
42
|
+
</button>
|
|
43
|
+
<div class="attn-menu" id="attn-menu" hidden>
|
|
44
|
+
<button type="button" class="attn-row" data-go="board" data-kind="overdue"><span>逾期任务</span><b id="attn-overdue">0</b></button>
|
|
45
|
+
<button type="button" class="attn-row" data-go="board" data-kind="review"><span>待验收</span><b id="attn-review">0</b></button>
|
|
46
|
+
<button type="button" class="attn-row" data-go="radar" data-kind="pending"><span>收件箱待确认</span><b id="attn-pending">0</b></button>
|
|
47
|
+
<div class="attn-foot muted small">轮询 30s · 点击跳到对应视图</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<button type="button" class="btn ghost" id="btn-search" title="工作搜索(任务 / 会话 / 提交 / 日报)"><i data-icon="search"></i>搜索<span class="kbd">Ctrl K</span></button>
|
|
51
|
+
<button type="button" class="btn" id="btn-new-task"><i data-icon="plus"></i>新建任务</button>
|
|
52
|
+
</header>
|
|
53
|
+
|
|
54
|
+
<main class="view" id="view"></main>
|
|
55
|
+
|
|
56
|
+
<footer class="foot">
|
|
57
|
+
<span id="foot-version" title="实例运行时版本(随实例重启更新;仓库版本见总览「版本与兼容性」)">运行时 —</span>
|
|
58
|
+
<span>仅绑定 127.0.0.1</span>
|
|
59
|
+
<span>凭据运行时读取 · 零落盘</span>
|
|
60
|
+
<span>Gitea 只读拉取 · SSRF 白名单</span>
|
|
61
|
+
<span>零构建 · vanilla ES Modules</span>
|
|
62
|
+
</footer>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div id="toasts"></div>
|
|
66
|
+
<div id="modal-root"></div>
|
|
67
|
+
<script type="module" src="js/app.js"></script>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
package/web/js/api.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// fetch 封装:统一 JSON 错误体 {"error":{"code","message"}} → ApiError;
|
|
2
|
+
// ?mock=1 时全部改走 web/mock.json 内存副本(零出网),由 mock.js 注册处理器
|
|
3
|
+
//
|
|
4
|
+
// WP4 插件化(SPEC-PLUGIN 2.3):视图层仍写 '/api/...' 字面量(F1-F5 断言锚点不动),
|
|
5
|
+
// 出口在此统一改写为宿主前缀路由 API_BASE(/fde-api/*);独立版回退 = API_BASE 改回 '/api'
|
|
6
|
+
// (SPEC-PLUGIN 2.6)。mock 分支不做改写:mock.js 路由表按 '/api/*' 契约匹配,语义不变。
|
|
7
|
+
|
|
8
|
+
export const API_BASE = '/fde-api';
|
|
9
|
+
|
|
10
|
+
// '/api' 与 '/api/xxx' → API_BASE 前缀;其余路径(含带 query)原样放行
|
|
11
|
+
function toApiUrl(path) {
|
|
12
|
+
if (path === '/api') return API_BASE;
|
|
13
|
+
if (path.startsWith('/api/')) return API_BASE + path.slice(4);
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class ApiError extends Error {
|
|
18
|
+
constructor(status, code, message) {
|
|
19
|
+
super(message || code || '请求失败');
|
|
20
|
+
this.name = 'ApiError';
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.code = code || 'UNKNOWN';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const isMock = (() => {
|
|
27
|
+
try {
|
|
28
|
+
if (typeof location === 'undefined') return false;
|
|
29
|
+
const sp = new URLSearchParams(location.search);
|
|
30
|
+
return sp.has('mock') && sp.get('mock') !== '0';
|
|
31
|
+
} catch { return false; }
|
|
32
|
+
})();
|
|
33
|
+
|
|
34
|
+
let mockHandler = null;
|
|
35
|
+
export function registerMock(fn) { mockHandler = fn; }
|
|
36
|
+
export function getMockHandler() { return mockHandler; }
|
|
37
|
+
|
|
38
|
+
async function request(path, { method = 'GET', body } = {}) {
|
|
39
|
+
if (isMock) {
|
|
40
|
+
if (!mockHandler) {
|
|
41
|
+
// 动态加载 mock 后端,避免非 mock 模式下的多余请求
|
|
42
|
+
const mod = await import('./mock.js');
|
|
43
|
+
if (!mockHandler) throw new ApiError(0, 'MOCK_INIT', 'mock 处理器未注册');
|
|
44
|
+
void mod;
|
|
45
|
+
}
|
|
46
|
+
return mockHandler(path, { method, body });
|
|
47
|
+
}
|
|
48
|
+
let res;
|
|
49
|
+
try {
|
|
50
|
+
res = await fetch(toApiUrl(path), {
|
|
51
|
+
method,
|
|
52
|
+
headers: body !== undefined ? { 'Content-Type': 'application/json' } : undefined,
|
|
53
|
+
body: body !== undefined ? JSON.stringify(body) : undefined
|
|
54
|
+
});
|
|
55
|
+
} catch {
|
|
56
|
+
throw new ApiError(0, 'NETWORK', '无法连接服务:请确认 DSH 宿主已启动且插件已启用');
|
|
57
|
+
}
|
|
58
|
+
if (res.status === 204) return null;
|
|
59
|
+
let data = null;
|
|
60
|
+
try { data = await res.json(); } catch { /* 空体或非 JSON */ }
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
const err = (data && data.error) || {};
|
|
63
|
+
throw new ApiError(res.status, err.code || `HTTP_${res.status}`, err.message || `请求失败(HTTP ${res.status})`);
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function api(path, opts) { return request(path, opts); }
|
|
69
|
+
export const apiGet = (path) => request(path);
|
|
70
|
+
export const apiPost = (path, body) => request(path, { method: 'POST', body });
|
|
71
|
+
export const apiPatch = (path, body) => request(path, { method: 'PATCH', body });
|
|
72
|
+
export const apiDel = (path) => request(path, { method: 'DELETE' });
|
package/web/js/app.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// F1 骨架:hash 路由 + 深色主题 + 顶栏状态 + mock 模式装载
|
|
2
|
+
import { api, isMock } from './api.js';
|
|
3
|
+
import { esc, toast, icon, startPolling } from './ui.js';
|
|
4
|
+
import { state } from './state.js';
|
|
5
|
+
import * as overviewView from './views/overview.js';
|
|
6
|
+
import * as boardView from './views/board.js';
|
|
7
|
+
import * as radarView from './views/radar.js';
|
|
8
|
+
import * as agentsView from './views/agents.js';
|
|
9
|
+
import * as membersView from './views/members.js';
|
|
10
|
+
import * as activityView from './views/activity.js';
|
|
11
|
+
import * as settingsView from './views/settings.js';
|
|
12
|
+
import * as learnView from './views/learn.js';
|
|
13
|
+
import { openWorkSearch } from './views/search.js';
|
|
14
|
+
import { shouldShowOnboarding, openOnboarding } from './views/onboarding.js';
|
|
15
|
+
|
|
16
|
+
// mock 模式:注册本地处理器后再开始渲染(零出网)
|
|
17
|
+
if (isMock) await import('./mock.js');
|
|
18
|
+
|
|
19
|
+
const VIEWS = {
|
|
20
|
+
overview: overviewView,
|
|
21
|
+
board: boardView,
|
|
22
|
+
radar: radarView,
|
|
23
|
+
agents: agentsView,
|
|
24
|
+
members: membersView,
|
|
25
|
+
activity: activityView,
|
|
26
|
+
learn: learnView,
|
|
27
|
+
settings: settingsView
|
|
28
|
+
};
|
|
29
|
+
const ROUTES = {
|
|
30
|
+
overview: '#/overview',
|
|
31
|
+
board: '#/board',
|
|
32
|
+
radar: '#/radar',
|
|
33
|
+
agents: '#/agents',
|
|
34
|
+
members: '#/members',
|
|
35
|
+
activity: '#/activity',
|
|
36
|
+
learn: '#/learn',
|
|
37
|
+
settings: '#/settings'
|
|
38
|
+
};
|
|
39
|
+
const TITLES = {
|
|
40
|
+
overview: '总览',
|
|
41
|
+
board: '任务看板',
|
|
42
|
+
radar: '任务雷达',
|
|
43
|
+
agents: '智能体',
|
|
44
|
+
members: '成员进度',
|
|
45
|
+
activity: '团队动态',
|
|
46
|
+
learn: '学习',
|
|
47
|
+
settings: '设置'
|
|
48
|
+
};
|
|
49
|
+
const NAV_ICONS = {
|
|
50
|
+
overview: 'layout-dashboard',
|
|
51
|
+
board: 'kanban',
|
|
52
|
+
radar: 'radar',
|
|
53
|
+
agents: 'bot',
|
|
54
|
+
members: 'users',
|
|
55
|
+
activity: 'activity',
|
|
56
|
+
learn: 'book-open',
|
|
57
|
+
settings: 'settings'
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const viewEl = document.getElementById('view');
|
|
61
|
+
let currentName = null;
|
|
62
|
+
let currentHash = ''; // 完整 hash(含 query):同视图深链(如看板内搜索点任务 #/board?task=x)也要重渲染
|
|
63
|
+
let navSeq = 0;
|
|
64
|
+
// v2.9.45 学习视图门控:只有设置了知识库(enabled + root 有效)才出现——"配置了才有",
|
|
65
|
+
// 不是灰掉。30s 随顶栏轮询刷新,配好之后不用重启或强刷。
|
|
66
|
+
let learnGate = false;
|
|
67
|
+
|
|
68
|
+
async function refreshLearnGate() {
|
|
69
|
+
let on = false;
|
|
70
|
+
try {
|
|
71
|
+
const st = await api('/api/learn/status');
|
|
72
|
+
on = !!(st && st.configured);
|
|
73
|
+
} catch { on = false; }
|
|
74
|
+
if (on !== learnGate) {
|
|
75
|
+
learnGate = on;
|
|
76
|
+
const btn = document.getElementById('nav-learn');
|
|
77
|
+
if (btn) btn.hidden = !on;
|
|
78
|
+
// 关掉开关时人可能正停在 #/learn:退回总览,别留一个进不去的页面
|
|
79
|
+
if (!on && currentRoute() === 'learn') location.hash = ROUTES.overview;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function currentRoute() {
|
|
84
|
+
const h = (location.hash || '').replace(/^#\/?/, '').split('?')[0];
|
|
85
|
+
if (h === 'learn' && !learnGate) return 'overview';
|
|
86
|
+
return VIEWS[h] ? h : 'overview';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function navigate() {
|
|
90
|
+
const name = currentRoute();
|
|
91
|
+
const fullHash = location.hash || '';
|
|
92
|
+
if (name === currentName && fullHash === currentHash) return;
|
|
93
|
+
const seq = ++navSeq;
|
|
94
|
+
// 离开旧视图:先销毁(清轮询/监听),再清容器
|
|
95
|
+
const prev = currentName && VIEWS[currentName];
|
|
96
|
+
if (prev && prev.destroy) {
|
|
97
|
+
try { prev.destroy(); } catch { /* 忽略销毁异常 */ }
|
|
98
|
+
}
|
|
99
|
+
currentName = name;
|
|
100
|
+
currentHash = fullHash;
|
|
101
|
+
viewEl.innerHTML = '';
|
|
102
|
+
|
|
103
|
+
document.querySelectorAll('#nav button').forEach((b) => {
|
|
104
|
+
const on = b.dataset.view === name;
|
|
105
|
+
b.classList.toggle('on', on);
|
|
106
|
+
if (on) b.setAttribute('aria-current', 'page');
|
|
107
|
+
else b.removeAttribute('aria-current');
|
|
108
|
+
});
|
|
109
|
+
document.getElementById('view-title').textContent = TITLES[name];
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
await VIEWS[name].render(viewEl);
|
|
113
|
+
if (seq !== navSeq) {
|
|
114
|
+
// 渲染期间用户已切走:立即回收
|
|
115
|
+
const mod = VIEWS[name];
|
|
116
|
+
if (mod.destroy) { try { mod.destroy(); } catch { /* noop */ } }
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (seq === navSeq) {
|
|
120
|
+
viewEl.innerHTML = `<div class="loading err">视图加载失败:${esc(e.message)}</div>`;
|
|
121
|
+
toast(e.message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ---- 侧栏导航 ----
|
|
127
|
+
document.querySelectorAll('#nav button').forEach((b) => {
|
|
128
|
+
const v = b.dataset.view;
|
|
129
|
+
if (!VIEWS[v]) return;
|
|
130
|
+
const holder = b.querySelector('i[data-icon]');
|
|
131
|
+
if (holder) holder.outerHTML = icon(NAV_ICONS[v] || v);
|
|
132
|
+
b.addEventListener('click', () => {
|
|
133
|
+
if (location.hash !== ROUTES[v]) location.hash = ROUTES[v];
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
// 顶栏与页脚里的静态图标
|
|
137
|
+
document.querySelectorAll('.topbar [data-icon], .side [data-icon]').forEach((i) => {
|
|
138
|
+
i.outerHTML = icon(i.dataset.icon);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ---- mock 模式标识 ----
|
|
142
|
+
if (isMock) {
|
|
143
|
+
document.getElementById('pill-mock').hidden = false;
|
|
144
|
+
document.getElementById('side-addr').textContent = 'MOCK 数据 · 零出网';
|
|
145
|
+
} else {
|
|
146
|
+
// 非 mock:侧栏地址显示实际访问地址(插件态端口任意,硬编码 127.0.0.1:7788 常显错误,SPEC-UX v2.1 W3)
|
|
147
|
+
const addr = document.getElementById('side-addr');
|
|
148
|
+
if (addr) addr.textContent = location.host;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ---- 顶栏「新建任务」:看板内直接弹层,其他视图先跳转 ----
|
|
152
|
+
document.getElementById('btn-new-task').addEventListener('click', () => {
|
|
153
|
+
if (currentName === 'board') {
|
|
154
|
+
window.dispatchEvent(new CustomEvent('fde:new-task'));
|
|
155
|
+
} else {
|
|
156
|
+
state.pendingNewTask = true;
|
|
157
|
+
if (location.hash === ROUTES.board) navigate();
|
|
158
|
+
else location.hash = ROUTES.board;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// ---- v2.9.23 工作搜索(考古层):顶栏按钮 + Ctrl/Cmd+K 全局呼出 ----
|
|
163
|
+
document.getElementById('btn-search').addEventListener('click', openWorkSearch);
|
|
164
|
+
document.addEventListener('keydown', (e) => {
|
|
165
|
+
if ((e.ctrlKey || e.metaKey) && String(e.key).toLowerCase() === 'k') {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
openWorkSearch();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ---- v2.9.26 Onboarding:首访自动弹一次;设置页可重开(自定义事件 onboardingRedo) ----
|
|
172
|
+
if (shouldShowOnboarding()) {
|
|
173
|
+
setTimeout(() => { if (document.getElementById('modal-root')) openOnboarding(); }, 600);
|
|
174
|
+
}
|
|
175
|
+
window.addEventListener('onboardingRedo', openOnboarding);
|
|
176
|
+
|
|
177
|
+
// ---- 顶栏状态胶囊(30s 轮询,隐藏页暂停)----
|
|
178
|
+
let multiWarned = false;
|
|
179
|
+
|
|
180
|
+
// v2.9.43 多实例告警:同一 base 目录还有别的存活实例 → 顶栏亮「多实例」并只 toast 一次。
|
|
181
|
+
// 依据 v2.9.25 真事故:桌面版与 CLI 同跑共享 data/,旧代码每 60s 写脏归因,累计清 156 条。
|
|
182
|
+
function drawMultiInstance(inst) {
|
|
183
|
+
const pill = document.getElementById('pill-multi');
|
|
184
|
+
if (!pill) return;
|
|
185
|
+
const others = (inst && inst.others) || [];
|
|
186
|
+
pill.hidden = others.length === 0;
|
|
187
|
+
if (!others.length) return;
|
|
188
|
+
const who = others.map((x) => `pid ${x.pid}${x.port ? ` · :${x.port}` : ''}${x.version ? ` · v${x.version}` : ''}`).join(';');
|
|
189
|
+
pill.title = `检测到其它存活实例:${who}\n多实例共用同一份 data/ 会互相覆盖,请只保留一个`;
|
|
190
|
+
if (!multiWarned) {
|
|
191
|
+
multiWarned = true;
|
|
192
|
+
toast('检测到多实例共用数据目录,请只保留一个实例');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function refreshChrome() {
|
|
197
|
+
const sess = document.getElementById('pill-sessions-text');
|
|
198
|
+
const gitea = document.getElementById('pill-gitea-text');
|
|
199
|
+
const foot = document.getElementById('foot-text');
|
|
200
|
+
const footDot = document.getElementById('foot-dot');
|
|
201
|
+
// v2.9.67 底部运行时版本号(health.version=实例加载时的 package.json,随实例重启更新)
|
|
202
|
+
try {
|
|
203
|
+
const h = await api('/api/health');
|
|
204
|
+
const ver = document.getElementById('foot-version');
|
|
205
|
+
if (ver) ver.textContent = `运行时 v${h.version}`;
|
|
206
|
+
} catch { /* 离线保留占位 */ }
|
|
207
|
+
try {
|
|
208
|
+
const ov = await api('/api/overview');
|
|
209
|
+
// goose v2.3 回归收口:会话登记表退役后 ov.sessionsRunning 字段已删(总览统计卡同步移除),
|
|
210
|
+
// pill 改数进行中任务(同 /api/overview 响应的 tasks.doing,契约 v1.4 既有字段,零后端改动)
|
|
211
|
+
const doing = Number(ov && ov.tasks && ov.tasks.doing) || 0;
|
|
212
|
+
if (sess) sess.textContent = `${doing} 个任务进行中`;
|
|
213
|
+
const ok = !!(ov.gitea && ov.gitea.ok);
|
|
214
|
+
if (gitea) gitea.textContent = ok ? 'Gitea 已连接' : 'Gitea 异常';
|
|
215
|
+
if (foot) foot.textContent = ok ? 'Gitea 已连接 · example-org' : 'Gitea 连接异常';
|
|
216
|
+
if (footDot) footDot.className = 'dot' + (ok ? '' : ' err');
|
|
217
|
+
// v2.9.43 多实例探测:端点不存在(旧版后端)就静默跳过,不打扰
|
|
218
|
+
try {
|
|
219
|
+
drawMultiInstance(await api('/api/instance'));
|
|
220
|
+
} catch { /* 旧版无 /api/instance */ }
|
|
221
|
+
// v2.9.45 学习门控随轮询刷新(设置里配好知识库后 30s 内自动出现)
|
|
222
|
+
await refreshLearnGate();
|
|
223
|
+
} catch {
|
|
224
|
+
if (sess) sess.textContent = '服务离线';
|
|
225
|
+
if (gitea) gitea.textContent = '—';
|
|
226
|
+
if (foot) foot.textContent = isMock ? 'MOCK 模式 · 零出网' : '服务离线:请确认 DSH 宿主已启动、FDE 指挥台插件已启用';
|
|
227
|
+
if (footDot) footDot.className = 'dot err';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
startPolling(refreshChrome, 30000);
|
|
231
|
+
refreshChrome();
|
|
232
|
+
|
|
233
|
+
// ---- v2.9.38 待办提醒(页内):顶栏铃铛计数 + 宿主侧栏图标红点 ----
|
|
234
|
+
// 口径复用既有端点,零后端改动:逾期=/api/overview tasks.overdue;待验收=tasks.review;
|
|
235
|
+
// 收件箱=/api/inbox/stats pending(只有这三类会被"等你看一眼"卡住)。
|
|
236
|
+
const ATTN = { overdue: 0, review: 0, pending: 0 };
|
|
237
|
+
let attnMenuOpen = false;
|
|
238
|
+
const attnTotal = () => ATTN.overdue + ATTN.review + ATTN.pending;
|
|
239
|
+
|
|
240
|
+
function renderAttention() {
|
|
241
|
+
const n = attnTotal();
|
|
242
|
+
const badge = document.getElementById('attn-count');
|
|
243
|
+
if (badge) {
|
|
244
|
+
badge.textContent = n > 99 ? '99+' : String(n);
|
|
245
|
+
badge.hidden = n === 0;
|
|
246
|
+
}
|
|
247
|
+
for (const [id, key] of [['attn-overdue', 'overdue'], ['attn-review', 'review'], ['attn-pending', 'pending']]) {
|
|
248
|
+
const el = document.getElementById(id);
|
|
249
|
+
if (!el) continue;
|
|
250
|
+
el.textContent = String(ATTN[key]);
|
|
251
|
+
const row = el.closest('.attn-row');
|
|
252
|
+
if (row) row.dataset.zero = ATTN[key] === 0 ? '1' : '0'; // 0 项灰显,仍可点(去该视图看一眼)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function refreshAttention() {
|
|
257
|
+
try {
|
|
258
|
+
const [o, s] = await Promise.all([api('/api/overview'), api('/api/inbox/stats')]);
|
|
259
|
+
ATTN.overdue = Number(o && o.tasks && o.tasks.overdue) || 0;
|
|
260
|
+
ATTN.review = Number(o && o.tasks && o.tasks.review) || 0;
|
|
261
|
+
ATTN.pending = Number(s && s.pending) || 0;
|
|
262
|
+
} catch { /* 拉不到就保留上次数值:宁可红点旧,也不要把提醒清空骗人 */ }
|
|
263
|
+
renderAttention();
|
|
264
|
+
// 同步给宿主页的侧栏图标(同 origin 的父窗口)——面板关着时红点也要亮
|
|
265
|
+
try {
|
|
266
|
+
if (window.parent && window.parent !== window) {
|
|
267
|
+
window.parent.postMessage({ type: 'fde:attention', overdue: ATTN.overdue, review: ATTN.review, pending: ATTN.pending }, location.origin);
|
|
268
|
+
}
|
|
269
|
+
} catch { /* 无父窗口/跨域:忽略 */ }
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function setAttnMenu(open) {
|
|
273
|
+
const menu = document.getElementById('attn-menu');
|
|
274
|
+
const btn = document.getElementById('btn-attn');
|
|
275
|
+
if (!menu || !btn) return;
|
|
276
|
+
menu.hidden = !open;
|
|
277
|
+
btn.setAttribute('aria-expanded', String(open));
|
|
278
|
+
attnMenuOpen = open;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
document.getElementById('btn-attn').addEventListener('click', (e) => {
|
|
282
|
+
e.stopPropagation();
|
|
283
|
+
if (!attnMenuOpen && attnTotal() === 0) {
|
|
284
|
+
toast('暂无待处理');
|
|
285
|
+
refreshAttention();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setAttnMenu(!attnMenuOpen);
|
|
289
|
+
});
|
|
290
|
+
document.getElementById('attn-menu').addEventListener('click', (e) => {
|
|
291
|
+
const row = e.target.closest('.attn-row');
|
|
292
|
+
if (!row) return;
|
|
293
|
+
setAttnMenu(false);
|
|
294
|
+
const go = row.dataset.go === 'radar' ? ROUTES.radar : ROUTES.board;
|
|
295
|
+
if (location.hash !== go) location.hash = go;
|
|
296
|
+
else navigate();
|
|
297
|
+
});
|
|
298
|
+
// 点外即收 / Esc 收起(与宿主浮层同款手感,避免菜单挂在那儿)
|
|
299
|
+
document.addEventListener('click', (e) => {
|
|
300
|
+
if (attnMenuOpen && !(e.target.closest && e.target.closest('.attn-wrap'))) setAttnMenu(false);
|
|
301
|
+
});
|
|
302
|
+
document.addEventListener('keydown', (e) => {
|
|
303
|
+
if (e.key === 'Escape' && attnMenuOpen) setAttnMenu(false);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
startPolling(refreshAttention, 30000);
|
|
307
|
+
refreshAttention();
|
|
308
|
+
|
|
309
|
+
// ---- 启动路由 ----
|
|
310
|
+
// 先定学习门控再首渲:否则直接打开 #/learn 的人会看到"进不去的页面"闪一下
|
|
311
|
+
await refreshLearnGate();
|
|
312
|
+
window.addEventListener('hashchange', navigate);
|
|
313
|
+
navigate();
|
package/web/js/icons.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// 内联 SVG 图标(lucide 形状,24x24 stroke),替代 CDN,满足零出网约束
|
|
2
|
+
const PATHS = {
|
|
3
|
+
'layout-dashboard': '<rect x="3" y="3" width="7" height="9" rx="1"/><rect x="14" y="3" width="7" height="5" rx="1"/><rect x="14" y="12" width="7" height="9" rx="1"/><rect x="3" y="16" width="7" height="5" rx="1"/>',
|
|
4
|
+
'kanban': '<path d="M6 5v11"/><path d="M12 5v6"/><path d="M18 5v14"/>',
|
|
5
|
+
'bot': '<path d="M12 8V4H8"/><rect x="4" y="8" width="16" height="12" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>',
|
|
6
|
+
'users': '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
|
7
|
+
'user': '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',
|
|
8
|
+
'activity': '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',
|
|
9
|
+
'settings': '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h.01a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h.01a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v.01a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>',
|
|
10
|
+
'plus': '<path d="M12 5v14"/><path d="M5 12h14"/>',
|
|
11
|
+
'x': '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
12
|
+
'refresh-cw': '<path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 21v-5h5"/>',
|
|
13
|
+
'play': '<polygon points="6 3 20 12 6 21 6 3"/>',
|
|
14
|
+
'pencil': '<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/>',
|
|
15
|
+
'trash': '<path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',
|
|
16
|
+
'search': '<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/>',
|
|
17
|
+
'columns': '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M12 3v18"/>',
|
|
18
|
+
'git-pull-request': '<circle cx="18" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><path d="M13 6h3a2 2 0 0 1 2 2v7"/><line x1="6" y1="9" x2="6" y2="21"/>',
|
|
19
|
+
'git-commit': '<circle cx="12" cy="12" r="3"/><line x1="3" y1="12" x2="9" y2="12"/><line x1="15" y1="12" x2="21" y2="12"/>',
|
|
20
|
+
'git-merge': '<circle cx="18" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><path d="M6 21V9a9 9 0 0 0 9 9"/>',
|
|
21
|
+
'git-branch': '<line x1="6" y1="3" x2="6" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',
|
|
22
|
+
'lock': '<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
|
|
23
|
+
'inbox': '<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',
|
|
24
|
+
'chevron-down': '<path d="m6 9 6 6 6-6"/>',
|
|
25
|
+
'folder': '<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',
|
|
26
|
+
'flag': '<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" x2="4" y1="22" y2="15"/>',
|
|
27
|
+
'zap': '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>',
|
|
28
|
+
'terminal': '<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>',
|
|
29
|
+
'radar': '<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34"/><path d="M4 6h.01"/><path d="M2.29 9.62a10 10 0 0 0 2.19 8.11"/><path d="M9.35 5.24 6.4 14.02a1 1 0 0 0 1.27 1.27l8.78-2.95"/><circle cx="12" cy="12" r="2"/><path d="m14.65 18.76 2.95-8.78"/>',
|
|
30
|
+
'check': '<path d="M20 6 9 17l-5-5"/>',
|
|
31
|
+
'check-circle': '<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>',
|
|
32
|
+
'ban': '<circle cx="12" cy="12" r="10"/><path d="m4.9 4.9 14.2 14.2"/>',
|
|
33
|
+
'radio': '<circle cx="12" cy="12" r="2"/><path d="M4.93 19.07a10 10 0 0 1 0-14.14"/><path d="M7.76 16.24a6 6 0 0 1 0-8.49"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49"/>',
|
|
34
|
+
'mic': '<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/>',
|
|
35
|
+
'file-text': '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>',
|
|
36
|
+
'link': '<path d="M9 17H7A5 5 0 0 1 7 7h2"/><path d="M15 7h2a5 5 0 1 1 0 10h-2"/><line x1="8" x2="16" y1="12" y2="12"/>',
|
|
37
|
+
'paperclip': '<path d="m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"/>',
|
|
38
|
+
'copy': '<rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',
|
|
39
|
+
'external-link': '<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',
|
|
40
|
+
'alert-triangle': '<path d="m21.73 18-8-14a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
|
|
41
|
+
'bell': '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',
|
|
42
|
+
'book-open': '<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>'
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function icon(name, cls) {
|
|
46
|
+
const inner = PATHS[name] || PATHS.bot;
|
|
47
|
+
return `<svg class="ic${cls ? ' ' + cls : ''}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${inner}</svg>`;
|
|
48
|
+
}
|