dsh-meili-search 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/client.js +13 -8
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -290,13 +290,15 @@ window.__ModuleLoader__.load({
290
290
  }
291
291
  } catch {}
292
292
  })();
293
- const t = setInterval(async () => {
293
+ const poll = async () => {
294
294
  try {
295
295
  const r = await fetch(STATUS_API);
296
296
  const b = await r.json();
297
297
  if (b.ok) setStat(b);
298
298
  } catch {}
299
- }, 3000);
299
+ };
300
+ poll(); // 挂载立即拉一次, 避免首帧长时间处于“…”占位
301
+ const t = setInterval(poll, 3000);
300
302
  return () => { clearInterval(t); clearTimeout(saveTimer.current); };
301
303
  }, []);
302
304
 
@@ -338,7 +340,10 @@ window.__ModuleLoader__.load({
338
340
 
339
341
  const idx = (cfg && cfg.index) || INDEX;
340
342
  const docs = stat && stat.indexes ? stat.indexes[idx] : undefined;
341
- const meiliOk = typeof docs === "number" && docs >= 0;
343
+ const loading = stat === null; // 首帧/加载中: 未拿到 /status 前不渲染“失败”
344
+ const meiliOk = !loading && typeof docs === "number" && docs >= 0;
345
+ const docsView = loading ? "…" : (typeof docs === "number" ? (docs >= 0 ? String(docs) : "连接失败") : "—");
346
+ const docsColor = meiliOk || loading ? "inherit" : "var(--dsh-state-error-primary, #e5534b)";
342
347
 
343
348
  const autoControl = React.createElement("div", null, [
344
349
  React.createElement("div", { key: "row", style: { display: "flex", gap: 8, alignItems: "center", flexWrap: "wrap" } },
@@ -348,11 +353,11 @@ window.__ModuleLoader__.load({
348
353
  busy ? "保存中…" : (saved ? "已保存 ✓" : "增量同步周期(ms); 0 = 关闭(仅手动)。改动约 0.5s 后自动保存并热生效。")),
349
354
  ]);
350
355
  const statusControl = React.createElement("div", { style: { ...monoStyle, color: "var(--dsh-text-secondary, #8a90a5)", display: "grid", gridTemplateColumns: "auto 1fr", gap: "2px 14px" } }, [
351
- React.createElement("span", { key: "a" }, "文档数"), React.createElement("span", { key: "b", style: { color: meiliOk ? "inherit" : "var(--dsh-state-error-primary, #e5534b)" } }, meiliOk ? String(docs) : "连接失败"),
352
- React.createElement("span", { key: "c" }, "会话游标"), React.createElement("span", { key: "d" }, stat ? String(stat.stateFiles) : "…"),
353
- React.createElement("span", { key: "e" }, "上次同步"), React.createElement("span", { key: "f" }, fmtWhen(stat && stat.lastSync)),
354
- React.createElement("span", { key: "g" }, "下次同步"), React.createElement("span", { key: "h" }, stat ? (stat.autoSyncMs > 0 ? fmtWhen(stat.nextRunAt) : "已关闭") : "…"),
355
- React.createElement("span", { key: "i" }, "同步状态"), React.createElement("span", { key: "j" }, stat ? (stat.syncing ? "同步中…" : (meiliOk ? "正常" : "Meili 不可达")) : "…"),
356
+ React.createElement("span", { key: "a" }, "文档数"), React.createElement("span", { key: "b", style: { color: docsColor } }, docsView),
357
+ React.createElement("span", { key: "c" }, "会话游标"), React.createElement("span", { key: "d" }, loading ? "…" : (stat ? String(stat.stateFiles) : "—")),
358
+ React.createElement("span", { key: "e" }, "上次同步"), React.createElement("span", { key: "f" }, loading ? "…" : fmtWhen(stat && stat.lastSync)),
359
+ React.createElement("span", { key: "g" }, "下次同步"), React.createElement("span", { key: "h" }, stat ? (stat.autoSyncMs > 0 ? fmtWhen(stat.nextRunAt) : "已关闭") : (loading ? "…" : "—")),
360
+ React.createElement("span", { key: "i" }, "同步状态"), React.createElement("span", { key: "j" }, loading ? "…" : (stat ? (stat.syncing ? "同步中…" : (meiliOk ? "正常" : "Meili 不可达")) : "—")),
356
361
  ]);
357
362
  const actionControl = React.createElement("div", null, [
358
363
  React.createElement("div", { key: "b", style: { display: "flex", gap: 8, alignItems: "center" } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-meili-search",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "DSH 会话内容检索(Meilisearch): 增量索引同步(按 seq/时间戳) + 原版搜索框内容检索替换 + 命中跳转定位与分词高亮 + Settings 配置卡",
5
5
  "type": "module",
6
6
  "main": "index.js",