dsh-feiyu-life 1.0.7 → 1.0.8
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 +8 -0
- package/README.md +3 -3
- package/assets/actions/bath.png +0 -0
- package/assets/icons/ATTRIBUTION.md +1 -1
- package/client.js +56 -14
- package/docs/CONFIGURATION.md +6 -4
- package/docs/DESIGN.md +3 -2
- package/image.js +53 -18
- package/index.js +13 -3
- package/life.js +3 -1
- package/package.json +9 -2
- package/plan.js +4 -2
- package/world.js +21 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 1.0.8
|
|
4
|
+
|
|
5
|
+
- **页面状态实时推进**:生活面板与照片面板在页面可见时定时刷新;未保存配置和历史时间预览不会被后台轮询覆盖。
|
|
6
|
+
- **校历边界修复**:只有学期内才加载课表,假期、特殊时段以及校历之外不再凭星期误判为上课日。
|
|
7
|
+
- **动作与地点扩展**:新增独立透明洗漱四帧;自定义地点可选择内置 Iconify 图标,不再全部退化成星光。
|
|
8
|
+
- **图片格式可靠性**:按下载内容识别 PNG、JPEG、WebP,文件扩展名、照片列表、额度统计与响应 MIME 保持一致。
|
|
9
|
+
- **工程加固**:Iconify MCP 固定版本,延迟任务随插件卸载取消,并增加 Chromium 实际渲染检查。
|
|
10
|
+
|
|
3
11
|
## 1.0.7
|
|
4
12
|
|
|
5
13
|
- **补发 1.0.6 的 Iconify 图标**:npm 上的 1.0.6 是统一图标那次提交之前打的包;这次代码与 main 的 1.0.6 一致(行为气泡和地图地点用 Lucide / Simple Icons 离线矢量图标)。
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
|
|
63
63
|
从一个地方去另一个地方,时间线上会自己插一段通勤。路线由 OSM 步道与道路的最大连通图自动生成,小人会沿真实路径转弯,不会再按手填折点穿楼。底图已内置在插件里,不会向外部地图服务上报角色位置;数据来源和许可见 [`assets/maps/ATTRIBUTION.md`](assets/maps/ATTRIBUTION.md)。
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
小人会站着发呆、走路、睡觉、抱着书看、吃饭、看手机、拍照和洗漱,每种行为都有独立的四帧透明动画。新剧本会直接写下地点和行为;旧剧本再用短语规则推断。规则会区分主语和否定,所以「看猫吃火腿肠」「陪室友吃饭」「睡不着」不会把别人的动作或没发生的动作算到我头上。
|
|
66
66
|
|
|
67
67
|
## 我的相机
|
|
68
68
|
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
设置 → 鱼的生活。我哥偶尔会打开它:
|
|
82
82
|
|
|
83
83
|
- **此刻**:时间线、注入的那几行、为什么这么算;也能选个时间点预览别的日子
|
|
84
|
-
-
|
|
84
|
+
- **地图**:地点图标、坐标、识别关键词、路径耗时、短句识别测试,以及要不要自动通勤
|
|
85
85
|
- **课表 / 作息**:周几有课,没课的日子几点起
|
|
86
86
|
- **身体**:经期和偶尔不按表走的概率;生活细节由模型剧本统一生成
|
|
87
87
|
- **照片**:相机配置、试拍、最近拍的照片
|
|
@@ -155,7 +155,7 @@ dsh plugin --profile web add /absolute/path/to/dsh-feiyu-life
|
|
|
155
155
|
|
|
156
156
|
⚠️ 这时要把 `cordis.patch.yml` 里的 `name:` 从包名换成该目录下 `index.js` 的绝对路径——客户端那半是拿「挂载行的模块名 + 解析基址」去找 `package.json` 的,按包名从工作区目录往上找不到 `node_modules` 会静默跳过,设置页就永远不出现。
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
改完代码要生效:在插件页卸掉再装一次(模块是加载时读的)。完整测试:`npm run test:all`。
|
|
159
159
|
|
|
160
160
|
## 反馈
|
|
161
161
|
|
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
界面行为图标与地图通用地点图标通过 Iconify MCP 获取,并以 SVG path 快照形式内嵌在 `client.js`,运行时不访问 Iconify API 或 CDN。
|
|
4
4
|
|
|
5
|
-
- [Lucide](https://lucide.dev/):`sparkles`、`moon`、`footprints`、`pencil`、`utensils`、`smartphone`、`camera`、`bath`、`bed`、`school`、`library-big`、`soup`、`store`、`trees`、`coffee`、`shopping-bag`,ISC License。
|
|
5
|
+
- [Lucide](https://lucide.dev/):`sparkles`、`moon`、`footprints`、`pencil`、`utensils`、`smartphone`、`camera`、`bath`、`bed`、`school`、`library-big`、`soup`、`store`、`trees`、`coffee`、`shopping-bag`、`map-pin`、`house`、`hospital`、`train-front`、`bus-front`、`dumbbell`、`gamepad-2`、`briefcase-business`、`music-2`、`paw-print`,ISC License。
|
|
6
6
|
- [Simple Icons](https://simpleicons.org/):`mcdonalds`,CC0 1.0。
|
|
7
7
|
|
|
8
8
|
项目自己的鲸鱼时钟品牌图标不属于上述图标集。
|
package/client.js
CHANGED
|
@@ -147,6 +147,7 @@ window.__ModuleLoader__.load({
|
|
|
147
147
|
[data-fl-avatar-motion][data-behavior='eat'] [data-fl-avatar-sprite]{animation-duration:1.25s;}
|
|
148
148
|
[data-fl-avatar-motion][data-behavior='phone'] [data-fl-avatar-sprite]{animation-duration:2s;}
|
|
149
149
|
[data-fl-avatar-motion][data-behavior='photo'] [data-fl-avatar-sprite]{animation-duration:1.6s;}
|
|
150
|
+
[data-fl-avatar-motion][data-behavior='bath'] [data-fl-avatar-sprite]{animation-duration:1.35s;}
|
|
150
151
|
[data-fl-avatar-bubble]{position:absolute;right:-9px;top:-6px;display:grid;place-items:center;width:28px;height:28px;border-radius:50%;background:Canvas;border:1px solid var(--fl-line);color:var(--fl-accent);box-shadow:0 4px 12px rgba(0,0,0,.12);}
|
|
151
152
|
[data-fl-avatar-bubble] svg{display:block;width:17px;height:17px;}
|
|
152
153
|
[data-fl-avatar-label]{position:absolute;left:50%;top:calc(100% + 4px);transform:translateX(-50%);white-space:nowrap;padding:2px 7px;border-radius:999px;background:rgba(16,66,68,.82);color:#fff;font-size:10px;box-shadow:0 3px 8px rgba(0,0,0,.14);}
|
|
@@ -264,6 +265,16 @@ window.__ModuleLoader__.load({
|
|
|
264
265
|
trees: [['path', { d: 'M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0m-3 6v6m6-3v3' }], ['path', { d: 'M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5' }]],
|
|
265
266
|
coffee: [['path', { d: 'M10 2v2m4-2v2m2 4a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1M6 2v2' }]],
|
|
266
267
|
shoppingBag: [['path', { d: 'M16 10a4 4 0 0 1-8 0M3.103 6.034h17.794' }], ['path', { d: 'M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z' }]],
|
|
268
|
+
mapPin: [['path', { d: 'M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0' }], ['circle', { cx: '12', cy: '10', r: '3' }]],
|
|
269
|
+
house: [['path', { d: 'M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8' }], ['path', { d: 'M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z' }]],
|
|
270
|
+
hospital: [['path', { d: 'M12 7v4m2 10v-3a2 2 0 0 0-4 0v3m4-12h-4' }], ['path', { d: 'M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2' }], ['path', { d: 'M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16' }]],
|
|
271
|
+
train: [['path', { d: 'M8 3.1V7a4 4 0 0 0 8 0V3.1M9 15l-1-1m7 1 1-1' }], ['path', { d: 'M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Zm-1 0-2 3m10-3 2 3' }]],
|
|
272
|
+
bus: [['path', { d: 'M4 6 2 7m8-1h4m8 1-2-1' }], ['rect', { width: '16', height: '16', x: '4', y: '3', rx: '2' }], ['path', { d: 'M4 11h16M8 15h.01M16 15h.01M6 19v2m12 0v-2' }]],
|
|
273
|
+
dumbbell: [['path', { d: 'M17.596 12.768a2 2 0 1 0 2.829-2.829l-1.768-1.767a2 2 0 0 0 2.828-2.829l-2.828-2.828a2 2 0 0 0-2.829 2.828l-1.767-1.768a2 2 0 1 0-2.829 2.829zM2.5 21.5l1.4-1.4M20.1 3.9l1.4-1.4M5.343 21.485a2 2 0 1 0 2.829-2.828l1.767 1.768a2 2 0 1 0 2.829-2.829l-6.364-6.364a2 2 0 1 0-2.829 2.829l1.768 1.767a2 2 0 0 0-2.828 2.829zM9.6 14.4l4.8-4.8' }]],
|
|
274
|
+
gamepad: [['path', { d: 'M6 11h4M8 9v4m7-1h.01M18 10h.01m-.69-5H6.68a4 4 0 0 0-3.978 3.59l-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258q-.01-.075-.017-.151A4 4 0 0 0 17.32 5' }]],
|
|
275
|
+
briefcase: [['path', { d: 'M12 12h.01M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2m14 7a18.15 18.15 0 0 1-20 0' }], ['rect', { width: '20', height: '14', x: '2', y: '6', rx: '2' }]],
|
|
276
|
+
music: [['circle', { cx: '8', cy: '18', r: '4' }], ['path', { d: 'M12 18V2l7 4' }]],
|
|
277
|
+
pawPrint: [['circle', { cx: '11', cy: '4', r: '2' }], ['circle', { cx: '18', cy: '8', r: '2' }], ['circle', { cx: '20', cy: '16', r: '2' }], ['path', { d: 'M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045q-.64-2.065-2.7-2.705A3.5 3.5 0 0 1 5.5 10Z' }]],
|
|
267
278
|
mcdonalds: [['path', { d: 'M17.243 3.006c2.066 0 3.742 8.714 3.742 19.478H24c0-11.588-3.042-20.968-6.766-20.968-2.127 0-4.007 2.81-5.248 7.227-1.241-4.416-3.121-7.227-5.231-7.227C3.031 1.516 0 10.888 0 22.476h3.014c0-10.763 1.658-19.47 3.724-19.47s3.741 8.05 3.741 17.98h2.997c0-9.93 1.684-17.98 3.75-17.98Z' }]],
|
|
268
279
|
}
|
|
269
280
|
|
|
@@ -284,6 +295,12 @@ window.__ModuleLoader__.load({
|
|
|
284
295
|
photo: ['camera', '拍照'], bath: ['bath', '洗漱'],
|
|
285
296
|
}
|
|
286
297
|
|
|
298
|
+
const placeIconOptions = [
|
|
299
|
+
'mapPin', 'house', 'bed', 'school', 'library', 'soup', 'store', 'trees', 'coffee',
|
|
300
|
+
'shoppingBag', 'mcdonalds', 'hospital', 'train', 'bus', 'dumbbell', 'gamepad',
|
|
301
|
+
'briefcase', 'music', 'pawPrint',
|
|
302
|
+
]
|
|
303
|
+
|
|
287
304
|
function FeiyuMark({ size = 20, map = false }) {
|
|
288
305
|
return h('svg', {
|
|
289
306
|
'data-fl-brand-mark': '', 'data-fl-map-logo': map ? '' : undefined,
|
|
@@ -297,13 +314,14 @@ window.__ModuleLoader__.load({
|
|
|
297
314
|
h('circle', { cx: '21.2', cy: '17.7', r: '.55', fill: '#245b78' }))
|
|
298
315
|
}
|
|
299
316
|
|
|
300
|
-
function PlaceGlyph({ id }) {
|
|
317
|
+
function PlaceGlyph({ id, icon }) {
|
|
301
318
|
const icons = {
|
|
302
319
|
dorm: 'bed', classroom: 'school', library: 'library', canteen: 'soup', shop: 'store',
|
|
303
320
|
outdoor: 'trees', cafe: 'coffee', mall: 'shoppingBag', mcdonalds: 'mcdonalds',
|
|
304
321
|
}
|
|
322
|
+
const name = iconifyGlyphs[icon] ? icon : (icons[id] || 'mapPin')
|
|
305
323
|
return h(IconifyGlyph, {
|
|
306
|
-
name
|
|
324
|
+
name, size: 34, 'data-fl-place-glyph': '',
|
|
307
325
|
style: id === 'mcdonalds' ? { color: '#ffbc0d' } : undefined,
|
|
308
326
|
})
|
|
309
327
|
}
|
|
@@ -314,7 +332,7 @@ window.__ModuleLoader__.load({
|
|
|
314
332
|
const mapStyle = map && map.底图 === 'none' ? 'none' : 'xueyuan-road'
|
|
315
333
|
const point = (world && world.position) || { x: 50, y: 50 }
|
|
316
334
|
const behavior = (world && world.behavior) || 'idle'
|
|
317
|
-
const spriteBehavior =
|
|
335
|
+
const spriteBehavior = behaviorMeta[behavior] ? behavior : 'idle'
|
|
318
336
|
const meta = behaviorMeta[behavior] || behaviorMeta.idle
|
|
319
337
|
const active = world && world.moving && world.destination ? world.destination.id : world && world.location && world.location.id
|
|
320
338
|
const routePairs = new Set(((world && world.route) || []).slice(1).map((id, i) => {
|
|
@@ -323,9 +341,9 @@ window.__ModuleLoader__.load({
|
|
|
323
341
|
}))
|
|
324
342
|
return h('div', { 'data-fl-map': '', 'data-map-style': mapStyle },
|
|
325
343
|
mapStyle === 'xueyuan-road' ? h('div', { 'data-fl-map-layers': '', 'aria-hidden': 'true' },
|
|
326
|
-
h('img', { 'data-fl-map-layer': 'base', src: `${API}/map/xueyuan?layer=base&v=1.0.
|
|
327
|
-
h('img', { 'data-fl-map-layer': 'anime', src: `${API}/map/xueyuan?layer=anime&v=1.0.
|
|
328
|
-
h('img', { 'data-fl-map-layer': 'buildings', src: `${API}/map/xueyuan?layer=buildings&v=1.0.
|
|
344
|
+
h('img', { 'data-fl-map-layer': 'base', src: `${API}/map/xueyuan?layer=base&v=1.0.8`, alt: '' }),
|
|
345
|
+
h('img', { 'data-fl-map-layer': 'anime', src: `${API}/map/xueyuan?layer=anime&v=1.0.8`, alt: '' }),
|
|
346
|
+
h('img', { 'data-fl-map-layer': 'buildings', src: `${API}/map/xueyuan?layer=buildings&v=1.0.8`, alt: '' })) : null,
|
|
329
347
|
h('div', { 'data-fl-map-scenery': '', 'aria-hidden': 'true' },
|
|
330
348
|
h('i', { 'data-fl-scenery': 'hill-a' }),
|
|
331
349
|
h('i', { 'data-fl-scenery': 'hill-b' }),
|
|
@@ -346,14 +364,14 @@ window.__ModuleLoader__.load({
|
|
|
346
364
|
nodes.map((node) => h('div', {
|
|
347
365
|
key: node.id, 'data-fl-place': '', 'data-place': node.id, 'data-fl-active': active === node.id ? '' : undefined,
|
|
348
366
|
style: { left: node.x + '%', top: node.y + '%' }, title: (node.关键词 || []).join('、'),
|
|
349
|
-
}, h('span', { 'data-fl-place-marker': '' }, h(PlaceGlyph, { id: node.id })),
|
|
367
|
+
}, h('span', { 'data-fl-place-marker': '' }, h(PlaceGlyph, { id: node.id, icon: node.icon })),
|
|
350
368
|
h('span', { 'data-fl-place-name': '' }, node.name))),
|
|
351
369
|
world && world.enabled !== false ? h('div', {
|
|
352
370
|
'data-fl-avatar': '', style: { left: point.x + '%', top: point.y + '%' },
|
|
353
371
|
}, h('div', { 'data-fl-avatar-motion': '', 'data-behavior': behavior },
|
|
354
372
|
h('div', {
|
|
355
373
|
'data-fl-avatar-sprite': '', 'aria-hidden': 'true',
|
|
356
|
-
style: { '--fl-avatar-image': `url(${API}/avatar/${spriteBehavior}?v=1.0.
|
|
374
|
+
style: { '--fl-avatar-image': `url(${API}/avatar/${spriteBehavior}?v=1.0.8)` },
|
|
357
375
|
}),
|
|
358
376
|
h('span', { 'data-fl-avatar-bubble': '', title: meta[1] }, h(IconifyGlyph, { name: meta[0], size: 17 })),
|
|
359
377
|
h('span', { 'data-fl-avatar-label': '' }, world.moving && world.destination
|
|
@@ -388,7 +406,7 @@ window.__ModuleLoader__.load({
|
|
|
388
406
|
const [inference, setInference] = useState(null)
|
|
389
407
|
const dirty = Boolean(config && savedConfig && JSON.stringify(config) !== JSON.stringify(savedConfig))
|
|
390
408
|
|
|
391
|
-
const load = async (preserveConfig = false) => {
|
|
409
|
+
const load = async (preserveConfig = false, silent = false) => {
|
|
392
410
|
try {
|
|
393
411
|
const data = await getJson(API + '/state')
|
|
394
412
|
if (!preserveConfig) {
|
|
@@ -405,9 +423,21 @@ window.__ModuleLoader__.load({
|
|
|
405
423
|
setAdjustments(data.adjustments || [])
|
|
406
424
|
setWorld(data.world || null)
|
|
407
425
|
setError('')
|
|
408
|
-
} catch (e) { setError('读不到配置:' + e.message) }
|
|
426
|
+
} catch (e) { if (!silent) setError('读不到配置:' + e.message) }
|
|
409
427
|
}
|
|
410
428
|
useEffect(() => { load() }, [])
|
|
429
|
+
useEffect(() => {
|
|
430
|
+
const refresh = () => {
|
|
431
|
+
if (document.hidden || previewAt) return
|
|
432
|
+
load(dirty, true)
|
|
433
|
+
}
|
|
434
|
+
const timer = window.setInterval(refresh, 30000)
|
|
435
|
+
document.addEventListener('visibilitychange', refresh)
|
|
436
|
+
return () => {
|
|
437
|
+
window.clearInterval(timer)
|
|
438
|
+
document.removeEventListener('visibilitychange', refresh)
|
|
439
|
+
}
|
|
440
|
+
}, [dirty, previewAt])
|
|
411
441
|
useEffect(() => {
|
|
412
442
|
const warn = (e) => { if (dirty) { e.preventDefault(); e.returnValue = '' } }
|
|
413
443
|
window.addEventListener('beforeunload', warn)
|
|
@@ -555,6 +585,7 @@ window.__ModuleLoader__.load({
|
|
|
555
585
|
const mapCfg = config.地图 || { 启用: true, 自动通勤: true, 地点: [], 路径: [] }
|
|
556
586
|
const placeRows = (mapCfg.地点 || []).map((node, i) => h('tr', { key: node.id || i },
|
|
557
587
|
h('td', null, h(Field, { value: node.name, width: 'data-fl-narrow', onChange: (v) => patch(['地图', '地点', i, 'name'], v) })),
|
|
588
|
+
h('td', null, h(Select, { value: node.icon || 'mapPin', options: placeIconOptions, onChange: (v) => patch(['地图', '地点', i, 'icon'], v) })),
|
|
558
589
|
h('td', null, h(Field, { value: node.x, type: 'number', width: 'data-fl-num', onChange: (v) => patch(['地图', '地点', i, 'x'], Number(v)) })),
|
|
559
590
|
h('td', null, h(Field, { value: node.y, type: 'number', width: 'data-fl-num', onChange: (v) => patch(['地图', '地点', i, 'y'], Number(v)) })),
|
|
560
591
|
h('td', null, h(Field, {
|
|
@@ -596,7 +627,7 @@ window.__ModuleLoader__.load({
|
|
|
596
627
|
h('div', { 'data-fl-note': '' }, '关键词用于从剧本短句判断地点;坐标是地图里的百分比位置。'),
|
|
597
628
|
h('table', { 'data-fl-table': '' },
|
|
598
629
|
h('thead', null, h('tr', null,
|
|
599
|
-
h('th', null, '地点'), h('th', null, 'X'), h('th', null, 'Y'), h('th', null, '识别关键词'))),
|
|
630
|
+
h('th', null, '地点'), h('th', null, '图标'), h('th', null, 'X'), h('th', null, 'Y'), h('th', null, '识别关键词'))),
|
|
600
631
|
h('tbody', null, placeRows)),
|
|
601
632
|
h('div', { 'data-fl-h': '' }, '路径耗时'),
|
|
602
633
|
h('table', { 'data-fl-table': '' },
|
|
@@ -853,16 +884,26 @@ window.__ModuleLoader__.load({
|
|
|
853
884
|
}
|
|
854
885
|
}
|
|
855
886
|
|
|
856
|
-
const load = async () => {
|
|
887
|
+
const load = async (preserveConfig = false, silent = false) => {
|
|
857
888
|
try {
|
|
858
889
|
const r = await fetch(`${API}/state`, { credentials: 'same-origin' })
|
|
859
890
|
const d = await r.json()
|
|
860
891
|
if (!d.ok) throw new Error(d.error || '读不到状态')
|
|
861
|
-
setStatus(d)
|
|
862
|
-
|
|
892
|
+
setStatus(d)
|
|
893
|
+
if (!preserveConfig) setConfig(d.config)
|
|
894
|
+
} catch (e) { if (!silent) setMessage('读取失败:' + String(e.message || e)) }
|
|
863
895
|
}
|
|
864
896
|
useEffect(() => { load() }, [])
|
|
865
897
|
useEffect(() => { loadModels() }, [])
|
|
898
|
+
useEffect(() => {
|
|
899
|
+
const refresh = () => { if (!document.hidden) load(true, true) }
|
|
900
|
+
const timer = window.setInterval(refresh, 30000)
|
|
901
|
+
document.addEventListener('visibilitychange', refresh)
|
|
902
|
+
return () => {
|
|
903
|
+
window.clearInterval(timer)
|
|
904
|
+
document.removeEventListener('visibilitychange', refresh)
|
|
905
|
+
}
|
|
906
|
+
}, [])
|
|
866
907
|
|
|
867
908
|
const edit = (k) => (e) => setConfig({ ...config, [k]: e && e.target ? e.target.value : e })
|
|
868
909
|
const editNum = (k) => (e) => setConfig({ ...config, [k]: Number(e.target.value) })
|
|
@@ -1038,6 +1079,7 @@ window.__ModuleLoader__.load({
|
|
|
1038
1079
|
|
|
1039
1080
|
return {
|
|
1040
1081
|
inject: ['slots'],
|
|
1082
|
+
__test: { CSS, WorldMap, IconifyGlyph, PlaceGlyph, behaviorMeta, placeIconOptions },
|
|
1041
1083
|
apply(ctx) {
|
|
1042
1084
|
const style = document.createElement('style')
|
|
1043
1085
|
style.setAttribute('data-plugin-css', 'dsh-feiyu-life')
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
## 生活配置
|
|
22
22
|
|
|
23
|
-
当前生活配置版本为 `
|
|
23
|
+
当前生活配置版本为 `7`。读取旧配置时会自动补齐新字段并保留兼容数据;旧版 `事件池` 会被移除,生活细节统一由每日模型剧本生成。
|
|
24
24
|
|
|
25
25
|
| 字段 | 类型 | 默认值/范围 | 说明 |
|
|
26
26
|
|---|---|---|---|
|
|
27
|
-
| `配置版本` | number | `
|
|
27
|
+
| `配置版本` | number | `7` | 由插件维护,不建议手动修改 |
|
|
28
28
|
| `总开关` | boolean | `true` | 关闭后不向角色会话注入生活状态 |
|
|
29
29
|
| `时区` | string | `Asia/Shanghai` | 必须是有效 IANA 时区 |
|
|
30
30
|
| `工作区` | string[] | `[]` | 目录前缀白名单;空数组代表所有顶层会话 |
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
{
|
|
84
84
|
"id": "dorm",
|
|
85
85
|
"name": "学生公寓",
|
|
86
|
+
"icon": "bed",
|
|
86
87
|
"x": 44.3,
|
|
87
88
|
"y": 51.3,
|
|
88
89
|
"关键词": ["宿舍", "床", "睡", "洗漱"]
|
|
@@ -101,6 +102,7 @@
|
|
|
101
102
|
|---|---|
|
|
102
103
|
| `id` | 唯一;只允许字母、数字、下划线和连字符,最多 40 字符 |
|
|
103
104
|
| `name` | 展示名称,最多 40 字符 |
|
|
105
|
+
| `icon` | 设置页内置的地点图标 ID;未知值会安全回退为地图图钉 |
|
|
104
106
|
| `x` | 地图横坐标,保存时限制到 4–96 |
|
|
105
107
|
| `y` | 地图纵坐标,保存时限制到 8–92 |
|
|
106
108
|
| `关键词` | 从活动短句推断地点;每项最多 24 字符、每地最多 30 项 |
|
|
@@ -113,7 +115,7 @@
|
|
|
113
115
|
|
|
114
116
|
关闭 `地图.自动通勤` 后仍会推断并显示当前地点,但不会向时间线插入移动段。关闭 `地图.启用` 后不再展示空间状态。
|
|
115
117
|
|
|
116
|
-
默认 `地图.底图` 为 `xueyuan-road`,显示中国矿业大学(北京)学院路校区及周边的离线分层地图;设为 `none` 时回退到抽象校园景观。默认九地点包含校内建筑、咖啡屋·上岛咖啡、BOM 嘻番里和麦当劳·成府路。路径可带 `via: [{x, y}]` 折点,地图道路和角色移动使用同一组折点。配置版本 5 开始只替换完全未改动的 v3/v4 默认地图,手动调整过的地点不会被覆盖;版本 6 移除了重复的
|
|
118
|
+
默认 `地图.底图` 为 `xueyuan-road`,显示中国矿业大学(北京)学院路校区及周边的离线分层地图;设为 `none` 时回退到抽象校园景观。默认九地点包含校内建筑、咖啡屋·上岛咖啡、BOM 嘻番里和麦当劳·成府路。路径可带 `via: [{x, y}]` 折点,地图道路和角色移动使用同一组折点。配置版本 5 开始只替换完全未改动的 v3/v4 默认地图,手动调整过的地点不会被覆盖;版本 6 移除了重复的 `事件池`;版本 7 为地点补充可配置的本地图标。
|
|
117
119
|
|
|
118
120
|
## 行为识别
|
|
119
121
|
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
| `eat` | 吃饭、食堂、早餐、午饭、晚饭、吃外卖、喝奶茶;排除等/点/取外卖和旁观、喂宠物语境 |
|
|
129
131
|
| `study` | 上课、自习、背书、复习、看书、作业、写稿、改稿、写作、码字、论文、海报、剪片、修图 |
|
|
130
132
|
| `photo` | 拍照、相机、自拍 |
|
|
131
|
-
| `bath` |
|
|
133
|
+
| `bath` | 洗澡、洗漱、刷牙、洗脸;使用独立四帧透明动作条 |
|
|
132
134
|
| `phone` | 刷手机、回消息、打游戏、B站、看剧、刷视频等明确短语 |
|
|
133
135
|
| `idle` | 未命中上述规则 |
|
|
134
136
|
|
package/docs/DESIGN.md
CHANGED
|
@@ -80,8 +80,9 @@ flowchart TD
|
|
|
80
80
|
| `eat.png` | `eat` | 吃东西 |
|
|
81
81
|
| `phone.png` | `phone` | 玩手机 |
|
|
82
82
|
| `photo.png` | `photo` | 拍照 |
|
|
83
|
+
| `bath.png` | `bath` | 洗漱/刷牙 |
|
|
83
84
|
|
|
84
|
-
`client.js`
|
|
85
|
+
`client.js` 按行为加载独立动作条并只在水平方向播放四帧,不能从完整纵向图集中偏移裁行,也不能用白底裁图、整图旋转或上下晃动代替动作。每个行为都必须有同名资源,不能静默借用 `idle` 掩盖缺图。
|
|
85
86
|
|
|
86
87
|
系统启用 `prefers-reduced-motion` 时应停在当前行为首帧,并禁用位置过渡;不能回退到另一张头像。
|
|
87
88
|
|
|
@@ -166,6 +167,6 @@ flowchart TD
|
|
|
166
167
|
|
|
167
168
|
1. 配置导入、导出与迁移记录可视化;
|
|
168
169
|
2. 重叠课表和作息空洞诊断;
|
|
169
|
-
3.
|
|
170
|
+
3. 为购物、户外等行为补充独立透明序列帧;
|
|
170
171
|
4. 将地图从节点图升级为可选场景图层,同时保持 `world` 接口稳定;
|
|
171
172
|
5. 端到端宿主测试,覆盖鉴权、热更新、模型失败、图片重拍和动画资源加载。
|
package/image.js
CHANGED
|
@@ -109,6 +109,28 @@ function writeImageConfig(next) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const sizeByAspect = { 竖幅: '1440x1920', 方形: '2048x2048', 横幅: '1920x1440' }
|
|
112
|
+
const originalPhoto = /^feiyu-\d+\.(?:png|jpe?g|webp)$/i
|
|
113
|
+
const generatedPhoto = /^feiyu-(?:retry-)?\d+(?:-small)?\.(?:png|jpe?g|webp)$/i
|
|
114
|
+
const photoTimestamp = (name) => /^feiyu-(\d+)\.(?:png|jpe?g|webp)$/i.exec(name)?.[1] || ''
|
|
115
|
+
|
|
116
|
+
export function detectImageFormat(buf, _contentType = '') {
|
|
117
|
+
if (!Buffer.isBuffer(buf) || !buf.length) return null
|
|
118
|
+
if (buf.length >= 8 && buf.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) {
|
|
119
|
+
return { ext: 'png', mime: 'image/png' }
|
|
120
|
+
}
|
|
121
|
+
if (buf.length >= 3 && buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) {
|
|
122
|
+
return { ext: 'jpg', mime: 'image/jpeg' }
|
|
123
|
+
}
|
|
124
|
+
if (buf.length >= 12 && buf.toString('ascii', 0, 4) === 'RIFF' && buf.toString('ascii', 8, 12) === 'WEBP') {
|
|
125
|
+
return { ext: 'webp', mime: 'image/webp' }
|
|
126
|
+
}
|
|
127
|
+
// Never trust the HTTP header on its own: gateways sometimes return an
|
|
128
|
+
// HTML error page while keeping the requested image content type.
|
|
129
|
+
return null
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const imageMimeForPath = (path) => /\.webp$/i.test(path) ? 'image/webp'
|
|
133
|
+
: /\.jpe?g$/i.test(path) ? 'image/jpeg' : 'image/png'
|
|
112
134
|
|
|
113
135
|
function migrateImageConfig(raw) {
|
|
114
136
|
const source = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {}
|
|
@@ -163,7 +185,7 @@ export function cleanupPhotos(cfg = readImageConfig(), now = Date.now()) {
|
|
|
163
185
|
let names = []
|
|
164
186
|
try { names = readdirSync(dir) } catch {}
|
|
165
187
|
for (const name of names) {
|
|
166
|
-
if (
|
|
188
|
+
if (!generatedPhoto.test(name)) continue
|
|
167
189
|
const path = join(dir, name)
|
|
168
190
|
try { if (statSync(path).mtimeMs < cutoff) { unlinkSync(path); removed++ } } catch {}
|
|
169
191
|
}
|
|
@@ -172,17 +194,24 @@ export function cleanupPhotos(cfg = readImageConfig(), now = Date.now()) {
|
|
|
172
194
|
}
|
|
173
195
|
|
|
174
196
|
function listPhotos(cfg) {
|
|
175
|
-
const
|
|
197
|
+
const byTimestamp = new Map()
|
|
176
198
|
for (const dir of photoDirs(cfg)) {
|
|
177
199
|
try {
|
|
178
200
|
for (const f of readdirSync(dir)) {
|
|
179
|
-
if (
|
|
201
|
+
if (!originalPhoto.test(f)) continue
|
|
180
202
|
const st = statSync(join(dir, f))
|
|
181
|
-
|
|
203
|
+
const key = photoTimestamp(f)
|
|
204
|
+
const current = byTimestamp.get(key)
|
|
205
|
+
// Before v1.0.8 the reduced JPEG reused the original timestamp. Keep
|
|
206
|
+
// one gallery item and prefer the full PNG/WebP when both still exist.
|
|
207
|
+
const rank = /\.png$/i.test(f) ? 3 : /\.webp$/i.test(f) ? 2 : 1
|
|
208
|
+
if (!current || rank > current.rank) byTimestamp.set(key, { name: f, time: st.mtimeMs, size: st.size, rank })
|
|
182
209
|
}
|
|
183
210
|
} catch {}
|
|
184
211
|
}
|
|
185
|
-
return
|
|
212
|
+
return [...byTimestamp.values()]
|
|
213
|
+
.map(({ rank, ...photo }) => photo)
|
|
214
|
+
.sort((a, b) => b.time - a.time).slice(0, 24)
|
|
186
215
|
}
|
|
187
216
|
|
|
188
217
|
/** Saved-today count and last shot time (retakes and character refs don't count). */
|
|
@@ -191,30 +220,30 @@ function todayUsage(cfg) {
|
|
|
191
220
|
let tz = 'Asia/Shanghai'
|
|
192
221
|
try { tz = String(readLifeConfig().时区 || tz) } catch {}
|
|
193
222
|
const today = zonedNow(new Date(), tz).ymd
|
|
194
|
-
|
|
223
|
+
const todayShots = new Set()
|
|
195
224
|
let last = 0
|
|
196
225
|
for (const dir of photoDirs(cfg)) {
|
|
197
226
|
let files = []
|
|
198
227
|
try { files = readdirSync(dir) } catch {}
|
|
199
228
|
for (const f of files) {
|
|
200
|
-
if (
|
|
229
|
+
if (!originalPhoto.test(f)) continue
|
|
201
230
|
const st = statSync(join(dir, f))
|
|
202
|
-
if (zonedNow(new Date(st.mtimeMs), tz).ymd === today)
|
|
231
|
+
if (zonedNow(new Date(st.mtimeMs), tz).ymd === today) todayShots.add(photoTimestamp(f))
|
|
203
232
|
last = Math.max(last, st.mtimeMs)
|
|
204
233
|
}
|
|
205
234
|
}
|
|
206
|
-
return { n, last }
|
|
235
|
+
return { n: todayShots.size, last }
|
|
207
236
|
} catch { return { n: 0, last: 0 } }
|
|
208
237
|
}
|
|
209
238
|
|
|
210
239
|
/** QQ renders large images poorly: save a small copy (long edge 1440, JPEG q88). */
|
|
211
|
-
async function shrink(
|
|
240
|
+
async function shrink(imagePath) {
|
|
212
241
|
try {
|
|
213
|
-
const jpg =
|
|
214
|
-
await execFileAsync('convert', [
|
|
242
|
+
const jpg = imagePath.replace(/\.(?:png|jpe?g|webp)$/i, '-small.jpg')
|
|
243
|
+
await execFileAsync('convert', [imagePath, '-resize', '1440x1440>', '-quality', '88', jpg], { timeout: 30000 })
|
|
215
244
|
const st = statSync(jpg)
|
|
216
|
-
return st.size > 0 ? jpg :
|
|
217
|
-
} catch { return
|
|
245
|
+
return st.size > 0 ? jpg : imagePath
|
|
246
|
+
} catch { return imagePath }
|
|
218
247
|
}
|
|
219
248
|
|
|
220
249
|
async function generateImage(cfg, prompt, opts = {}) {
|
|
@@ -253,9 +282,11 @@ async function arkGenerate(cfg, prompt, opts = {}) {
|
|
|
253
282
|
const img = await fetch(url, { signal: timeoutSignal(timeoutMs) })
|
|
254
283
|
if (!img.ok) throw new Error('下载失败 ' + img.status)
|
|
255
284
|
const buf = Buffer.from(await img.arrayBuffer())
|
|
285
|
+
const format = detectImageFormat(buf, img.headers.get('content-type'))
|
|
286
|
+
if (!format) throw new Error('下载结果不是支持的 PNG、JPEG 或 WebP 图片')
|
|
256
287
|
const dir = String(cfg.存图目录 || '').trim() || OUT_DIR
|
|
257
288
|
mkdirSync(dir, { recursive: true })
|
|
258
|
-
const path = join(dir, `feiyu-${Date.now()}.
|
|
289
|
+
const path = join(dir, `feiyu-${Date.now()}.${format.ext}`)
|
|
259
290
|
writeFileSync(path, buf)
|
|
260
291
|
const small = await shrink(path)
|
|
261
292
|
return { path: small, original: path, bytes: statSync(small).size, prompt }
|
|
@@ -263,7 +294,7 @@ async function arkGenerate(cfg, prompt, opts = {}) {
|
|
|
263
294
|
|
|
264
295
|
/** Rename a retaken bad shot so it keeps for review but doesn't count against today's limit. */
|
|
265
296
|
function markRetake(result) {
|
|
266
|
-
const rename = (p) => String(p).replace(/([\\/]feiyu-)(\d+)
|
|
297
|
+
const rename = (p) => String(p).replace(/([\\/]feiyu-)(\d+)(-small)?\.(png|jpe?g|webp)$/i, '$1retry-$2$3.$4')
|
|
267
298
|
if (!result) return
|
|
268
299
|
const nextOriginal = rename(result.original)
|
|
269
300
|
const nextSmall = rename(result.path)
|
|
@@ -467,9 +498,10 @@ function registerRoutes(ctx) {
|
|
|
467
498
|
ctx.effect(() => ctx.webServer.register({
|
|
468
499
|
kind: 'exact', path: ROUTE_PREFIX + '/file',
|
|
469
500
|
handler: onlyOwner(async (req, res) => {
|
|
501
|
+
if (req.method !== 'GET') return reply(res, 405, { ok: false })
|
|
470
502
|
const url = new URL(req.url || '/', 'http://x')
|
|
471
503
|
const name = url.searchParams.get('n') || ''
|
|
472
|
-
if (!/^feiyu-[\w-]+\.png
|
|
504
|
+
if (!/^feiyu-[\w-]+\.(?:png|jpe?g|webp)$/i.test(name) && !/^[\u4e00-\u9fa5\w-]+\.(?:jpe?g|png|webp)$/i.test(name)) return reply(res, 400, { ok: false })
|
|
473
505
|
const cfg = readImageConfig()
|
|
474
506
|
const candidates = []
|
|
475
507
|
for (const dir of photoDirs(cfg)) candidates.push(join(dir, name))
|
|
@@ -477,7 +509,10 @@ function registerRoutes(ctx) {
|
|
|
477
509
|
for (const p of candidates) {
|
|
478
510
|
try {
|
|
479
511
|
const buf = readFileSync(p)
|
|
480
|
-
|
|
512
|
+
// Old releases could save JPEG/WebP bytes under a .png suffix. Sniff
|
|
513
|
+
// the response too so those existing photos remain viewable.
|
|
514
|
+
const mime = detectImageFormat(buf)?.mime || imageMimeForPath(p)
|
|
515
|
+
res.writeHead(200, { 'content-type': mime, 'content-length': buf.length, 'cache-control': 'max-age=60' })
|
|
481
516
|
res.end(buf)
|
|
482
517
|
return
|
|
483
518
|
} catch {}
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export const inject = ['systemPrompt', 'agents', 'timer', 'webServer', 'connecti
|
|
|
37
37
|
const ROUTE_PREFIX = '/dsh-feiyu-life'
|
|
38
38
|
const WEEKDAY = ['', '一', '二', '三', '四', '五', '六', '日']
|
|
39
39
|
const AVATAR_FILE = new URL('./assets/character-actions.png', import.meta.url)
|
|
40
|
-
const AVATAR_BEHAVIORS = ['idle', 'walk', 'sleep', 'study', 'eat', 'phone', 'photo']
|
|
40
|
+
const AVATAR_BEHAVIORS = ['idle', 'walk', 'sleep', 'study', 'eat', 'phone', 'photo', 'bath']
|
|
41
41
|
const AVATAR_ACTION_FILES = new Map(AVATAR_BEHAVIORS.map((behavior) => [
|
|
42
42
|
behavior,
|
|
43
43
|
new URL(`./assets/actions/${behavior}.png`, import.meta.url),
|
|
@@ -264,7 +264,12 @@ export function apply(ctx) {
|
|
|
264
264
|
})
|
|
265
265
|
|
|
266
266
|
tick()
|
|
267
|
-
try {
|
|
267
|
+
try {
|
|
268
|
+
ctx.effect(() => {
|
|
269
|
+
const timer = setTimeout(() => { ensurePlan(new Date()).catch(() => {}) }, 8000)
|
|
270
|
+
return () => clearTimeout(timer)
|
|
271
|
+
})
|
|
272
|
+
} catch {}
|
|
268
273
|
try { ctx.effect(() => ctx.interval(() => { ensurePlan(new Date()).catch(() => {}) }, 20 * 60 * 1000)) } catch {}
|
|
269
274
|
|
|
270
275
|
// ── Settings page endpoints ──────────────────────────────────────────
|
|
@@ -568,6 +573,11 @@ export function apply(ctx) {
|
|
|
568
573
|
try { ctx.logger?.warn?.('feiyu-life: 自动清理失败 ' + String((e && e.message) || e)) } catch {}
|
|
569
574
|
}
|
|
570
575
|
}
|
|
571
|
-
try {
|
|
576
|
+
try {
|
|
577
|
+
ctx.effect(() => {
|
|
578
|
+
const timer = setTimeout(maintain, 15000)
|
|
579
|
+
return () => clearTimeout(timer)
|
|
580
|
+
})
|
|
581
|
+
} catch {}
|
|
572
582
|
try { ctx.effect(() => ctx.interval(maintain, 24 * 60 * 60 * 1000)) } catch {}
|
|
573
583
|
}
|
package/life.js
CHANGED
|
@@ -31,7 +31,7 @@ const phoneChoices = ['在手', '静音', '在床头', '不在手边']
|
|
|
31
31
|
const routineNames = ['日常', '晚起', '假期', '备考']
|
|
32
32
|
const datePattern = /^\d{4}-\d{2}-\d{2}$/
|
|
33
33
|
const timePattern = /^(?:[01]\d|2[0-3]):[0-5]\d$|^24:00$/
|
|
34
|
-
export const LIFE_CONFIG_VERSION =
|
|
34
|
+
export const LIFE_CONFIG_VERSION = 7
|
|
35
35
|
|
|
36
36
|
export const defaultConfig = {
|
|
37
37
|
配置版本: LIFE_CONFIG_VERSION,
|
|
@@ -562,6 +562,8 @@ export function migrateConfig(raw) {
|
|
|
562
562
|
// v6 removes the legacy event pool. Daily-plan details now come only from
|
|
563
563
|
// the model plan (or template fallback), and later changes use life_adjust.
|
|
564
564
|
delete next.事件池
|
|
565
|
+
// v7 adds a safe local Iconify glyph id to each map location. Normalization
|
|
566
|
+
// fills defaults for existing locations and custom locations.
|
|
565
567
|
next.配置版本 = LIFE_CONFIG_VERSION
|
|
566
568
|
return { value: next, changed: version !== LIFE_CONFIG_VERSION || Object.hasOwn(source, '事件池') }
|
|
567
569
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-feiyu-life",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "大肥鱼的生活(DSH 插件):每日剧本 + 时序状态机 + 二维生活地图;角色会在地点间移动并显示行为动效,对话与相机复用同一份世界状态。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,14 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"check": "node --check index.js && node --check life.js && node --check plan.js && node --check state.js && node --check world.js && node --check runtime.js && node --check gen.js && node --check image.js && node --check image-prompt.js && node --check client.js && node --check scripts/build-xueyuan-map.mjs",
|
|
31
|
-
"test": "node --test"
|
|
31
|
+
"test": "node --test",
|
|
32
|
+
"test:ui": "node scripts/verify-ui.mjs",
|
|
33
|
+
"test:all": "npm test && npm run test:ui"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"playwright": "^1.56.1",
|
|
37
|
+
"react": "^18.3.1",
|
|
38
|
+
"react-dom": "^18.3.1"
|
|
32
39
|
},
|
|
33
40
|
"exports": {
|
|
34
41
|
".": "./index.js",
|
package/plan.js
CHANGED
|
@@ -76,7 +76,8 @@ export function dayType(cfg, t, calendar) {
|
|
|
76
76
|
if (calendar.special) return { id: 'special', name: calendar.special.名 || '特殊日' }
|
|
77
77
|
if (calendar.vacation) return { id: 'vacation', name: calendar.vacation.名 || '假期' }
|
|
78
78
|
if (calendar.festival && calendar.festival.起) return { id: 'festival', name: calendar.festival.名 || '节日' }
|
|
79
|
-
const classes =
|
|
79
|
+
const classes = calendar.term && !calendar.holiday && !calendar.special
|
|
80
|
+
? ((cfg.课表 || {})[t.weekday] || []) : []
|
|
80
81
|
if (classes.length) return { id: 'schoolDay', name: '上课日' }
|
|
81
82
|
if (t.weekday >= 6) return r() < 0.55 ? { id: 'weekendHome', name: '周末·宅家' } : { id: 'outing', name: '周末·出门' }
|
|
82
83
|
return r() < 0.6 ? { id: 'offDay', name: '没课日' } : { id: 'outing', name: '出门转转' }
|
|
@@ -99,7 +100,8 @@ export function timeline(cfg, t, calendar, deviation = {}, type = null) {
|
|
|
99
100
|
{ start: 19 * 60, end: 24 * 60, what: '点了个外卖,还是躺着', phone: '在手' },
|
|
100
101
|
].map((x) => ({ ...x, outfit: '' })), cfg, t)
|
|
101
102
|
}
|
|
102
|
-
const classes = calendar.
|
|
103
|
+
const classes = calendar.term && !calendar.holiday && !calendar.special
|
|
104
|
+
? ((cfg.课表 || {})[t.weekday] || []) : []
|
|
103
105
|
const routine = cfg[calendar.routine] || fallbackDay()
|
|
104
106
|
const segs = []
|
|
105
107
|
for (const b of [...routine, ...classes]) {
|
package/world.js
CHANGED
|
@@ -6,20 +6,31 @@ import { xueyuanGeometry } from './assets/maps/xueyuan-world.js'
|
|
|
6
6
|
// infers a place/behaviour for each segment and inserts deterministic travel
|
|
7
7
|
// segments when two consecutive activities happen in different places.
|
|
8
8
|
|
|
9
|
+
export const PLACE_ICON_IDS = [
|
|
10
|
+
'mapPin', 'house', 'bed', 'school', 'library', 'soup', 'store', 'trees', 'coffee',
|
|
11
|
+
'shoppingBag', 'mcdonalds', 'hospital', 'train', 'bus', 'dumbbell', 'gamepad',
|
|
12
|
+
'briefcase', 'music', 'pawPrint',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const defaultPlaceIcons = {
|
|
16
|
+
dorm: 'bed', classroom: 'school', library: 'library', canteen: 'soup', shop: 'store',
|
|
17
|
+
outdoor: 'trees', cafe: 'coffee', mall: 'shoppingBag', mcdonalds: 'mcdonalds',
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
export const defaultWorldConfig = {
|
|
10
21
|
启用: true,
|
|
11
22
|
自动通勤: true,
|
|
12
23
|
底图: 'xueyuan-road',
|
|
13
24
|
地点: [
|
|
14
|
-
{ id: 'dorm', name: '学生公寓', ...xueyuanGeometry.locations.dorm, 关键词: ['宿舍', '公寓', '床', '睡', '起床', '洗澡', '洗漱', '刷手机', '剪片', '修图', '游戏', '看剧', '外卖'] },
|
|
15
|
-
{ id: 'classroom', name: '教学楼', ...xueyuanGeometry.locations.classroom, 关键词: ['上课', '教室', '教学楼', '专业课', '讲座', '点名', '课件'] },
|
|
16
|
-
{ id: 'library', name: '矿大图书馆', ...xueyuanGeometry.locations.library, 关键词: ['图书馆', '自习', '背书', '复习'] },
|
|
17
|
-
{ id: 'canteen', name: '裕园餐厅', ...xueyuanGeometry.locations.canteen, 关键词: ['食堂', '裕园', '餐厅', '吃饭', '早餐', '午饭', '晚饭', '排队'] },
|
|
18
|
-
{ id: 'shop', name: '幸福超市 · 快递点', ...xueyuanGeometry.locations.shop, 关键词: ['幸福超市', '便利店', '超市', '快递', '取件', '买东西'] },
|
|
19
|
-
{ id: 'outdoor', name: '学院路校门', ...xueyuanGeometry.locations.outdoor, 关键词: ['外面', '街上', '学院路', '公园', '书店', '电影院', '拍照', '校门口', '地铁', '公交'] },
|
|
20
|
-
{ id: 'cafe', name: '咖啡屋 · 上岛咖啡', ...xueyuanGeometry.locations.cafe, 关键词: ['上岛咖啡', '咖啡屋', '咖啡店', '咖啡馆', '咖啡厅', '喝咖啡'] },
|
|
21
|
-
{ id: 'mall', name: 'BOM 嘻番里', ...xueyuanGeometry.locations.mall, 关键词: ['BOM嘻番里', '嘻番里', '商场', '逛商场', '买谷', '谷子店', '手办', '桌游'] },
|
|
22
|
-
{ id: 'mcdonalds', name: '麦当劳 · 成府路', ...xueyuanGeometry.locations.mcdonalds, 关键词: ['麦当劳', '麦门', '成府路麦当劳', '汉堡', '薯条', '麦旋风'] },
|
|
25
|
+
{ id: 'dorm', name: '学生公寓', icon: 'bed', ...xueyuanGeometry.locations.dorm, 关键词: ['宿舍', '公寓', '床', '睡', '起床', '洗澡', '洗漱', '刷手机', '剪片', '修图', '游戏', '看剧', '外卖'] },
|
|
26
|
+
{ id: 'classroom', name: '教学楼', icon: 'school', ...xueyuanGeometry.locations.classroom, 关键词: ['上课', '教室', '教学楼', '专业课', '讲座', '点名', '课件'] },
|
|
27
|
+
{ id: 'library', name: '矿大图书馆', icon: 'library', ...xueyuanGeometry.locations.library, 关键词: ['图书馆', '自习', '背书', '复习'] },
|
|
28
|
+
{ id: 'canteen', name: '裕园餐厅', icon: 'soup', ...xueyuanGeometry.locations.canteen, 关键词: ['食堂', '裕园', '餐厅', '吃饭', '早餐', '午饭', '晚饭', '排队'] },
|
|
29
|
+
{ id: 'shop', name: '幸福超市 · 快递点', icon: 'store', ...xueyuanGeometry.locations.shop, 关键词: ['幸福超市', '便利店', '超市', '快递', '取件', '买东西'] },
|
|
30
|
+
{ id: 'outdoor', name: '学院路校门', icon: 'trees', ...xueyuanGeometry.locations.outdoor, 关键词: ['外面', '街上', '学院路', '公园', '书店', '电影院', '拍照', '校门口', '地铁', '公交'] },
|
|
31
|
+
{ id: 'cafe', name: '咖啡屋 · 上岛咖啡', icon: 'coffee', ...xueyuanGeometry.locations.cafe, 关键词: ['上岛咖啡', '咖啡屋', '咖啡店', '咖啡馆', '咖啡厅', '喝咖啡'] },
|
|
32
|
+
{ id: 'mall', name: 'BOM 嘻番里', icon: 'shoppingBag', ...xueyuanGeometry.locations.mall, 关键词: ['BOM嘻番里', '嘻番里', '商场', '逛商场', '买谷', '谷子店', '手办', '桌游'] },
|
|
33
|
+
{ id: 'mcdonalds', name: '麦当劳 · 成府路', icon: 'mcdonalds', ...xueyuanGeometry.locations.mcdonalds, 关键词: ['麦当劳', '麦门', '成府路麦当劳', '汉堡', '薯条', '麦旋风'] },
|
|
23
34
|
],
|
|
24
35
|
路径: xueyuanGeometry.paths,
|
|
25
36
|
}
|
|
@@ -75,6 +86,7 @@ export function normalizeWorldConfig(input) {
|
|
|
75
86
|
return [{
|
|
76
87
|
id,
|
|
77
88
|
name: String(node.name || id).trim().slice(0, 40) || id,
|
|
89
|
+
icon: PLACE_ICON_IDS.includes(String(node.icon || '')) ? String(node.icon) : (defaultPlaceIcons[id] || 'mapPin'),
|
|
78
90
|
x: tenth(clamp(node.x, 4, 96, 50)),
|
|
79
91
|
y: tenth(clamp(node.y, 8, 92, 50)),
|
|
80
92
|
关键词: Array.isArray(node.关键词)
|