@nestim/koishi-plugin-qqgm-webui 0.2.9 → 0.2.11
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/index.js +1 -1
- package/lib/data.js +9 -1
- package/package.json +1 -1
- package/public/app.js +20 -0
- package/public/index.html +6 -2
- package/public/styles.css +6 -0
package/index.js
CHANGED
package/lib/data.js
CHANGED
|
@@ -166,7 +166,15 @@ function memory(ctx, { scope = '', query = '', limit = 50 } = {}) {
|
|
|
166
166
|
params.push(Math.max(1, Math.min(200, Number(limit) || 50)));
|
|
167
167
|
const items = db.prepare(sql).all(...params);
|
|
168
168
|
const total = db.prepare('SELECT COUNT(*) n FROM memories WHERE active=1').get().n;
|
|
169
|
-
|
|
169
|
+
const scopes = db.prepare(`
|
|
170
|
+
SELECT scope_kind, scope_id, COUNT(*) n FROM memories
|
|
171
|
+
WHERE active=1 GROUP BY scope_kind, scope_id ORDER BY n DESC
|
|
172
|
+
`).all();
|
|
173
|
+
const categories = db.prepare(`
|
|
174
|
+
SELECT COALESCE(category, '未分类') category, COUNT(*) n FROM memories
|
|
175
|
+
WHERE active=1 GROUP BY COALESCE(category, '未分类') ORDER BY n DESC
|
|
176
|
+
`).all();
|
|
177
|
+
return { installed: true, items, total, scopes, categories };
|
|
170
178
|
} catch (error) {
|
|
171
179
|
return { installed: false, error: String(error), items: [] };
|
|
172
180
|
} finally {
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -24,6 +24,11 @@ function showToast(text) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function go(page) {
|
|
27
|
+
const monitorNav = $('.nav-item[data-page="monitor"]');
|
|
28
|
+
if (page === 'monitor' && monitorNav && monitorNav.classList.contains('disabled')) {
|
|
29
|
+
showToast('安装 qqgm-monitor 后可用');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
$$('.nav-item').forEach((item) => item.classList.toggle('active', item.dataset.page === page));
|
|
28
33
|
$$('.nav-sub').forEach((item) => item.classList.toggle('active', item.dataset.page === page));
|
|
29
34
|
$$('.page').forEach((item) => item.classList.toggle('active', item.id === `page-${page}`));
|
|
@@ -57,6 +62,8 @@ function setMonitorState(on) {
|
|
|
57
62
|
if (!monitor || !welcome) return;
|
|
58
63
|
monitor.hidden = !on;
|
|
59
64
|
welcome.hidden = on;
|
|
65
|
+
const nav = $('.nav-item[data-page="monitor"]');
|
|
66
|
+
if (nav) nav.classList.toggle('disabled', !on);
|
|
60
67
|
const title = $('#pageTitle');
|
|
61
68
|
if (title) title.textContent = '总览';
|
|
62
69
|
}
|
|
@@ -119,6 +126,19 @@ async function initMemoryData() {
|
|
|
119
126
|
if (!data || !data.installed) return;
|
|
120
127
|
const badge = $('.nav-badge');
|
|
121
128
|
if (badge) badge.textContent = String(data.total || 0);
|
|
129
|
+
const scopes = $('#memoryScopes');
|
|
130
|
+
if (scopes) {
|
|
131
|
+
const scopeButtons = [`<h3>范围</h3><button class="scope active"><span>全部</span><b>${data.total || 0}</b></button>`];
|
|
132
|
+
for (const item of data.scopes || []) {
|
|
133
|
+
const label = item.scope_kind === 'group' ? `群 ${item.scope_id}` : item.scope_kind === 'private' ? `私聊 ${item.scope_id}` : `全局 ${item.scope_id || ''}`;
|
|
134
|
+
scopeButtons.push(`<button class="scope"><span>${label}</span><b>${item.n}</b></button>`);
|
|
135
|
+
}
|
|
136
|
+
scopeButtons.push('<h3 class="mt">分类</h3>');
|
|
137
|
+
for (const item of data.categories || []) {
|
|
138
|
+
scopeButtons.push(`<button class="scope"><span>${item.category}</span><b>${item.n}</b></button>`);
|
|
139
|
+
}
|
|
140
|
+
scopes.innerHTML = scopeButtons.join('');
|
|
141
|
+
}
|
|
122
142
|
const list = $('#memoryList');
|
|
123
143
|
if (!list) return;
|
|
124
144
|
if (!data.items.length) {
|
package/public/index.html
CHANGED
|
@@ -198,6 +198,10 @@
|
|
|
198
198
|
</div>
|
|
199
199
|
</div>
|
|
200
200
|
|
|
201
|
+
<div class="welcome-status">
|
|
202
|
+
<div><span class="pulse"></span><b>主插件已连接</b><span>v1.6.0 · 作者 Miseat</span></div>
|
|
203
|
+
<div>已安装 6 个附属插件 · 监控未安装</div>
|
|
204
|
+
</div>
|
|
201
205
|
<div class="welcome-grid">
|
|
202
206
|
<article class="card welcome-card">
|
|
203
207
|
<span class="step">01</span>
|
|
@@ -315,13 +319,13 @@
|
|
|
315
319
|
<div class="page-head">
|
|
316
320
|
<div><h1>记忆库</h1><p>默认 MD;安装 qqgm-memory 后可切换 SQLite</p></div>
|
|
317
321
|
<div class="head-actions">
|
|
318
|
-
<div class="segmented"><button class="active">MD</button><button data-toast="SQLite 需要安装 qqgm-memory
|
|
322
|
+
<div class="segmented"><button class="active">MD</button><button data-toast="SQLite 需要安装 qqgm-memory 并切换主插件后端">SQLite(需切换)</button></div>
|
|
319
323
|
<button class="btn primary" data-toast="新增记忆(原型)">+ 新增</button>
|
|
320
324
|
</div>
|
|
321
325
|
</div>
|
|
322
326
|
<div class="memory-note" id="memoryBackend">默认使用 MD,兼容现有记忆文件;安装数据库附属插件 <b>qqgm-memory</b> 后可切换 SQLite,迁移前会先备份。</div>
|
|
323
327
|
<div class="memory-layout">
|
|
324
|
-
<aside class="card scope-list">
|
|
328
|
+
<aside class="card scope-list" id="memoryScopes">
|
|
325
329
|
<h3>范围</h3>
|
|
326
330
|
<button class="scope active"><span>全部</span><b>128</b></button>
|
|
327
331
|
<button class="scope"><span>群 1103369527</span><b>86</b></button>
|
package/public/styles.css
CHANGED
|
@@ -46,6 +46,8 @@ svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round
|
|
|
46
46
|
.nav-item:hover { color: #e8eefb; background: rgba(255,255,255,.045); }
|
|
47
47
|
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(79,125,243,.24), rgba(79,125,243,.08)); box-shadow: inset 2px 0 0 #5b8def; }
|
|
48
48
|
.nav-item.active svg { color: #8fb0ff; }
|
|
49
|
+
.nav-item.disabled { opacity: .35; cursor: not-allowed; }
|
|
50
|
+
.nav-item.disabled:hover { background: none; color: #93a1b8; }
|
|
49
51
|
.nav-badge { margin-left: auto; font-style: normal; font-size: 10.5px; background: #1c2b42; color: #9fb4d6; border-radius: 20px; padding: 2px 7px; }
|
|
50
52
|
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #2dd4bf; margin-left: auto; box-shadow: 0 0 0 4px rgba(45,212,191,.12); }
|
|
51
53
|
.sidebar-footer { position: absolute; left: 14px; right: 14px; bottom: 16px; border-top: 1px solid rgba(255,255,255,.07); padding-top: 11px; background: var(--nav); }
|
|
@@ -273,6 +275,10 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
273
275
|
.welcome-actions .btn.primary { background: #fff; color: #1b3154; box-shadow: none; }
|
|
274
276
|
.welcome-actions .link-btn { color: #9dbcf0; margin-left: 4px; }
|
|
275
277
|
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
|
|
278
|
+
.welcome-status { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 10.5px; color: #8796aa; }
|
|
279
|
+
.welcome-status div { display: flex; align-items: center; gap: 8px; }
|
|
280
|
+
.welcome-status b { color: #3e4e65; font-weight: 600; }
|
|
281
|
+
.welcome-status .pulse { width: 6px; height: 6px; }
|
|
276
282
|
.welcome-card { position: relative; padding: 18px; }
|
|
277
283
|
.welcome-card .step { font-size: 10px; letter-spacing: .1em; color: #8fa3bd; }
|
|
278
284
|
.welcome-card h3 { margin: 8px 0 6px; font-size: 14px; }
|