skillmkt 0.1.2 → 0.1.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/client/public/app.js +7 -2
- package/package.json +1 -1
package/client/public/app.js
CHANGED
|
@@ -5,7 +5,12 @@ const el = (h) => { const d = document.createElement('div'); d.innerHTML = h; re
|
|
|
5
5
|
const esc = (s) => String(s ?? '').replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c]));
|
|
6
6
|
let S = null, tab = 'skills';
|
|
7
7
|
|
|
8
|
-
async function refresh() {
|
|
8
|
+
async function refresh() {
|
|
9
|
+
try { S = await api('/state'); }
|
|
10
|
+
catch (e) { document.getElementById('app').innerHTML = `<p class="pill bad">/api/state failed: ${esc(e.message)} — daemon 挂了?skillmkt serve --stop 后重开</p>`; return; }
|
|
11
|
+
if (S?.error) { document.getElementById('app').innerHTML = `<p class="pill bad">${esc(S.error)} — URL 里的 token 过期了,重跑 skillmkt serve 拿新链接</p>`; return; }
|
|
12
|
+
render();
|
|
13
|
+
}
|
|
9
14
|
document.querySelectorAll('.tab').forEach((t) => t.onclick = () => { document.querySelectorAll('.tab').forEach((x) => x.classList.remove('on')); t.classList.add('on'); tab = t.dataset.t; render(); });
|
|
10
15
|
const es = new EventSource(`/api/events?token=${T}`);
|
|
11
16
|
es.addEventListener('decide', () => refresh());
|
|
@@ -14,7 +19,7 @@ es.onerror = () => document.getElementById('live').textContent = '○offline';
|
|
|
14
19
|
|
|
15
20
|
const pill = (v) => `<span class="pill ${v === 'clean' || v === 'installed' || v === 'active' ? 'ok' : v === 'malicious' || v === 'pending' ? 'bad' : 'warn'}">${esc(v)}</span>`;
|
|
16
21
|
|
|
17
|
-
function render() {
|
|
22
|
+
async function render() {
|
|
18
23
|
const app = document.getElementById('app');
|
|
19
24
|
if (!S) return;
|
|
20
25
|
if (tab === 'skills') {
|