@nestim/koishi-plugin-qqgm-webui 0.3.0 → 0.3.1
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/CHANGELOG.md +30 -0
- package/README.md +3 -1
- package/index.js +2 -1
- package/lib/data.js +23 -5
- package/lib/plugin-config.js +56 -4
- package/package.json +1 -1
- package/public/app.js +336 -79
- package/public/index.html +2 -3
- package/public/styles.css +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### 配置页:不再生搬 JSON
|
|
6
|
+
|
|
7
|
+
- 字符串列表(违禁词、删除词、白名单、QQ 号名单等)改为逐行编辑,支持 +/−;
|
|
8
|
+
- 对象列表改为可视化编辑:
|
|
9
|
+
- 字面替换:原文 / 替换为 两列;
|
|
10
|
+
- 术语解释:术语 / 含义;
|
|
11
|
+
- 追加风格:风格、概率、启用、字数上限、行数上限;
|
|
12
|
+
- 分群配置:群号卡片 + 组内字段,支持嵌套追加风格;
|
|
13
|
+
- 人设、系统提示词、私聊规则等长文本改用大文本框;
|
|
14
|
+
- 访问题目保留小眼睛;`hidden` 被 flex 覆盖导致折叠卡片自动展开的问题修复。
|
|
15
|
+
|
|
16
|
+
### 主插件配置:白名单可见
|
|
17
|
+
|
|
18
|
+
- 群规则卡片默认展开,不再需要点「展开」才能看到「该群违禁词白名单」;
|
|
19
|
+
- 群规则顶部加说明:每个群可单独设置违禁词、白名单、禁止项与自动管控,没填的跟随全局;
|
|
20
|
+
- 展开/收起按钮改成 ▸/▾,不再竖排换行。
|
|
21
|
+
|
|
22
|
+
### 记忆库:分页与筛选
|
|
23
|
+
|
|
24
|
+
- 服务端分页:`page` / `pageSize`(10、20、50、100 条/页),返回 `matched / pages / scopeTotal`;
|
|
25
|
+
- 范围、分类、搜索都走服务端筛选,切分类后计数跟随当前范围;
|
|
26
|
+
- 底部增加「筛选出 X 条 · 第 X / Y 页」、上一页/下一页、每页条数;
|
|
27
|
+
- 搜索改为 300ms 防抖后查全库,不再只过滤当前页 DOM。
|
|
28
|
+
|
|
29
|
+
### 测试
|
|
30
|
+
|
|
31
|
+
- `test/webui.test.mjs` 增加记忆分页/分类筛选、嵌套 Schema 控件识别用例(15 项通过)。
|
|
32
|
+
|
|
3
33
|
## 0.3.0
|
|
4
34
|
|
|
5
35
|
### 界面
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
# qqgm-webui(0.3.
|
|
1
|
+
# qqgm-webui(0.3.1)
|
|
2
2
|
|
|
3
3
|
QQGM 附属插件的图形化管理台。
|
|
4
4
|
|
|
5
5
|
- 首页、插件、监控、记忆页接**真实 API**(监控 SQLite、记忆 SQLite、插件扫描、`ctx.bots`);
|
|
6
6
|
- 主插件配置、附属插件配置、访问令牌都直接读写 `koishi.yml`(写前备份);
|
|
7
|
+
- 配置页按 Schema 生成可视化控件:列表逐行编辑、对象列表用卡片、长文本用大文本框,不把数组/对象塞成 JSON;
|
|
8
|
+
- 记忆库支持服务端分页(10/20/50/100 条/页)与范围/分类/关键词筛选;
|
|
7
9
|
- 日志页接进程内日志缓冲,支持级别/关键词过滤与暂停;
|
|
8
10
|
- 左侧导航适配手机(抽屉式),顶栏 Bot 状态来自真实连接状态;
|
|
9
11
|
- 默认只在 `/qqgm` 提供页面,公网访问必须设置 token。
|
package/index.js
CHANGED
|
@@ -300,7 +300,8 @@ function apply(ctx, config) {
|
|
|
300
300
|
scope: koa.query.scope || '',
|
|
301
301
|
query: koa.query.q || '',
|
|
302
302
|
category: koa.query.category || '',
|
|
303
|
-
|
|
303
|
+
page: koa.query.page || 1,
|
|
304
|
+
pageSize: koa.query.pageSize || koa.query.limit || 20,
|
|
304
305
|
}));
|
|
305
306
|
});
|
|
306
307
|
|
package/lib/data.js
CHANGED
|
@@ -156,7 +156,9 @@ function parseScope(text) {
|
|
|
156
156
|
return { kind: 'group', id: value };
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
function memory(ctx, {
|
|
159
|
+
function memory(ctx, {
|
|
160
|
+
scope = '', query = '', category = '', limit = 0, page = 1, pageSize = 20,
|
|
161
|
+
} = {}) {
|
|
160
162
|
const base = ctx.baseDir || process.cwd();
|
|
161
163
|
const file = path.join(base, 'data', 'qqgm-memory.sqlite');
|
|
162
164
|
const cfg = readMemoryConfig(ctx);
|
|
@@ -181,16 +183,27 @@ function memory(ctx, { scope = '', query = '', category = '', limit = 50 } = {})
|
|
|
181
183
|
const parsed = parseScope(scope);
|
|
182
184
|
let filtered = source;
|
|
183
185
|
if (parsed) filtered = filtered.filter((item) => item.scope_kind === parsed.kind && String(item.scope_id) === String(parsed.id));
|
|
186
|
+
|
|
187
|
+
// 分类计数跟随当前范围,切范围时计数不会对不上
|
|
188
|
+
const scopeFiltered = filtered;
|
|
189
|
+
const categories = new Map();
|
|
190
|
+
for (const item of scopeFiltered) {
|
|
191
|
+
const key = item.category || '未分类';
|
|
192
|
+
categories.set(key, (categories.get(key) || 0) + 1);
|
|
193
|
+
}
|
|
194
|
+
|
|
184
195
|
if (category) filtered = filtered.filter((item) => (item.category || '未分类') === category);
|
|
185
196
|
if (query) filtered = filtered.filter((item) => String(item.content).includes(query) || String(item.label || '').includes(query));
|
|
186
|
-
|
|
197
|
+
|
|
198
|
+
const size = Math.max(1, Math.min(100, Number(limit) || Number(pageSize) || 20));
|
|
199
|
+
const pages = Math.max(1, Math.ceil(filtered.length / size));
|
|
200
|
+
const current = Math.max(1, Math.min(pages, Number(page) || 1));
|
|
201
|
+
const items = filtered.slice((current - 1) * size, current * size);
|
|
202
|
+
|
|
187
203
|
const scopes = new Map();
|
|
188
|
-
const categories = new Map();
|
|
189
204
|
for (const item of source) {
|
|
190
205
|
const key = `${item.scope_kind}:${item.scope_id || ''}`;
|
|
191
206
|
scopes.set(key, (scopes.get(key) || 0) + 1);
|
|
192
|
-
const category = item.category || '未分类';
|
|
193
|
-
categories.set(category, (categories.get(category) || 0) + 1);
|
|
194
207
|
}
|
|
195
208
|
return {
|
|
196
209
|
installed: sqliteInstalled || md.entries.length > 0,
|
|
@@ -201,6 +214,11 @@ function memory(ctx, { scope = '', query = '', category = '', limit = 50 } = {})
|
|
|
201
214
|
needsMigration: md.entries.length > 0 && !useSqlite,
|
|
202
215
|
items,
|
|
203
216
|
total: source.length,
|
|
217
|
+
scopeTotal: scopeFiltered.length,
|
|
218
|
+
matched: filtered.length,
|
|
219
|
+
page: current,
|
|
220
|
+
pageSize: size,
|
|
221
|
+
pages,
|
|
204
222
|
md: { files: md.files, total: md.entries.length },
|
|
205
223
|
scopes: [...scopes].map(([key, n]) => {
|
|
206
224
|
const [scope_kind, scope_id] = key.split(':');
|
package/lib/plugin-config.js
CHANGED
|
@@ -49,6 +49,33 @@ function humanLabel(key, description) {
|
|
|
49
49
|
return key;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
const LABELS = {
|
|
53
|
+
from: '原文',
|
|
54
|
+
to: '替换为',
|
|
55
|
+
term: '术语',
|
|
56
|
+
meaning: '含义',
|
|
57
|
+
style: '风格',
|
|
58
|
+
probability: '概率',
|
|
59
|
+
enabled: '启用',
|
|
60
|
+
maxChars: '字数上限',
|
|
61
|
+
maxLines: '行数上限',
|
|
62
|
+
groupId: '群号',
|
|
63
|
+
systemPrompt: '系统提示词',
|
|
64
|
+
primaryStyle: '主风格',
|
|
65
|
+
extraStyles: '追加风格',
|
|
66
|
+
bannedPatterns: '删除词/短语',
|
|
67
|
+
replacements: '字面替换',
|
|
68
|
+
glossary: '术语解释',
|
|
69
|
+
allowedUsers: '只回复这些 QQ 号',
|
|
70
|
+
blockedUsers: '不回复这些 QQ 号',
|
|
71
|
+
allowedUserIds: '允许的用户 ID',
|
|
72
|
+
dbFile: 'SQLite 文件',
|
|
73
|
+
bannedWords: '违禁词',
|
|
74
|
+
whitelistKeywords: '白名单关键词',
|
|
75
|
+
strongKeywords: '强关键词',
|
|
76
|
+
bannedWordScoreThreshold: '违禁词阈值',
|
|
77
|
+
};
|
|
78
|
+
|
|
52
79
|
function fieldInfo(key, field, groupTitle) {
|
|
53
80
|
const meta = (field && field.meta) || {};
|
|
54
81
|
const type = String((field && field.type) || 'string');
|
|
@@ -62,21 +89,45 @@ function fieldInfo(key, field, groupTitle) {
|
|
|
62
89
|
const description = meta.description || '';
|
|
63
90
|
const defaultValue = meta.default;
|
|
64
91
|
const long = type === 'string' && (
|
|
65
|
-
|
|
92
|
+
meta.role === 'textarea'
|
|
93
|
+
|| /prompt|system|persona|template|greeting|welcome|instruction|rule|meaning/i.test(key)
|
|
66
94
|
|| (typeof defaultValue === 'string' && defaultValue.length > 60)
|
|
67
95
|
);
|
|
96
|
+
|
|
97
|
+
let list = false;
|
|
98
|
+
let objectList = false;
|
|
99
|
+
let itemFields = [];
|
|
100
|
+
let objectFields = [];
|
|
101
|
+
if (type === 'array') {
|
|
102
|
+
if (/^string\[\]/.test(String(field))) {
|
|
103
|
+
list = true;
|
|
104
|
+
} else if (field.inner && field.inner.dict) {
|
|
105
|
+
objectList = true;
|
|
106
|
+
itemFields = Object.keys(field.inner.dict).map((name) => fieldInfo(name, field.inner.dict[name], groupTitle));
|
|
107
|
+
}
|
|
108
|
+
} else if (type === 'object' && field.dict) {
|
|
109
|
+
objectFields = Object.keys(field.dict).map((name) => fieldInfo(name, field.dict[name], groupTitle));
|
|
110
|
+
}
|
|
111
|
+
|
|
68
112
|
return {
|
|
69
113
|
key,
|
|
70
114
|
group: groupTitle || '',
|
|
71
|
-
label: humanLabel(key, description),
|
|
115
|
+
label: LABELS[key] || humanLabel(key, description),
|
|
72
116
|
type,
|
|
73
117
|
description,
|
|
74
118
|
default: defaultValue,
|
|
75
119
|
options,
|
|
76
120
|
sensitive: /key|token|secret|password/i.test(key),
|
|
121
|
+
required: meta.required === true,
|
|
77
122
|
long,
|
|
78
|
-
list
|
|
79
|
-
|
|
123
|
+
list,
|
|
124
|
+
objectList,
|
|
125
|
+
itemFields,
|
|
126
|
+
objectFields,
|
|
127
|
+
scored: /bannedWords|strongKeywords/.test(key),
|
|
128
|
+
json: !list && !objectList && !objectFields.length && (
|
|
129
|
+
type === 'array' || type === 'object' || type === 'intersect'
|
|
130
|
+
),
|
|
80
131
|
};
|
|
81
132
|
}
|
|
82
133
|
|
|
@@ -232,5 +283,6 @@ module.exports = {
|
|
|
232
283
|
KNOWN,
|
|
233
284
|
readPluginConfig,
|
|
234
285
|
writePluginConfig,
|
|
286
|
+
flattenFields,
|
|
235
287
|
shortName,
|
|
236
288
|
};
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -476,13 +476,14 @@ $('#monitorExport')?.addEventListener('click', async () => {
|
|
|
476
476
|
|
|
477
477
|
let memoryItems = [];
|
|
478
478
|
let memoryState = null;
|
|
479
|
+
const memoryQuery = { scope: '', category: '', q: '', page: 1, pageSize: 20 };
|
|
479
480
|
|
|
480
481
|
function renderMemoryList(items) {
|
|
481
482
|
memoryItems = items || [];
|
|
482
483
|
const list = $('#memoryList');
|
|
483
484
|
if (!list) return;
|
|
484
485
|
if (!memoryItems.length) {
|
|
485
|
-
list.innerHTML = '<div class="memory-empty"><b>没有匹配的记忆</b><p
|
|
486
|
+
list.innerHTML = '<div class="memory-empty"><b>没有匹配的记忆</b><p>换个范围/分类,或调整搜索关键词。</p></div>';
|
|
486
487
|
return;
|
|
487
488
|
}
|
|
488
489
|
list.innerHTML = memoryItems.map((item, index) => `
|
|
@@ -497,75 +498,125 @@ function renderMemoryList(items) {
|
|
|
497
498
|
</article>`).join('');
|
|
498
499
|
}
|
|
499
500
|
|
|
500
|
-
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
501
|
+
function renderMemoryPager(data) {
|
|
502
|
+
const pager = $('#memoryPager');
|
|
503
|
+
if (!pager) return;
|
|
504
|
+
const pages = Number(data.pages) || 1;
|
|
505
|
+
const page = Number(data.page) || 1;
|
|
506
|
+
const size = Number(data.pageSize) || 20;
|
|
507
|
+
pager.innerHTML = `<div class="pager-info">筛选出 <b>${data.matched || 0}</b> 条 · 第 <b>${page}</b> / ${pages} 页</div>
|
|
508
|
+
<div class="pager-actions">
|
|
509
|
+
<select class="select tiny" id="memoryPageSize">${[10, 20, 50, 100].map((n) => `<option value="${n}" ${n === size ? 'selected' : ''}>${n} 条/页</option>`).join('')}</select>
|
|
510
|
+
<button class="btn ghost small" data-memory-page="${page - 1}" ${page <= 1 ? 'disabled' : ''}>上一页</button>
|
|
511
|
+
<button class="btn ghost small" data-memory-page="${page + 1}" ${page >= pages ? 'disabled' : ''}>下一页</button>
|
|
512
|
+
</div>`;
|
|
513
|
+
const count = $('#memoryCount');
|
|
514
|
+
if (count) count.textContent = `共 ${data.matched || 0} 条`;
|
|
510
515
|
}
|
|
511
516
|
|
|
512
|
-
|
|
517
|
+
function renderMemorySidebar(data) {
|
|
518
|
+
const scopes = $('#memoryScopes');
|
|
519
|
+
if (!scopes) return;
|
|
520
|
+
const activeScope = memoryQuery.scope;
|
|
521
|
+
const activeCategory = memoryQuery.category;
|
|
522
|
+
const buttons = [`<h3>范围</h3><button class="scope ${!activeScope && !activeCategory ? 'active' : ''}" data-scope="" data-category=""><span>全部</span><b>${data.total || 0}</b></button>`];
|
|
523
|
+
for (const item of data.scopes || []) {
|
|
524
|
+
const key = `${item.scope_kind}:${item.scope_id || ''}`;
|
|
525
|
+
const label = item.scope_kind === 'group' ? `群 ${item.scope_id}` : item.scope_kind === 'private' ? `私聊 ${item.scope_id}` : `全局 ${item.scope_id || ''}`;
|
|
526
|
+
buttons.push(`<button class="scope ${activeScope === key ? 'active' : ''}" data-scope="${key}"><span>${label}</span><b>${item.n}</b></button>`);
|
|
527
|
+
}
|
|
528
|
+
buttons.push('<h3 class="mt">分类</h3>');
|
|
529
|
+
buttons.push(`<button class="scope ${activeCategory === '' ? 'active' : ''}" data-category=""><span>全部分类</span><b>${data.scopeTotal || 0}</b></button>`);
|
|
530
|
+
for (const item of data.categories || []) {
|
|
531
|
+
const category = item.category || '未分类';
|
|
532
|
+
buttons.push(`<button class="scope ${activeCategory === category ? 'active' : ''}" data-category="${escHtml(category)}"><span>${escHtml(category)}</span><b>${item.n}</b></button>`);
|
|
533
|
+
}
|
|
534
|
+
scopes.innerHTML = buttons.join('');
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function renderMemoryHeader(data) {
|
|
538
|
+
const badge = $('.nav-badge');
|
|
539
|
+
if (badge) badge.textContent = String(data.total || 0);
|
|
540
|
+
const headP = $('#page-memory .page-head p');
|
|
541
|
+
if (headP) {
|
|
542
|
+
headP.textContent = data.useSqlite
|
|
543
|
+
? `当前 SQLite · ${data.total || 0} 条;切换前备份 koishi.yml`
|
|
544
|
+
: (data.md?.total
|
|
545
|
+
? `当前 MD · 识别到 ${data.md.total} 条旧记忆,可迁移到 SQLite`
|
|
546
|
+
: '当前 MD · 没有识别到旧记忆文件');
|
|
547
|
+
}
|
|
548
|
+
const pill = $('#memoryBackendPill');
|
|
549
|
+
if (pill) {
|
|
550
|
+
pill.textContent = data.useSqlite ? `当前:SQLite · ${data.total || 0} 条` : `当前:MD · ${data.total || 0} 条`;
|
|
551
|
+
pill.classList.toggle('sqlite', !!data.useSqlite);
|
|
552
|
+
}
|
|
553
|
+
const migrateBtn = $('#migrateMemory');
|
|
554
|
+
const switchSqliteBtn = $('#switchSqlite');
|
|
555
|
+
const switchBtn = $('#switchMd');
|
|
556
|
+
if (migrateBtn) migrateBtn.hidden = !(data.md?.total > 0);
|
|
557
|
+
if (switchSqliteBtn) switchSqliteBtn.hidden = !(data.backend === 'md' && (data.sqliteTotal || 0) > 0);
|
|
558
|
+
if (switchBtn) switchBtn.hidden = data.backend !== 'sqlite';
|
|
559
|
+
const note = $('#memoryBackend');
|
|
560
|
+
if (note) {
|
|
561
|
+
note.innerHTML = data.useSqlite
|
|
562
|
+
? '当前使用 SQLite;修改前会备份 <code>koishi.yml</code>,旧 MD 文件保留可回滚。'
|
|
563
|
+
: (data.md?.total
|
|
564
|
+
? `当前使用 MD,识别到 ${data.md.total} 条旧记忆、${data.md.files?.length || 0} 个文件。先点“迁移 MD → SQLite”导入,再点“切换到 SQLite”;迁移不会自动切换。`
|
|
565
|
+
: '默认使用 MD;没有识别到旧记忆文件。');
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
async function loadMemory(resetPage = false) {
|
|
570
|
+
if (resetPage) memoryQuery.page = 1;
|
|
571
|
+
const params = new URLSearchParams({
|
|
572
|
+
page: String(memoryQuery.page),
|
|
573
|
+
pageSize: String(memoryQuery.pageSize),
|
|
574
|
+
});
|
|
575
|
+
if (memoryQuery.scope) params.set('scope', memoryQuery.scope);
|
|
576
|
+
if (memoryQuery.category) params.set('category', memoryQuery.category);
|
|
577
|
+
if (memoryQuery.q) params.set('q', memoryQuery.q);
|
|
513
578
|
try {
|
|
514
|
-
const data = await apiGet(
|
|
579
|
+
const data = await apiGet(`api/memory?${params}`);
|
|
515
580
|
if (!data || !data.installed) return;
|
|
516
|
-
memoryItems = data.items || [];
|
|
517
581
|
memoryState = data;
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (migrateBtn) migrateBtn.hidden = !(data.md?.total > 0);
|
|
537
|
-
if (switchSqliteBtn) switchSqliteBtn.hidden = !(data.backend === 'md' && (data.sqliteTotal || 0) > 0);
|
|
538
|
-
if (switchBtn) switchBtn.hidden = data.backend !== 'sqlite';
|
|
539
|
-
const note = $('#memoryBackend');
|
|
540
|
-
if (note) {
|
|
541
|
-
note.innerHTML = data.useSqlite
|
|
542
|
-
? '当前使用 SQLite;修改前会备份 <code>koishi.yml</code>,旧 MD 文件保留可回滚。'
|
|
543
|
-
: (data.md?.total
|
|
544
|
-
? `当前使用 MD,识别到 ${data.md.total} 条旧记忆、${data.md.files?.length || 0} 个文件。先点“迁移 MD → SQLite”导入,再点“切换到 SQLite”;迁移不会自动切换。`
|
|
545
|
-
: '默认使用 MD;没有识别到旧记忆文件。');
|
|
546
|
-
}
|
|
547
|
-
const scopes = $('#memoryScopes');
|
|
548
|
-
if (scopes) {
|
|
549
|
-
const buttons = [`<h3>范围</h3><button class="scope active" data-scope="" data-category=""><span>全部</span><b>${data.total || 0}</b></button>`];
|
|
550
|
-
for (const item of data.scopes || []) {
|
|
551
|
-
const label = item.scope_kind === 'group' ? `群 ${item.scope_id}` : item.scope_kind === 'private' ? `私聊 ${item.scope_id}` : `全局 ${item.scope_id || ''}`;
|
|
552
|
-
buttons.push(`<button class="scope" data-scope="${item.scope_kind}:${item.scope_id || ''}"><span>${label}</span><b>${item.n}</b></button>`);
|
|
553
|
-
}
|
|
554
|
-
buttons.push('<h3 class="mt">分类</h3>');
|
|
555
|
-
for (const item of data.categories || []) {
|
|
556
|
-
buttons.push(`<button class="scope" data-category="${escHtml(item.category)}"><span>${escHtml(item.category)}</span><b>${item.n}</b></button>`);
|
|
557
|
-
}
|
|
558
|
-
scopes.innerHTML = buttons.join('');
|
|
559
|
-
}
|
|
560
|
-
renderMemoryList(data.items);
|
|
561
|
-
} catch { /* 文件预览保留静态示例 */ }
|
|
582
|
+
memoryItems = data.items || [];
|
|
583
|
+
renderMemoryList(memoryItems);
|
|
584
|
+
renderMemoryPager(data);
|
|
585
|
+
renderMemorySidebar(data);
|
|
586
|
+
renderMemoryHeader(data);
|
|
587
|
+
} catch {
|
|
588
|
+
showToast('记忆库读取失败');
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
async function filterMemory(scope, category) {
|
|
593
|
+
memoryQuery.scope = scope || '';
|
|
594
|
+
memoryQuery.category = category || '';
|
|
595
|
+
await loadMemory(true);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
async function initMemoryData() {
|
|
599
|
+
await loadMemory(true);
|
|
562
600
|
}
|
|
563
601
|
|
|
564
602
|
$('#memoryScopes')?.addEventListener('click', (event) => {
|
|
565
603
|
const btn = event.target.closest('.scope');
|
|
566
604
|
if (!btn) return;
|
|
567
605
|
if (btn.dataset.scope === undefined && btn.dataset.category === undefined) return;
|
|
568
|
-
filterMemory(btn.dataset.scope || '', btn.dataset.category || ''
|
|
606
|
+
filterMemory(btn.dataset.scope || '', btn.dataset.category || '').catch(() => {});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
$('#memoryPager')?.addEventListener('click', (event) => {
|
|
610
|
+
const button = event.target.closest('[data-memory-page]');
|
|
611
|
+
if (!button || button.disabled) return;
|
|
612
|
+
memoryQuery.page = Number(button.dataset.memoryPage) || 1;
|
|
613
|
+
loadMemory();
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
$('#memoryPager')?.addEventListener('change', (event) => {
|
|
617
|
+
if (event.target.id !== 'memoryPageSize') return;
|
|
618
|
+
memoryQuery.pageSize = Number(event.target.value) || 20;
|
|
619
|
+
loadMemory(true);
|
|
569
620
|
});
|
|
570
621
|
|
|
571
622
|
function memoryScopeLabel(item) {
|
|
@@ -751,7 +802,7 @@ function groupCardHtml(field, group = {}, collapsed = true) {
|
|
|
751
802
|
return `<article class="group-rule" data-group-card>
|
|
752
803
|
<div class="group-rule-head">
|
|
753
804
|
<input class="group-rule-id" value="${escHtml(group.guildId || '')}" placeholder="群号" />
|
|
754
|
-
<button type="button" class="row-btn" data-toggle-group>${collapsed ? '
|
|
805
|
+
<button type="button" class="row-btn" data-toggle-group title="展开/收起">${collapsed ? '▸' : '▾'}</button>
|
|
755
806
|
<button type="button" class="row-btn" data-remove-group>×</button>
|
|
756
807
|
</div>
|
|
757
808
|
<div class="group-rule-body" ${collapsed ? 'hidden' : ''}>
|
|
@@ -765,9 +816,13 @@ function renderGroupRules(field, value) {
|
|
|
765
816
|
const groups = Array.isArray(value) ? value : [];
|
|
766
817
|
const enabled = groups.length > 0;
|
|
767
818
|
return `<div class="group-rules" data-group-rules>
|
|
768
|
-
<
|
|
819
|
+
<div class="group-rules-head">
|
|
820
|
+
<label class="switch"><input type="checkbox" data-group-enabled ${enabled ? 'checked' : ''} /><i></i><span>${enabled ? '按群号覆盖' : '未开启,使用全局配置'}</span></label>
|
|
821
|
+
<button type="button" class="link-btn" data-toggle-all-groups="collapse">全部收起</button>
|
|
822
|
+
</div>
|
|
823
|
+
<p class="group-rule-hint">每个群可以单独设置违禁词、白名单、禁止项与自动管控;没填的项跟随全局。</p>
|
|
769
824
|
<div class="group-rules-list" ${enabled ? '' : 'hidden'}>
|
|
770
|
-
${groups.map((group) => groupCardHtml(field, group,
|
|
825
|
+
${groups.map((group) => groupCardHtml(field, group, false)).join('')}
|
|
771
826
|
<button type="button" class="link-btn" data-add-group>+ 添加群规则</button>
|
|
772
827
|
</div>
|
|
773
828
|
</div>`;
|
|
@@ -894,8 +949,22 @@ function renderMainGroup(index) {
|
|
|
894
949
|
const body = toggleGroup.closest('[data-group-card]')?.querySelector('.group-rule-body');
|
|
895
950
|
if (body) {
|
|
896
951
|
body.hidden = !body.hidden;
|
|
897
|
-
toggleGroup.textContent = body.hidden ? '
|
|
952
|
+
toggleGroup.textContent = body.hidden ? '▸' : '▾';
|
|
898
953
|
}
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const toggleAll = event.target.closest('[data-toggle-all-groups]');
|
|
957
|
+
if (toggleAll) {
|
|
958
|
+
const rules = toggleAll.closest('[data-group-rules]');
|
|
959
|
+
const collapse = toggleAll.dataset.toggleAllGroups === 'collapse';
|
|
960
|
+
rules?.querySelectorAll('[data-group-card]').forEach((card) => {
|
|
961
|
+
const body = card.querySelector('.group-rule-body');
|
|
962
|
+
const button = card.querySelector('[data-toggle-group]');
|
|
963
|
+
if (body) body.hidden = collapse;
|
|
964
|
+
if (button) button.textContent = collapse ? '▸' : '▾';
|
|
965
|
+
});
|
|
966
|
+
toggleAll.dataset.toggleAllGroups = collapse ? 'expand' : 'collapse';
|
|
967
|
+
toggleAll.textContent = collapse ? '全部展开' : '全部收起';
|
|
899
968
|
}
|
|
900
969
|
};
|
|
901
970
|
|
|
@@ -1024,6 +1093,86 @@ async function initPluginConfig(force = false) {
|
|
|
1024
1093
|
}
|
|
1025
1094
|
}
|
|
1026
1095
|
|
|
1096
|
+
const fieldRegistry = new Map();
|
|
1097
|
+
let fieldSeq = 0;
|
|
1098
|
+
|
|
1099
|
+
function registerField(field) {
|
|
1100
|
+
fieldSeq += 1;
|
|
1101
|
+
const id = `f${fieldSeq}`;
|
|
1102
|
+
fieldRegistry.set(id, field);
|
|
1103
|
+
return id;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function listEditorHtml(field, value) {
|
|
1107
|
+
const values = Array.isArray(value) ? value : [];
|
|
1108
|
+
const rows = values.length
|
|
1109
|
+
? values.map((item) => {
|
|
1110
|
+
const [text, score] = splitScored(item);
|
|
1111
|
+
return listRowHtml(field.scored, text, score);
|
|
1112
|
+
}).join('')
|
|
1113
|
+
: listRowHtml(field.scored);
|
|
1114
|
+
return `<div class="list-editor" data-list-key="${field.key}" data-field-id="${registerField(field)}" data-list-scored="${field.scored ? '1' : '0'}">
|
|
1115
|
+
<div class="list-rows">${rows}</div>
|
|
1116
|
+
<button type="button" class="link-btn add-row" data-add-row>+ 添加一行</button>
|
|
1117
|
+
</div>`;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function objectControlHtml(field, value) {
|
|
1121
|
+
const current = value == null ? (field.default ?? '') : value;
|
|
1122
|
+
if (field.type === 'boolean') {
|
|
1123
|
+
return `<label class="switch mini"><input type="checkbox" ${current ? 'checked' : ''} /><i></i><span>${current ? '开启' : '关闭'}</span></label>`;
|
|
1124
|
+
}
|
|
1125
|
+
if (field.type === 'union') {
|
|
1126
|
+
const options = (field.options || []).slice();
|
|
1127
|
+
if (current !== '' && !options.includes(String(current))) options.unshift(String(current));
|
|
1128
|
+
const empty = field.required ? '' : (current === '' ? '<option value="" selected>(留空)</option>' : '<option value="">(留空)</option>');
|
|
1129
|
+
return `<select>${empty}${options.map((opt) => `<option ${String(current) === String(opt) ? 'selected' : ''}>${escHtml(opt)}</option>`).join('')}</select>`;
|
|
1130
|
+
}
|
|
1131
|
+
if (field.type === 'number') {
|
|
1132
|
+
return `<input type="number" value="${current === '' ? '' : escHtml(current)}" />`;
|
|
1133
|
+
}
|
|
1134
|
+
if (field.list) return listEditorHtml(field, current);
|
|
1135
|
+
if (field.objectList) return objectListHtml(field, current);
|
|
1136
|
+
if (field.long) return `<textarea rows="4">${escHtml(current)}</textarea>`;
|
|
1137
|
+
return `<input type="text" value="${escHtml(current)}" />`;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
function objectRowHtml(field, item) {
|
|
1141
|
+
const data = item || {};
|
|
1142
|
+
const compact = field.itemFields.length <= 2
|
|
1143
|
+
&& field.itemFields.every((sub) => !sub.objectList && !(sub.objectFields && sub.objectFields.length));
|
|
1144
|
+
if (compact) {
|
|
1145
|
+
return `<div class="kv-row" data-object-row>
|
|
1146
|
+
${field.itemFields.map((sub) => `<label class="kv-cell" data-obj-field="${sub.key}"><span>${escHtml(sub.label || sub.key)}</span>${objectControlHtml(sub, data[sub.key])}</label>`).join('')}
|
|
1147
|
+
<button type="button" class="row-btn" data-remove-object title="删除">−</button>
|
|
1148
|
+
</div>`;
|
|
1149
|
+
}
|
|
1150
|
+
const titleField = field.itemFields[0];
|
|
1151
|
+
const rest = field.itemFields.slice(1);
|
|
1152
|
+
return `<article class="object-card" data-object-row>
|
|
1153
|
+
<div class="object-card-head">
|
|
1154
|
+
<input class="object-card-title" data-object-title value="${escHtml(data[titleField.key] ?? titleField.default ?? '')}" placeholder="${escHtml(titleField.label || titleField.key)}" />
|
|
1155
|
+
<button type="button" class="row-btn" data-toggle-object title="展开/收起">▸</button>
|
|
1156
|
+
<button type="button" class="row-btn" data-remove-object title="删除">×</button>
|
|
1157
|
+
</div>
|
|
1158
|
+
<div class="object-card-body" hidden>
|
|
1159
|
+
${rest.map((sub) => `<div class="obj-field ${sub.long || sub.list || sub.objectList ? 'block' : ''}" data-obj-field="${sub.key}">
|
|
1160
|
+
<span>${escHtml(sub.label || sub.key)}</span>
|
|
1161
|
+
<div class="obj-control">${objectControlHtml(sub, data[sub.key])}</div>
|
|
1162
|
+
</div>`).join('')}
|
|
1163
|
+
</div>
|
|
1164
|
+
</article>`;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
function objectListHtml(field, value) {
|
|
1168
|
+
const items = Array.isArray(value) ? value : [];
|
|
1169
|
+
const rows = items.length ? items.map((item) => objectRowHtml(field, item)).join('') : objectRowHtml(field, {});
|
|
1170
|
+
return `<div class="object-list" data-object-key="${field.key}" data-field-id="${registerField(field)}">
|
|
1171
|
+
<div class="object-rows">${rows}</div>
|
|
1172
|
+
<button type="button" class="link-btn add-row" data-add-object>+ 添加${escHtml(field.label || '一条')}</button>
|
|
1173
|
+
</div>`;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1027
1176
|
function fieldControl(field, value) {
|
|
1028
1177
|
const current = value == null ? (field.value ?? field.default ?? '') : value;
|
|
1029
1178
|
if (field.type === 'boolean') {
|
|
@@ -1038,6 +1187,11 @@ function fieldControl(field, value) {
|
|
|
1038
1187
|
if (field.type === 'number') {
|
|
1039
1188
|
return `<input type="number" data-key="${field.key}" data-kind="number" value="${escHtml(current ?? field.default ?? 0)}" />`;
|
|
1040
1189
|
}
|
|
1190
|
+
if (field.list) return listEditorHtml(field, current);
|
|
1191
|
+
if (field.objectList) return objectListHtml(field, current);
|
|
1192
|
+
if (field.objectFields?.length) {
|
|
1193
|
+
return `<div class="object-fields" data-object-fields="${field.key}" data-field-id="${registerField(field)}">${field.objectFields.map((sub) => `<div class="obj-field ${sub.long ? 'block' : ''}" data-obj-field="${sub.key}"><span>${escHtml(sub.label || sub.key)}</span><div class="obj-control">${objectControlHtml(sub, current?.[sub.key])}</div></div>`).join('')}</div>`;
|
|
1194
|
+
}
|
|
1041
1195
|
if (field.json) {
|
|
1042
1196
|
const val = field.type === 'array' && !Array.isArray(current) ? [] : (current || (field.type === 'array' ? [] : {}));
|
|
1043
1197
|
return `<textarea rows="4" class="json-input" data-key="${field.key}" data-kind="json">${escHtml(JSON.stringify(val, null, 2))}</textarea>`;
|
|
@@ -1049,7 +1203,7 @@ function fieldControl(field, value) {
|
|
|
1049
1203
|
</div>`;
|
|
1050
1204
|
}
|
|
1051
1205
|
if (field.long) {
|
|
1052
|
-
return `<textarea rows="
|
|
1206
|
+
return `<textarea rows="8" data-key="${field.key}" data-kind="string">${escHtml(current ?? field.default ?? '')}</textarea>`;
|
|
1053
1207
|
}
|
|
1054
1208
|
return `<input type="text" data-key="${field.key}" data-kind="string" value="${escHtml(current ?? field.default ?? '')}" />`;
|
|
1055
1209
|
}
|
|
@@ -1094,15 +1248,20 @@ async function openPluginConfig(pkg) {
|
|
|
1094
1248
|
return;
|
|
1095
1249
|
}
|
|
1096
1250
|
const badges = `<span class="status ${info.configured ? 'ok' : 'warn'}">${info.configured ? '已启用' : '未启用'}</span>`;
|
|
1251
|
+
fieldRegistry.clear();
|
|
1252
|
+
fieldSeq = 0;
|
|
1097
1253
|
const fieldHtml = groupFields(info.fields).map(([group, fields]) => `<div class="form-section"><h3>${escHtml(group)}</h3>`
|
|
1098
|
-
+ fields.map((field) =>
|
|
1254
|
+
+ fields.map((field) => {
|
|
1255
|
+
const wide = field.long || field.list || field.objectList;
|
|
1256
|
+
return `<div class="schema-field ${wide ? 'long' : ''}">
|
|
1099
1257
|
<div class="schema-field-info">
|
|
1100
1258
|
<div class="schema-field-title">${escHtml(field.label || field.key)}</div>
|
|
1101
1259
|
${field.description ? `<p class="schema-field-desc">${escHtml(field.description)}</p>` : ''}
|
|
1102
1260
|
<code class="schema-field-key">${escHtml(field.key)}${field.foreign ? ' · 主插件' : ''}</code>
|
|
1103
1261
|
</div>
|
|
1104
|
-
<div class="schema-field-control">${fieldControl(field, info.values[field.key])}</div>
|
|
1105
|
-
</div
|
|
1262
|
+
<div class="schema-field-control" data-plugin-field="${field.key}" data-field-id="${registerField(field)}">${fieldControl(field, info.values[field.key])}</div>
|
|
1263
|
+
</div>`;
|
|
1264
|
+
}).join('')
|
|
1106
1265
|
+ '</div>').join('');
|
|
1107
1266
|
form.innerHTML = `<div class="form-head"><div><h2>${escHtml(info.title || info.name)}</h2><p>${escHtml(info.name)} · v${escHtml(info.version || '未知')}${info.instance ? ` · ${escHtml(info.instance)}` : ''}</p></div>${badges}</div>`
|
|
1108
1267
|
+ (pkg === '@nestim/koishi-plugin-qqgm-memory' ? '<div class="sync-note" id="memorySyncNote">记忆后端状态读取中…</div>' : '')
|
|
@@ -1116,6 +1275,44 @@ async function openPluginConfig(pkg) {
|
|
|
1116
1275
|
input.type = show ? 'text' : 'password';
|
|
1117
1276
|
btn.innerHTML = show ? EYE_OFF_ICON : EYE_ICON;
|
|
1118
1277
|
}));
|
|
1278
|
+
form.onclick = (event) => {
|
|
1279
|
+
const addRow = event.target.closest('[data-add-row]');
|
|
1280
|
+
if (addRow) {
|
|
1281
|
+
const editor = addRow.closest('.list-editor');
|
|
1282
|
+
const field = fieldRegistry.get(editor?.dataset.fieldId);
|
|
1283
|
+
if (editor && field) editor.querySelector('.list-rows').insertAdjacentHTML('beforeend', listRowHtml(field.scored));
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
const removeRow = event.target.closest('[data-remove-row]');
|
|
1287
|
+
if (removeRow) {
|
|
1288
|
+
const editor = removeRow.closest('.list-editor');
|
|
1289
|
+
removeRow.closest('.list-row')?.remove();
|
|
1290
|
+
if (editor && !editor.querySelector('.list-row')) {
|
|
1291
|
+
const field = fieldRegistry.get(editor.dataset.fieldId);
|
|
1292
|
+
editor.querySelector('.list-rows').innerHTML = listRowHtml(field ? field.scored : false);
|
|
1293
|
+
}
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
const addObject = event.target.closest('[data-add-object]');
|
|
1297
|
+
if (addObject) {
|
|
1298
|
+
const list = addObject.closest('[data-object-key]');
|
|
1299
|
+
const field = fieldRegistry.get(list?.dataset.fieldId);
|
|
1300
|
+
if (list && field) list.querySelector(':scope > .object-rows').insertAdjacentHTML('beforeend', objectRowHtml(field, {}));
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const removeObject = event.target.closest('[data-remove-object]');
|
|
1304
|
+
if (removeObject) {
|
|
1305
|
+
removeObject.closest('[data-object-row]')?.remove();
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
const toggleObject = event.target.closest('[data-toggle-object]');
|
|
1309
|
+
if (toggleObject) {
|
|
1310
|
+
const body = toggleObject.closest('.object-card')?.querySelector('.object-card-body');
|
|
1311
|
+
if (!body) return;
|
|
1312
|
+
body.hidden = !body.hidden;
|
|
1313
|
+
toggleObject.textContent = body.hidden ? '▸' : '▾';
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1119
1316
|
form.onchange = (event) => {
|
|
1120
1317
|
if (event.target.matches('.switch input')) {
|
|
1121
1318
|
const text = event.target.parentElement?.querySelector('span');
|
|
@@ -1139,17 +1336,75 @@ async function updateMemorySyncNote() {
|
|
|
1139
1336
|
}
|
|
1140
1337
|
}
|
|
1141
1338
|
|
|
1339
|
+
function collectSimpleValue(container, field) {
|
|
1340
|
+
if (!container) return undefined;
|
|
1341
|
+
if (field.type === 'boolean') {
|
|
1342
|
+
const checkbox = container.querySelector('input[type="checkbox"]');
|
|
1343
|
+
return checkbox ? !!checkbox.checked : undefined;
|
|
1344
|
+
}
|
|
1345
|
+
const input = container.querySelector('input, select, textarea');
|
|
1346
|
+
if (!input) return undefined;
|
|
1347
|
+
if (field.type === 'number') return input.value === '' ? undefined : Number(input.value);
|
|
1348
|
+
if (field.json) {
|
|
1349
|
+
try { return JSON.parse(input.value); }
|
|
1350
|
+
catch { throw new Error(`${field.label || field.key} 的 JSON 格式不对`); }
|
|
1351
|
+
}
|
|
1352
|
+
return input.value;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
function collectObjectList(container, field) {
|
|
1356
|
+
if (!container) return [];
|
|
1357
|
+
const rows = [...container.querySelectorAll(':scope > .object-rows > [data-object-row]')];
|
|
1358
|
+
const result = [];
|
|
1359
|
+
for (const row of rows) {
|
|
1360
|
+
const item = {};
|
|
1361
|
+
const isCompact = row.classList.contains('kv-row');
|
|
1362
|
+
if (!isCompact && field.itemFields[0]) {
|
|
1363
|
+
const title = row.querySelector('.object-card-title');
|
|
1364
|
+
if (title) item[field.itemFields[0].key] = title.value;
|
|
1365
|
+
}
|
|
1366
|
+
const cells = isCompact
|
|
1367
|
+
? [...row.querySelectorAll(':scope > [data-obj-field]')]
|
|
1368
|
+
: [...row.querySelectorAll(':scope > .object-card-body > [data-obj-field]')];
|
|
1369
|
+
for (const cell of cells) {
|
|
1370
|
+
const sub = field.itemFields.find((entry) => entry.key === cell.dataset.objField);
|
|
1371
|
+
if (!sub) continue;
|
|
1372
|
+
let value;
|
|
1373
|
+
if (sub.list) value = collectList(cell.querySelector('[data-list-key]'), sub);
|
|
1374
|
+
else if (sub.objectList) value = collectObjectList(cell.querySelector('[data-object-key]'), sub);
|
|
1375
|
+
else value = collectSimpleValue(cell, sub);
|
|
1376
|
+
if (value !== undefined) item[sub.key] = value;
|
|
1377
|
+
}
|
|
1378
|
+
if (Object.keys(item).length) result.push(item);
|
|
1379
|
+
}
|
|
1380
|
+
return result;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function collectObjectFields(container, field) {
|
|
1384
|
+
const item = {};
|
|
1385
|
+
for (const sub of field.objectFields || []) {
|
|
1386
|
+
const cell = container.querySelector(`:scope > [data-obj-field="${sub.key}"]`);
|
|
1387
|
+
if (!cell) continue;
|
|
1388
|
+
let value;
|
|
1389
|
+
if (sub.list) value = collectList(cell.querySelector('[data-list-key]'), sub);
|
|
1390
|
+
else if (sub.objectList) value = collectObjectList(cell.querySelector('[data-object-key]'), sub);
|
|
1391
|
+
else value = collectSimpleValue(cell, sub);
|
|
1392
|
+
if (value !== undefined) item[sub.key] = value;
|
|
1393
|
+
}
|
|
1394
|
+
return item;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1142
1397
|
function collectPluginValues(form, info) {
|
|
1143
1398
|
const values = {};
|
|
1144
1399
|
for (const field of info.fields) {
|
|
1145
|
-
const
|
|
1146
|
-
if (!
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
else if (field.
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1400
|
+
const cell = form.querySelector(`[data-plugin-field="${field.key}"]`);
|
|
1401
|
+
if (!cell) continue;
|
|
1402
|
+
let value;
|
|
1403
|
+
if (field.list) value = collectList(cell.querySelector('[data-list-key]'), field);
|
|
1404
|
+
else if (field.objectList) value = collectObjectList(cell.querySelector('[data-object-key]'), field);
|
|
1405
|
+
else if (field.objectFields?.length) value = collectObjectFields(cell, field);
|
|
1406
|
+
else value = collectSimpleValue(cell, field);
|
|
1407
|
+
if (value !== undefined) values[field.key] = value;
|
|
1153
1408
|
}
|
|
1154
1409
|
return values;
|
|
1155
1410
|
}
|
|
@@ -1261,12 +1516,14 @@ setInterval(() => {
|
|
|
1261
1516
|
// ---------------------------------------------------------------- 记忆库搜索与其它
|
|
1262
1517
|
|
|
1263
1518
|
const memorySearch = $('#memorySearch');
|
|
1519
|
+
let memorySearchTimer = null;
|
|
1264
1520
|
if (memorySearch) {
|
|
1265
1521
|
memorySearch.addEventListener('input', () => {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1522
|
+
clearTimeout(memorySearchTimer);
|
|
1523
|
+
memorySearchTimer = setTimeout(() => {
|
|
1524
|
+
memoryQuery.q = memorySearch.value.trim();
|
|
1525
|
+
loadMemory(true);
|
|
1526
|
+
}, 300);
|
|
1270
1527
|
});
|
|
1271
1528
|
}
|
|
1272
1529
|
|
package/public/index.html
CHANGED
|
@@ -334,12 +334,11 @@
|
|
|
334
334
|
</aside>
|
|
335
335
|
<div class="memory-main">
|
|
336
336
|
<div class="card">
|
|
337
|
-
<div class="memory-toolbar"><label class="search wide"><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="6"/><path d="m16 16 4 4"/></svg><input id="memorySearch" placeholder="搜索记忆内容、关键词…" /></label><
|
|
337
|
+
<div class="memory-toolbar"><label class="search wide"><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="6"/><path d="m16 16 4 4"/></svg><input id="memorySearch" placeholder="搜索记忆内容、关键词…" /></label><span class="memory-count" id="memoryCount">-</span></div>
|
|
338
338
|
<div class="memory-list" id="memoryList">
|
|
339
339
|
<article class="memory-item"><div class="memory-head"><span class="tag group">群 1103369527</span><span class="tag soft">偏好</span><time>12-02 18:42</time></div><p>群友偏好短句、直接给结论,不喜欢“首先/其次”这种套话。</p><div class="memory-foot"><code>#语言风格</code><code>#短句</code><span>来源:自动归纳</span><button class="link-btn" data-toast="编辑记忆(原型)">编辑</button></div></article>
|
|
340
|
-
<article class="memory-item"><div class="memory-head"><span class="tag group">群 1103369527</span><span class="tag soft">事实</span><time>12-02 17:10</time></div><p>群主是 Miseat,主插件 1.5.3,监控用 SQLite;讨论技术时可以直接上结论。</p><div class="memory-foot"><code>#群主</code><code>#技术栈</code><span>来源:自动归纳</span><button class="link-btn" data-toast="编辑记忆(原型)">编辑</button></div></article>
|
|
341
|
-
<article class="memory-item"><div class="memory-head"><span class="tag private">私聊</span><span class="tag soft">梗</span><time>12-01 23:18</time></div><p>“迪迦三形态”指表情包的三种选择模式:复合/候选/描述。</p><div class="memory-foot"><code>#梗</code><code>#表情包</code><span>来源:自动归纳</span><button class="link-btn" data-toast="编辑记忆(原型)">编辑</button></div></article>
|
|
342
340
|
</div>
|
|
341
|
+
<div class="memory-pager" id="memoryPager"></div>
|
|
343
342
|
</div>
|
|
344
343
|
</div>
|
|
345
344
|
</div>
|
package/public/styles.css
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--radius: 14px;
|
|
17
17
|
}
|
|
18
18
|
* { box-sizing: border-box; }
|
|
19
|
+
[hidden] { display: none !important; }
|
|
19
20
|
html, body { margin: 0; height: 100%; }
|
|
20
21
|
body {
|
|
21
22
|
font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
|
|
@@ -228,7 +229,13 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
228
229
|
.scope b { font-size: 10px; color: #9ba8ba; font-weight: 500; }
|
|
229
230
|
.scope.active { background: #eef3ff; color: #3f68d8; }
|
|
230
231
|
.scope.active b { color: #4f7df3; }
|
|
231
|
-
.memory-toolbar { display: flex; gap: 9px; margin-bottom: 8px; }
|
|
232
|
+
.memory-toolbar { display: flex; gap: 9px; margin-bottom: 8px; align-items: center; }
|
|
233
|
+
.memory-count { font-size: 10.5px; color: #8d9aab; white-space: nowrap; }
|
|
234
|
+
.memory-pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 4px 2px; border-top: 1px solid #f1f4f8; margin-top: 6px; flex-wrap: wrap; }
|
|
235
|
+
.pager-info { font-size: 10.5px; color: #8d9aab; }
|
|
236
|
+
.pager-info b { color: #3f4e63; }
|
|
237
|
+
.pager-actions { display: flex; align-items: center; gap: 6px; }
|
|
238
|
+
.btn.small:disabled { opacity: .45; cursor: not-allowed; }
|
|
232
239
|
.search.wide { flex: 1; width: auto; }
|
|
233
240
|
.memory-item { padding: 13px 4px; border-bottom: 1px solid #f0f3f8; }
|
|
234
241
|
.memory-item:last-child { border-bottom: 0; }
|
|
@@ -359,6 +366,25 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
359
366
|
.switch input:checked + i::after { transform: translateX(15px); }
|
|
360
367
|
.switch span { font-size: 10.5px; color: #9aa7b8; }
|
|
361
368
|
.list-editor { border: 1px solid #e6ecf4; border-radius: 9px; padding: 8px; background: #fbfcfe; }
|
|
369
|
+
.object-list { display: flex; flex-direction: column; gap: 8px; }
|
|
370
|
+
.object-rows { display: flex; flex-direction: column; gap: 8px; }
|
|
371
|
+
.object-card { border: 1px solid #e6ecf4; border-radius: 9px; background: #fbfcfe; overflow: hidden; }
|
|
372
|
+
.object-card-head { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #f7f9fc; }
|
|
373
|
+
.object-card-title { flex: 1; min-width: 0; height: 32px; border: 1px solid #e2e8f1; border-radius: 6px; padding: 0 9px; font-size: 11.5px; background: #fff; outline: none; }
|
|
374
|
+
.object-card-body { padding: 10px 12px 12px; border-top: 1px solid #eef2f7; display: flex; flex-direction: column; gap: 8px; }
|
|
375
|
+
.obj-field { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 11.5px; color: #596a80; }
|
|
376
|
+
.obj-field > span { color: #6b7b90; }
|
|
377
|
+
.obj-field.block { display: block; }
|
|
378
|
+
.obj-field.block > span { display: block; margin-bottom: 6px; }
|
|
379
|
+
.obj-control { min-width: 0; }
|
|
380
|
+
.obj-control > input, .obj-control > select, .obj-control > textarea { width: 100%; border: 1px solid #e2e8f1; border-radius: 6px; background: #fff; padding: 7px 9px; font-size: 11.5px; color: #3b4b61; outline: none; font-family: inherit; }
|
|
381
|
+
.obj-control > textarea { resize: vertical; line-height: 1.6; }
|
|
382
|
+
.kv-row { display: flex; gap: 8px; align-items: flex-end; }
|
|
383
|
+
.kv-cell { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: #8d9aab; }
|
|
384
|
+
.kv-cell input, .kv-cell textarea, .kv-cell select { width: 100%; border: 1px solid #e2e8f1; border-radius: 6px; background: #fff; padding: 7px 9px; font-size: 11.5px; color: #3b4b61; outline: none; font-family: inherit; }
|
|
385
|
+
.kv-cell textarea { resize: vertical; }
|
|
386
|
+
.object-fields { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid #e6ecf4; border-radius: 9px; background: #fbfcfe; }
|
|
387
|
+
.switch.mini span { display: none; }
|
|
362
388
|
.list-rows { display: flex; flex-direction: column; gap: 6px; }
|
|
363
389
|
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 26px 26px; gap: 6px; align-items: center; }
|
|
364
390
|
.list-row:not(:has(.list-score)) { grid-template-columns: minmax(0, 1fr) 26px 26px; }
|
|
@@ -369,6 +395,7 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
369
395
|
.row-btn:hover { filter: brightness(.96); }
|
|
370
396
|
.add-row { margin-top: 7px; font-size: 11px; }
|
|
371
397
|
.group-rules { border: 1px solid #e6ecf4; border-radius: 9px; padding: 12px; background: #fbfcfe; }
|
|
398
|
+
.group-rules-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
|
372
399
|
.group-rules-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
|
|
373
400
|
.group-rule { border: 1px solid #e4ebf4; border-radius: 9px; background: #fff; overflow: hidden; }
|
|
374
401
|
.group-rule-head { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #f7f9fc; }
|
|
@@ -439,6 +466,7 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
439
466
|
.scope-list h3.mt { margin-top: 8px; }
|
|
440
467
|
.scope { width: auto; gap: 8px; }
|
|
441
468
|
.schema-field, .schema-field.long { grid-template-columns: 1fr; gap: 8px; padding: 14px 0; }
|
|
469
|
+
.obj-field { grid-template-columns: 1fr; gap: 5px; }
|
|
442
470
|
.schema-field .field > span { flex: 0 0 120px; }
|
|
443
471
|
.field > span { flex: 0 0 120px; }
|
|
444
472
|
.config-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
|