coopani-world-journey 0.3.2 → 0.3.3

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.3.3 — 2026-10-31
4
+
5
+ ### 一个开关,一个按钮
6
+
7
+ Mr.Q 的意思:既然她会在你还没反应过来的时候就走了,那就别用「宽限」去猜你的意图 ——
8
+ 把决定权直接给你。
9
+
10
+ - **开关「出门等我点头」**(设置页 `journey.pace`):打开后她一次都不会自己走,就在家等着。
11
+ 默认关 —— 自动的那一套才是这个扩展的主张,想掌控的人打开就是。
12
+ - **按钮「让她出发」**(面板「她此刻」,仅她在家时出现):按一下就动身,
13
+ 然后**按钮锁住直到她回家**。锁着的时候说清为什么(还在歇着 / 没找到能去的地方)。
14
+
15
+ 两个细节:
16
+
17
+ - **手按的那一下跳过自动门禁**:加载宽限、7–21 点的出门窗口。你明确说「现在走吧」,
18
+ 再回一句「现在不是出门的点」就是抬杠。
19
+ - **开关关着时按钮不出现**,只写一句「什么时候走,她自己定」—— 那个按钮存在但按不动,
20
+ 比不存在更让人困惑。
21
+
22
+ 服务端也拦了一道:`panelInvoke('now','depart')` 会检查「在不在家」「在不在休息期」,
23
+ 绕开前端直接发请求也不会被静默吞掉。
24
+
3
25
  ## 0.3.2 — 2026-10-31
4
26
 
5
27
  ### 改出发地 = 搬家
package/README.md CHANGED
@@ -64,6 +64,21 @@ key 失效也只是降级,不是故障:下一次查询就落到 Open-Meteo
64
64
 
65
65
  **照片** —— 她路上拍的。一天一张,全是空镜:窗外、街角、傍晚的城墙。**画面里没有她。**
66
66
 
67
+ ### 她在家的时候:一个开关,一个按钮
68
+
69
+ 她在家时,面板上多一块:
70
+
71
+ - **开关「出门等我点头」** —— 打开后她不会自己走,就在家等着你按。
72
+ - **按钮「让她出发」** —— 按一下她就动身,然后按钮锁住,直到她回家。
73
+
74
+ 开关默认**关**。关着的时候她是自己过日子的:歇够了就走,不问。这是这个扩展的主张 ——
75
+ 打开就能看见它自己在动。想自己掌控节奏的人把开关打开即可,两种人都照顾到了。
76
+
77
+ 按钮锁着的时候会说清为什么:还在歇着(显示歇到哪天)、或者这会儿没找到能去的地方。
78
+
79
+ **手按的那一下会跳过两个自动门禁**:加载宽限、以及 7–21 点的出门窗口。
80
+ 你明确说「现在走吧」,再回你一句「现在不是出门的点」就是抬杠。
81
+
67
82
  ### 第一次打开会有三句话
68
83
 
69
84
  不是配置检查清单 —— 这个扩展不配置也能跑。引导讲的是三件最容易被误解的事:
@@ -85,6 +100,7 @@ key 失效也只是降级,不是故障:下一次查询就落到 Open-Meteo
85
100
  | 从哪儿出发 | 空 | 填城市名(兰州 / 西安)。**改它等于搬家**:她在家就跟着搬过去,在外面就把回家的目标换成新家 |
86
101
  | 时间倍速 | 1 | 1 = 真实速度。4 = 一天压缩成六小时。24 = 一天一小时 |
87
102
  | 路上消息间隔 | 2 | 路上隔多久冒一句(服务区、过站、餐车)。0 = 一路安静,只在出发和到站开口。一趟最多三条 |
103
+ | 出门等你点头 | 关 | 打开后她不会自己走,只在面板上按「让她出发」。关着就自己按节奏走 |
88
104
  | 回家后歇几天 | 3 | 0 = 当天就能再走 |
89
105
  | 一次最多在外多久 | 6 | 到了强制回家 |
90
106
 
package/dist/webui.css CHANGED
@@ -245,3 +245,67 @@
245
245
  /* 身后的那个节点:灰掉但还在,时间轴才像「走到这儿了」而不是待办清单 */
246
246
  .jr-tl-item[data-past="true"] { opacity: .42; }
247
247
  .jr-tl-item[data-past="true"]::before { background: var(--jr-ink); }
248
+
249
+ /* ---------- 她在家:开关 + 出发按钮 ---------- */
250
+ .jr-home {
251
+ margin-top: 20px;
252
+ padding: 14px 16px 16px;
253
+ border: 1px solid var(--jr-line);
254
+ border-radius: 14px;
255
+ background: var(--jr-card);
256
+ }
257
+ .jr-home[hidden] { display: none; }
258
+ .jr-home .jr-next-title { margin-bottom: 0 !important; }
259
+
260
+ .jr-toggle {
261
+ position: relative;
262
+ display: inline-flex;
263
+ align-items: center;
264
+ gap: 10px;
265
+ margin-top: 10px;
266
+ font-size: 13px;
267
+ cursor: pointer;
268
+ user-select: none;
269
+ }
270
+ /* 真 checkbox 藏起来但保留可聚焦、可读屏 */
271
+ .jr-toggle input {
272
+ position: absolute;
273
+ width: 1px;
274
+ height: 1px;
275
+ opacity: 0;
276
+ }
277
+ .jr-toggle-knob {
278
+ position: relative;
279
+ flex: 0 0 auto;
280
+ width: 36px;
281
+ height: 20px;
282
+ border-radius: 999px;
283
+ background: var(--jr-line);
284
+ transition: background .18s ease;
285
+ }
286
+ .jr-toggle-knob::after {
287
+ content: "";
288
+ position: absolute;
289
+ top: 2px;
290
+ left: 2px;
291
+ width: 16px;
292
+ height: 16px;
293
+ border-radius: 50%;
294
+ background: #fff;
295
+ box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
296
+ transition: transform .18s ease;
297
+ }
298
+ .jr-toggle input:checked + .jr-toggle-knob { background: var(--jr-accent); }
299
+ .jr-toggle input:checked + .jr-toggle-knob::after { transform: translateX(16px); }
300
+ .jr-toggle input:focus-visible + .jr-toggle-knob { outline: 2px solid var(--jr-accent); outline-offset: 3px; }
301
+ .jr-toggle-text { color: var(--jr-ink); }
302
+
303
+ .jr-home-actions {
304
+ display: flex;
305
+ align-items: center;
306
+ gap: 12px;
307
+ margin-top: 12px;
308
+ flex-wrap: wrap;
309
+ }
310
+ .jr-home-actions .jr-btn { margin-top: 0; }
311
+ .jr-hint { font-size: 12.5px; color: var(--jr-soft); }
package/dist/webui.js CHANGED
@@ -35,6 +35,14 @@ const TEXT = {
35
35
  homeAt: '家 · {n}',
36
36
  homeFrom: '从 {n} 出发',
37
37
  tripFrom: '这一趟从',
38
+ homeTitle: '她在家',
39
+ askToggle: '出门等我点头',
40
+ departBtn: '让她出发',
41
+ departSelf: '什么时候走,她自己定。',
42
+ departWait: '她在家等着 —— 按一下就上路。',
43
+ departRest: '她在歇着,{n} 之后才动。',
44
+ departBusy: '这会儿动不了(没找到能去的地方)。',
45
+ departErr: '没走成',
38
46
  guideTitle: '第一次来,先把这三件事说清',
39
47
  guide1Title: '她在另一个时区过日子',
40
48
  guide1Body: '上面那个钟是**她那边的**时间。她按当地时间吃饭、睡觉、出门 —— 你这边几点跟她没关系。',
@@ -77,6 +85,14 @@ const TEXT = {
77
85
  homeAt: 'home {n}',
78
86
  homeFrom: 'from {n}',
79
87
  tripFrom: 'this trip from',
88
+ homeTitle: 'She is home',
89
+ askToggle: 'Wait for my go',
90
+ departBtn: 'Send her off',
91
+ departSelf: 'She decides when to leave.',
92
+ departWait: 'She is waiting — one press and she goes.',
93
+ departRest: 'Resting until {n}.',
94
+ departBusy: 'She cannot head out right now.',
95
+ departErr: 'Did not leave',
80
96
  guideTitle: 'First time here — three things worth knowing',
81
97
  guide1Title: 'She lives on another time zone',
82
98
  guide1Body: 'That clock is **her** time. She eats, sleeps and goes out on local time — your hour means nothing to her.',
@@ -149,13 +165,15 @@ export default {
149
165
  right.append(status, clock);
150
166
  head.append(left, right);
151
167
 
168
+ const homeBox = el('section', 'jr-home');
169
+ const homeNote = el('p', 'jr-warn', '');
152
170
  const guide = el('section', 'jr-guide');
153
171
  const legBox = el('section', 'jr-leg');
154
172
  const facts = el('section', 'jr-facts');
155
173
  const nextBox = el('section', 'jr-next');
156
174
  const foot = el('footer', 'jr-foot');
157
175
 
158
- app.append(head, guide, legBox, facts, nextBox, foot);
176
+ app.append(head, homeBox, guide, legBox, facts, nextBox, foot);
159
177
 
160
178
  const render = (s) => {
161
179
  app.dataset.mode = s.mode;
@@ -194,6 +212,56 @@ export default {
194
212
  guide.append(title, steps, done);
195
213
  }
196
214
 
215
+ /* ---- 她在家:开关 + 出发按钮 ---- */
216
+ homeBox.replaceChildren();
217
+ homeNote.textContent = '';
218
+ homeBox.hidden = s.mode !== 'home';
219
+ if (s.mode === 'home') {
220
+ const pending = !!(s.askBeforeDepart);
221
+ homeBox.append(el('h2', 'jr-next-title', T.homeTitle));
222
+
223
+ const toggleRow = el('label', 'jr-toggle');
224
+ const box = el('input');
225
+ box.type = 'checkbox';
226
+ box.checked = pending;
227
+ const knob = el('span', 'jr-toggle-knob');
228
+ const labelText = el('span', 'jr-toggle-text', T.askToggle);
229
+ toggleRow.append(box, knob, labelText);
230
+ box.addEventListener('change', () => {
231
+ box.disabled = true;
232
+ // 只写这一个字段:配置面接受部分提交(未提交的字段保持不变)。
233
+ ctx.setConfig('journey.pace', { 'worlds.journey.askBeforeDepart': box.checked })
234
+ .then(load)
235
+ .catch(() => { box.checked = !box.checked; })
236
+ .finally(() => { box.disabled = false; });
237
+ }, { signal: ctx.signal });
238
+ homeBox.append(toggleRow);
239
+
240
+ // 开关关着的时候按钮不出现 —— 她自己会走,按了也没有意义。
241
+ if (pending) {
242
+ const go = el('button', 'jr-btn jr-btn-primary', T.departBtn);
243
+ go.type = 'button';
244
+ go.disabled = !s.canDepart;
245
+ go.addEventListener('click', () => {
246
+ go.disabled = true;
247
+ ctx.invoke('depart')
248
+ .then(render)
249
+ .catch((e) => { homeNote.textContent = `${T.departErr}${e && e.message ? `:${e.message}` : ''}`; })
250
+ .finally(() => { go.textContent = T.departBtn; });
251
+ }, { signal: ctx.signal });
252
+ const hint = el('p', 'jr-hint', '');
253
+ hint.textContent = s.restUntil
254
+ ? fmt(T.departRest, s.restUntil)
255
+ : s.canDepart ? T.departWait : T.departBusy;
256
+ const row = el('div', 'jr-home-actions');
257
+ row.append(go, hint);
258
+ homeBox.append(row);
259
+ } else {
260
+ homeBox.append(el('p', 'jr-hint', T.departSelf));
261
+ }
262
+ homeBox.append(homeNote);
263
+ }
264
+
197
265
  /* ---- 在路上 ---- */
198
266
  legBox.replaceChildren();
199
267
  legBox.hidden = !s.leg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coopani-world-journey",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "description": "大肥鱼环游世界:她真的出门、真的按当地时间过日子。从你家出发,自己挑去哪、坐什么去,路上耗掉真实的时间;到了按当地时间吃饭、看日出、住店、写日记。装了「一起听歌」的话,你放的歌会跟着她走。需 Coopani 0.2.16 以上。",
6
6
  "author": {
package/src/config.ts CHANGED
@@ -34,6 +34,17 @@ export interface JourneyConfigSection extends WorldSection {
34
34
  memoryDir: string;
35
35
  /** 回家后休息几天再出发。0 = 当天就又能走。 */
36
36
  restDays: number;
37
+ /**
38
+ * 出门要你点头。
39
+ *
40
+ * 关(默认):她按自己的节奏走 —— 歇够了就走,不问你。
41
+ * 开:她就在家等着,直到你在面板上按「让她出发」。
42
+ *
43
+ * 为什么做成开关而不是直接改默认:**两种人都存在**。有人要的是「打开就能看见她自己
44
+ * 过日子」,有人要的是「我按了她才动」。默认关,是因为自动的那一套才是这个扩展的主张;
45
+ * 想自己掌控的人打开就是。
46
+ */
47
+ askBeforeDepart: boolean;
37
48
  /** 一次连续旅行最多几个月,到了就强制回家。压住「一直旅行半年」这个上限。 */
38
49
  maxTripMonths: number;
39
50
  /**
@@ -81,6 +92,7 @@ export const JOURNEY_DEFAULTS = (): JourneyConfigSection => ({
81
92
  beatGap: 2,
82
93
  memoryDir: '',
83
94
  restDays: 3,
95
+ askBeforeDepart: false,
84
96
  maxTripMonths: 6,
85
97
  withUser: false,
86
98
  moneyEnabled: false,
@@ -131,6 +143,12 @@ export function journeyConfigGroups(): ConfigGroup[] {
131
143
  enum: [1, 4, 24],
132
144
  'x-hot': true,
133
145
  },
146
+ 'worlds.journey.askBeforeDepart': {
147
+ type: 'boolean',
148
+ title: '出门等你点头',
149
+ description: '打开后她不会自己走,只在面板上按「让她出发」才动身。关着就一直自己走。',
150
+ 'x-hot': true,
151
+ },
134
152
  'worlds.journey.beatGap': {
135
153
  type: 'number',
136
154
  title: '路上消息间隔',
package/src/ui.ts CHANGED
@@ -78,6 +78,13 @@ export interface UiSnapshot {
78
78
  readonly diary: { readonly dir: string; readonly days: number; readonly problem: string | null };
79
79
  readonly photos: readonly UiPhoto[];
80
80
  /** 配置里的家。 */
81
+ /** 「出门等他点头」开着没有。 */
82
+ readonly askBeforeDepart: boolean;
83
+ /** 现在能手动让她出发吗(在家、而且不在休息期)。 */
84
+ readonly canDepart: boolean;
85
+ /** 还在休息的话,歇到哪天(`11-03`)。按钮锁着时要说明为什么。 */
86
+ readonly restUntil: string | null;
87
+
81
88
  readonly home: string;
82
89
  /**
83
90
  * 这一趟是从哪个家出发的。
package/src/world.ts CHANGED
@@ -490,6 +490,9 @@ export class JourneyWorld implements World {
490
490
 
491
491
  if (this.st.phase === 'home') {
492
492
  if (this.stillResting(now)) return;
493
+ // 他开了「出门等点头」:她就在家等着,一次都不自己走。
494
+ // 手动那个按钮走 `panelInvoke`,跟这条无关 —— 所以这里什么都不用做。
495
+ if (this.cfg.askBeforeDepart) return;
493
496
  await this.depart(now);
494
497
  return;
495
498
  }
@@ -529,26 +532,35 @@ export class JourneyWorld implements World {
529
532
  this.log?.info(`歌里提到${c.name},记进想去的地方。`);
530
533
  }
531
534
 
532
- private async depart(now: Date): Promise<void> {
533
- // **刚加载完先待一会儿。**
534
- //
535
- // 不挡的话,World 一被挂上就出发:用户装好扩展、改完配置重启、甚至只是重启了
536
- // Coopani,抬眼看到的都是「她已经走了」。宽限不是休息期,只是「别在我刚按下
537
- // 那个按钮的下一秒就消失」。
538
- if (this.realNow().getTime() - this.bootedAt < BOOT_GRACE_MS) return;
535
+ /**
536
+ * 出发。
537
+ *
538
+ * `manual` = 他在面板上按了「让她出发」。手动那一下**跳过两个门禁**:
539
+ * 加载宽限、以及 7–21 点的出门窗口。理由很简单 —— 他明确要求现在走,
540
+ * 这时候再跟他说「现在不是出门的点」就是抬杠。
541
+ */
542
+ private async depart(now: Date, manual = false): Promise<void> {
543
+ if (!manual) {
544
+ // **刚加载完先待一会儿。**
545
+ //
546
+ // 不挡的话,World 一被挂上就出发:用户装好扩展、改完配置重启、甚至只是重启了
547
+ // Coopani,抬眼看到的都是「她已经走了」。宽限不是休息期,只是「别在我刚按下
548
+ // 那个按钮的下一秒就消失」。
549
+ if (this.realNow().getTime() - this.bootedAt < BOOT_GRACE_MS) return;
550
+
551
+ // 在家出发也要挑个像样的钟点。休息期到点的那一刻就是出发的时刻,
552
+ // 而 `restingUntil` = 上次回家的时刻 + 休息天数,所以**上次几点到家,
553
+ // 这次就几点出门** —— 原来只挡了「太早」,模拟里出现过晚上九点从家出发。
554
+ //
555
+ // 两头都要挡:7 点前不出门,21 点后也不出门。挡住的这一轮直接 return,
556
+ // 下一轮巡检(几秒到一分钟之后)会重新判断,自然等到第二天早上。
557
+ const boot = localMoment(now, this.cityOrNull(this.st.hereId)?.tz ?? this.resolveHome().city.tz).decimal;
558
+ if (boot < 7 || boot >= 21) return;
559
+ }
539
560
 
540
561
  const home = this.resolveHome().city;
541
562
  const from = this.cityOrNull(this.st.hereId) ?? home;
542
563
 
543
- // 在家出发也要挑个像样的钟点。休息期到点的那一刻就是出发的时刻,
544
- // 而 `restingUntil` = 上次回家的时刻 + 休息天数,所以**上次几点到家,
545
- // 这次就几点出门** —— 原来只挡了「太早」,模拟里出现过晚上九点从家出发。
546
- //
547
- // 两头都要挡:7 点前不出门,21 点后也不出门。挡住的这一轮直接 return,
548
- // 下一轮巡检(几秒到一分钟之后)会重新判断,自然等到第二天早上。
549
- const departHour = localMoment(now, from.tz).decimal;
550
- if (departHour < 7 || departHour >= 21) return;
551
-
552
564
  this.maybeSongWish(readNowPlaying());
553
565
  const picked = pickDestination({
554
566
  from,
@@ -1455,6 +1467,16 @@ export class JourneyWorld implements World {
1455
1467
  this.uiStore.resetGuide();
1456
1468
  return this.uiSnapshot();
1457
1469
  }
1470
+ if (method === 'depart') {
1471
+ // 他按了「让她出发」。这里**不检查开关** —— 按钮只在开关打开时才出现,
1472
+ // 但真要绕过前端发这个请求也不该被静默吞掉:直接告诉他为什么不行。
1473
+ if (this.st.phase !== 'home') throw new Error('她已经在外面了');
1474
+ const now = this.worldNow();
1475
+ if (this.stillResting(now)) throw new Error('她还在休息,还没到能走的日子');
1476
+ await this.depart(now, true);
1477
+ // 出发可能因为「没有可去的地方」之类失败,把最新状态交回去让面板自己判断。
1478
+ return this.uiSnapshot();
1479
+ }
1458
1480
  }
1459
1481
  if (panel === 'album') {
1460
1482
  if (method === 'list') return { photos: this.uiSnapshot().photos };
@@ -1540,6 +1562,11 @@ export class JourneyWorld implements World {
1540
1562
  photos: this.photos.list().slice(0, 60).map((p) => ({
1541
1563
  handle: p.handle, title: p.title, city: p.cityName, dateKey: p.dateKey,
1542
1564
  })),
1565
+ askBeforeDepart: this.cfg.askBeforeDepart,
1566
+ canDepart: this.st.phase === 'home' && !this.stillResting(now),
1567
+ restUntil: this.st.phase === 'home' && this.stillResting(now) && this.st.restingUntil
1568
+ ? this.st.restingUntil.slice(5, 10)
1569
+ : null,
1543
1570
  home: home.name,
1544
1571
  // 这一趟出发时的家;还没出发就是现在的家。
1545
1572
  tripHome: this.cityName(this.st.tripHomeId ?? this.st.homeId),