@nestim/koishi-plugin-qqgm-webui 0.2.13 → 0.2.15
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 +9 -2
- package/package.json +1 -1
- package/public/app.js +11 -0
package/index.js
CHANGED
|
@@ -15,8 +15,15 @@ const { scan: scanMemoryMd, scopeOfFile } = require('./lib/memory-md');
|
|
|
15
15
|
const run = promisify(execFile);
|
|
16
16
|
|
|
17
17
|
async function readBody(koa) {
|
|
18
|
+
const parsed = koa.request && koa.request.body;
|
|
19
|
+
if (parsed && typeof parsed === 'object') return parsed;
|
|
20
|
+
if (typeof parsed === 'string' && parsed.trim()) {
|
|
21
|
+
try { return JSON.parse(parsed); } catch { return {}; }
|
|
22
|
+
}
|
|
18
23
|
let raw = '';
|
|
19
|
-
|
|
24
|
+
try {
|
|
25
|
+
for await (const chunk of koa.req) raw += chunk;
|
|
26
|
+
} catch { /* body already consumed */ }
|
|
20
27
|
if (!raw) return {};
|
|
21
28
|
try { return JSON.parse(raw); } catch { return {}; }
|
|
22
29
|
}
|
|
@@ -107,7 +114,7 @@ function apply(ctx, config) {
|
|
|
107
114
|
ctx.server.get(`${route}/api/health`, (koa) => json(koa, {
|
|
108
115
|
ok: true,
|
|
109
116
|
name,
|
|
110
|
-
version: '0.2.
|
|
117
|
+
version: '0.2.15',
|
|
111
118
|
route,
|
|
112
119
|
tokenRequired: !!config.token,
|
|
113
120
|
remoteAllowed: !!config.allowRemote,
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -126,6 +126,17 @@ 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 headP = $('#page-memory .page-head p');
|
|
130
|
+
if (headP) {
|
|
131
|
+
headP.textContent = data.useSqlite
|
|
132
|
+
? `当前 SQLite · ${data.total || 0} 条;切换前备份 koishi.yml`
|
|
133
|
+
: (data.needsMigration
|
|
134
|
+
? `当前 MD · 识别到 ${data.md?.total || 0} 条旧记忆,可迁移到 SQLite`
|
|
135
|
+
: '当前 MD · 没有识别到旧记忆文件');
|
|
136
|
+
}
|
|
137
|
+
const segButtons = $$('#page-memory .segmented button');
|
|
138
|
+
if (segButtons[0]) segButtons[0].classList.toggle('active', !data.useSqlite);
|
|
139
|
+
if (segButtons[1]) segButtons[1].classList.toggle('active', !!data.useSqlite);
|
|
129
140
|
const migrateBtn = $('#migrateMemory');
|
|
130
141
|
const switchBtn = $('#switchMd');
|
|
131
142
|
if (migrateBtn) migrateBtn.hidden = !data.needsMigration;
|