@coda-console/friends 0.5.0 → 0.6.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/view/app.mjs CHANGED
@@ -1,67 +1,28 @@
1
- // 好友页:各台电脑的 Accord 身份与名片(Hero)、编辑名片(含本地选图裁剪上传)、按电脑分节的好友列表与详情、添加好友。
2
- // 页面不自己选机器:视图里有几台就都读,名片按身份合并、好友按电脑分节(lib/view-members.mjs);写操作发往它所在的那一台。
3
- // Accord 的读写(coda/accord@1)都在这里按交互发起;备注只经模块存在各台本机。好友的昵称、备注、节点名等外来数据一律用
4
- // textContent / DOM API 渲染,从不拼 HTML 字符串;头像图片地址只来自 resolveAvatar(经 readContentPointer 白名单校验)。
5
- import { accordStatusSummary, blobUploadUrl, initialChar, resolveAvatar } from '../lib/avatar.mjs';
6
- import { CARD_KIND, COLORS, cardFallbackNotice, checked, normalizeCardInput, normalizeContentPointer, parseInvite, readProfileRecord, shortAuthor } from '../lib/friends.mjs';
1
+ // 好友页:各台电脑的 Accord 身份(Hero)、按电脑分节的好友列表与详情、添加好友。
2
+ // 页面不自己选机器:视图里有几台就都读,身份按公钥归组、好友按电脑分节(lib/view-members.mjs);写操作发往它所在的那一台。
3
+ // Accord 的读写(coda/accord@1)都在这里按交互发起。昵称、头像都由 Accord 公钥推出(nickname.mjs、avatar.mjs),没有可编辑的名片;
4
+ // 节点名等外来数据一律用 textContent / DOM API 渲染,从不拼 HTML 字符串。
5
+ import { accordStatusSummary, resolveAvatar } from '../lib/avatar.mjs';
6
+ import { checked, parseInvite } from '../lib/friends.mjs';
7
+ import { identityTitle } from '../lib/nickname.mjs';
7
8
  import { friendSections, identities, listMembers } from '../lib/view-members.mjs';
8
- import { createCropper } from './cropper.mjs';
9
- import { fill, h, identiconSvg, svg } from './dom.mjs';
9
+ import { fill, h, identiconSvg } from './dom.mjs';
10
10
 
11
11
  const ACCORD = 'coda/accord@1', LOCAL = { kind: ACCORD, id: 'local' };
12
12
  const coda = window.coda;
13
13
  const root = document.getElementById('root');
14
- const COLOR_NAMES = { blue: '蓝', orange: '橙', green: '绿', purple: '紫', pink: '粉', teal: '青', gray: '灰' };
15
14
  const STATUS_TEXT = { bound: '已互认', pending: '待互认', conflict: '密钥冲突' };
16
- const MODES = [['photo', '照片'], ['identicon', '几何纹'], ['emoji', 'Emoji'], ['monogram', '字标']];
17
- const EMOJIS = ['😀', '😎', '🦊', '🐱', '🐼', '🌿', '☕', '🎧', '🚀', '⚡', '🌙', '✨'];
18
- const UPLOAD_ERRORS = { 404: '当前客户端还不支持上传头像,请升级 Coda 后再试', 413: '图片太大(超过 5 MiB),请换一张' };
19
15
 
20
16
  // 视图里的每台电脑(成员在页面生命周期内不变)各存一份数据;读不到的(unreachable)也在,只是不发请求。
21
- const members = listMembers(coda).map(m => ({ ...m, entry: null, author: null, friends: [], profiles: [], cards: [], notes: {}, loaded: false,
22
- problem: null, notesProblem: null, accordProblem: null, reading: 0 }));
17
+ const members = listMembers(coda).map(m => ({ ...m, entry: null, author: null, friends: [], loaded: false, accordProblem: null }));
23
18
  const live = members.filter(m => !m.unreachable);
24
19
  const multi = members.length > 1;
25
- const state = { busy: new Set(), notice: new Map(), heroNotice: new Map(), detail: null, removing: null, failedPhotos: new Set() };
20
+ const state = { busy: new Set(), notice: new Map(), heroNotice: new Map(), detail: null, removing: null };
26
21
  const via = m => ({ machine: m.id });
27
- // 头像图片的读取地址只在多机空间里带 machine。
28
- const blobMachine = id => (multi ? id : null);
29
22
  const rowKey = (m, node) => `${m.id}\u0000${node}`;
30
- // 编辑名片的会话代际:每次打开、关闭编辑弹层自增;旧会话的发布做完后不碰新会话的弹层、按钮、提示和裁剪。
31
- let editorGen = 0;
32
23
  function say(target, text, kind = 'hint') { target.className = kind; target.textContent = text; }
33
24
 
34
- // ---- 备注:经各台的模块存在那台本机 ----
35
- const pendingReplies = new Map();
36
- let counter = 0;
37
- function ask(m, type, input = {}) {
38
- const rid = `n${++counter}`;
39
- return new Promise((resolve, reject) => {
40
- const settle = fn => v => { clearTimeout(timer); pendingReplies.delete(rid); fn(v); };
41
- const timer = setTimeout(() => { pendingReplies.delete(rid); reject(new Error('模块没有回应')); }, 10_000);
42
- pendingReplies.set(rid, { machine: m.id, resolve: settle(resolve), reject: settle(reject) });
43
- Promise.resolve().then(() => coda.postMessage({ type, rid, ...input }, via(m))).catch(error => pendingReplies.get(rid)?.reject(new Error(`发送失败:${error?.message ?? error}`)));
44
- });
45
- }
46
- addEventListener('message', event => {
47
- const { type, rid, ok, value, error } = event.data ?? {};
48
- const wait = type === 'reply' ? pendingReplies.get(rid) : null;
49
- if (!wait || (event.machine?.id && event.machine.id !== wait.machine)) return;
50
- if (ok) wait.resolve(value); else wait.reject(new Error(error));
51
- });
52
-
53
25
  // ---- 读各台的 Accord ----
54
- // profile 与 friends/card 各读各的:一种读不到或没有记录,不挡另一种。
55
- async function readProfiles(m) {
56
- const mine = ++m.reading;
57
- const [profiles, cards] = await Promise.allSettled(['profile', CARD_KIND].map(kind => coda.query(LOCAL, 'records', { kind, limit: 200 }, via(m))));
58
- if (mine !== m.reading) return;
59
- if (profiles.status === 'fulfilled') m.profiles = profiles.value?.records ?? [];
60
- if (cards.status === 'fulfilled') m.cards = cards.value?.records ?? [];
61
- const failed = [profiles, cards].find(read => read.status === 'rejected');
62
- m.problem = failed ? `读不到好友名片:${failed.reason?.message ?? failed.reason}` : null;
63
- draw();
64
- }
65
26
  function onChange(m, { type, entry }) {
66
27
  if (type === 'DELETED' || !entry) return;
67
28
  m.entry = entry;
@@ -69,41 +30,29 @@ function onChange(m, { type, entry }) {
69
30
  m.friends = entry.status?.friends ?? [];
70
31
  m.loaded = true;
71
32
  draw();
72
- readProfiles(m);
73
33
  }
74
34
  async function start(m) {
75
- try { m.notes = await ask(m, 'notes.list'); m.notesProblem = null; }
76
- catch (e) { m.notesProblem = `读不到本地备注:${e.message}`; draw(); }
77
35
  try { await coda.watch(ACCORD, event => onChange(m, event), { id: 'local' }, via(m)); }
78
36
  catch (e) { m.accordProblem = `读不到本机的好友信息:${e.message}`; }
79
37
  draw();
80
38
  }
81
39
 
82
40
  // ---- 头像 ----
83
- // 按 resolveAvatar 的描述画头像;图片加载失败记下地址、就地换成它的 fallback,重绘时不再试(点「刷新」清空重试)。
41
+ // 按 resolveAvatar 的描述画头像:公钥的几何纹,没有公钥时取首字。
84
42
  function avatar(desc, size) {
85
- const node = h('span', { 'aria-hidden': 'true' });
86
- const show = d => {
87
- if (d.kind === 'photo' && state.failedPhotos.has(d.url)) return show(d.fallback);
88
- node.className = `av ${size} k-${d.kind}`;
89
- if (d.kind === 'photo') node.replaceChildren(h('img', { src: d.url, alt: '', draggable: 'false', onerror: () => { state.failedPhotos.add(d.url); show(d.fallback); } }));
90
- else if (d.kind === 'identicon') node.replaceChildren(identiconSvg(d.grid));
91
- else node.textContent = d.kind === 'emoji' ? d.emoji : d.text;
92
- };
93
- show(desc);
43
+ const node = h('span', { 'aria-hidden': 'true', class: `av ${size} k-${desc.kind}` });
44
+ if (desc.kind === 'identicon') node.replaceChildren(identiconSvg(desc.grid)); else node.textContent = desc.text;
94
45
  return node;
95
46
  }
96
- const rowAvatar = (m, row) => resolveAvatar({ avatar: row.avatar, emoji: row.emoji, author: row.author, name: row.title, machine: blobMachine(m.id) });
97
- const cameraIcon = () => svg('svg', { viewBox: '0 0 24 24', width: 11, height: 11, fill: 'none', stroke: 'currentColor', 'stroke-width': 2.4, 'aria-hidden': 'true' },
98
- svg('path', { d: 'M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z' }), svg('circle', { cx: 12, cy: 13, r: 4 }));
47
+ const rowAvatar = row => resolveAvatar({ author: row.author, name: row.title });
99
48
 
100
49
  // ---- 弹层:宽屏居中模态,窄屏底部抽屉;同一时间只开一个 ----
101
50
  let openDialog = null;
102
- function makeDialog({ title, close: closeLabel, onClose, foot }) {
51
+ function makeDialog({ title, close: closeLabel, onClose }) {
103
52
  const heading = h('h3', {}, title), body = h('div', { class: 'dlg-body' });
104
53
  const panel = h('div', { class: 'dialog', role: 'dialog', 'aria-modal': 'true' }, h('div', { class: 'grabber', 'aria-hidden': 'true' }),
105
54
  h('div', { class: 'dlg-head' }, heading, h('button', { class: 'btn quiet small', type: 'button', onclick: () => closeDialog() }, closeLabel)),
106
- body, foot ? h('div', { class: 'dlg-foot' }, foot) : null);
55
+ body);
107
56
  const scrim = h('div', { class: 'scrim', onclick: e => { if (e.target === scrim) closeDialog(); } }, panel);
108
57
  scrim.hidden = true;
109
58
  return { scrim, heading, body, onClose };
@@ -124,11 +73,11 @@ function closeDialog() {
124
73
  }
125
74
  addEventListener('keydown', e => { if (e.key === 'Escape' && openDialog) closeDialog(); });
126
75
 
127
- // ---- 我的名片:每个身份一张 Hero ----
128
- // 只有一台电脑时,名片上带这台的状态条和「添加好友」;几台时这两样都在各自的节里。
76
+ // ---- 本机身份:每个身份一张 Hero ----
77
+ // 只有一台电脑时,Hero 上带这台的状态条和「添加好友」;几台时这两样都在各自的节里。
129
78
  const CERT = {
130
79
  active: { dot: 'ok-dot', text: '可发布' },
131
- needs_cert: { dot: 'warn-dot', text: '需要证书', sub: '需绑定或续期代签证书:前往客户端「设置 › 身份」处理后再发布名片' },
80
+ needs_cert: { dot: 'warn-dot', text: '需要证书', sub: '需绑定或续期代签证书:前往客户端「设置 › 身份」处理' },
132
81
  no_identity: { dot: 'off-dot', text: '未建身份', sub: '前往客户端「设置 › 身份」创建' },
133
82
  };
134
83
  const formatTime = ms => new Date(ms).toLocaleString('zh-CN', { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' });
@@ -139,7 +88,7 @@ function tile(label, value, sub, dot) {
139
88
  function statusTiles(m, rows) {
140
89
  if (!m.loaded) return h('div', { class: 'bento' }, tile('好友', '读取中…'), tile('身份', '读取中…'));
141
90
  const summary = accordStatusSummary(m.entry, rows), { bound, pending, conflict, total } = summary.friends, cert = CERT[summary.cert];
142
- const sub = summary.cert === 'active' ? (summary.certUntil ? `证书有效至 ${formatTime(summary.certUntil)}` : '名片可正常发布') : cert.sub;
91
+ const sub = summary.cert === 'active' ? (summary.certUntil ? `证书有效至 ${formatTime(summary.certUntil)}` : '可正常发布记录') : cert.sub;
143
92
  return h('div', { class: 'bento' },
144
93
  tile('好友', `${bound} 位已互认`, h('span', { class: 'tile-s' },
145
94
  conflict ? h('span', { class: 'badge conflict' }, `${conflict} 冲突`) : null,
@@ -148,26 +97,22 @@ function statusTiles(m, rows) {
148
97
  tile('身份', cert.text, h('span', { class: 'tile-s' }, sub), cert.dot));
149
98
  }
150
99
  function drawHero(id, sections) {
151
- const { author, card, signer } = id, ready = Boolean(signer);
152
- const own = card ?? blankOwn(), noticeKey = author ?? '';
100
+ const { author, signer } = id, ready = Boolean(signer);
153
101
  const summary = accordStatusSummary(signer?.entry, []);
154
- const avatarDesc = resolveAvatar({ avatar: card?.avatarPresent ? card.avatar : undefined, emoji: own.emoji, author, name: own.name, machine: blobMachine(card?.from) });
155
- const notice = state.heroNotice.get(noticeKey);
102
+ const notice = state.heroNotice.get(author ?? '');
156
103
  const settled = members.every(m => m.loaded || m.unreachable || m.accordProblem);
157
- const name = own.name || (!settled ? '读取中…' : ready ? '还没有名片' : '读不到名片');
104
+ const name = author ? identityTitle(author) : !settled ? '读取中…' : ready ? '未建身份' : '读不到身份';
158
105
  const single = !multi && sections[0];
159
- return h('section', { class: `hero c-${own.color ?? 'blue'}` },
106
+ return h('section', { class: 'hero' },
160
107
  h('div', { class: 'banner' }, h('div', { class: 'banner-acts' },
161
- h('button', { class: 'pill', type: 'button', disabled: !ready, onclick: () => openEditor(id) }, '编辑名片'),
162
108
  single && !single.unreachable ? h('button', { class: 'pill strong', type: 'button', onclick: () => openInvite(single.member) }, '添加好友') : null)),
163
109
  h('div', { class: 'hero-body' },
164
110
  h('div', { class: 'hero-id' },
165
- h('button', { class: 'av-ring', type: 'button', 'aria-label': '更换头像', title: '更换头像', disabled: !ready, onclick: () => openEditor(id) },
166
- avatar(avatarDesc, 'lg'), h('span', { class: 'cam' }, cameraIcon())),
167
- h('div', { class: 'hero-names' }, h('div', { class: 'name-line' }, h('h2', { class: 'hero-name selectable' }, name), h('span', { class: 'tag' }, '我的名片')),
111
+ h('span', { class: 'av-ring' }, avatar(resolveAvatar({ author, name }), 'lg')),
112
+ h('div', { class: 'hero-names' }, h('div', { class: 'name-line' }, h('h2', { class: 'hero-name selectable' }, name), h('span', { class: 'tag' }, '我的身份')),
168
113
  h('button', { class: 'fp mono', type: 'button', disabled: !author, title: author ? '复制完整公钥' : '', onclick: () => copyKey(author),
169
114
  }, author ? `ed25519:${summary.short}… · 复制` : !ready ? (settled ? '读不到公钥' : '读取中…') : summary.cert === 'no_identity' ? '未建身份' : '未取得公钥'))),
170
- !own.name && ready && settled ? h('p', { class: 'hint' }, '点「编辑名片」设置昵称、头像和主题色,好友就能认出你。名片对所有人公开。') : null,
115
+ !author && ready && settled ? h('p', { class: 'hint' }, '这台电脑还没有 Accord 身份:前往客户端「设置 › 身份」创建后,好友才能认出你。') : null,
171
116
  notice ? h('p', { class: notice.kind }, notice.text) : null,
172
117
  single && !single.unreachable ? statusTiles(single.member, single.rows) : null));
173
118
  }
@@ -176,177 +121,6 @@ async function copyKey(author) {
176
121
  draw();
177
122
  }
178
123
 
179
- // ---- 编辑名片 ----
180
- // 正在编辑的名片所属的身份、发往的那一台,和这张名片当前已发布的内容(编辑弹层另有一份草稿,打开时从它拷贝)。
181
- const blankOwn = () => ({ name: '', emoji: '', color: 'blue', avatar: undefined });
182
- const own = blankOwn();
183
- const editing = { author: null, member: null, avatarMachine: null };
184
- // 草稿:mode 决定头像怎么发;avatar 是沿用的已有图片指针(清除照片后为 null),新选的图在 cropper 里。
185
- const draft = { name: '', color: 'blue', mode: 'identicon', emoji: '', avatar: null };
186
- const preview = { canvas: h('canvas', { class: 'preview-canvas', width: 144, height: 144 }) };
187
- const cropper = createCropper({ onChange: () => { if (draft.mode === 'photo' && cropper.ready) mirrorCrop(); } });
188
- function mirrorCrop() {
189
- const ctx = preview.canvas.getContext('2d');
190
- ctx.clearRect(0, 0, 144, 144);
191
- ctx.drawImage(cropper.canvas, 0, 0, 144, 144);
192
- }
193
- const editor = {
194
- dialog: null,
195
- preview: h('div', { class: 'mini-card' }),
196
- modes: h('div', { class: 'seg', role: 'group', 'aria-label': '头像类型' }),
197
- file: h('input', { type: 'file', accept: 'image/*', onchange: pickFile }),
198
- photo: h('div', { class: 'pane' }),
199
- emoji: h('input', { type: 'text', maxlength: '8', placeholder: '自定义 Emoji(1–8 字)', autocomplete: 'off', oninput: e => { draft.emoji = e.target.value; syncEditor(); } }),
200
- emojis: h('div', { class: 'emoji-grid' }),
201
- other: h('p', { class: 'hint' }),
202
- name: h('input', { type: 'text', maxlength: '40', placeholder: '昵称(1–40 字)', autocomplete: 'off', oninput: e => { draft.name = e.target.value; syncPreview(); } }),
203
- swatches: h('div', { class: 'swatches', role: 'group', 'aria-label': '主题色' }),
204
- message: h('p', { class: 'hint' }),
205
- publish: h('button', { class: 'btn', type: 'button', onclick: publishCard }, '发布名片'),
206
- };
207
- editor.file.hidden = true;
208
- editor.emojiPane = h('div', { class: 'pane' }, editor.emojis, editor.emoji);
209
- editor.dialog = makeDialog({ title: '编辑名片', close: '取消', onClose: () => { editorGen++; cropper.clear(); },
210
- foot: [editor.message, h('span', { class: 'spacer' }), editor.publish] });
211
- editor.dialog.body.append(h('div', { class: 'ed-cols' },
212
- h('div', { class: 'ed-preview' }, editor.preview, h('p', { class: 'hint center' }, '实时预览 · 好友看到的效果')),
213
- h('div', { class: 'ed-controls' },
214
- h('span', { class: 'lbl' }, '头像'), editor.modes, editor.file, editor.photo, editor.emojiPane, editor.other,
215
- h('label', { class: 'field' }, h('span', { class: 'lbl' }, '昵称'), editor.name),
216
- h('div', { class: 'field' }, h('span', { class: 'lbl' }, '主题色'), editor.swatches))));
217
-
218
- const modeOf = card => (card.avatar ? 'photo' : !card.emoji ? 'identicon' : card.emoji === initialChar(card.name, '') ? 'monogram' : 'emoji');
219
- // 改名片只发给这个身份的一台(id.signer),页面只确认这一台写入成功;同一身份的其他台要等 Coda 基座同步后才显示新名片(本插件不保证、不检查);头像也上传到这一台。
220
- function openEditor(id) {
221
- if (!id.signer) return;
222
- editorGen++;
223
- Object.assign(own, blankOwn(), id.card && { name: id.card.name, emoji: id.card.emoji ?? '', color: id.card.color ?? 'blue', avatar: id.card.avatarPresent ? id.card.avatar : undefined });
224
- Object.assign(editing, { author: id.author, member: id.signer, avatarMachine: blobMachine(id.card?.from) });
225
- cropper.clear();
226
- editor.publish.disabled = false;
227
- Object.assign(draft, { name: own.name, color: own.color, mode: modeOf(own), emoji: own.emoji, avatar: own.avatar ?? null });
228
- editor.name.value = draft.name;
229
- editor.emoji.value = draft.mode === 'emoji' ? draft.emoji : '';
230
- if (draft.mode !== 'emoji') draft.emoji = '';
231
- say(editor.message, '');
232
- syncEditor();
233
- showDialog(editor.dialog);
234
- }
235
- function draftAvatar() {
236
- const author = editing.author, name = draft.name;
237
- if (draft.mode === 'photo') return resolveAvatar({ avatar: draft.avatar, emoji: own.emoji, author, name, machine: editing.avatarMachine });
238
- if (draft.mode === 'emoji') return resolveAvatar({ emoji: draft.emoji, author, name });
239
- if (draft.mode === 'monogram') return { kind: 'monogram', text: initialChar(name) };
240
- return resolveAvatar({ author, name });
241
- }
242
- function syncPreview() {
243
- const fresh = draft.mode === 'photo' && cropper.ready;
244
- editor.preview.className = `mini-card c-${draft.color}`;
245
- editor.preview.replaceChildren(h('div', { class: 'banner small' }),
246
- h('div', { class: 'mini-body' },
247
- h('span', { class: 'av-ring md' }, fresh ? h('span', { class: 'av md k-photo' }, preview.canvas) : avatar(draftAvatar(), 'md')),
248
- h('div', { class: 'mini-name truncate' }, draft.name.trim() || '未命名'),
249
- editing.author ? h('div', { class: 'mono secondary' }, `@${shortAuthor(editing.author)}`) : null));
250
- if (fresh) mirrorCrop();
251
- if (draft.mode === 'monogram') editor.other.textContent = `以昵称首字「${initialChar(draft.name)}」作头像,昵称改了它跟着变。`;
252
- }
253
- function syncEditor() {
254
- editor.modes.replaceChildren(...MODES.map(([mode, label]) => h('button', { type: 'button', 'aria-pressed': String(draft.mode === mode), onclick: () => { draft.mode = mode; syncEditor(); } }, label)));
255
- editor.photo.hidden = draft.mode !== 'photo';
256
- editor.emojiPane.hidden = draft.mode !== 'emoji';
257
- editor.other.hidden = draft.mode !== 'identicon' && draft.mode !== 'monogram';
258
- editor.other.textContent = draft.mode === 'identicon' ? (editing.author ? '由你的公钥确定性生成的 5×5 几何纹,换设备也一样。' : '取得身份后按公钥生成几何纹;现在先以昵称首字代替。') : '';
259
- const choose = h('button', { class: 'btn quiet small', type: 'button', onclick: () => editor.file.click() }, cropper.ready || draft.avatar ? '换一张' : '选择图片');
260
- const clear = cropper.ready || draft.avatar ? h('button', { class: 'btn danger small', type: 'button', onclick: clearPhoto }, '清除照片') : null;
261
- fill(editor.photo, ...(cropper.ready
262
- ? [cropper.box, h('div', { class: 'zoom-row' }, h('span', { class: 'secondary' }, '缩放'), cropper.zoom, cropper.zoomText),
263
- h('div', { class: 'actions' }, choose, h('button', { class: 'btn quiet small', type: 'button', onclick: () => cropper.reset() }, '重置裁切'), clear),
264
- h('p', { class: 'hint' }, '拖动图片调整位置;发布时导出 512×512 的正方形头像。')]
265
- : [h('p', { class: 'hint' }, draft.avatar ? '正在使用已发布的照片。' : '从本机选一张图片,裁剪成正方形头像。'), h('div', { class: 'actions' }, choose, clear)]));
266
- editor.emojis.replaceChildren(...EMOJIS.map(mark => h('button', { type: 'button', class: 'emoji-opt', 'aria-label': `Emoji ${mark}`, 'aria-pressed': String(draft.emoji === mark),
267
- onclick: () => { draft.emoji = mark; editor.emoji.value = mark; syncEditor(); } }, mark)));
268
- editor.swatches.replaceChildren(...COLORS.map(color => h('button', { class: `swatch c-${color}`, type: 'button', 'aria-label': `主题色:${COLOR_NAMES[color]}`, 'aria-pressed': String(draft.color === color),
269
- onclick: () => { draft.color = color; syncEditor(); } })));
270
- syncPreview();
271
- }
272
- function pickFile(e) {
273
- const file = e.target.files?.[0];
274
- e.target.value = '';
275
- if (!file) return;
276
- say(editor.message, '');
277
- cropper.load(file).then(loaded => { if (loaded) { draft.mode = 'photo'; syncEditor(); } }, error => { say(editor.message, error.message, 'error'); syncEditor(); });
278
- }
279
- function clearPhoto() {
280
- cropper.clear();
281
- draft.avatar = null;
282
- draft.mode = 'identicon';
283
- syncEditor();
284
- }
285
- // 发布用的名片字段:原名片有图而这次不用照片,就显式写 avatar: null 清除;照片模式没换图就沿用已有指针,不重复上传。
286
- function draftFields() {
287
- const fields = { name: draft.name, color: draft.color }, drop = own.avatar ? null : undefined;
288
- if (draft.mode === 'photo') {
289
- if (!cropper.ready && !draft.avatar) throw new Error('请先选择一张图片,或换用其他头像类型');
290
- return { ...fields, emoji: own.emoji, avatar: cropper.ready ? undefined : draft.avatar };
291
- }
292
- if (draft.mode === 'emoji') {
293
- if (!draft.emoji.trim()) throw new Error('请选一个或输入一个 Emoji');
294
- return { ...fields, emoji: draft.emoji, avatar: drop };
295
- }
296
- // 字标不扩协议:把昵称首字写进 emoji,双方都按 emoji 显示。
297
- return { ...fields, emoji: draft.mode === 'monogram' ? initialChar(draft.name, '') : undefined, avatar: drop };
298
- }
299
- async function uploadAvatar(blob, machine) {
300
- let response;
301
- try { response = await fetch(blobUploadUrl(machine), { method: 'POST', headers: { 'Content-Type': blob.type }, body: blob }); }
302
- catch (e) { throw new Error(`头像上传失败(网络错误:${e.message})`); }
303
- if (!response.ok) throw new Error(UPLOAD_ERRORS[response.status] ?? `头像上传失败(HTTP ${response.status})`);
304
- const { owner, path, sha256, mime, size, name } = await response.json();
305
- return normalizeContentPointer({ owner, path, sha256, mime, size, name });
306
- }
307
- // 发 profile;绑定了代签证书时 profile 须由客户端根签,这里发不了:改发可代签的社交名片 friends/card,好友一样看得到。
308
- async function publishBody(body, opts, author) {
309
- try {
310
- await coda.call(LOCAL, 'publish', { kind: 'profile', id: 'self', body, audience: ['public'] }, opts);
311
- return '名片已发布,好友会看到它';
312
- } catch (e) {
313
- if (e?.code !== 'forbidden') throw e;
314
- await coda.call(LOCAL, 'publish', { kind: CARD_KIND, id: 'self', body, audience: ['public'] }, opts);
315
- // 缓存的 profiles 可能还没读完或读失败了:现查一次本机作者的根签 profile,查不出来就不承诺。
316
- let rooted = null;
317
- try { rooted = ((await coda.query(LOCAL, 'records', { kind: 'profile', author, limit: 1 }, opts))?.records ?? []).some(record => readProfileRecord(record)); } catch { /* 按没读出来提示 */ }
318
- return cardFallbackNotice(rooted);
319
- }
320
- }
321
- // 上传与发布都发往入口时定下的那一台;弹层被关掉、重开后,旧会话做完也不往新会话的弹层写任何状态。
322
- async function publishCard() {
323
- const upload = draft.mode === 'photo' && cropper.ready;
324
- let body;
325
- try { body = normalizeCardInput(draftFields()); } catch (e) { return say(editor.message, e.message, 'error'); }
326
- const session = editorGen, { member, author } = editing, opts = via(member), machine = blobMachine(member.id);
327
- const current = () => session === editorGen;
328
- editor.publish.disabled = true;
329
- try {
330
- if (upload) {
331
- say(editor.message, '正在处理图片…', 'progress');
332
- const blob = await cropper.export();
333
- if (current()) say(editor.message, '正在上传头像…', 'progress');
334
- body = { ...body, avatar: await uploadAvatar(blob, machine) };
335
- }
336
- if (current()) say(editor.message, '正在发布…', 'progress');
337
- const notice = await publishBody(body, opts, author);
338
- readProfiles(member);
339
- if (current()) {
340
- // 关弹层会让会话代际自增,所以先恢复按钮。
341
- editor.publish.disabled = false;
342
- closeDialog();
343
- state.heroNotice.set(author ?? '', { kind: 'ok', text: notice });
344
- draw();
345
- }
346
- } catch (e) { if (current()) say(editor.message, `没有发布成功:${e.message}`, 'error'); }
347
- if (current()) editor.publish.disabled = false;
348
- }
349
-
350
124
  // ---- 添加好友 ----
351
125
  const invite = {
352
126
  paste: h('textarea', { placeholder: '粘贴邀请:JSON、coda-friend:// 链接,或多行 control=… / authKey=…', autocomplete: 'off', spellcheck: 'false', oninput: parsePaste }),
@@ -427,7 +201,7 @@ async function submitInvite() {
427
201
  invite.button.disabled = false;
428
202
  }
429
203
 
430
- // ---- 好友详情:备注、重新互认、移除都发给这一行所在的电脑 ----
204
+ // ---- 好友详情:重新互认、移除都发给这一行所在的电脑 ----
431
205
  // 不同电脑上的 node 可能相同,忙碌与提示按(电脑, node)记。
432
206
  const sectionRows = m => friendSections([m])[0].rows;
433
207
 
@@ -453,40 +227,17 @@ async function remove(m, row) {
453
227
  }
454
228
  draw();
455
229
  }
456
- async function saveNote(m, row, text) {
457
- const key = rowKey(m, row.node);
458
- state.busy.add(key); state.notice.set(key, { kind: 'progress', text: '正在保存备注…' }); draw();
459
- let saved, failure;
460
- try { saved = await ask(m, text.trim() ? 'notes.set' : 'notes.delete', { node: row.node, note: text }); }
461
- catch (e) { failure = { kind: 'error', text: `备注没存下:${e.message}` }; }
462
- state.busy.delete(key);
463
- if (failure) state.notice.set(key, failure);
464
- else {
465
- m.notes = saved;
466
- state.notice.set(key, { kind: 'ok', text: text.trim() ? '备注已保存' : '备注已清空' });
467
- if (state.detail?.key === key) detail.note.value = detailRow()?.note ?? '';
468
- }
469
- draw();
470
- }
471
-
472
230
  const detail = {
473
231
  dialog: makeDialog({ title: '好友', close: '完成', onClose: () => { state.detail = null; state.removing = null; } }),
474
232
  card: h('div'),
475
233
  info: h('dl', { class: 'facts' }),
476
- note: h('input', { type: 'text', maxlength: '40', placeholder: '备注名(只存在本机,不会发给好友)', autocomplete: 'off',
477
- onkeydown: e => { if (e.key === 'Enter') noteAction(row => saveNote(state.detail.member, row, detail.note.value)); } }),
478
- noteButtons: h('div', { class: 'line' }),
479
234
  actions: h('div', { class: 'actions split' }),
480
235
  notice: h('div'),
481
236
  };
482
- detail.dialog.body.append(h('div', { class: 'stack' }, detail.card, detail.info,
483
- h('div', { class: 'field' }, h('span', { class: 'lbl' }, '本机备注'), h('div', { class: 'line nowrap' }, detail.note, detail.noteButtons)),
484
- detail.actions, detail.notice));
237
+ detail.dialog.body.append(h('div', { class: 'stack' }, detail.card, detail.info, detail.actions, detail.notice));
485
238
  const detailRow = () => state.detail && sectionRows(state.detail.member).find(row => row.node === state.detail.node);
486
- function noteAction(run) { const row = detailRow(); if (row && !state.busy.has(state.detail.key)) run(row); }
487
239
  function openDetail(m, row) {
488
240
  state.detail = { member: m, node: row.node, key: rowKey(m, row.node) }; state.removing = null;
489
- detail.note.value = row.note;
490
241
  drawDetail();
491
242
  showDialog(detail.dialog);
492
243
  }
@@ -502,19 +253,15 @@ function drawDetail() {
502
253
  if (!row) return;
503
254
  const busy = state.busy.has(key), notice = state.notice.get(key);
504
255
  detail.dialog.heading.textContent = multi ? `${row.title} · ${m.name}` : row.title;
505
- detail.card.replaceChildren(h('div', { class: `mini-card c-${row.color}` }, h('div', { class: 'banner small' }),
506
- h('div', { class: 'mini-body row' }, h('span', { class: 'av-ring lg' }, avatar(rowAvatar(m, row), 'lg')),
507
- h('div', { class: 'mini-names' }, h('div', { class: 'mini-name truncate selectable' }, row.title),
508
- row.note && row.profileName ? h('div', { class: 'secondary truncate selectable' }, `原名 ${row.profileName}`) : null),
256
+ detail.card.replaceChildren(h('div', { class: 'mini-card' }, h('div', { class: 'banner small' }),
257
+ h('div', { class: 'mini-body row' }, h('span', { class: 'av-ring lg' }, avatar(rowAvatar(row), 'lg')),
258
+ h('div', { class: 'mini-names' }, h('div', { class: 'mini-name truncate selectable' }, row.title)),
509
259
  h('span', { class: `badge ${row.status}` }, STATUS_TEXT[row.status]))));
510
260
  detail.info.replaceChildren(
511
261
  ...fact('公钥', row.author ? h('span', { class: 'mono key-full' }, row.author) : h('span', { class: 'secondary' }, '密钥未互认'),
512
262
  row.author ? h('button', { class: 'btn quiet small', type: 'button', onclick: () => copyFriendKey(m, row) }, '复制公钥') : null),
513
263
  ...fact('节点', h('span', { class: 'mono' }, row.peerNode ?? row.node)),
514
264
  ...fact('连接', STATUS_TEXT[row.status]));
515
- fill(detail.noteButtons,
516
- h('button', { class: 'btn small', type: 'button', disabled: busy, onclick: () => noteAction(r => saveNote(m, r, detail.note.value)) }, '保存'),
517
- row.note ? h('button', { class: 'btn quiet small', type: 'button', disabled: busy, onclick: () => noteAction(r => saveNote(m, r, '')) }, '清空') : null);
518
265
  detail.actions.replaceChildren(...(state.removing === key
519
266
  ? [h('span', { class: 'secondary' }, '移除后不再同步这位好友,确定吗?'), h('span', { class: 'spacer' }),
520
267
  h('button', { class: 'btn danger small', type: 'button', disabled: busy, onclick: () => remove(m, row) }, '确认移除'),
@@ -527,26 +274,22 @@ function drawDetail() {
527
274
  }
528
275
 
529
276
  function friendTile(m, row) {
530
- const secondary = [row.note && row.profileName ? row.profileName : null, row.short ? `@${row.short}` : '密钥未互认'].filter(Boolean).join(' · ');
531
- return h('li', {}, h('button', { class: `f-tile c-${row.color}`, type: 'button', 'aria-label': `${row.title},${STATUS_TEXT[row.status]}`, onclick: () => openDetail(m, row) },
532
- avatar(rowAvatar(m, row), 'sm'),
533
- h('span', { class: 'f-info' }, h('span', { class: 'f-name truncate' }, row.title), h('span', { class: 'f-meta truncate' }, secondary)),
277
+ return h('li', {}, h('button', { class: 'f-tile', type: 'button', 'aria-label': `${row.title},${STATUS_TEXT[row.status]}`, onclick: () => openDetail(m, row) },
278
+ avatar(rowAvatar(row), 'sm'),
279
+ h('span', { class: 'f-info' }, h('span', { class: 'f-name truncate' }, row.title), h('span', { class: 'f-meta truncate' }, row.short ? `@${row.short}` : '密钥未互认')),
534
280
  h('span', { class: `badge ${row.status}` }, STATUS_TEXT[row.status])));
535
281
  }
536
282
 
537
- // 每台电脑一节;只有一台时没有节标题,也不重复画名片上已有的状态条和「添加好友」。
538
- const memberProblems = m => [m.notesProblem, m.problem].filter(Boolean).join(';');
283
+ // 每台电脑一节;只有一台时没有节标题,也不重复画身份卡上已有的状态条和「添加好友」。
539
284
  function drawSection({ member: m, title, unreachable, rows }) {
540
- const problems = memberProblems(m);
541
285
  const down = !unreachable ? null : m.unreachable ? `${m.name} 读不到:${unreachable}` : `${multi ? `${m.name}:` : ''}${unreachable}`;
542
286
  const summary = !unreachable && m.loaded ? accordStatusSummary(m.entry, rows) : null;
543
- // 几台时状态条只在有需要提示的状态(证书有问题、待互认、冲突)时出;只有一台时状态条在名片上。
287
+ // 几台时状态条只在有需要提示的状态(证书有问题、待互认、冲突)时出;只有一台时状态条在身份卡上。
544
288
  const attention = summary && (summary.cert !== 'active' || summary.friends.pending || summary.friends.conflict);
545
289
  const empty = !m.loaded ? '正在读取…' : '还没有好友。点上方「添加好友」,粘贴对方发来的邀请即可。';
546
290
  return h('section', {},
547
291
  h('h2', { class: 'sec' }, title ?? '好友', unreachable ? null : h('span', { class: 'count', hidden: !rows.length }, String(rows.length))),
548
292
  down ? h('p', { class: 'error selectable' }, down) : [
549
- multi && problems ? h('p', { class: 'error selectable' }, problems) : null,
550
293
  multi && attention ? statusTiles(m, rows) : null,
551
294
  multi ? h('div', { class: 'line' }, h('button', { class: 'pill strong', type: 'button', onclick: () => openInvite(m) }, '添加好友')) : null,
552
295
  rows.length ? h('ul', { class: 'friends' }, rows.map(row => friendTile(m, row))) : multi && m.loaded ? null : h('p', { class: 'empty' }, empty)]);
@@ -556,18 +299,13 @@ const page = h('div', { class: 'page' });
556
299
  function draw() {
557
300
  const sections = friendSections(members);
558
301
  const ids = identities(live);
559
- if (!ids.length) ids.push({ author: null, card: null, signer: null, members: [] });
560
- // 单台时的问题放在页首,和以前一致;几台时各在各的节里。
561
- const head = multi ? null : memberProblems(members[0] ?? {}) && h('p', { class: 'error selectable' }, memberProblems(members[0]));
562
- fill(page, head, ids.map(id => drawHero(id, sections)), sections.map(drawSection));
302
+ if (!ids.length) ids.push({ author: null, signer: null, members: [] });
303
+ fill(page, ids.map(id => drawHero(id, sections)), sections.map(drawSection));
563
304
  if (state.detail) { if (detailRow()) drawDetail(); else closeDialog(); }
564
305
  }
565
306
 
566
- root.replaceChildren(page, editor.dialog.scrim, detail.dialog.scrim, invite.dialog.scrim);
567
- syncEditor();
307
+ root.replaceChildren(page, detail.dialog.scrim, invite.dialog.scrim);
568
308
  draw();
569
309
 
570
- coda.on('toolbar', ({ id } = {}) => { if (id === 'refresh') { state.failedPhotos.clear(); for (const m of live) readProfiles(m); draw(); } });
571
- coda.toolbar([{ id: 'refresh', label: '刷新', icon: 'arrow.clockwise', kind: 'button' }]).catch(() => {});
572
310
  coda.header({ text: '好友' }).catch(() => {});
573
311
  for (const m of live) start(m);
package/view/style.css CHANGED
@@ -1,4 +1,4 @@
1
- /* 好友页「活的极客名片 · Bento」:颜色只取 App 给的 --coda-* 变量(带回退),手机优先,>= 680px 宽屏。 */
1
+ /* 好友页「Bento」:颜色只取 App 给的 --coda-* 变量(带回退),手机优先,>= 680px 宽屏。 */
2
2
  :root {
3
3
  color-scheme: light dark;
4
4
  --fg: var(--coda-foreground, CanvasText);
@@ -28,14 +28,12 @@ button:disabled { opacity: .5; cursor: default; }
28
28
  .secondary { color: var(--fg2); }
29
29
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
30
30
  .spacer { flex: 1 1 auto; }
31
- .center { text-align: center; }
32
31
 
33
32
  .page { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
34
33
  .hint, .progress, .empty { margin: 0; color: var(--fg2); font-size: .92em; }
35
34
  .error { margin: 0; color: var(--red); overflow-wrap: anywhere; }
36
35
  .ok { margin: 0; color: var(--green); overflow-wrap: anywhere; }
37
36
  .line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
38
- .line.nowrap { flex-wrap: nowrap; }
39
37
  .stack { display: flex; flex-direction: column; gap: 12px; }
40
38
  .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
41
39
  .actions.split { padding-top: 12px; border-top: 1px solid var(--line); }
@@ -46,7 +44,6 @@ button:disabled { opacity: .5; cursor: default; }
46
44
  input, textarea { width: 100%; min-width: 0; padding: 8px 10px; border-radius: var(--coda-radius, 9px); border: 1px solid var(--line); background: var(--bg); outline: none; }
47
45
  input:focus, textarea:focus { border-color: var(--accent); }
48
46
  textarea { min-height: 84px; resize: vertical; }
49
- input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--fg); }
50
47
  details > summary { cursor: pointer; color: var(--fg2); }
51
48
  details[open] > summary { margin-bottom: 10px; }
52
49
 
@@ -55,11 +52,9 @@ details[open] > summary { margin-bottom: 10px; }
55
52
  .btn.danger { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
56
53
  .btn.small { padding: 4px 11px; font-weight: 550; font-size: .92em; }
57
54
 
58
- /* 主题色:每个色类给出 --c,再派生柔和底色与前景色,浅/深色都跟着背景走。 */
59
- .c-blue { --c: var(--coda-blue, #0a84ff); } .c-orange { --c: var(--coda-orange, #ff9500); } .c-green { --c: var(--coda-green, #34c759); }
60
- .c-purple { --c: var(--coda-purple, #af52de); } .c-pink { --c: var(--coda-pink, #ff2d55); } .c-teal { --c: var(--coda-teal, #30b0c7); }
61
- .c-gray { --c: var(--coda-gray, #8e8e93); }
62
- .c-blue, .c-orange, .c-green, .c-purple, .c-pink, .c-teal, .c-gray {
55
+ /* 公钥派生的头像统一用灰色:--c 是底色,派生柔和底色与前景色,浅/深色都跟着背景走。 */
56
+ :root {
57
+ --c: var(--coda-gray, #8e8e93);
63
58
  --c-soft: color-mix(in srgb, var(--c) 16%, var(--bg));
64
59
  --c-ink: color-mix(in srgb, var(--c) 78%, var(--fg));
65
60
  }
@@ -82,21 +77,14 @@ details[open] > summary { margin-bottom: 10px; }
82
77
 
83
78
  /* 跨界方圆头像 */
84
79
  .av { display: grid; place-items: center; overflow: hidden; flex: none; background: var(--c-soft, var(--fill)); color: var(--c-ink, var(--fg)); font-weight: 700; line-height: 1; }
85
- .av img, .av svg, .av canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
80
+ .av svg { width: 100%; height: 100%; display: block; }
86
81
  .av.k-identicon svg { padding: 6%; }
87
82
  .av.lg { width: 100%; height: 100%; border-radius: 17px; font-size: 30px; }
88
- .av.lg.k-emoji { font-size: 36px; }
89
- .av.md { width: 100%; height: 100%; border-radius: 14px; font-size: 24px; }
90
83
  .av.sm { width: 44px; height: 44px; border-radius: 13px; font-size: 18px; }
91
- .av.sm.k-emoji { font-size: 22px; }
92
84
  .av-ring { position: relative; flex: none; display: block; width: 78px; height: 78px; padding: 3.5px; border: 0; border-radius: 22px; background: var(--bg); box-shadow: 0 4px 14px rgba(0, 0, 0, .14); }
93
- .av-ring.md { width: 62px; height: 62px; padding: 3px; border-radius: 18px; }
94
85
  .av-ring.lg { width: 70px; height: 70px; }
95
- button.av-ring { transition: transform .14s ease; }
96
- button.av-ring:active:not(:disabled) { transform: scale(.96); }
97
- .cam { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--fg); color: var(--bg); border: 2.5px solid var(--bg); }
98
86
 
99
- /* Hero 名片卡 */
87
+ /* Hero 身份卡 */
100
88
  .hero { border-radius: 22px; border: 1px solid var(--line); background: var(--bg); overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
101
89
  .hero-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
102
90
  .hero-id { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
@@ -142,44 +130,14 @@ button.av-ring:active:not(:disabled) { transform: scale(.96); }
142
130
  .dlg-head h3 { margin: 0; font-size: 1.12em; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
143
131
  .dlg-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }
144
132
  .dlg-body:last-child { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
145
- .dlg-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
146
133
 
147
- /* 迷你名片(编辑预览、好友详情) */
134
+ /* 迷你卡(好友详情) */
148
135
  .mini-card { border-radius: 18px; border: 1px solid var(--line); background: var(--bg); overflow: hidden; }
149
- .mini-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
150
- .mini-body > .av-ring { margin-top: -30px; z-index: 1; }
151
- .mini-body.row { flex-direction: row; align-items: flex-end; gap: 12px; }
152
- .mini-body.row > .av-ring { margin-top: -34px; }
136
+ .mini-body { padding: 0 14px 14px; display: flex; flex-direction: row; align-items: flex-end; gap: 12px; }
137
+ .mini-body > .av-ring { margin-top: -34px; }
153
138
  .mini-names { flex: 1 1 auto; min-width: 0; padding-bottom: 2px; }
154
139
  .mini-name { font-size: 1.25em; font-weight: 700; }
155
140
 
156
- /* 编辑名片 */
157
- .ed-cols { display: grid; gap: 16px; }
158
- .ed-controls { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
159
- .seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
160
- .seg button { height: 28px; border: 0; border-radius: 7px; background: none; color: var(--fg2); font-size: .92em; font-weight: 550; }
161
- .seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
162
- .pane { display: flex; flex-direction: column; gap: 8px; }
163
- .crop-box { position: relative; width: min(240px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 18px; overflow: hidden; cursor: grab; touch-action: none;
164
- -webkit-user-select: none; user-select: none; background: color-mix(in srgb, var(--fg) 88%, var(--bg)); box-shadow: 0 6px 20px rgba(0, 0, 0, .16); }
165
- .crop-box.dragging { cursor: grabbing; }
166
- .crop-canvas { display: block; width: 100%; height: 100%; }
167
- .crop-grid { position: absolute; inset: 0; pointer-events: none; border-radius: 18px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85); opacity: .75;
168
- background:
169
- linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255, 255, 255, .35) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255, 255, 255, .35) 0 calc(66.66% + .5px), transparent 0),
170
- linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255, 255, 255, .35) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255, 255, 255, .35) 0 calc(66.66% + .5px), transparent 0);
171
- transition: opacity .15s; }
172
- .crop-box:not(.dragging) .crop-grid { background: none; }
173
- .zoom-row { display: flex; align-items: center; gap: 8px; font-size: .9em; }
174
- .zoom-row input { flex: 1 1 auto; }
175
- .zoom-value { min-width: 3.2em; text-align: right; color: var(--fg2); }
176
- .emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
177
- .emoji-opt { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; border: 2px solid transparent; background: var(--card); font-size: 1.4em; padding: 0; }
178
- .emoji-opt[aria-pressed="true"] { border-color: var(--fg); }
179
- .swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 280px; }
180
- .swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 0; background: var(--c); box-shadow: inset 0 0 0 2px var(--bg); }
181
- .swatch[aria-pressed="true"] { border-color: var(--fg); }
182
-
183
141
  /* 好友详情 */
184
142
  .facts { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: baseline; }
185
143
  .facts dt { color: var(--fg2); font-size: .92em; }
@@ -198,6 +156,5 @@ button.av-ring:active:not(:disabled) { transform: scale(.96); }
198
156
  .dialog { max-width: 560px; max-height: calc(100% - 40px); border-radius: 14px; box-shadow: 0 22px 60px rgba(0, 0, 0, .26); }
199
157
  .grabber { display: none; }
200
158
  .dlg-head { padding-top: 12px; }
201
- .dlg-body:last-child, .dlg-foot { padding-bottom: 12px; }
202
- .ed-cols { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
159
+ .dlg-body:last-child { padding-bottom: 12px; }
203
160
  }