agent-loft 0.2.44 → 0.2.45

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.
@@ -0,0 +1,265 @@
1
+ /* ---------- 多服务器:左上角切换(lib/shell.js) ---------- */
2
+
3
+ .side-switch {
4
+ padding: 10px 10px 0;
5
+ }
6
+
7
+ .side-switch[hidden],
8
+ .auth-switch[hidden],
9
+ .srv-pill[hidden] {
10
+ display: none;
11
+ }
12
+
13
+ .server-switch {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 8px;
17
+ width: 100%;
18
+ min-width: 0;
19
+ padding: 6px 8px;
20
+ border-radius: 10px;
21
+ font-size: 15px;
22
+ font-weight: 600;
23
+ text-align: left;
24
+ }
25
+
26
+ .server-switch:hover {
27
+ background: var(--bg-hover);
28
+ }
29
+
30
+ .srv-icon {
31
+ width: 24px;
32
+ height: 24px;
33
+ flex-shrink: 0;
34
+ display: inline-grid;
35
+ place-items: center;
36
+ border-radius: 7px;
37
+ font-size: 16px;
38
+ line-height: 1;
39
+ }
40
+
41
+ .srv-icon.letter {
42
+ background: var(--accent);
43
+ color: var(--accent-fg);
44
+ font-size: 12px;
45
+ font-weight: 600;
46
+ }
47
+
48
+ .srv-name,
49
+ .srv-item-name {
50
+ flex: 1;
51
+ min-width: 0;
52
+ overflow: hidden;
53
+ text-overflow: ellipsis;
54
+ white-space: nowrap;
55
+ }
56
+
57
+ .srv-chev {
58
+ display: inline-grid;
59
+ opacity: 0.55;
60
+ }
61
+
62
+ .srv-chev svg {
63
+ width: 14px;
64
+ height: 14px;
65
+ }
66
+
67
+ .srv-badge {
68
+ min-width: 18px;
69
+ height: 18px;
70
+ padding: 0 5px;
71
+ border-radius: 9px;
72
+ background: var(--danger);
73
+ color: #fff;
74
+ font-size: 11px;
75
+ font-weight: 600;
76
+ line-height: 18px;
77
+ text-align: center;
78
+ }
79
+
80
+ .srv-busy {
81
+ width: 8px;
82
+ height: 8px;
83
+ border-radius: 50%;
84
+ background: var(--accent);
85
+ animation: srv-pulse 1.4s ease-in-out infinite;
86
+ }
87
+
88
+ @keyframes srv-pulse {
89
+ 50% {
90
+ opacity: 0.35;
91
+ }
92
+ }
93
+
94
+ .srv-down {
95
+ font-size: 12px;
96
+ color: var(--fg-faint);
97
+ }
98
+
99
+ .srv-check {
100
+ color: var(--accent);
101
+ font-weight: 600;
102
+ }
103
+
104
+ .menu .srv-item {
105
+ min-width: 220px;
106
+ padding: 7px 10px;
107
+ }
108
+
109
+ .menu .srv-item.on {
110
+ font-weight: 600;
111
+ }
112
+
113
+ .menu .srv-manage {
114
+ color: var(--fg-soft);
115
+ }
116
+
117
+ /* 登录页(被嵌着、还没登录):左上角照样能切回去 */
118
+ .auth-switch {
119
+ position: absolute;
120
+ top: calc(env(safe-area-inset-top) + 10px);
121
+ left: 10px;
122
+ max-width: min(260px, calc(100vw - 20px));
123
+ }
124
+
125
+ /* ---------- 外壳上的 iframe ---------- */
126
+
127
+ /* 用 absolute 不用 fixed:iOS PWA 会拿贴着顶部的 fixed 元素给状态栏上色(见 mobile.css) */
128
+ .server-frames {
129
+ position: absolute;
130
+ inset: 0;
131
+ z-index: 38;
132
+ background: var(--bg);
133
+ }
134
+
135
+ .server-frames[hidden] {
136
+ display: none;
137
+ }
138
+
139
+ /* 不显示的也只是藏起来(visibility),页面照常排版,切回来时滚动位置、输入框都还在 */
140
+ .server-frame {
141
+ position: absolute;
142
+ inset: 0;
143
+ visibility: hidden;
144
+ box-sizing: border-box;
145
+ background: var(--bg);
146
+ }
147
+
148
+ .server-frame.on {
149
+ visibility: visible;
150
+ }
151
+
152
+ .server-frame iframe {
153
+ display: block;
154
+ width: 100%;
155
+ height: 100%;
156
+ border: 0;
157
+ background: var(--bg);
158
+ }
159
+
160
+ .srv-overlay {
161
+ position: absolute;
162
+ inset: 0;
163
+ display: grid;
164
+ place-items: center;
165
+ padding: 24px;
166
+ background: var(--bg);
167
+ }
168
+
169
+ .srv-overlay[hidden] {
170
+ display: none;
171
+ }
172
+
173
+ .srv-loading {
174
+ display: flex;
175
+ align-items: center;
176
+ gap: 10px;
177
+ color: var(--fg-soft);
178
+ }
179
+
180
+ .srv-card {
181
+ max-width: 440px;
182
+ padding: 20px 22px;
183
+ border: 1px solid var(--border);
184
+ border-radius: var(--radius);
185
+ box-shadow: var(--shadow);
186
+ background: var(--bg);
187
+ }
188
+
189
+ .srv-card h3 {
190
+ margin: 0 0 8px;
191
+ font-size: 17px;
192
+ }
193
+
194
+ .srv-card ul {
195
+ margin: 0 0 14px;
196
+ padding-left: 20px;
197
+ color: var(--fg-soft);
198
+ font-size: 14px;
199
+ }
200
+
201
+ .srv-card .row {
202
+ flex-wrap: wrap;
203
+ }
204
+
205
+ /* iframe 里的页面还没报到(加载中、没响应)时浮在左上角的切换按钮:不然手机上就回不去了 */
206
+ .srv-pill {
207
+ position: absolute;
208
+ top: calc(env(safe-area-inset-top) + 8px);
209
+ left: 8px;
210
+ z-index: 2;
211
+ max-width: min(260px, calc(100vw - 16px));
212
+ background: var(--bg);
213
+ border: 1px solid var(--border);
214
+ border-radius: 12px;
215
+ box-shadow: var(--shadow);
216
+ }
217
+
218
+ /* ---------- 设置 → 服务器 ---------- */
219
+
220
+ .srv-rows {
221
+ display: flex;
222
+ flex-direction: column;
223
+ gap: 8px;
224
+ }
225
+
226
+ .srv-edit {
227
+ display: flex;
228
+ align-items: center;
229
+ gap: 8px;
230
+ flex-wrap: wrap;
231
+ }
232
+
233
+ .srv-edit-fields {
234
+ flex: 1;
235
+ min-width: 260px;
236
+ display: grid;
237
+ grid-template-columns: 48px minmax(80px, 1fr) minmax(140px, 2fr);
238
+ gap: 6px;
239
+ }
240
+
241
+ .srv-edit-fields.self {
242
+ grid-template-columns: 48px minmax(0, 1fr);
243
+ }
244
+
245
+ .srv-edit-fields input.srv-emoji {
246
+ text-align: center;
247
+ padding-left: 4px;
248
+ padding-right: 4px;
249
+ }
250
+
251
+ .srv-edit-actions {
252
+ display: flex;
253
+ align-items: center;
254
+ gap: 4px;
255
+ }
256
+
257
+ @media (max-width: 768px) {
258
+ .srv-edit-fields {
259
+ grid-template-columns: 48px minmax(0, 1fr);
260
+ }
261
+
262
+ .srv-edit-fields input:nth-child(3) {
263
+ grid-column: 1 / -1;
264
+ }
265
+ }
package/web/index.html CHANGED
@@ -28,6 +28,7 @@
28
28
  <link rel="stylesheet" href="/css/skills.css" />
29
29
  <link rel="stylesheet" href="/css/terminal.css" />
30
30
  <link rel="stylesheet" href="/css/remote.css" />
31
+ <link rel="stylesheet" href="/css/servers.css" />
31
32
  <link rel="stylesheet" href="/css/mobile.css" />
32
33
  </head>
33
34
  <body>
package/web/lib/api.js CHANGED
@@ -4,6 +4,7 @@ export async function api(path, opts = {}) {
4
4
  const res = await fetch(path, {
5
5
  method: opts.method ?? "GET",
6
6
  credentials: "same-origin",
7
+ keepalive: opts.keepalive ?? false,
7
8
  headers: opts.body !== undefined && !(opts.body instanceof Blob) ? { "Content-Type": "application/json" } : opts.headers,
8
9
  body: opts.body === undefined ? undefined : opts.body instanceof Blob ? opts.body : JSON.stringify(opts.body),
9
10
  });
@@ -12,7 +12,7 @@ export function showMenu(anchor, items) {
12
12
  : h(
13
13
  "button",
14
14
  {
15
- class: it.danger ? "danger" : "",
15
+ class: [it.danger ? "danger" : "", it.class ?? ""].join(" ").trim(),
16
16
  onclick: () => {
17
17
  closeMenu();
18
18
  it.onclick();
package/web/lib/push.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { api } from "./api.js";
2
- import { desktop } from "../state.js";
2
+ import { desktop, framed } from "../state.js";
3
3
 
4
4
  // ---------- 系统通知(Web Push) ----------
5
5
 
@@ -7,6 +7,7 @@ export function pushSupport() {
7
7
  const ios = /iPhone|iPad|iPod/.test(navigator.userAgent);
8
8
  const standalone = window.matchMedia("(display-mode: standalone)").matches || navigator.standalone === true;
9
9
  if (desktop) return { ok: false, why: "桌面端会直接弹出 macOS 系统通知,不需要在这里开启。" };
10
+ if (framed) return { ok: false, framed: true, why: "这台是在别的服务器的页面里打开的:通知跟着外层那台走,在那边的 设置 → 通知 里开启,这台的提醒也会推过去。" };
10
11
  if (!window.isSecureContext) return { ok: false, why: "通知需要 HTTPS 访问(localhost 除外)。请通过 HTTPS 的反向代理地址打开。" };
11
12
  if (ios && !standalone) {
12
13
  return { ok: false, why: "iPhone / iPad 上要先在 Safari 里点「分享 → 添加到主屏幕」,再从桌面图标打开,才能开启通知(需 iOS 16.4+)。" };
@@ -52,6 +53,12 @@ export async function enablePush() {
52
53
 
53
54
  /** 这台设备不再收通知:服务端删掉订阅,浏览器也退订 */
54
55
  export async function dropPushSub() {
56
+ if (framed) {
57
+ // 只撤销这台的转发订阅,不能退订外壳与其他服务器共用的浏览器订阅。
58
+ const { dropRelayPush } = await import("./shell.js");
59
+ await dropRelayPush();
60
+ return;
61
+ }
55
62
  const sub = await currentPushSub();
56
63
  if (!sub) return;
57
64
  await api("/api/push/unsubscribe", { method: "POST", body: { endpoint: sub.endpoint } }).catch(() => {});