cortico-world-fun 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.
- package/CHANGELOG.md +10 -0
- package/PUBLISHING.md +20 -8
- package/README.md +8 -0
- package/dist/webui.js +180 -82
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
市场按 `##` 标题里的版本号切段,显示在「历史版本」里。
|
|
4
4
|
|
|
5
|
+
## 0.2.1
|
|
6
|
+
|
|
7
|
+
- 三个面板统一为轻手账风格,调整字号、留白、卡片、圆角、窄屏布局与键盘焦点,沿用宿主明暗主题。
|
|
8
|
+
- 「去哪儿」增加全部、现在开着、室内、户外、夜游、我的地点快捷筛选,可与名称、别名和标签搜索叠加。
|
|
9
|
+
- 纪念册优先展示当前或最近行程,增加全部行程、珍藏、心愿分类;行程按日期分组,「常去的」保留为折叠区域。
|
|
10
|
+
- 新增心愿表单默认折叠,保存成功后收起;已实现、暂缓与取消的心愿折叠收纳,操作中或失败时保持反馈可见。
|
|
11
|
+
- 行程卡支持展开完整路线、事件、选择结果、纪念品、拍照、吃喝、同行人与收摊备注,并保留已有 scene/outfits 指引。
|
|
12
|
+
- 纪念品架采用收藏小卡和探索进度条,提示仅保留账本的旧收藏;修复没有购买纪念品时探索进度被隐藏及说明文字重复的问题。
|
|
13
|
+
- 三个面板补充加载提示、失败重试,刷新失败时保留已有内容;新增交互回归测试。状态格式、工具与提示词保持兼容。
|
|
14
|
+
|
|
5
15
|
## 0.2.0
|
|
6
16
|
|
|
7
17
|
- 精简常驻环境提示词与工具描述,地点清单改为按需查询;进门集中提供可逛、买、拍、吃喝清单,游逛回执只保留本次事实与选择提示,减少重复上下文。纪念册备注、长期收藏和心愿仍可完整按需查询。
|
package/PUBLISHING.md
CHANGED
|
@@ -11,22 +11,34 @@
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 本次准备发布:0.2.1(尚未发布)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
2026-11-18(Asia/Shanghai)核对 npm:线上 latest 为 0.2.0,0.2.1 版本端点返回 404。当前本地版本已设为 **0.2.1**,不要再次运行 `npm version patch`。本轮仅准备发布,不执行 npm publish、Git 提交、推送、标签或 Coo 安装。
|
|
17
|
+
|
|
18
|
+
本版为三个面板的 UI 与交互精修:地点快捷筛选、纪念册分类与行程详情、折叠心愿表单、收藏小卡与探索进度、加载重试和失败保留内容。状态格式、工具和提示词不变。
|
|
19
|
+
|
|
20
|
+
发布前验证已通过:完整 `prepublishOnly`(面板 42/42、世界集成 75/75)、本地安装形态验证。市场检查为 **26 项通过、0 失败、1 警告**:未配置市场截图。线上可用版本检查已改为直接请求 registry,避免 Windows 非交互子进程导致的误报;若目标版本已存在会阻止重复发布。
|
|
21
|
+
|
|
22
|
+
修正后的 `verify-published.mjs` 已对 npm 上的 **0.2.0** 完成真实整包验收:下载、解包、三方面工具名称对账、三个面板取数与客户端 ID 对账、海洋馆进门/游逛/购买/收摊及纪念册记录均通过。此结果不代表 0.2.1 已上线;0.2.1 需发布后单独验包。
|
|
23
|
+
|
|
24
|
+
仍待实机确认:Coo 内的视觉验收与市场截图。此前 Edge 截图进程受权限限制,不能把 DOM 测试当成实机视觉验收。工作树中的修改尚未提交,本地验证日志及 `.tmp` 不应加入提交或发布包。
|
|
25
|
+
|
|
26
|
+
准备流程:
|
|
17
27
|
|
|
18
28
|
```powershell
|
|
19
|
-
npm
|
|
20
|
-
npm run verify
|
|
29
|
+
npm run prepublishOnly
|
|
21
30
|
node tools/verify-tarball.mjs
|
|
22
|
-
node tools/publish-check.mjs --online
|
|
23
31
|
npm pack --dry-run
|
|
24
|
-
npm publish
|
|
25
32
|
```
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
用户确认正式发布后,在已认证的终端执行 `npm publish` 并按实际提示完成认证;不要把恢复码作为 OTP,也不要在对话或日志中粘贴令牌。发布后执行:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
node tools/verify-published.mjs 0.2.1
|
|
38
|
+
npm view cortico-world-fun dist-tags
|
|
39
|
+
```
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
下文均为历史流程参考,旧版本、旧提交和旧数量不作为本轮状态。
|
|
30
42
|
|
|
31
43
|
## 0. 发版前自查
|
|
32
44
|
|
package/README.md
CHANGED
|
@@ -26,6 +26,14 @@ powershell -ExecutionPolicy Bypass -File .\install.ps1 -CooRoot "E:\Coopanion"
|
|
|
26
26
|
|
|
27
27
|
装完重启 Coo,面板 → 世界 →「娱乐时间」应为 `active`,配置页有 4 项。
|
|
28
28
|
|
|
29
|
+
## 面板里的出游手账
|
|
30
|
+
|
|
31
|
+
- **去哪儿**:查看当前行程,用「现在开着 / 室内 / 户外 / 夜游 / 我的地点」快捷筛选,再按名字、别名或标签搜索。分类依据地点已有标签。
|
|
32
|
+
- **纪念册**:切换全部行程、珍藏与心愿;行程按日期排列,点「查看详情」回看路线、完整事件、选择结果、收获与收摊备注。心愿页点击「记个心愿」再填写,保存成功后收起。
|
|
33
|
+
- **纪念品架**:按地方查看收藏小卡,展开物品可看保留下来的行程回忆;探索进度独立显示,没有购买纪念品也能看到逛过哪些地方。
|
|
34
|
+
|
|
35
|
+
三个面板跟随宿主明暗主题,支持窄屏与键盘操作。刷新失败会保留上次内容,可点击重试。旧行程详情若已超出保留窗口且没有珍藏,长期收藏账本仍会保留。
|
|
36
|
+
|
|
29
37
|
## 同一处地方,不同时段不是一回事
|
|
30
38
|
|
|
31
39
|
有几处地方**会随一天的时间改变样子**,不只是换句话:
|
package/dist/webui.js
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* 颜色走宿主主题的自定义属性(--surface/--foreground/--border/--accent…),
|
|
13
13
|
* 自定义属性会继承进 shadow root,所以明暗两套主题都不用自己写。
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* 三个面板:
|
|
16
16
|
* places —— 二十处地方(以及自己加的、改过的)此刻的状态,以及她正在逛的这一趟
|
|
17
|
-
* book ——
|
|
17
|
+
* book —— 纪念册:去过的每一趟与出游心愿
|
|
18
|
+
* shelf —— 纪念品架:长期收藏与探索进度
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
const CSS = `
|
|
@@ -119,6 +120,45 @@ const CSS = `
|
|
|
119
120
|
.fun-stat span{font-size:11.5px;color:var(--f-dim)}
|
|
120
121
|
.fun-empty{padding:22px 12px;text-align:center;color:var(--f-dim);font-size:12.5px}
|
|
121
122
|
.fun-err{border:1px solid #d9534f;border-radius:var(--radius-sm,6px);padding:10px 12px;color:#d9534f;background:color-mix(in srgb,#d9534f 10%,transparent);font-size:12.5px}
|
|
123
|
+
/* 轻手账:跟随宿主主题,只用少量色彩区分内容层次。 */
|
|
124
|
+
.fun{font-size:14px;line-height:1.65;padding:8px 4px 24px;--f-round:12px}
|
|
125
|
+
.fun button,.fun input,.fun select{min-height:34px}
|
|
126
|
+
.fun button:focus-visible,.fun input:focus-visible,.fun select:focus-visible,.fun textarea:focus-visible,.fun summary:focus-visible{outline:2px solid var(--f-accent);outline-offset:3px}
|
|
127
|
+
.fun button:disabled{cursor:default;opacity:.6}
|
|
128
|
+
.fun .fun-btn-primary{background:var(--f-accent);border-color:var(--f-accent);color:var(--accent-foreground,#fff)}
|
|
129
|
+
.fun-heading{margin-bottom:16px;padding:4px 0 12px;border-bottom:1px solid var(--f-line)}
|
|
130
|
+
.fun-heading h2{font-size:20px;line-height:1.4;margin:0 0 4px;letter-spacing:.03em}
|
|
131
|
+
.fun-heading p{margin:0;color:var(--f-dim);font-size:12.5px}
|
|
132
|
+
.fun-live,.fun-trip,.fun-stats,.fun-form{border-radius:var(--f-round);padding:14px 16px}
|
|
133
|
+
.fun-live{background:linear-gradient(120deg,color-mix(in srgb,var(--f-accent) 8%,var(--f-card)),var(--f-card));margin-bottom:16px}
|
|
134
|
+
.fun-live h3{font-size:16px}
|
|
135
|
+
.fun-grid{grid-template-columns:repeat(auto-fill,minmax(min(232px,100%),1fr));gap:12px}
|
|
136
|
+
.fun-card{padding:14px;border-radius:var(--f-round);min-height:136px;background:linear-gradient(180deg,color-mix(in srgb,var(--f-accent) 4%,var(--f-card)),var(--f-card) 65%)}
|
|
137
|
+
.fun-card-name{font-size:15px}.fun-card-head{flex-wrap:wrap}.fun-card-desc{line-height:1.7;margin-top:8px}
|
|
138
|
+
.fun-detail{padding:16px;border-radius:0 0 var(--f-round) var(--f-round)}
|
|
139
|
+
.fun-card-active{border-bottom-left-radius:0;border-bottom-right-radius:0;background:color-mix(in srgb,var(--f-accent) 7%,var(--f-card))}
|
|
140
|
+
.fun-tabs,.fun-filters{display:flex;gap:7px;flex-wrap:wrap;margin:12px 0 16px}
|
|
141
|
+
.fun-tabs button,.fun-filters button{border-radius:999px;padding:5px 13px;background:transparent}
|
|
142
|
+
.fun-tabs button[aria-pressed="true"],.fun-filters button[aria-pressed="true"]{border-color:var(--f-accent);color:var(--f-ink);background:color-mix(in srgb,var(--f-accent) 12%,var(--f-card));font-weight:600}
|
|
143
|
+
.fun-stats{gap:18px;background:var(--f-soft);border:none}.fun-stat b{font-size:21px}.fun-stat span{font-size:12px}
|
|
144
|
+
.fun-trip-head{flex-wrap:wrap}.fun-trip-name{font-size:14px}.fun-trip-when{white-space:normal}
|
|
145
|
+
.fun-date{margin:20px 0 10px;font-size:12px;color:var(--f-dim);font-weight:600;display:flex;align-items:center;gap:10px}
|
|
146
|
+
.fun-date:after{content:'';height:1px;background:var(--f-line);flex:1}
|
|
147
|
+
.fun-ticket{position:relative;border-left:3px solid color-mix(in srgb,var(--f-accent) 55%,var(--f-line));margin-bottom:12px}
|
|
148
|
+
.fun-trip-detail{border-top:1px dashed var(--f-line);margin-top:12px;padding-top:4px}
|
|
149
|
+
.fun-trip-detail .fun-sec{margin-top:10px}.fun-trip-detail p{margin:4px 0;font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
150
|
+
.fun-wish-history{margin-top:14px}.fun-wish-history>summary{cursor:pointer;padding:8px 0;color:var(--f-dim)}
|
|
151
|
+
.fun-shelf-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(180px,100%),1fr));gap:10px;margin-top:12px}
|
|
152
|
+
.fun-keepsake{border:1px solid var(--f-line);border-radius:10px;padding:12px;background:var(--f-soft);min-width:0}
|
|
153
|
+
.fun-keepsake>summary{cursor:pointer;line-height:1.7;overflow-wrap:anywhere}.fun-keepsake>summary strong{display:block;color:var(--f-ink);font-weight:600}
|
|
154
|
+
.fun-keepsake .fun-trip-sum{border-top:1px dashed var(--f-line);margin-top:9px;padding-top:9px}
|
|
155
|
+
.fun-progress{display:block;width:100%;height:7px;margin:10px 0;accent-color:var(--f-accent);border:0;border-radius:8px;overflow:hidden;background:var(--f-line)}
|
|
156
|
+
.fun-progress::-webkit-progress-bar{background:var(--f-line);border-radius:8px}.fun-progress::-webkit-progress-value{background:var(--f-accent);border-radius:8px}.fun-progress::-moz-progress-bar{background:var(--f-accent);border-radius:8px}
|
|
157
|
+
.fun-feedback:empty{display:none}.fun-feedback{margin:10px 0}.fun-feedback .fun-err{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
|
|
158
|
+
.fun-loading{padding:18px;color:var(--f-dim);font-size:13px}.fun-empty{border:1px dashed var(--f-line);border-radius:var(--f-round);margin:10px 0;background:var(--f-soft)}
|
|
159
|
+
@media(max-width:420px){.fun{padding-inline:0}.fun-live,.fun-trip,.fun-form{padding:12px}.fun-stats{gap:12px}.fun-detail-cols,.fun-form-grid{grid-template-columns:1fr}.fun-detail-top{flex-wrap:wrap}.fun-trip-actions{flex-wrap:wrap}}
|
|
160
|
+
@media(prefers-reduced-motion:reduce){.fun *{transition:none!important;scroll-behavior:auto!important}}
|
|
161
|
+
|
|
122
162
|
`;
|
|
123
163
|
|
|
124
164
|
/** 小工具:建元素 + 设属性,省掉一屏 createElement。 */
|
|
@@ -157,8 +197,20 @@ function shell(root) {
|
|
|
157
197
|
return box;
|
|
158
198
|
}
|
|
159
199
|
|
|
160
|
-
function errorCard(err) {
|
|
161
|
-
return el('div', { class: 'fun-err',
|
|
200
|
+
function errorCard(err, retry, retained = false) {
|
|
201
|
+
return el('div', { class: 'fun-err', role: 'alert' },
|
|
202
|
+
el('span', { text: retained ? `刷新失败,保留上次内容:${err?.message ?? String(err)}` : `面板加载失败:${err?.message ?? String(err)}` }),
|
|
203
|
+
retry ? el('button', { type: 'button', onclick: () => { void retry(); } }, '重试') : null);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function heading(title, subtitle) {
|
|
207
|
+
return el('header', { class: 'fun-heading' }, el('h2', { text: title }), el('p', { text: subtitle }));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function feedback(box) {
|
|
211
|
+
const node = el('div', { class: 'fun-feedback' });
|
|
212
|
+
box.appendChild(node);
|
|
213
|
+
return node;
|
|
162
214
|
}
|
|
163
215
|
|
|
164
216
|
// ---------------------------------------------------------------------------
|
|
@@ -173,12 +225,15 @@ function mountPlaces(ctx) {
|
|
|
173
225
|
box.appendChild(body);
|
|
174
226
|
|
|
175
227
|
let keyword = '';
|
|
228
|
+
let quickFilter = '全部';
|
|
176
229
|
let expanded = null;
|
|
177
230
|
/** null = 没在编辑;{ mode: 'new' | 'edit', venue } = 打开表单。 */
|
|
178
231
|
let editing = null;
|
|
179
232
|
let formError = '';
|
|
180
233
|
/** 表单打开期间收到的最新数据,等关掉表单再补画,免得把用户填的内容冲掉。 */
|
|
181
234
|
let currentData = null;
|
|
235
|
+
const status = feedback(box);
|
|
236
|
+
body.appendChild(el('div', { class: 'fun-loading', role: 'status', text: '正在看看有哪些地方开着…' }));
|
|
182
237
|
|
|
183
238
|
const render = (data) => {
|
|
184
239
|
// 表单相关声明要放在最前:点「添加地点」时 render 会重跑,
|
|
@@ -188,7 +243,8 @@ function mountPlaces(ctx) {
|
|
|
188
243
|
const fields = {};
|
|
189
244
|
const lines = (v) => (Array.isArray(v) ? v.join('\n') : '');
|
|
190
245
|
const parseLines = (s) => String(s ?? '').split(/[\n,,、]/).map((x) => x.trim()).filter(Boolean);
|
|
191
|
-
|
|
246
|
+
currentData = data;
|
|
247
|
+
body.replaceChildren(heading('去哪儿', '挑一处喜欢的地方,慢慢逛。'));
|
|
192
248
|
|
|
193
249
|
// ---- 正在逛的那一趟 ----
|
|
194
250
|
if (data.session) {
|
|
@@ -234,7 +290,6 @@ function mountPlaces(ctx) {
|
|
|
234
290
|
renderList();
|
|
235
291
|
});
|
|
236
292
|
const addBtn = el('button', {
|
|
237
|
-
class: 'fun-btn-primary',
|
|
238
293
|
type: 'button',
|
|
239
294
|
onclick: () => {
|
|
240
295
|
editing = { mode: 'new', venue: null };
|
|
@@ -258,7 +313,6 @@ function mountPlaces(ctx) {
|
|
|
258
313
|
// 一键恢复全部预设:只在真有覆盖层时给,免得平时多一个没用的按钮。
|
|
259
314
|
if (data.overriddenCount) {
|
|
260
315
|
body.appendChild(el('button', {
|
|
261
|
-
class: 'fun-btn-primary',
|
|
262
316
|
type: 'button',
|
|
263
317
|
style: { marginBottom: '10px' },
|
|
264
318
|
onclick: async () => {
|
|
@@ -277,6 +331,18 @@ function mountPlaces(ctx) {
|
|
|
277
331
|
// ---- 编辑表单(打开时在最上面) ----
|
|
278
332
|
if (editing) body.appendChild(venueForm());
|
|
279
333
|
|
|
334
|
+
const filterBar = el('div', { class: 'fun-filters', role: 'group', 'aria-label': '地点快捷筛选' });
|
|
335
|
+
const filterButtons = [];
|
|
336
|
+
for (const label of ['全部', '现在开着', '室内', '户外', '夜游', '我的地点']) {
|
|
337
|
+
const button = el('button', { type: 'button', 'aria-pressed': String(quickFilter === label), onclick: () => {
|
|
338
|
+
quickFilter = label;
|
|
339
|
+
for (const item of filterButtons) item.button.setAttribute('aria-pressed', String(item.label === label));
|
|
340
|
+
renderList();
|
|
341
|
+
} }, label);
|
|
342
|
+
filterButtons.push({ label, button });
|
|
343
|
+
filterBar.appendChild(button);
|
|
344
|
+
}
|
|
345
|
+
body.appendChild(filterBar);
|
|
280
346
|
const listBox = el('div');
|
|
281
347
|
body.appendChild(listBox);
|
|
282
348
|
|
|
@@ -289,11 +355,20 @@ function mountPlaces(ctx) {
|
|
|
289
355
|
function renderList() {
|
|
290
356
|
listBox.replaceChildren();
|
|
291
357
|
const kw = keyword.trim().toLowerCase();
|
|
358
|
+
const filtered = data.places.filter((p) => {
|
|
359
|
+
const tags = p.tags ?? [];
|
|
360
|
+
if (quickFilter === '现在开着') return p.state !== 'closed';
|
|
361
|
+
if (quickFilter === '我的地点') return p.userVenue;
|
|
362
|
+
if (quickFilter === '室内') return tags.some((tag) => tag.includes('室内'));
|
|
363
|
+
if (quickFilter === '户外') return tags.some((tag) => /户外|室外/.test(tag));
|
|
364
|
+
if (quickFilter === '夜游') return tags.some((tag) => /夜/.test(tag));
|
|
365
|
+
return true;
|
|
366
|
+
});
|
|
292
367
|
const matched = kw
|
|
293
|
-
?
|
|
368
|
+
? filtered.filter((p) => p.name.toLowerCase().includes(kw)
|
|
294
369
|
|| p.aliases.some((a) => a.toLowerCase().includes(kw))
|
|
295
370
|
|| p.tags.some((t) => t.toLowerCase().includes(kw)))
|
|
296
|
-
:
|
|
371
|
+
: filtered;
|
|
297
372
|
|
|
298
373
|
const open = matched.filter((p) => p.state !== 'closed');
|
|
299
374
|
const closed = matched.filter((p) => p.state === 'closed');
|
|
@@ -312,10 +387,10 @@ function mountPlaces(ctx) {
|
|
|
312
387
|
listBox.appendChild(el('div', { class: 'fun-sec', text: title }));
|
|
313
388
|
listBox.appendChild(el('div', { class: 'fun-grid' }, items.map(cell)));
|
|
314
389
|
};
|
|
315
|
-
section(kw ?
|
|
390
|
+
section(kw || quickFilter !== '全部' ? `筛选结果 · 开着的(${open.length})` : `开着的(${open.length})`, open);
|
|
316
391
|
section('已经关了', closed);
|
|
317
392
|
if (!matched.length) {
|
|
318
|
-
listBox.appendChild(el('div', { class: 'fun-empty', text: `没有匹配「${keyword}
|
|
393
|
+
listBox.appendChild(el('div', { class: 'fun-empty', text: kw ? `没有匹配「${keyword}」的地方,试试其他筛选。` : '这个筛选下还没有地方,换一项看看。' }));
|
|
319
394
|
}
|
|
320
395
|
}
|
|
321
396
|
|
|
@@ -375,7 +450,7 @@ function mountPlaces(ctx) {
|
|
|
375
450
|
const target = active?.parentNode ?? active;
|
|
376
451
|
// 真 DOM 有 scrollIntoView;测试桩没有,判一下再用。
|
|
377
452
|
if (target && typeof target.scrollIntoView === 'function') {
|
|
378
|
-
target.scrollIntoView({ block: 'nearest', behavior: '
|
|
453
|
+
target.scrollIntoView({ block: 'nearest', behavior: 'auto' });
|
|
379
454
|
}
|
|
380
455
|
}
|
|
381
456
|
}
|
|
@@ -603,12 +678,11 @@ function mountPlaces(ctx) {
|
|
|
603
678
|
if (!data?.ok) throw new Error(data?.error ?? '返回不正常');
|
|
604
679
|
// 正在填表单时别重画——一分钟的自动刷新会把用户刚填的一整页冲掉。
|
|
605
680
|
if (editing) { currentData = data; return; }
|
|
681
|
+
status.replaceChildren();
|
|
606
682
|
render(data);
|
|
607
683
|
} catch (err) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const box2 = shell(root);
|
|
611
|
-
box2.appendChild(errorCard(err));
|
|
684
|
+
if (!currentData) body.replaceChildren();
|
|
685
|
+
status.replaceChildren(errorCard(err, load, Boolean(currentData)));
|
|
612
686
|
}
|
|
613
687
|
};
|
|
614
688
|
|
|
@@ -628,7 +702,11 @@ function mountBook(ctx) {
|
|
|
628
702
|
const box = shell(root);
|
|
629
703
|
const body = el('div');
|
|
630
704
|
box.appendChild(body);
|
|
631
|
-
let
|
|
705
|
+
let bookTab = 'all';
|
|
706
|
+
let wishFormOpen = false;
|
|
707
|
+
const expandedTrips = new Set();
|
|
708
|
+
const status = feedback(box);
|
|
709
|
+
body.appendChild(el('div', { class: 'fun-loading', role: 'status', text: '正在翻开纪念册…' }));
|
|
632
710
|
const pending = new Set();
|
|
633
711
|
const errors = new Map();
|
|
634
712
|
let currentData = null;
|
|
@@ -642,7 +720,9 @@ function mountBook(ctx) {
|
|
|
642
720
|
const wishes = data.wishes ?? [];
|
|
643
721
|
const adding = wishPending.has('add');
|
|
644
722
|
const section = el('section', { class: 'fun-wishes', 'aria-label': '出游心愿' });
|
|
645
|
-
section.appendChild(el('div', { class: 'fun-
|
|
723
|
+
section.appendChild(el('div', { class: 'fun-bar' },
|
|
724
|
+
el('span', { class: 'fun-sec', text: '出游心愿' }),
|
|
725
|
+
el('button', { type: 'button', 'aria-expanded': String(wishFormOpen), disabled: adding ? 'disabled' : null, onclick: () => { wishFormOpen = !wishFormOpen; render(currentData); } }, wishFormOpen ? '收起表单' : '记个心愿')));
|
|
646
726
|
const field = (label, input) => el('label', { class: 'fun-field' },
|
|
647
727
|
el('span', { class: 'fun-field-label', text: label }), input);
|
|
648
728
|
const select = (className, placeholder, options, value) => {
|
|
@@ -697,13 +777,16 @@ function mountBook(ctx) {
|
|
|
697
777
|
wishDraft = { placeId: payload.placeId, type: payload.type, target: payload.target, reason: reasonInput.value };
|
|
698
778
|
await changeWish('add', payload, data);
|
|
699
779
|
};
|
|
700
|
-
section.appendChild(el('div', { class: 'fun-form fun-wish-form' },
|
|
780
|
+
if (wishFormOpen) section.appendChild(el('div', { class: 'fun-form fun-wish-form' },
|
|
701
781
|
el('div', { class: 'fun-form-note', text: '由你选择想去的地方,按保存才记下心愿;心愿不保证立即出发。' }),
|
|
702
782
|
el('div', { class: 'fun-form-grid' }, field('地点', placeInput), field('心愿类型', typeInput), field('目标', targetInput)),
|
|
703
783
|
field('缘由(可选)', reasonInput), errorNode,
|
|
704
784
|
el('button', { class: 'fun-btn-primary', type: 'button', disabled: adding ? 'disabled' : null, onclick: save }, adding ? '保存中…' : '保存心愿')));
|
|
705
785
|
if (!wishes.length) section.appendChild(el('div', { class: 'fun-note', text: '还没有出游心愿,想好了再记下。' }));
|
|
706
786
|
const statusNames = { active: '待实现', paused: '已暂缓', completed: '已实现', cancelled: '已取消' };
|
|
787
|
+
const history = el('details', { class: 'fun-wish-history',
|
|
788
|
+
open: wishes.some((w) => w.status !== 'active' && (wishErrors.has(`wish:${w.id}`) || wishPending.has(`wish:${w.id}`))) ? 'open' : null,
|
|
789
|
+
}, el('summary', { text: `已实现、暂缓与取消(${wishes.filter((w) => w.status !== 'active').length})` }));
|
|
707
790
|
for (const wish of wishes) {
|
|
708
791
|
const key = `wish:${wish.id}`;
|
|
709
792
|
const busy = wishPending.has(key);
|
|
@@ -717,13 +800,14 @@ function mountBook(ctx) {
|
|
|
717
800
|
}
|
|
718
801
|
if (busy) actions.appendChild(el('span', { class: 'fun-dim', text: '保存中…' }));
|
|
719
802
|
if (wishErrors.has(key)) actions.appendChild(el('span', { class: 'fun-trip-error', role: 'alert', text: wishErrors.get(key) }));
|
|
720
|
-
section.appendChild(el('div', { class: 'fun-wish fun-trip' },
|
|
803
|
+
(state === 'active' ? section : history).appendChild(el('div', { class: 'fun-wish fun-trip' },
|
|
721
804
|
el('div', { class: 'fun-trip-head' },
|
|
722
805
|
el('span', { class: 'fun-trip-name', text: wish.placeName ?? places.find((p) => p.id === wish.placeId)?.name ?? wish.placeId }),
|
|
723
806
|
el('span', { class: 'fun-wish-status fun-dim', text: statusNames[state] ?? state ?? '状态未知' })),
|
|
724
807
|
el('div', { class: 'fun-trip-sum', text: `${wishTypes[wish.type] ?? wish.type}${wish.target ? ` · ${wish.target}` : ''}` }),
|
|
725
808
|
wish.reason ? el('div', { class: 'fun-wish-note fun-note', text: `缘由:${wish.reason}` }) : null, actions));
|
|
726
809
|
}
|
|
810
|
+
if (wishes.some((w) => w.status !== 'active')) section.appendChild(history);
|
|
727
811
|
body.appendChild(section);
|
|
728
812
|
};
|
|
729
813
|
|
|
@@ -737,10 +821,11 @@ function mountBook(ctx) {
|
|
|
737
821
|
const result = await ctx.invoke('wish', [payload]);
|
|
738
822
|
if (!result?.ok) throw new Error(result?.error ?? '心愿保存失败');
|
|
739
823
|
saved = true;
|
|
740
|
-
if (key === 'add') wishDraft = { placeId: '', type: '', target: '', reason: '' };
|
|
824
|
+
if (key === 'add') { wishDraft = { placeId: '', type: '', target: '', reason: '' }; wishFormOpen = false; }
|
|
741
825
|
await load(true);
|
|
742
826
|
} catch (error) {
|
|
743
827
|
wishErrors.set(key, `${saved ? '已保存,但列表刷新失败:' : ''}${error?.message ?? String(error)}`);
|
|
828
|
+
if (key === 'add') wishFormOpen = true;
|
|
744
829
|
} finally {
|
|
745
830
|
wishPending.delete(key);
|
|
746
831
|
render(currentData ?? data);
|
|
@@ -749,70 +834,78 @@ function mountBook(ctx) {
|
|
|
749
834
|
|
|
750
835
|
const render = (data) => {
|
|
751
836
|
currentData = data;
|
|
752
|
-
body.replaceChildren();
|
|
753
|
-
|
|
754
|
-
|
|
837
|
+
body.replaceChildren(heading('纪念册', '把走过的地方,收成可以回看的小回忆。'));
|
|
838
|
+
if (data.session) body.appendChild(el('div', { class: 'fun-live' },
|
|
839
|
+
el('h3', { text: '正在逛 · ' + data.session.placeName }), el('div', { class: 'fun-trip-sum', text: data.session.summary })));
|
|
840
|
+
else if (data.trips?.length) body.appendChild(el('div', { class: 'fun-live' },
|
|
841
|
+
el('div', { class: 'fun-meta', text: '最近一趟 · ' + data.trips[0].day }),
|
|
842
|
+
el('h3', { text: data.trips[0].placeName }), el('div', { class: 'fun-trip-sum', text: data.trips[0].summary })));
|
|
843
|
+
|
|
844
|
+
const tabs = el('nav', { class: 'fun-tabs', 'aria-label': '纪念册分类' });
|
|
845
|
+
for (const [id, label] of [['all', '全部行程'], ['kept', '珍藏'], ['wishes', '心愿']]) tabs.appendChild(el('button', {
|
|
846
|
+
type: 'button', 'aria-pressed': String(bookTab === id), onclick: () => { bookTab = id; render(currentData); },
|
|
847
|
+
}, label));
|
|
848
|
+
body.appendChild(tabs);
|
|
849
|
+
if (bookTab === 'wishes') { renderWishes(data); return; }
|
|
850
|
+
if (!data.total && !(data.keepsakeCount > 0)) {
|
|
755
851
|
body.appendChild(el('div', { class: 'fun-empty', text: '纪念册还是空的——她收一次摊,这里就有一趟。' }));
|
|
756
852
|
return;
|
|
757
853
|
}
|
|
758
|
-
|
|
759
854
|
body.appendChild(el('div', { class: 'fun-stats' },
|
|
760
|
-
stat(data.totalRecent ?? data.total, '近期行程'),
|
|
761
|
-
stat(data.
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
if (data.mostVisited.length) {
|
|
767
|
-
body.appendChild(el('div', { class: 'fun-sec', text: '常去的' }));
|
|
768
|
-
body.appendChild(el('div', { class: 'fun-chips' },
|
|
769
|
-
data.mostVisited.slice(0, 8).map((m) => el('span', { class: 'fun-chip', text: `${m.name} ×${m.times}` }))));
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
if (data.session) {
|
|
773
|
-
body.appendChild(el('div', { class: 'fun-sec', text: '正在逛' }));
|
|
774
|
-
body.appendChild(el('div', { class: 'fun-trip' },
|
|
775
|
-
el('div', { class: 'fun-trip-sum', text: data.session.summary })));
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
body.appendChild(el('div', { class: 'fun-bar' },
|
|
779
|
-
el('button', { class: 'fun-toggle', type: 'button', 'aria-pressed': keepsakesOnly ? 'true' : 'false', onclick: () => { keepsakesOnly = !keepsakesOnly; render(data); } }, keepsakesOnly ? '全部行程' : '仅看珍藏')));
|
|
780
|
-
const trips = keepsakesOnly ? data.trips.filter((t) => t.kept) : data.trips;
|
|
781
|
-
body.appendChild(el('div', { class: 'fun-sec', text: keepsakesOnly ? `珍藏行程(${trips.length})` : `近期与珍藏行程(${data.totalRecent ?? data.total})` }));
|
|
855
|
+
stat(data.totalRecent ?? data.total, '近期行程'), stat(data.keepsakeCount ?? 0, '珍藏'),
|
|
856
|
+
stat(data.visitedAreaCount, '处逛过'), stat(data.souvenirCount, '件纪念品'), stat(data.photoCount, '张照片')));
|
|
857
|
+
if (data.mostVisited?.length) body.appendChild(el('details', { class: 'fun-wish-history' },
|
|
858
|
+
el('summary', { text: '常去的' }), el('div', { class: 'fun-chips' }, data.mostVisited.slice(0, 8).map((m) => el('span', { class: 'fun-chip', text: `${m.name} ×${m.times}` })))));
|
|
859
|
+
const trips = bookTab === 'kept' ? data.trips.filter((t) => t.kept) : data.trips;
|
|
860
|
+
let previousDay = null;
|
|
782
861
|
for (const t of trips) {
|
|
862
|
+
if (t.day !== previousDay) { body.appendChild(el('div', { class: 'fun-date', text: t.day || '日期不详' })); previousDay = t.day; }
|
|
783
863
|
const err = errors.get(t.id);
|
|
864
|
+
const open = expandedTrips.has(t.id);
|
|
784
865
|
const toggleKeep = async () => {
|
|
785
866
|
if (pending.has(t.id)) return;
|
|
786
|
-
pending.add(t.id);
|
|
787
|
-
errors.delete(t.id);
|
|
788
|
-
render(data);
|
|
867
|
+
pending.add(t.id); errors.delete(t.id); render(data);
|
|
789
868
|
try {
|
|
790
869
|
const result = await ctx.invoke('favorite', [{ id: t.id, keep: !t.kept }]);
|
|
791
870
|
if (!result?.ok) throw new Error(result?.error ?? '珍藏状态保存失败');
|
|
792
|
-
await load();
|
|
793
|
-
} catch (error) {
|
|
794
|
-
|
|
795
|
-
render(data);
|
|
796
|
-
} finally {
|
|
797
|
-
pending.delete(t.id);
|
|
798
|
-
render(currentData ?? data);
|
|
799
|
-
}
|
|
871
|
+
await load(true);
|
|
872
|
+
} catch (error) { errors.set(t.id, error?.message ?? String(error)); }
|
|
873
|
+
finally { pending.delete(t.id); render(currentData ?? data); }
|
|
800
874
|
};
|
|
801
|
-
|
|
802
|
-
el('div', { class: 'fun-trip-head' },
|
|
803
|
-
el('span', { class: 'fun-trip-
|
|
804
|
-
el('span', { class: 'fun-trip-when', text: `${t.day} ${t.enteredHm}–${t.leftHm}${t.stayedMin ? ` · ${t.stayedMin} 分钟` : ''}` })),
|
|
875
|
+
const card = el('article', { class: 'fun-trip fun-ticket' },
|
|
876
|
+
el('div', { class: 'fun-trip-head' }, el('span', { class: 'fun-trip-name', text: t.placeName }),
|
|
877
|
+
el('span', { class: 'fun-trip-when', text: t.enteredHm + '–' + t.leftHm + (t.stayedMin ? ' · ' + t.stayedMin + ' 分钟' : '') })),
|
|
805
878
|
el('div', { class: 'fun-trip-sum', text: t.summary }),
|
|
806
|
-
(t.events.length || t.scene)
|
|
807
|
-
? el('div', { class: 'fun-trip-extras' },
|
|
808
|
-
t.events.length ? el('div', { text: t.events.slice(0, 2).join(' / ') }) : null,
|
|
809
|
-
t.scene ? el('div', { text: `生图 scene:${t.scene}${t.outfit ? ` · outfits:${t.outfit}` : ''}` }) : null)
|
|
810
|
-
: null,
|
|
811
879
|
el('div', { class: 'fun-trip-actions' },
|
|
880
|
+
el('button', { type: 'button', 'aria-expanded': String(open), onclick: () => {
|
|
881
|
+
if (open) expandedTrips.delete(t.id); else expandedTrips.add(t.id);
|
|
882
|
+
render(currentData);
|
|
883
|
+
const focus = body.querySelectorAll('.fun-detail-toggle');
|
|
884
|
+
[...focus].find((node) => node.getAttribute('data-trip-id') === t.id)?.focus();
|
|
885
|
+
}, class: 'fun-detail-toggle', 'data-trip-id': t.id }, open ? '收起详情' : '查看详情'),
|
|
812
886
|
el('button', { type: 'button', disabled: pending.has(t.id) ? 'disabled' : null, onclick: toggleKeep }, pending.has(t.id) ? '保存中…' : (t.kept ? '取消珍藏' : '珍藏')),
|
|
813
|
-
err ? el('span', { class: 'fun-trip-error', role: 'alert', text: err }) : null))
|
|
887
|
+
err ? el('span', { class: 'fun-trip-error', role: 'alert', text: err }) : null));
|
|
888
|
+
if (open) {
|
|
889
|
+
const detail = el('section', { class: 'fun-trip-detail', 'aria-label': t.placeName + '行程详情' });
|
|
890
|
+
const part = (title, values) => {
|
|
891
|
+
if (!values.length) return;
|
|
892
|
+
detail.appendChild(el('div', { class: 'fun-sec', text: title }));
|
|
893
|
+
detail.appendChild(el('ul', { class: 'fun-list' }, values.map((text) => el('li', { text }))));
|
|
894
|
+
};
|
|
895
|
+
if (t.company) detail.appendChild(el('p', { text: '同行 · ' + t.company }));
|
|
896
|
+
part('沿途逛过', t.visited ?? []);
|
|
897
|
+
part('遇见的小事', t.events ?? []);
|
|
898
|
+
part('当时的选择', (t.choices ?? []).map((c) => c.event + ' · ' + c.result));
|
|
899
|
+
part('带回的纪念品', t.souvenirs ?? []);
|
|
900
|
+
part('拍照记录', t.photos ?? []);
|
|
901
|
+
part('吃喝记录', (t.ate ?? []).map((x) => x.verb + '了 ' + x.item));
|
|
902
|
+
if (t.note) detail.appendChild(el('p', { text: '收摊备注 · ' + t.note }));
|
|
903
|
+
if (t.scene) detail.appendChild(el('p', { class: 'fun-dim', text: '生图 scene:' + t.scene + (t.outfit ? ' · outfits:' + t.outfit : '') }));
|
|
904
|
+
card.appendChild(detail);
|
|
905
|
+
}
|
|
906
|
+
body.appendChild(card);
|
|
814
907
|
}
|
|
815
|
-
if (
|
|
908
|
+
if (bookTab === 'kept' && !trips.length) body.appendChild(el('div', { class: 'fun-empty', text: '还没有珍藏的行程。' }));
|
|
816
909
|
};
|
|
817
910
|
|
|
818
911
|
const stat = (n, label) => el('div', { class: 'fun-stat' },
|
|
@@ -822,10 +915,12 @@ function mountBook(ctx) {
|
|
|
822
915
|
try {
|
|
823
916
|
const data = await ctx.invoke('list');
|
|
824
917
|
if (!data?.ok) throw new Error(data?.error ?? '返回不正常');
|
|
918
|
+
status.replaceChildren();
|
|
825
919
|
render(data);
|
|
826
920
|
} catch (err) {
|
|
827
921
|
if (propagate) throw err;
|
|
828
|
-
body.replaceChildren(
|
|
922
|
+
if (!currentData) body.replaceChildren();
|
|
923
|
+
status.replaceChildren(errorCard(err, load, Boolean(currentData)));
|
|
829
924
|
}
|
|
830
925
|
};
|
|
831
926
|
|
|
@@ -845,6 +940,9 @@ function mountShelf(ctx) {
|
|
|
845
940
|
const box = shell(root);
|
|
846
941
|
const body = el('div');
|
|
847
942
|
box.appendChild(body);
|
|
943
|
+
const status = feedback(box);
|
|
944
|
+
let currentData = null;
|
|
945
|
+
body.appendChild(el('div', { class: 'fun-loading', role: 'status', text: '正在整理纪念品架…' }));
|
|
848
946
|
|
|
849
947
|
const stat = (n, label) => el('div', { class: 'fun-stat' },
|
|
850
948
|
el('b', { text: String(n) }), el('span', { text: label }));
|
|
@@ -852,10 +950,10 @@ function mountShelf(ctx) {
|
|
|
852
950
|
const pct = (part) => `${part.done}/${part.total}`;
|
|
853
951
|
|
|
854
952
|
const render = (data) => {
|
|
855
|
-
|
|
953
|
+
currentData = data;
|
|
954
|
+
body.replaceChildren(heading('纪念品架', '每一件小东西,都有带它回来的那一天。'));
|
|
856
955
|
if (!data.total) {
|
|
857
956
|
body.appendChild(el('div', { class: 'fun-empty', text: '架子上还什么都没有——她买过纪念品,这里就有了。' }));
|
|
858
|
-
return;
|
|
859
957
|
}
|
|
860
958
|
|
|
861
959
|
body.appendChild(el('div', { class: 'fun-stats' },
|
|
@@ -866,20 +964,20 @@ function mountShelf(ctx) {
|
|
|
866
964
|
|
|
867
965
|
body.appendChild(el('div', { class: 'fun-meta', text: '收藏账本长期保留;详细行程可查看最近 40 趟与珍藏行程。进度按当前场所清单统计,移除或改名不删除旧回忆。' }));
|
|
868
966
|
|
|
869
|
-
body.appendChild(el('div', { class: 'fun-meta', text: '收藏账本长期保留;详细行程可查看最近 40 趟与珍藏行程。进度按当前场所清单统计,移除或改名不删除旧回忆。' }));
|
|
870
|
-
|
|
871
967
|
// 每一处的架子:只列真有东西的,空的不用占版面。
|
|
872
|
-
body.appendChild(el('div', { class: 'fun-sec', text: '按地方归着' }));
|
|
968
|
+
if (data.byPlace.length) body.appendChild(el('div', { class: 'fun-sec', text: '按地方归着' }));
|
|
873
969
|
for (const g of data.byPlace) {
|
|
874
970
|
body.appendChild(el('div', { class: 'fun-trip' },
|
|
875
971
|
el('div', { class: 'fun-trip-head' },
|
|
876
972
|
el('span', { class: 'fun-trip-name', text: g.placeName }),
|
|
877
973
|
el('span', { class: 'fun-trip-when', text: `${g.items.length} 样 · 最早 ${g.firstDay || '—'}` })),
|
|
878
|
-
|
|
879
|
-
el('summary', { text: `${it.name}${it.times > 1 ? ` ×${it.times}` : ''}
|
|
974
|
+
el('div', { class: 'fun-shelf-grid' }, g.items.map((it) => el('details', { class: 'fun-keepsake' },
|
|
975
|
+
el('summary', null, el('strong', { text: `${it.name}${it.times > 1 ? ` ×${it.times}` : ''}` }),
|
|
976
|
+
el('span', { class: 'fun-dim', text: `记录中最早 ${it.firstDay || '日期不详'}` })),
|
|
977
|
+
it.archivedCount ? el('div', { class: 'fun-note', text: `${it.archivedCount} 次收藏仅保留账本,详细行程已不在近期记录中。` }) : null,
|
|
880
978
|
...(it.memories ?? []).map((m) => el('div', { class: 'fun-trip-sum' },
|
|
881
979
|
el('div', { text: `${m.day || '日期不详'} · ${m.summary}` }),
|
|
882
|
-
m.note ? el('div', { text: `你记的:${m.note}` }) : null))))));
|
|
980
|
+
m.note ? el('div', { text: `你记的:${m.note}` }) : null)))))));
|
|
883
981
|
}
|
|
884
982
|
|
|
885
983
|
// 进度:只列去过的。服务端已按「快逛遍的」排好,这里照顺序画。
|
|
@@ -892,6 +990,7 @@ function mountShelf(ctx) {
|
|
|
892
990
|
el('div', { class: 'fun-trip-head' },
|
|
893
991
|
el('span', { class: 'fun-trip-name', text: p.placeName }),
|
|
894
992
|
el('span', { class: 'fun-trip-when', text: `去过 ${p.visits} 次 · ${p.percent}%` })),
|
|
993
|
+
el('progress', { class: 'fun-progress', max: '100', value: String(p.percent), 'aria-label': `${p.placeName}探索进度 ${p.percent}%` }),
|
|
895
994
|
el('div', { class: 'fun-meta', text: `逛过 ${pct(p.areas)}${p.souvenirs.total ? ` · 纪念品 ${pct(p.souvenirs)}` : ''}${p.photos.total ? ` · 拍过 ${pct(p.photos)}` : ''}` }),
|
|
896
995
|
left
|
|
897
996
|
? el('div', { class: 'fun-trip-sum', text: `还差:${p.areas.left.slice(0, 6).join('、')}${left > 6 ? ` 等 ${left} 处` : ''}` })
|
|
@@ -904,12 +1003,11 @@ function mountShelf(ctx) {
|
|
|
904
1003
|
try {
|
|
905
1004
|
const data = await ctx.invoke('list');
|
|
906
1005
|
if (!data?.ok) throw new Error(data?.error ?? '返回不正常');
|
|
1006
|
+
status.replaceChildren();
|
|
907
1007
|
render(data);
|
|
908
1008
|
} catch (err) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
const box2 = shell(root);
|
|
912
|
-
box2.appendChild(errorCard(err));
|
|
1009
|
+
if (!currentData) body.replaceChildren();
|
|
1010
|
+
status.replaceChildren(errorCard(err, load, Boolean(currentData)));
|
|
913
1011
|
}
|
|
914
1012
|
};
|
|
915
1013
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-fun",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "娱乐时间 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。进门、逛摊位、买纪念品、拍张照、吃喝点什么,收摊记一笔。能和「鱼的每一天」「生图工作室」联动,但都不依赖。",
|
|
6
6
|
"license": "MIT",
|