@nestim/koishi-plugin-qqgm-webui 0.2.10 → 0.2.12
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 +14 -1
- package/public/index.html +3 -3
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
|
@@ -65,7 +65,7 @@ function setMonitorState(on) {
|
|
|
65
65
|
const nav = $('.nav-item[data-page="monitor"]');
|
|
66
66
|
if (nav) nav.classList.toggle('disabled', !on);
|
|
67
67
|
const title = $('#pageTitle');
|
|
68
|
-
if (title) title.textContent = '总览';
|
|
68
|
+
if (title && $('#page-overview.active')) title.textContent = '总览';
|
|
69
69
|
}
|
|
70
70
|
const demoNoMonitor = $('#demoNoMonitor');
|
|
71
71
|
const demoMonitor = $('#demoMonitor');
|
|
@@ -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
|
@@ -317,15 +317,15 @@
|
|
|
317
317
|
|
|
318
318
|
<section class="page" id="page-memory">
|
|
319
319
|
<div class="page-head">
|
|
320
|
-
<div><h1>记忆库</h1><p>默认 MD
|
|
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
|
|
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>
|