@nestim/koishi-plugin-qqgm-webui 0.2.10 → 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 CHANGED
@@ -98,7 +98,7 @@ function apply(ctx, config) {
98
98
  ctx.server.get(`${route}/api/health`, (koa) => json(koa, {
99
99
  ok: true,
100
100
  name,
101
- version: '0.2.10',
101
+ version: '0.2.11',
102
102
  route,
103
103
  tokenRequired: !!config.token,
104
104
  remoteAllowed: !!config.allowRemote,
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
- return { installed: true, items, total };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestim/koishi-plugin-qqgm-webui",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "QQGM 附属 WebUI:插件识别、监控看板、记忆库、配置与日志。",
5
5
  "main": "index.js",
6
6
  "files": [
package/public/app.js CHANGED
@@ -126,6 +126,19 @@ async function initMemoryData() {
126
126
  if (!data || !data.installed) return;
127
127
  const badge = $('.nav-badge');
128
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
+ }
129
142
  const list = $('#memoryList');
130
143
  if (!list) return;
131
144
  if (!data.items.length) {
package/public/index.html CHANGED
@@ -319,13 +319,13 @@
319
319
  <div class="page-head">
320
320
  <div><h1>记忆库</h1><p>默认 MD;安装 qqgm-memory 后可切换 SQLite</p></div>
321
321
  <div class="head-actions">
322
- <div class="segmented"><button class="active">MD</button><button data-toast="SQLite 需要安装 qqgm-memory;默认仍用 MD">SQLite(未安装)</button></div>
322
+ <div class="segmented"><button class="active">MD</button><button data-toast="SQLite 需要安装 qqgm-memory 并切换主插件后端">SQLite(需切换)</button></div>
323
323
  <button class="btn primary" data-toast="新增记忆(原型)">+ 新增</button>
324
324
  </div>
325
325
  </div>
326
326
  <div class="memory-note" id="memoryBackend">默认使用 MD,兼容现有记忆文件;安装数据库附属插件 <b>qqgm-memory</b> 后可切换 SQLite,迁移前会先备份。</div>
327
327
  <div class="memory-layout">
328
- <aside class="card scope-list">
328
+ <aside class="card scope-list" id="memoryScopes">
329
329
  <h3>范围</h3>
330
330
  <button class="scope active"><span>全部</span><b>128</b></button>
331
331
  <button class="scope"><span>群 1103369527</span><b>86</b></button>