better-dsh-pet 0.1.0 → 0.2.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.
Files changed (104) hide show
  1. package/assets/thumb//344/270/211/347/220/203/346/212/233/346/216/245.webm +0 -0
  2. package/assets/thumb//344/270/213/344/272/224/345/255/220/346/243/213.webm +0 -0
  3. package/assets/thumb//344/270/234/345/274/240/350/245/277/346/234/233.webm +0 -0
  4. package/assets/thumb//344/270/255/347/247/213/350/265/217/346/234/210/345/220/203/346/234/210/351/245/274.webm +0 -0
  5. package/assets/thumb//344/274/230/351/233/205/345/245/263/344/273/206/350/210/236.webm +0 -0
  6. package/assets/thumb//345/201/267/345/220/203/351/233/266/351/243/237/350/242/253/346/212/223/344/275/217.webm +0 -0
  7. package/assets/thumb//345/206/231/344/273/243/347/240/201.webm +0 -0
  8. package/assets/thumb//345/206/231/347/246/217/345/255/227.webm +0 -0
  9. package/assets/thumb//345/207/255/347/251/272/347/224/237/350/212/261.webm +0 -0
  10. package/assets/thumb//345/212/250/347/211/251/347/216/257/347/273/225.webm +0 -0
  11. package/assets/thumb//345/216/237/345/234/260/344/270/223/345/277/203/347/216/251/351/255/224/346/226/271.webm +0 -0
  12. package/assets/thumb//345/216/237/345/234/260/345/260/217/346/206/251/346/262/211/347/234/240.webm +0 -0
  13. package/assets/thumb//345/216/237/345/234/260/345/267/246/350/275/254/345/245/224/350/267/221.webm +0 -0
  14. package/assets/thumb//345/216/237/345/234/260/346/225/262/345/207/273/346/241/214/351/235/242/344/272/222/345/212/250.webm +0 -0
  15. package/assets/thumb//345/216/237/345/234/260/346/274/202/346/265/256/350/270/217/346/255/245.webm +0 -0
  16. package/assets/thumb//345/216/237/345/234/260/350/267/263/350/267/203/346/212/223/347/242/216/345/244/264/351/241/266/347/211/251/345/223/201.webm +0 -0
  17. package/assets/thumb//345/216/237/345/234/260/350/271/262/344/270/213/347/216/251/347/216/251/345/205/267/346/261/275/350/275/246.webm +0 -0
  18. package/assets/thumb//345/216/237/345/234/260/351/207/215/345/212/233/344/270/213/350/271/262/345/216/213/347/274/251.webm +0 -0
  19. package/assets/thumb//345/217/230/351/270/275/345/255/220.webm +0 -0
  20. package/assets/thumb//345/217/257/347/210/261/345/256/205/350/210/236.webm +0 -0
  21. package/assets/thumb//345/220/203Token.webm +0 -0
  22. package/assets/thumb//345/220/203/345/206/260/346/267/207/346/267/213/350/236/215/345/214/226.webm +0 -0
  23. package/assets/thumb//345/220/203/345/215/210/351/244/220.webm +0 -0
  24. package/assets/thumb//345/220/203/345/244/247/351/227/270/350/237/271.webm +0 -0
  25. package/assets/thumb//345/220/203/345/271/264/347/263/225.webm +0 -0
  26. package/assets/thumb//345/220/203/346/227/251/351/244/220.webm +0 -0
  27. package/assets/thumb//345/220/203/346/231/232/351/244/220.webm +0 -0
  28. package/assets/thumb//345/220/203/346/261/244/345/234/206.webm +0 -0
  29. package/assets/thumb//345/220/203/347/231/275/351/245/255.webm +0 -0
  30. package/assets/thumb//345/220/203/347/262/275/345/255/220.webm +0 -0
  31. package/assets/thumb//345/220/203/347/263/226/350/221/253/350/212/246.webm +0 -0
  32. package/assets/thumb//345/220/203/350/205/212/345/205/253/347/262/245.webm +0 -0
  33. package/assets/thumb//345/220/203/350/245/277/347/223/234.webm +0 -0
  34. package/assets/thumb//345/220/203/351/207/215/351/230/263/347/263/225.webm +0 -0
  35. package/assets/thumb//345/220/203/351/225/277/345/257/277/351/235/242.webm +0 -0
  36. package/assets/thumb//345/220/203/351/235/222/345/233/242.webm +0 -0
  37. package/assets/thumb//345/220/203/351/245/272/345/255/220.webm +0 -0
  38. package/assets/thumb//345/220/271/346/260/224/347/220/203.webm +0 -0
  39. package/assets/thumb//345/220/271/347/254/233/345/255/220.webm +0 -0
  40. package/assets/thumb//345/223/210/346/254/240/350/277/236/345/244/251.webm +0 -0
  41. package/assets/thumb//345/240/206/351/233/252/344/272/272.webm +0 -0
  42. package/assets/thumb//345/244/247/345/217/243/345/220/203/351/233/266/351/243/237.webm +0 -0
  43. package/assets/thumb//345/245/263/344/273/206/345/261/210/350/206/235/347/244/274/344/273/252.webm +0 -0
  44. package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260360/345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
  45. package/assets/thumb//345/260/217/346/217/220/347/220/264/346/274/224/345/245/217.webm +0 -0
  46. package/assets/thumb//345/276/205/346/234/272/345/221/274/345/220/270/344/274/221/351/227/262.webm +0 -0
  47. package/assets/thumb//346/202/240/351/227/262/345/223/274/346/255/214.webm +0 -0
  48. package/assets/thumb//346/211/221/345/205/213/351/255/224/346/234/257.webm +0 -0
  49. package/assets/thumb//346/211/223/347/236/214/347/235/241/350/242/253/346/203/212/351/206/222.webm +0 -0
  50. package/assets/thumb//346/212/275/351/231/200/350/236/272.webm +0 -0
  51. package/assets/thumb//346/213/206/347/244/274/347/211/251.webm +0 -0
  52. package/assets/thumb//346/217/222/350/214/261/350/220/270/350/265/217/350/217/212.webm +0 -0
  53. package/assets/thumb//346/221/207/346/211/207/347/272/263/345/207/211.webm +0 -0
  54. package/assets/thumb//346/222/270/347/214/253.webm +0 -0
  55. package/assets/thumb//346/224/266/347/272/242/345/214/205.webm +0 -0
  56. package/assets/thumb//346/224/276/345/255/224/346/230/216/347/201/257.webm +0 -0
  57. package/assets/thumb//346/224/276/346/262/263/347/201/257.webm +0 -0
  58. package/assets/thumb//346/224/276/347/203/237/350/212/261.webm +0 -0
  59. package/assets/thumb//346/224/276/351/243/216/347/255/235.webm +0 -0
  60. package/assets/thumb//346/225/264/344/275/223/346/215/242/350/243/205/350/257/225/350/211/262.webm +0 -0
  61. package/assets/thumb//346/230/257/345/225/212/357/274/214/345/220/203/344/273/200/344/271/210.webm +0 -0
  62. package/assets/thumb//346/231/250/351/227/264/345/210/267/347/211/231.webm +0 -0
  63. package/assets/thumb//346/266/256/347/201/253/351/224/205.webm +0 -0
  64. package/assets/thumb//346/267/261/345/272/246/346/200/235/350/200/203/347/242/216/347/242/216/345/277/265.webm +0 -0
  65. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/202/262/345/250/207/347/224/237/346/260/224.webm +0 -0
  66. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/205/203/346/260/224/346/214/245/346/211/213.webm +0 -0
  67. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
  68. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
  69. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/346/214/240/347/227/222/345/222/257/345/222/257/347/254/221.webm +0 -0
  70. package/assets/thumb//347/205/247/351/225/234/345/255/220.webm +0 -0
  71. package/assets/thumb//347/216/251/346/260/264/346/236/252.webm +0 -0
  72. package/assets/thumb//347/216/251/346/270/270/346/210/217/346/260/224/346/200/245/350/264/245/345/235/217.webm +0 -0
  73. package/assets/thumb//347/224/250/351/262/270/351/261/274/345/260/276/345/267/264/346/213/215/346/211/223/345/234/260/351/235/242.webm +0 -0
  74. package/assets/thumb//347/251/277/351/222/210/344/271/236/345/267/247.webm +0 -0
  75. package/assets/thumb//350/210/236/347/213/256/345/244/264.webm +0 -0
  76. package/assets/thumb//350/215/241/347/247/213/345/215/203.webm +0 -0
  77. package/assets/thumb//350/220/214/345/214/226/345/260/217/345/271/275/347/201/265.webm +0 -0
  78. package/assets/thumb//350/223/235/351/262/270/347/216/260/344/270/226.webm +0 -0
  79. package/assets/thumb//350/235/264/350/235/266/350/234/234/350/234/202/347/216/257/347/273/225/345/244/264/351/241/266/345/274/200/350/212/261.webm +0 -0
  80. package/assets/thumb//350/236/203/350/237/271/350/265/260/350/267/257.webm +0 -0
  81. package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263.webm +0 -0
  82. package/assets/thumb//350/242/253/350/220/275/345/217/266/346/267/271/346/262/241.webm +0 -0
  83. package/assets/thumb//350/242/253/351/274/240/346/240/207/346/213/226/346/213/275/346/202/254/347/251/272/345/217/215/351/246/210.webm +0 -0
  84. package/assets/thumb//350/243/205/347/202/271/345/234/243/350/257/236/346/240/221.webm +0 -0
  85. package/assets/thumb//350/256/250/347/263/226/345/215/227/347/223/234/347/201/257.webm +0 -0
  86. package/assets/thumb//350/266/205/345/244/247/344/274/270/346/207/222/350/205/260.webm +0 -0
  87. package/assets/thumb//350/270/242/346/257/275/345/255/220.webm +0 -0
  88. package/assets/thumb//350/275/273/345/277/253/346/221/207/346/221/206/350/210/236.webm +0 -0
  89. package/assets/thumb//350/275/273/345/277/253/350/256/260/345/275/225.webm +0 -0
  90. package/assets/thumb//351/252/221/346/234/250/351/251/254.webm +0 -0
  91. package/assets/thumb//351/262/270/351/261/274/345/220/220/346/263/241/346/263/241/347/211/271/346/225/210.webm +0 -0
  92. package/cordis.patch.yml +6 -0
  93. package/lib/client.js +45 -0
  94. package/lib/index.js +18 -0
  95. package/lib/types/client/index.d.ts +6 -0
  96. package/lib/types/index.d.ts +12 -0
  97. package/package.json +1 -1
  98. package/runtime/electron-helper/renderer.js +449 -38
  99. package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260 360 /345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
  100. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/202/262/345/250/207/347/224/237/346/260/224/357/274/210/344/276/247/350/272/253/345/261/225/347/244/272/357/274/211.webm +0 -0
  101. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
  102. package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
  103. package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263/357/274/210/347/202/270/346/257/233/357/274/211.webm +0 -0
  104. package/lib/index.js.bak-20260819-104008 +0 -483
@@ -18,6 +18,12 @@ const CONFIG = {
18
18
  workMinutes: Number(params.get('workMinutes') || '25'),
19
19
  breakMinutes: Number(params.get('breakMinutes') || '5'),
20
20
  roastEnabled: params.get('roastEnabled') === '1',
21
+ walkEnabled: params.get('walkEnabled') !== '0',
22
+ enabledActions: [],
23
+ actionOrder: [],
24
+ petSize: Number(params.get('petSize') || '460'),
25
+ moveChance: Number(params.get('moveChance') || '20'),
26
+ actionDelayMs: Number(params.get('actionDelayMs') || '0'),
21
27
  }
22
28
 
23
29
  // ---------- 资源根 ----------
@@ -33,15 +39,23 @@ const IDLE = '待机呼吸休闲'
33
39
  const TURN = '东张西望'
34
40
  const DRAG = '被鼠标拖拽悬空反馈'
35
41
  const ACTS = [
36
- '悠闲哼歌', '超大伸懒腰', '原地专心玩魔方', '原地敲击桌面互动',
37
- '原地重力下蹲压缩', '哈欠连天', '原地小憩沉眠', '原地蹲下玩玩具汽车',
38
- '鲸鱼吐泡泡特效', '女仆屈膝礼仪', '被吓一跳(炸毛)', '原地跳跃抓碎头顶物品',
39
- '小幅度原地 360 度旋转展示', '偷吃零食被抓住', '玩游戏气急败坏',
40
- '用鲸鱼尾巴拍打地面', '打瞌睡被惊醒', '玩水枪', '小提琴演奏', '蓝鲸现世',
41
- '吃白饭', '照镜子', '优雅女仆舞', '轻快摇摆舞', '可爱宅舞', '整体换装试色',
42
- '大口吃零食', '吹气球', '动物环绕', '深度思考碎碎念', '轻快记录', '写代码',
43
- '吃Token', '吃早餐', '吃午餐', '吃晚餐', '放风筝', '摇扇纳凉', '吃冰淇淋融化',
44
- '被落叶淹没', '中秋赏月吃月饼', '堆雪人',
42
+ '被落叶淹没', '被吓一跳', '变鸽子', '插茱萸赏菊', '拆礼物',
43
+ '超大伸懒腰', '晨间刷牙', '吃Token', '吃白饭', '吃冰淇淋融化',
44
+ '吃大闸蟹', '吃饺子', '吃腊八粥', '吃年糕', '吃青团',
45
+ '吃汤圆', '吃糖葫芦', '吃晚餐', '吃午餐', '吃西瓜',
46
+ '吃早餐', '吃长寿面', '吃重阳糕', '吃粽子', '抽陀螺',
47
+ '穿针乞巧', '吹笛子', '吹气球', '打瞌睡被惊醒', '大口吃零食',
48
+ '荡秋千', '动物环绕', '堆雪人', '放风筝', '放河灯',
49
+ '放孔明灯', '放烟花', '哈欠连天', '蝴蝶蜜蜂环绕头顶开花', '鲸鱼吐泡泡特效',
50
+ '可爱宅舞', '蓝鲸现世', '撸猫', '萌化小幽灵', '女仆屈膝礼仪',
51
+ '凭空生花', '扑克魔术', '骑木马', '轻快记录', '轻快摇摆舞',
52
+ '三球抛接', '深度思考碎碎念', '是啊,吃什么', '收红包', '涮火锅',
53
+ '讨糖南瓜灯', '踢毽子', '偷吃零食被抓住', '玩水枪', '玩游戏气急败坏',
54
+ '舞狮头', '下五子棋', '小幅度原地360度旋转展示', '小提琴演奏', '写代码',
55
+ '写福字', '摇扇纳凉', '用鲸鱼尾巴拍打地面', '优雅女仆舞', '悠闲哼歌',
56
+ '原地蹲下玩玩具汽车', '原地敲击桌面互动', '原地跳跃抓碎头顶物品', '原地小憩沉眠',
57
+ '原地重力下蹲压缩', '原地专心玩魔方', '照镜子', '整体换装试色',
58
+ '中秋赏月吃月饼', '装点圣诞树',
45
59
  ]
46
60
  const ACTION_COPY = {
47
61
  '东张西望': '大肥鱼东张西望,看看有没有鱼干~',
@@ -55,9 +69,9 @@ const ACTION_COPY = {
55
69
  '原地蹲下玩玩具汽车': '大肥鱼蹲在地上玩小汽车~',
56
70
  '鲸鱼吐泡泡特效': '大肥鱼吐出一串可爱的泡泡~',
57
71
  '女仆屈膝礼仪': '大肥鱼向你行了个女仆礼~',
58
- '被吓一跳(炸毛)': '大肥鱼被吓得炸毛啦!',
72
+ '被吓一跳': '大肥鱼被吓得炸毛啦!',
59
73
  '原地跳跃抓碎头顶物品': '大肥鱼跳起来抓碎了头顶的东西~',
60
- '小幅度原地 360 度旋转展示': '大肥鱼原地转圈圈展示自己~',
74
+ '小幅度原地360度旋转展示': '大肥鱼原地转圈圈展示自己~',
61
75
  '偷吃零食被抓住': '大肥鱼偷吃零食被抓住啦!',
62
76
  '玩游戏气急败坏': '大肥鱼玩游戏玩到气急败坏~',
63
77
  '用鲸鱼尾巴拍打地面': '大肥鱼用尾巴拍地面抗议~',
@@ -87,22 +101,33 @@ const ACTION_COPY = {
87
101
  '被落叶淹没': '大肥鱼被落叶埋住啦~',
88
102
  '中秋赏月吃月饼': '大肥鱼中秋赏月吃月饼~',
89
103
  '堆雪人': '大肥鱼在堆雪人~',
104
+ '螃蟹走路': '大肥鱼横着走路,超嚣张~',
105
+ '原地漂浮踏步': '大肥鱼原地踏步漂浮中~',
106
+ '原地左转奔跑': '大肥鱼向左奔跑!',
90
107
  }
91
- const CLICKS = ['点击回应 - 开心跃动', '点击回应 - 害羞惊讶', '点击回应 - 傲娇生气(侧身展示)']
108
+ const CLICKS = ['点击回应-开心跃动', '点击回应-害羞惊讶', '点击回应-傲娇生气', '点击回应-挠痒咯咯笑', '点击回应-元气挥手']
92
109
  const CLICK_COPY = {
93
- '点击回应 - 开心跃动': '大肥鱼被摸得好开心~',
94
- '点击回应 - 害羞惊讶': '大肥鱼害羞地躲了一下~',
95
- '点击回应 - 傲娇生气(侧身展示)': '大肥鱼傲娇地哼了一声!',
110
+ '点击回应-开心跃动': '大肥鱼被摸得好开心~',
111
+ '点击回应-害羞惊讶': '大肥鱼害羞地躲了一下~',
112
+ '点击回应-傲娇生气': '大肥鱼傲娇地哼了一声!',
113
+ '点击回应-挠痒咯咯笑': '大肥鱼被挠痒痒,咯咯笑~',
114
+ '点击回应-元气挥手': '大肥鱼元气满满地挥手~',
96
115
  }
97
116
  const EAT_ANIMS = ['吃白饭', '吃早餐', '吃午餐', '吃晚餐', '大口吃零食', '吃Token', '吃冰淇淋融化', '偷吃零食被抓住']
98
117
  const MOVES = ['螃蟹走路', '原地漂浮踏步', '原地左转奔跑']
118
+ // 每个走动动画的“开头不动/结尾不动”时长(秒),按动作实际节奏微调。
119
+ const MOVE_TIMING = {
120
+ '原地漂浮踏步': { lead: 0.83, tail: 0.83 },
121
+ '螃蟹走路': { lead: 1, tail: 2 },
122
+ '原地左转奔跑': { lead: 1.67, tail: 5.58 },
123
+ }
99
124
  const STATE_ANIMS = {
100
125
  IDLE: [IDLE],
101
126
  THINKING: ['深度思考碎碎念', '原地专心玩魔方', '东张西望'],
102
127
  WORKING: ['写代码', '轻快记录', '原地敲击桌面互动', '吃Token'],
103
128
  WAITING: ['东张西望', '悠闲哼歌', '原地敲击桌面互动'],
104
- SUCCESS: ['点击回应 - 开心跃动', '优雅女仆舞', '轻快摇摆舞', '可爱宅舞', '女仆屈膝礼仪'],
105
- ERROR: ['被吓一跳(炸毛)', '玩游戏气急败坏', '偷吃零食被抓住'],
129
+ SUCCESS: ['点击回应-开心跃动', '优雅女仆舞', '轻快摇摆舞', '可爱宅舞', '女仆屈膝礼仪'],
130
+ ERROR: ['被吓一跳', '玩游戏气急败坏', '偷吃零食被抓住'],
106
131
  }
107
132
 
108
133
  // ---------- DOM ----------
@@ -117,13 +142,23 @@ const bubbleDetail = document.getElementById('bubble-detail')
117
142
  const menuEl = document.getElementById('menu')
118
143
 
119
144
  // ---------- 基础尺寸 ----------
120
- const size = 462 * CONFIG.scale
121
- const halfW = size / 2
122
- const halfH = size * 9 / 16 / 2
123
- const bottomPad = (size * 9 / 16 * (CANVAS_H - FEET_Y)) / CANVAS_H
124
- stageEl.style.width = size + 'px'
125
- stageEl.style.height = (size * 9 / 16) + 'px'
126
- stageEl.style.transform = `translateY(${bottomPad}px)`
145
+ let size = (CONFIG.petSize || 460) * CONFIG.scale
146
+ let halfW = size / 2
147
+ let halfH = size * 9 / 16 / 2
148
+ let bottomPad = (size * 9 / 16 * (CANVAS_H - FEET_Y)) / CANVAS_H
149
+ function applySize() {
150
+ size = (CONFIG.petSize || 460) * CONFIG.scale
151
+ halfW = size / 2
152
+ halfH = size * 9 / 16 / 2
153
+ bottomPad = (size * 9 / 16 * (CANVAS_H - FEET_Y)) / CANVAS_H
154
+ stageEl.style.width = size + 'px'
155
+ stageEl.style.height = (size * 9 / 16) + 'px'
156
+ stageEl.style.transform = `translateY(${bottomPad}px)`
157
+ // 尺寸变化后把位置夹回屏幕内。
158
+ petPos.x = Math.min(Math.max(petPos.x, -(HIT_BOX.x0 / 640 * size)), window.innerWidth - (HIT_BOX.x1 / 640 * size))
159
+ petPos.y = Math.min(Math.max(petPos.y, 0), window.innerHeight - size * 9 / 16)
160
+ applyPetPosition()
161
+ }
127
162
  hitEl.style.left = (HIT_BOX.x0 / 640 * 100) + '%'
128
163
  hitEl.style.top = (HIT_BOX.y0 / 360 * 100) + '%'
129
164
  hitEl.style.width = ((HIT_BOX.x1 - HIT_BOX.x0) / 640 * 100) + '%'
@@ -145,6 +180,7 @@ function applyPetPosition() {
145
180
  rootEl.style.transform = 'none'
146
181
  }
147
182
  applyPetPosition()
183
+ applySize()
148
184
 
149
185
  // ---------- 状态 ----------
150
186
  let front = 0 // 0 = A, 1 = B
@@ -178,6 +214,11 @@ let pomodoro = null
178
214
  let pomodoroTimer = null
179
215
  let menuPage = 'main'
180
216
  let lastMenuPos = { x: 0, y: 0 }
217
+ let moveRef = null
218
+ let moveToken = 0
219
+ let movePlan = null
220
+ let actionOrderIndex = 0
221
+ let idleDelayTimer = null
181
222
 
182
223
  // ---------- 工具 ----------
183
224
  const randomBetween = (min, max) => Math.floor(min + Math.random() * (max - min))
@@ -228,6 +269,8 @@ function switchTo(next, { once = true, loop = false } = {}) {
228
269
  pending = null
229
270
  el.style.transform = facing === 'right' ? 'scaleX(-1)' : ''
230
271
  el.play().catch(() => {})
272
+ // 走动动画加载完成后,用真实视频时长驱动移动。
273
+ if (currentMode === 'move' && movePlan) startMoveDrive()
231
274
  }
232
275
  el.addEventListener('loadeddata', onReady)
233
276
  if (el.readyState >= 2) onReady()
@@ -235,30 +278,61 @@ function switchTo(next, { once = true, loop = false } = {}) {
235
278
 
236
279
  // ---------- 播放控制 ----------
237
280
  function playIdle() {
281
+ clearIdleDelay()
282
+ stopMove()
238
283
  currentMode = 'idle'
239
- const roll = Math.random()
284
+ // 自定义动作池:设置了 enabledActions 时只从这些动作里选。
285
+ const actionPool = CONFIG.enabledActions.length > 0
286
+ ? ACTS.filter((name) => CONFIG.enabledActions.includes(name))
287
+ : ACTS
288
+ const usableActions = actionPool.length > 0 ? actionPool : ACTS
289
+ // 自定义播放顺序:非空时按顺序循环播放。
290
+ const order = CONFIG.actionOrder.length > 0
291
+ ? CONFIG.actionOrder.filter((name) => ACTS.includes(name) || MOVES.includes(name) || name === TURN)
292
+ : []
240
293
  let next = IDLE
241
- if (roll < 0.3) {
242
- next = IDLE
243
- } else if (roll < 0.4) {
244
- next = TURN
245
- } else if (roll < 0.8) {
246
- next = pick(ACTS, anim)
294
+ let isMove = false
295
+ if (order.length > 0) {
296
+ next = order[actionOrderIndex % order.length]
297
+ actionOrderIndex++
298
+ if (MOVES.includes(next) && CONFIG.walkEnabled && tryMove(next)) isMove = true
247
299
  } else {
248
- next = pick(ACTS, anim) // 桌面版暂不实现自动漫游,避免窗口移动过于复杂
300
+ const roll = Math.random()
301
+ if (roll < 0.3) {
302
+ next = IDLE
303
+ } else if (roll < 0.4) {
304
+ next = TURN
305
+ } else if (roll < 0.8) {
306
+ next = pick(usableActions, anim)
307
+ } else {
308
+ // 按“移动频繁度”概率尝试走动(可关闭);空间不够或关闭时退回随机动作。
309
+ const moveCandidate = pick(MOVES, anim)
310
+ if (CONFIG.walkEnabled && Math.random() * 100 < CONFIG.moveChance && tryMove(moveCandidate)) {
311
+ next = moveCandidate
312
+ isMove = true
313
+ } else {
314
+ next = pick(usableActions, anim)
315
+ }
316
+ }
249
317
  }
250
318
  anim = next
251
319
  animOnce = true
252
320
  animLoop = false
253
321
  switchTo(next, { once: true })
254
- // 随机动作播放时,给出与动作匹配的可爱气泡描述。
322
+ if (isMove) {
323
+ currentMode = 'move'
324
+ // 移动驱动在视频加载完成后启动(switchTo onReady 里调用),
325
+ // 这样可以使用视频真实时长,避免动画还没播完就提前停下。
326
+ }
327
+ // 随机动作/走动播放时,给出与动作匹配的可爱气泡描述。
255
328
  if (next !== IDLE) {
256
- const copy = ACTION_COPY[next] || '大肥鱼正在表演小动作~'
329
+ const copy = ACTION_COPY[next] || `大肥鱼正在${next}~`
257
330
  showManualBubble(copy, '大肥鱼的小剧场~', 4200)
258
331
  }
259
332
  }
260
333
 
261
334
  function playState(state, { pulse = false } = {}) {
335
+ stopMove()
262
336
  currentMode = pulse ? 'pulse' : 'state'
263
337
  const pool = STATE_ANIMS[state] || STATE_ANIMS.IDLE
264
338
  const next = state === 'IDLE' ? IDLE : pick(pool, anim)
@@ -270,6 +344,7 @@ function playState(state, { pulse = false } = {}) {
270
344
  }
271
345
 
272
346
  function playClick() {
347
+ stopMove()
273
348
  currentMode = 'click'
274
349
  const next = pick(CLICKS, anim)
275
350
  anim = next
@@ -280,6 +355,7 @@ function playClick() {
280
355
  }
281
356
 
282
357
  function playDrag() {
358
+ stopMove()
283
359
  currentMode = 'drag'
284
360
  anim = DRAG
285
361
  animOnce = true
@@ -287,6 +363,100 @@ function playDrag() {
287
363
  switchTo(DRAG, { once: true })
288
364
  }
289
365
 
366
+ // ---------- 走动效果 ----------
367
+ function tryMove(moveName) {
368
+ if (moveRef !== null || movePlan) return true
369
+ const W = window.innerWidth
370
+ const H = window.innerHeight
371
+ const minX = -(HIT_BOX.x0 / 640 * size)
372
+ const maxX = W - (HIT_BOX.x1 / 640 * size)
373
+ const minY = 0
374
+ const maxY = H - size * 9 / 16
375
+
376
+ // “原地漂浮踏步”面朝观众,适合稍微向屏幕下方(朝用户)移动一点。
377
+ if (moveName === '原地漂浮踏步') {
378
+ const distance = randomBetween(40, 90)
379
+ const targetY = petPos.y + distance
380
+ if (targetY > maxY) return false
381
+ movePlan = { startX: petPos.x, targetX: petPos.x, startY: petPos.y, targetY }
382
+ return true
383
+ }
384
+
385
+ const dir = Math.random() < 0.5 ? -1 : 1
386
+ const distance = randomBetween(200, 450)
387
+ const targetX = petPos.x + dir * distance
388
+ if (targetX < minX || targetX > maxX) return false
389
+ // 让角色面朝移动方向,避免“向左跑却镜像成向右”的错乱。
390
+ facing = dir > 0 ? 'right' : 'left'
391
+ movePlan = { startX: petPos.x, targetX, startY: petPos.y, targetY: petPos.y }
392
+ return true
393
+ }
394
+
395
+ function startMoveDrive() {
396
+ if (!movePlan) return
397
+ const plan = movePlan
398
+ const el = currentVideo()
399
+ const duration = Number.isFinite(el?.duration) && el.duration > 0 ? el.duration : 9
400
+ // 每个动作的“开头不动/结尾不动”时长不同,按动作单独配置。
401
+ const timing = MOVE_TIMING[anim] || { lead: 1.5, tail: 2 }
402
+ const lead = timing.lead
403
+ const tail = timing.tail
404
+ const travelWindow = Math.max(0.1, duration - lead - tail)
405
+ const token = ++moveToken
406
+ const step = () => {
407
+ if (moveToken !== token || !movePlan) return
408
+ const t = el.currentTime || 0
409
+ let x = plan.startX
410
+ let y = plan.startY ?? petPos.y
411
+ if (t > lead && t < duration - tail) {
412
+ const progress = Math.min(1, Math.max(0, (t - lead) / travelWindow))
413
+ x = plan.startX + (plan.targetX - plan.startX) * progress
414
+ y = (plan.startY ?? petPos.y) + ((plan.targetY ?? petPos.y) - (plan.startY ?? petPos.y)) * progress
415
+ } else if (t >= duration - tail) {
416
+ x = plan.targetX
417
+ y = plan.targetY ?? petPos.y
418
+ }
419
+ petPos.x = x
420
+ petPos.y = y
421
+ applyPetPosition()
422
+ if (t < duration - tail) {
423
+ moveRef = requestAnimationFrame(step)
424
+ } else {
425
+ moveRef = null
426
+ movePlan = null
427
+ }
428
+ }
429
+ moveRef = requestAnimationFrame(step)
430
+ }
431
+
432
+ function stopMove() {
433
+ movePlan = null
434
+ moveToken++
435
+ if (moveRef !== null) {
436
+ cancelAnimationFrame(moveRef)
437
+ moveRef = null
438
+ }
439
+ }
440
+
441
+ function clearIdleDelay() {
442
+ if (idleDelayTimer) {
443
+ clearTimeout(idleDelayTimer)
444
+ idleDelayTimer = null
445
+ }
446
+ }
447
+
448
+ function scheduleNextIdle() {
449
+ clearIdleDelay()
450
+ if (CONFIG.actionDelayMs > 0) {
451
+ idleDelayTimer = setTimeout(() => {
452
+ idleDelayTimer = null
453
+ playIdle()
454
+ }, CONFIG.actionDelayMs)
455
+ } else {
456
+ playIdle()
457
+ }
458
+ }
459
+
290
460
  function handleEnded() {
291
461
  if (dragging || dragState.active) return
292
462
  if (overlay && overlay.state) {
@@ -301,19 +471,24 @@ function handleEnded() {
301
471
  applyResume()
302
472
  return
303
473
  }
474
+ if (currentMode === 'move') {
475
+ stopMove()
476
+ scheduleNextIdle()
477
+ return
478
+ }
304
479
  if (currentMode === 'state') {
305
480
  const state = overlay ? overlay.state : currentState
306
481
  if (state && state !== 'IDLE') {
307
482
  playState(state)
308
483
  return
309
484
  }
310
- playIdle()
485
+ scheduleNextIdle()
311
486
  return
312
487
  }
313
488
  if (anim === TURN) {
314
489
  facing = facing === 'left' ? 'right' : 'left'
315
490
  }
316
- playIdle()
491
+ scheduleNextIdle()
317
492
  }
318
493
 
319
494
  function applyResume() {
@@ -584,6 +759,7 @@ document.addEventListener('mousemove', (e) => {
584
759
  })
585
760
 
586
761
  function startDrag(e) {
762
+ stopMove()
587
763
  e.currentTarget.classList.add('dragging')
588
764
  try { e.currentTarget.setPointerCapture(e.pointerId) } catch { /* 忽略捕获失败 */ }
589
765
  dragState = {
@@ -677,12 +853,25 @@ function showMenu(x, y) {
677
853
  menuEl.innerHTML = ''
678
854
  if (menuPage === 'pomodoro') {
679
855
  renderPomodoroSettings()
856
+ } else if (menuPage === 'actions') {
857
+ renderActionSettings()
858
+ } else if (menuPage === 'appearance') {
859
+ renderAppearanceSettings()
680
860
  } else {
681
861
  renderMainMenu()
682
862
  }
683
- menuEl.style.left = Math.min(x, window.innerWidth - 180) + 'px'
684
- menuEl.style.top = Math.min(y, window.innerHeight - 200) + 'px'
863
+ // 外层菜单不滚动,动作列表等长内容由内部子面板自己滚动,避免出现双滚动条。
864
+ menuEl.style.maxHeight = 'none'
865
+ menuEl.style.overflowY = 'visible'
685
866
  menuEl.classList.add('visible')
867
+ // 让菜单向右上方展开,避开宠物模型;再根据实际尺寸夹在屏幕内。
868
+ const rect = menuEl.getBoundingClientRect()
869
+ let left = x + 24
870
+ let top = y - rect.height - 12
871
+ left = Math.max(4, Math.min(left, window.innerWidth - rect.width - 4))
872
+ top = Math.max(4, Math.min(top, window.innerHeight - rect.height - 4))
873
+ menuEl.style.left = left + 'px'
874
+ menuEl.style.top = top + 'px'
686
875
  window.petBridge.setIgnoreMouse(false)
687
876
  }
688
877
 
@@ -713,6 +902,30 @@ function renderMainMenu() {
713
902
  menuPage = 'pomodoro'
714
903
  showMenu(lastMenuPos.x, lastMenuPos.y)
715
904
  })
905
+ addMenuButton('行为设置', () => {
906
+ menuPage = 'appearance'
907
+ showMenu(lastMenuPos.x, lastMenuPos.y)
908
+ })
909
+ // 选择待机动作:鼠标悬停展开,移开自动关闭。
910
+ const actionWrap = document.createElement('div')
911
+ actionWrap.style.cssText = 'position:static'
912
+ const actionBtn = document.createElement('button')
913
+ actionBtn.textContent = '选择待机动作'
914
+ const actionFlyout = document.createElement('div')
915
+ actionFlyout.style.cssText = 'margin-top:4px;background:#fff;border:1px solid #e3e5e8;border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.18);padding:8px;max-height:70vh;overflow-y:auto;display:none'
916
+ actionBtn.addEventListener('mouseenter', () => {
917
+ renderActionFlyoutContent(actionFlyout)
918
+ actionFlyout.style.display = 'block'
919
+ })
920
+ actionWrap.addEventListener('mouseleave', (e) => {
921
+ if (!actionFlyout.contains(e.relatedTarget)) actionFlyout.style.display = 'none'
922
+ })
923
+ actionFlyout.addEventListener('mouseleave', (e) => {
924
+ if (!actionWrap.contains(e.relatedTarget)) actionFlyout.style.display = 'none'
925
+ })
926
+ actionWrap.appendChild(actionBtn)
927
+ actionWrap.appendChild(actionFlyout)
928
+ menuEl.appendChild(actionWrap)
716
929
  addMenuButton(CONFIG.roastEnabled ? '关闭自动吐槽' : '开启自动吐槽', () => {
717
930
  const next = !CONFIG.roastEnabled
718
931
  CONFIG.roastEnabled = next
@@ -720,6 +933,13 @@ function renderMainMenu() {
720
933
  menuEl.classList.remove('visible')
721
934
  updateClickThrough()
722
935
  })
936
+ addMenuButton(CONFIG.walkEnabled ? '关闭行走' : '开启行走', () => {
937
+ const next = !CONFIG.walkEnabled
938
+ CONFIG.walkEnabled = next
939
+ window.petBridge.saveConfig({ walkEnabled: next })
940
+ menuEl.classList.remove('visible')
941
+ updateClickThrough()
942
+ })
723
943
  addMenuButton('让大肥鱼吐槽一下', () => {
724
944
  menuEl.classList.remove('visible')
725
945
  updateClickThrough()
@@ -743,6 +963,10 @@ function renderMainMenu() {
743
963
  }
744
964
 
745
965
  function renderPomodoroSettings() {
966
+ addMenuButton('← 返回主菜单', () => {
967
+ menuPage = 'main'
968
+ showMenu(lastMenuPos.x, lastMenuPos.y)
969
+ })
746
970
  const workInput = document.createElement('input')
747
971
  workInput.type = 'number'
748
972
  workInput.min = 1
@@ -784,6 +1008,185 @@ function renderPomodoroSettings() {
784
1008
  })
785
1009
  }
786
1010
 
1011
+ function renderAppearanceSettings() {
1012
+ addMenuButton('← 返回主菜单', () => {
1013
+ menuPage = 'main'
1014
+ showMenu(lastMenuPos.x, lastMenuPos.y)
1015
+ })
1016
+
1017
+ const sizeInput = document.createElement('input')
1018
+ sizeInput.type = 'number'
1019
+ sizeInput.min = 100
1020
+ sizeInput.max = 1000
1021
+ sizeInput.step = 10
1022
+ sizeInput.value = String(CONFIG.petSize)
1023
+ sizeInput.style.width = '80px'
1024
+
1025
+ const moveInput = document.createElement('input')
1026
+ moveInput.type = 'range'
1027
+ moveInput.min = 0
1028
+ moveInput.max = 100
1029
+ moveInput.step = 1
1030
+ moveInput.value = String(CONFIG.moveChance)
1031
+ moveInput.style.width = '120px'
1032
+
1033
+ const delayInput = document.createElement('input')
1034
+ delayInput.type = 'range'
1035
+ delayInput.min = 0
1036
+ delayInput.max = 5000
1037
+ delayInput.step = 100
1038
+ delayInput.value = String(CONFIG.actionDelayMs)
1039
+ delayInput.style.width = '120px'
1040
+
1041
+ const row = (label, input, hint) => {
1042
+ const div = document.createElement('div')
1043
+ div.style.cssText = 'display:flex;justify-content:space-between;align-items:center;gap:8px;padding:4px 0;font-size:12px'
1044
+ const left = document.createElement('span')
1045
+ left.textContent = label
1046
+ div.append(left, input)
1047
+ if (hint) {
1048
+ const small = document.createElement('small')
1049
+ small.textContent = hint
1050
+ small.style.cssText = 'display:block;opacity:.65;font-size:11px'
1051
+ div.appendChild(small)
1052
+ }
1053
+ return div
1054
+ }
1055
+
1056
+ menuEl.append(
1057
+ row('宠物宽度(px)', sizeInput, '重启后生效'),
1058
+ row(`移动频繁度 ${moveInput.value}%`, moveInput),
1059
+ row(`动作切换间隔 ${delayInput.value}ms`, delayInput),
1060
+ )
1061
+ moveInput.addEventListener('input', () => {
1062
+ const label = moveInput.parentElement
1063
+ label.firstChild.textContent = `移动频繁度 ${moveInput.value}%`
1064
+ })
1065
+ delayInput.addEventListener('input', () => {
1066
+ const label = delayInput.parentElement
1067
+ label.firstChild.textContent = `动作切换间隔 ${delayInput.value}ms`
1068
+ })
1069
+
1070
+ addMenuButton('保存', () => {
1071
+ CONFIG.petSize = Math.min(1000, Math.max(100, Math.round(Number(sizeInput.value) / 10) * 10 || 460))
1072
+ CONFIG.moveChance = Math.min(100, Math.max(0, Number(moveInput.value) || 0))
1073
+ CONFIG.actionDelayMs = Math.min(5000, Math.max(0, Number(delayInput.value) || 0))
1074
+ window.petBridge.saveConfig({
1075
+ petSize: CONFIG.petSize,
1076
+ moveChance: CONFIG.moveChance,
1077
+ actionDelayMs: CONFIG.actionDelayMs,
1078
+ })
1079
+ menuPage = 'main'
1080
+ menuEl.classList.remove('visible')
1081
+ updateClickThrough()
1082
+ })
1083
+ addMenuButton('返回', () => {
1084
+ menuPage = 'main'
1085
+ showMenu(lastMenuPos.x, lastMenuPos.y)
1086
+ })
1087
+ }
1088
+
1089
+ function renderActionSettings() {
1090
+ // 空数组 = 全部动作,所以 UI 里初始化为全选。
1091
+ addMenuButton('← 返回主菜单', () => {
1092
+ menuPage = 'main'
1093
+ showMenu(lastMenuPos.x, lastMenuPos.y)
1094
+ })
1095
+ const working = CONFIG.enabledActions.length > 0 ? CONFIG.enabledActions.slice() : ACTS.slice()
1096
+ const list = document.createElement('div')
1097
+ list.style.cssText = 'max-height:70vh;overflow-y:auto;margin:4px 0'
1098
+
1099
+ const addToggle = (name) => {
1100
+ const label = document.createElement('label')
1101
+ label.style.cssText = 'display:flex;align-items:center;gap:6px;padding:2px 0;font-size:12px;cursor:pointer'
1102
+ const checkbox = document.createElement('input')
1103
+ checkbox.type = 'checkbox'
1104
+ checkbox.checked = working.includes(name)
1105
+ checkbox.addEventListener('change', () => {
1106
+ if (checkbox.checked) {
1107
+ if (!working.includes(name)) working.push(name)
1108
+ } else {
1109
+ const index = working.indexOf(name)
1110
+ if (index >= 0) working.splice(index, 1)
1111
+ }
1112
+ })
1113
+ label.append(checkbox, name)
1114
+ list.appendChild(label)
1115
+ }
1116
+
1117
+ ACTS.forEach(addToggle)
1118
+ menuEl.append(list)
1119
+
1120
+ addMenuButton('全部动作', () => {
1121
+ working.length = 0
1122
+ working.push(...ACTS)
1123
+ for (const input of list.querySelectorAll('input')) input.checked = true
1124
+ })
1125
+ addMenuButton('保存', () => {
1126
+ // 全选时保存空数组 = 全部动作;否则保存勾选子集。
1127
+ const next = working.length === ACTS.length ? [] : working.slice()
1128
+ CONFIG.enabledActions = next
1129
+ window.petBridge.saveConfig({ enabledActions: next })
1130
+ menuPage = 'main'
1131
+ menuEl.classList.remove('visible')
1132
+ updateClickThrough()
1133
+ })
1134
+ addMenuButton('返回', () => {
1135
+ menuPage = 'main'
1136
+ showMenu(lastMenuPos.x, lastMenuPos.y)
1137
+ })
1138
+ }
1139
+
1140
+ function renderActionFlyoutContent(panel) {
1141
+ panel.innerHTML = ''
1142
+ const working = CONFIG.enabledActions.length > 0 ? CONFIG.enabledActions.slice() : ACTS.slice()
1143
+ const list = document.createElement('div')
1144
+ list.style.cssText = 'max-height:60vh;overflow-y:auto;margin:2px 0'
1145
+ ACTS.forEach((name) => {
1146
+ const label = document.createElement('label')
1147
+ label.style.cssText = 'display:flex;align-items:center;gap:6px;padding:2px 0;font-size:12px;cursor:pointer'
1148
+ const checkbox = document.createElement('input')
1149
+ checkbox.type = 'checkbox'
1150
+ checkbox.checked = working.includes(name)
1151
+ checkbox.addEventListener('change', () => {
1152
+ if (checkbox.checked) {
1153
+ if (!working.includes(name)) working.push(name)
1154
+ } else {
1155
+ const index = working.indexOf(name)
1156
+ if (index >= 0) working.splice(index, 1)
1157
+ }
1158
+ })
1159
+ label.append(checkbox, name)
1160
+ list.appendChild(label)
1161
+ })
1162
+ panel.appendChild(list)
1163
+
1164
+ const row = document.createElement('div')
1165
+ row.style.cssText = 'display:flex;gap:6px;margin-top:4px'
1166
+ const allBtn = document.createElement('button')
1167
+ allBtn.textContent = '全部动作'
1168
+ allBtn.addEventListener('click', () => {
1169
+ working.length = 0
1170
+ working.push(...ACTS)
1171
+ for (const input of panel.querySelectorAll('input')) input.checked = true
1172
+ })
1173
+ const saveBtn = document.createElement('button')
1174
+ saveBtn.textContent = '保存'
1175
+ saveBtn.addEventListener('click', () => {
1176
+ const next = working.length === ACTS.length ? [] : working.slice()
1177
+ CONFIG.enabledActions = next
1178
+ window.petBridge.saveConfig({ enabledActions: next })
1179
+ panel.style.display = 'none'
1180
+ })
1181
+ const closeBtn = document.createElement('button')
1182
+ closeBtn.textContent = '关闭'
1183
+ closeBtn.addEventListener('click', () => {
1184
+ panel.style.display = 'none'
1185
+ })
1186
+ row.append(allBtn, saveBtn, closeBtn)
1187
+ panel.appendChild(row)
1188
+ }
1189
+
787
1190
  document.addEventListener('click', (e) => {
788
1191
  if (!menuEl.contains(e.target)) {
789
1192
  menuEl.classList.remove('visible')
@@ -804,6 +1207,14 @@ function applyStatus(incoming) {
804
1207
  CONFIG.workMinutes = Number(incoming.config.workMinutes) || CONFIG.workMinutes
805
1208
  CONFIG.breakMinutes = Number(incoming.config.breakMinutes) || CONFIG.breakMinutes
806
1209
  CONFIG.roastEnabled = incoming.config.roastEnabled === true
1210
+ CONFIG.walkEnabled = incoming.config.walkEnabled !== false
1211
+ CONFIG.enabledActions = Array.isArray(incoming.config.enabledActions) ? incoming.config.enabledActions : []
1212
+ CONFIG.actionOrder = Array.isArray(incoming.config.actionOrder) ? incoming.config.actionOrder : []
1213
+ CONFIG.petSize = Number(incoming.config.petSize) || CONFIG.petSize
1214
+ CONFIG.moveChance = Number(incoming.config.moveChance) ?? CONFIG.moveChance
1215
+ CONFIG.actionDelayMs = Number(incoming.config.actionDelayMs) ?? CONFIG.actionDelayMs
1216
+ CONFIG.scale = Number(incoming.config.scale) || CONFIG.scale
1217
+ applySize()
807
1218
  }
808
1219
 
809
1220
  if (incoming.tokenUsage) {