@nestim/koishi-plugin-qqgm-webui 0.2.2 → 0.2.3
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/package.json +1 -1
- package/public/app.js +29 -0
- package/public/styles.css +3 -0
package/index.js
CHANGED
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -92,6 +92,35 @@ async function initRealData() {
|
|
|
92
92
|
}
|
|
93
93
|
initRealData();
|
|
94
94
|
|
|
95
|
+
async function initMemoryData() {
|
|
96
|
+
try {
|
|
97
|
+
const token = new URLSearchParams(location.search).get('token') || '';
|
|
98
|
+
const res = await fetch(`api/memory?limit=20${token ? `&token=${encodeURIComponent(token)}` : ''}`, { cache: 'no-store' });
|
|
99
|
+
if (!res.ok) return;
|
|
100
|
+
const data = await res.json();
|
|
101
|
+
if (!data || !data.installed) return;
|
|
102
|
+
const badge = $('.nav-badge');
|
|
103
|
+
if (badge) badge.textContent = String(data.total || 0);
|
|
104
|
+
const list = $('#memoryList');
|
|
105
|
+
if (!list) return;
|
|
106
|
+
if (!data.items.length) {
|
|
107
|
+
list.innerHTML = '<div class="memory-empty"><b>还没有记忆</b><p>主插件当前使用 MD 后端,或 SQLite 里还没有数据。<br>切到 SQLite 并执行 <code>memdb migrate</code> 后会出现在这里。</p></div>';
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
list.innerHTML = data.items.map((item) => `
|
|
111
|
+
<article class="memory-item">
|
|
112
|
+
<div class="memory-head">
|
|
113
|
+
<span class="tag ${item.scope_kind === 'private' ? 'private' : 'group'}">${item.scope_kind === 'group' ? '群' : item.scope_kind === 'private' ? '私聊' : '全局'} ${item.scope_id || ''}</span>
|
|
114
|
+
<span class="tag soft">${item.category || '未分类'}</span>
|
|
115
|
+
<time>${new Date(item.created_at).toLocaleString('zh-CN', { hour12: false })}</time>
|
|
116
|
+
</div>
|
|
117
|
+
<p>${String(item.content || '').replace(/[<>&]/g, (c) => ({ '<': '<', '>': '>', '&': '&' }[c]))}</p>
|
|
118
|
+
<div class="memory-foot"><code>${item.label || '记忆'}</code><span>#${item.id}</span></div>
|
|
119
|
+
</article>`).join('');
|
|
120
|
+
} catch { /* 文件预览保留 mock */ }
|
|
121
|
+
}
|
|
122
|
+
initMemoryData();
|
|
123
|
+
|
|
95
124
|
// memory backend note
|
|
96
125
|
const memoryNote = $('#memoryBackend');
|
|
97
126
|
if (memoryNote) {
|
package/public/styles.css
CHANGED
|
@@ -257,6 +257,9 @@ code { background: #f2f5f9; color: #55657d; border-radius: 4px; padding: 1px 4px
|
|
|
257
257
|
.statusbar .pulse { width: 5px; height: 5px; margin-right: 5px; }
|
|
258
258
|
.memory-note { background: #fff8e8; border: 1px solid #f3e4c4; color: #8d7138; font-size: 10.5px; line-height: 1.55; padding: 8px 11px; border-radius: 8px; margin: -8px 0 14px; }
|
|
259
259
|
.memory-note b { color: #775c24; }
|
|
260
|
+
.memory-empty { text-align: center; padding: 44px 20px; color: #7d8b9f; }
|
|
261
|
+
.memory-empty b { display: block; font-size: 14px; color: #45556b; margin-bottom: 7px; }
|
|
262
|
+
.memory-empty p { margin: 0; font-size: 11px; line-height: 1.7; }
|
|
260
263
|
.overview-meta { text-align: right; color: #a5b1c2; font-size: 9.5px; padding: 4px 2px 0; letter-spacing: .01em; }
|
|
261
264
|
|
|
262
265
|
/* welcome / no monitor */
|