pi-hub-server 0.3.2 → 0.4.0

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/web/style.css CHANGED
@@ -52,6 +52,41 @@ body {
52
52
  inset: 0;
53
53
  }
54
54
 
55
+ /* ---------- 首帧骨架 ---------- */
56
+ .boot {
57
+ position: fixed;
58
+ inset: 0;
59
+ z-index: 60;
60
+ display: grid;
61
+ place-items: center;
62
+ background: radial-gradient(1200px 600px at 50% -10%, #1b2436 0%, var(--bg) 60%);
63
+ }
64
+
65
+ .boot-mark {
66
+ font-size: 40px;
67
+ color: var(--accent);
68
+ opacity: 0.75;
69
+ animation: boot-pulse 1.1s ease-in-out infinite;
70
+ }
71
+
72
+ @keyframes boot-pulse {
73
+ 0%,
74
+ 100% {
75
+ opacity: 0.35;
76
+ transform: scale(0.96);
77
+ }
78
+ 50% {
79
+ opacity: 0.9;
80
+ transform: scale(1);
81
+ }
82
+ }
83
+
84
+ @media (prefers-reduced-motion: reduce) {
85
+ .boot-mark {
86
+ animation: none;
87
+ }
88
+ }
89
+
55
90
  /* ---------- 登录 ---------- */
56
91
  .login {
57
92
  display: flex;
@@ -162,7 +197,10 @@ select:focus {
162
197
  .app {
163
198
  display: grid;
164
199
  grid-template-rows: auto 1fr auto;
165
- height: 100dvh;
200
+ /*
201
+ * 不要写 `height: 100dvh`:`.screen` 已经是 `position: fixed; inset: 0`,高度由视口定。
202
+ * 显式 dvh 会随移动端地址栏收起/展开变化 ⇒ 首次滚动时整页重排(肉眼就是「闪一下/卡」)。
203
+ */
166
204
  }
167
205
 
168
206
  .topbar {
@@ -307,6 +345,44 @@ select:focus {
307
345
  flex-wrap: wrap;
308
346
  }
309
347
 
348
+ /* 消息操作行:默认淡出,指针移到消息上或键盘聚焦时亮起(移动端无 hover,直接常驻) */
349
+ .msg-actions {
350
+ display: flex;
351
+ gap: 6px;
352
+ flex-wrap: wrap;
353
+ opacity: 0.55;
354
+ transition: opacity 0.15s ease;
355
+ }
356
+
357
+ .msg:hover .msg-actions,
358
+ .msg-actions:focus-within {
359
+ opacity: 1;
360
+ }
361
+
362
+ @media (hover: none) {
363
+ .msg-actions {
364
+ opacity: 0.85;
365
+ }
366
+ }
367
+
368
+ button.mini {
369
+ border: 1px solid var(--line);
370
+ background: transparent;
371
+ color: var(--fg-dim);
372
+ border-radius: 999px;
373
+ padding: 2px 9px;
374
+ font-size: 11px;
375
+ line-height: 1.6;
376
+ cursor: pointer;
377
+ touch-action: manipulation;
378
+ }
379
+
380
+ button.mini:hover {
381
+ color: var(--fg);
382
+ border-color: var(--accent-dim);
383
+ background: var(--bg-raise);
384
+ }
385
+
310
386
  .empty {
311
387
  margin: auto;
312
388
  color: var(--fg-dim);
@@ -539,6 +615,7 @@ select:focus {
539
615
 
540
616
  /* ---------- 输入区 ---------- */
541
617
  .composer {
618
+ position: relative;
542
619
  border-top: 1px solid var(--line);
543
620
  background: var(--bg-soft);
544
621
  padding: 8px 10px calc(8px + var(--safe-bottom));
@@ -547,6 +624,63 @@ select:focus {
547
624
  gap: 8px;
548
625
  }
549
626
 
627
+ /* 命令补全浮层:悬在输入区上方(不撑动布局) */
628
+ .slash {
629
+ position: absolute;
630
+ left: 10px;
631
+ right: 10px;
632
+ bottom: calc(100% - 4px);
633
+ max-height: 40dvh;
634
+ overflow-y: auto;
635
+ z-index: 30;
636
+ display: flex;
637
+ flex-direction: column;
638
+ gap: 2px;
639
+ padding: 4px;
640
+ background: var(--bg-raise);
641
+ border: 1px solid var(--line);
642
+ border-radius: 10px;
643
+ box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
644
+ }
645
+
646
+ .slash-item {
647
+ display: flex;
648
+ align-items: baseline;
649
+ gap: 8px;
650
+ padding: 6px 8px;
651
+ border-radius: 8px;
652
+ cursor: pointer;
653
+ }
654
+
655
+ .slash-item.active,
656
+ .slash-item:hover {
657
+ background: var(--accent-dim);
658
+ }
659
+
660
+ .slash-name {
661
+ flex: none;
662
+ font-size: 13px;
663
+ font-weight: 600;
664
+ }
665
+
666
+ .slash-src {
667
+ flex: none;
668
+ font-size: 10px;
669
+ color: var(--fg-dim);
670
+ border: 1px solid var(--line);
671
+ border-radius: 999px;
672
+ padding: 0 6px;
673
+ }
674
+
675
+ .slash-desc {
676
+ min-width: 0;
677
+ font-size: 11px;
678
+ color: var(--fg-dim);
679
+ white-space: nowrap;
680
+ overflow: hidden;
681
+ text-overflow: ellipsis;
682
+ }
683
+
550
684
  .composer textarea {
551
685
  resize: none;
552
686
  max-height: 40dvh;
@@ -780,3 +914,69 @@ select:focus {
780
914
  max-width: 70%;
781
915
  }
782
916
  }
917
+
918
+ /* ---------- 桌面(≥900px):抽屉常驻左侧固定侧栏 ---------- */
919
+ /*
920
+ * 移动端抽屉是浮层(hidden 控制 + scrim),桌面上改成布局的一部分:
921
+ * - 不受 `hidden` 影响(JS 里 closeDrawer() 仍可调用,窄窗口恢复原语义)
922
+ * - 不画 scrim、不显示开关按钮
923
+ * - 登录页在前时整块隐藏,避免侧栏压在登录卡上方
924
+ */
925
+ @media (min-width: 900px) {
926
+ :root {
927
+ --sidebar: 300px;
928
+ }
929
+
930
+ .drawer,
931
+ .drawer[hidden] {
932
+ display: flex !important;
933
+ width: var(--sidebar);
934
+ transform: none;
935
+ padding-top: 0;
936
+ padding-bottom: 0;
937
+ }
938
+
939
+ #login:not([hidden]) ~ #drawer {
940
+ display: none !important;
941
+ }
942
+
943
+ .scrim {
944
+ display: none !important;
945
+ }
946
+
947
+ #btn-drawer,
948
+ #btn-drawer-close {
949
+ display: none;
950
+ }
951
+
952
+ .app {
953
+ left: var(--sidebar);
954
+ }
955
+
956
+ .session-item:hover {
957
+ background: var(--bg-raise);
958
+ }
959
+
960
+ .topbar {
961
+ padding-top: calc(10px + var(--safe-top));
962
+ padding-left: 16px;
963
+ padding-right: 16px;
964
+ }
965
+
966
+ .messages {
967
+ padding: 20px max(20px, calc((100% - 860px) / 2));
968
+ }
969
+
970
+ .composer {
971
+ padding-left: max(12px, calc((100% - 860px) / 2));
972
+ padding-right: max(12px, calc((100% - 860px) / 2));
973
+ }
974
+
975
+ .toast {
976
+ left: calc(50% + var(--sidebar) / 2);
977
+ }
978
+
979
+ .msg.user .bubble {
980
+ max-width: 76%;
981
+ }
982
+ }
package/web/sw.js CHANGED
@@ -2,17 +2,13 @@
2
2
  // 不缓存 /v1 响应(会话与 SSE 都是实时的,缓存只会让状态错乱)。
3
3
  "use strict";
4
4
 
5
- const CACHE = "pihub-shell-v1";
6
- const SHELL = ["/", "/index.html", "/app.js", "/style.css", "/manifest.webmanifest", "/icons/icon.svg"];
5
+ const CACHE = "pihub-shell-v2";
7
6
 
8
- self.addEventListener("install", (event) => {
9
- event.waitUntil(
10
- caches
11
- .open(CACHE)
12
- .then((cache) => cache.addAll(SHELL))
13
- .then(() => self.skipWaiting())
14
- .catch(() => self.skipWaiting()),
15
- );
7
+ // install 阶段**不**预热外壳:原来的 `cache.addAll([...])` 会让首访多下 4 个已在路上的文件
8
+ // (实测 `GET /` 304 + `/index.html` + `/manifest.webmanifest` 全被重复拉一次),
9
+ // 在慢网络下与页面自身加载抢带宽,首屏更卡。外壳靠下面的 fetch 处理按需填充。
10
+ self.addEventListener("install", () => {
11
+ self.skipWaiting();
16
12
  });
17
13
 
18
14
  self.addEventListener("activate", (event) => {