@vincentbanana/banana-gui 1.0.13 → 1.0.14

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 (3) hide show
  1. package/package.json +2 -2
  2. package/ui/app.js +86 -1
  3. package/ui/style.css +67 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/banana-gui",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Banana 鐨勫浘褰㈢晫闈細鏈湴鏈嶅姟 + 娴忚鍣ㄣ€傞粦鐧戒富棰橈紝鑷粯鍥炬爣锛屾棤绗笁鏂?UI 渚濊禆",
5
5
  "type": "module",
6
6
  "engines": {
@@ -72,7 +72,7 @@
72
72
  "electron-builder": "^25.0.0"
73
73
  },
74
74
  "dependencies": {
75
- "@vincentbanana/bananacli": "^0.8.13"
75
+ "@vincentbanana/bananacli": "^0.8.14"
76
76
  },
77
77
  "license": "MIT",
78
78
  "publishConfig": {
package/ui/app.js CHANGED
@@ -555,6 +555,57 @@ function prefersReducedMotion() {
555
555
  );
556
556
  }
557
557
 
558
+ // ---------------- 灵动动效 ----------------
559
+ const MOTION_KEY = 'banana.motion';
560
+ const MOTION_LEVEL_KEY = 'banana.motion.level';
561
+ const MOTION_LEVELS = ['subtle', 'natural', 'playful'];
562
+
563
+ function motionOn() {
564
+ try {
565
+ return localStorage.getItem(MOTION_KEY) === '1';
566
+ } catch {
567
+ return false;
568
+ }
569
+ }
570
+
571
+ function motionLevel() {
572
+ try {
573
+ const value = localStorage.getItem(MOTION_LEVEL_KEY);
574
+ return MOTION_LEVELS.includes(value) ? value : 'natural';
575
+ } catch {
576
+ return 'natural';
577
+ }
578
+ }
579
+
580
+ function motionEffective() {
581
+ return motionOn() && !prefersReducedMotion();
582
+ }
583
+
584
+ function applyMotion() {
585
+ const root = document.documentElement;
586
+ root.dataset.motion = motionEffective() ? '1' : '0';
587
+ root.dataset.motionLevel = motionLevel();
588
+ }
589
+
590
+ function setMotion(on) {
591
+ try {
592
+ localStorage.setItem(MOTION_KEY, on ? '1' : '0');
593
+ } catch {}
594
+ applyMotion();
595
+ }
596
+
597
+ function setMotionLevel(level) {
598
+ try {
599
+ localStorage.setItem(MOTION_LEVEL_KEY, MOTION_LEVELS.includes(level) ? level : 'natural');
600
+ } catch {}
601
+ applyMotion();
602
+ }
603
+
604
+ function motionScrollFactor() {
605
+ if (!motionEffective()) return 0.12;
606
+ return { subtle: 0.15, natural: 0.11, playful: 0.085 }[motionLevel()];
607
+ }
608
+
558
609
  function stopCamera() {
559
610
  camera.running = false;
560
611
  if (camera.raf) cancelAnimationFrame(camera.raf);
@@ -581,7 +632,7 @@ function cameraTick() {
581
632
  stopCamera();
582
633
  return;
583
634
  }
584
- const step = Math.min(64, Math.max(1, distance * 0.12));
635
+ const step = Math.min(64, Math.max(1, distance * motionScrollFactor()));
585
636
  THREAD.scrollTop = current + step;
586
637
  camera.lastTop = THREAD.scrollTop;
587
638
  camera.programmaticAt = Date.now();
@@ -3544,6 +3595,38 @@ function renderAppearanceSettings(body) {
3544
3595
  );
3545
3596
  section.appendChild(card);
3546
3597
 
3598
+ const lively = settingsCard();
3599
+ lively.appendChild(
3600
+ settingsRow(
3601
+ '灵动动效',
3602
+ '测试功能:消息、按钮和面板带自然弹力与阻尼;终端与代码区不受影响。',
3603
+ settingsSwitch(motionOn(), (on) => {
3604
+ setMotion(on);
3605
+ renderSettings();
3606
+ toast(on ? '灵动动效已开启' : '灵动动效已关闭');
3607
+ }),
3608
+ ),
3609
+ );
3610
+ lively.appendChild(
3611
+ settingsRow(
3612
+ '动效强度',
3613
+ '阻尼越大越收得住;大面板不会来回晃。',
3614
+ settingsSeg(
3615
+ [
3616
+ { value: 'subtle', label: '克制' },
3617
+ { value: 'natural', label: '自然' },
3618
+ { value: 'playful', label: '明显' },
3619
+ ],
3620
+ motionLevel(),
3621
+ (value) => {
3622
+ setMotionLevel(value);
3623
+ toast('动效强度:' + (value === 'subtle' ? '克制' : value === 'playful' ? '明显' : '自然'));
3624
+ },
3625
+ ),
3626
+ ),
3627
+ );
3628
+ section.appendChild(lively);
3629
+
3547
3630
  const motion = settingsCard();
3548
3631
  motion.appendChild(
3549
3632
  settingsRow('减少动效', '关闭大部分弹簧和入场动画,适合晕动或低性能设备。', settingsSwitch(
@@ -3552,6 +3635,7 @@ function renderAppearanceSettings(body) {
3552
3635
  if (on) document.documentElement.dataset.reduceMotion = '1';
3553
3636
  else delete document.documentElement.dataset.reduceMotion;
3554
3637
  localStorage.setItem('banana.reduceMotion', on ? '1' : '0');
3638
+ applyMotion();
3555
3639
  toast(on ? '已减少动效' : '已恢复弹力动画');
3556
3640
  },
3557
3641
  )),
@@ -5584,6 +5668,7 @@ async function maybePromptProjectTrust() {
5584
5668
  async function boot() {
5585
5669
  bind();
5586
5670
  applyLanguage();
5671
+ applyMotion();
5587
5672
  // 命令表来自服务端(与 CLI 同一份),拉不到也不影响对话
5588
5673
  try {
5589
5674
  const all = (await get('commands')).commands ?? [];
package/ui/style.css CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, 0.05);
50
50
  --shadow-1: var(--shadow-sm);
51
- --shadow-overlay: 0 12px 32px rgba(16, 16, 20, 0.14);
51
+ --shadow-overlay: 0 8px 24px rgba(16, 16, 20, 0.10);
52
52
  --shadow-lg: var(--shadow-overlay);
53
53
  --shadow-raised: var(--shadow-sm);
54
54
 
@@ -96,7 +96,7 @@
96
96
  --info: #82bdbd;
97
97
  --on-danger: #ffffff;
98
98
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
99
- --shadow-overlay: 0 16px 40px rgba(0, 0, 0, 0.55);
99
+ --shadow-overlay: 0 8px 24px rgba(0, 0, 0, 0.40);
100
100
  --shadow-lg: var(--shadow-overlay);
101
101
  --shadow-raised: var(--shadow-sm);
102
102
  }
@@ -129,7 +129,7 @@
129
129
  --info: #82bdbd;
130
130
  --on-danger: #ffffff;
131
131
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
132
- --shadow-overlay: 0 16px 40px rgba(0, 0, 0, 0.55);
132
+ --shadow-overlay: 0 8px 24px rgba(0, 0, 0, 0.40);
133
133
  --shadow-lg: var(--shadow-overlay);
134
134
  --shadow-raised: var(--shadow-sm);
135
135
  }
@@ -4326,6 +4326,70 @@ input:focus-visible, textarea:focus-visible { outline: none; }
4326
4326
  transition: width 200ms var(--ease);
4327
4327
  }
4328
4328
 
4329
+ /* ---------- 灵动动效(测试功能,默认关闭) ---------- */
4330
+ :root[data-motion='1'] {
4331
+ --motion-dur: 240ms;
4332
+ --motion-dur-slow: 320ms;
4333
+ --motion-spring: cubic-bezier(0.22, 1.16, 0.36, 1);
4334
+ --motion-shift: 7px;
4335
+ --motion-press: 0.96;
4336
+ }
4337
+ :root[data-motion='1'][data-motion-level='subtle'] {
4338
+ --motion-dur: 180ms;
4339
+ --motion-dur-slow: 250ms;
4340
+ --motion-spring: cubic-bezier(0.28, 1.04, 0.5, 1);
4341
+ --motion-shift: 4px;
4342
+ --motion-press: 0.975;
4343
+ }
4344
+ :root[data-motion='1'][data-motion-level='playful'] {
4345
+ --motion-dur: 300ms;
4346
+ --motion-dur-slow: 380ms;
4347
+ --motion-spring: cubic-bezier(0.2, 1.4, 0.34, 1);
4348
+ --motion-shift: 10px;
4349
+ --motion-press: 0.94;
4350
+ }
4351
+
4352
+ @keyframes motionIn {
4353
+ from { opacity: 0; transform: translateY(var(--motion-shift, 6px)) scale(0.996); }
4354
+ to { opacity: 1; transform: none; }
4355
+ }
4356
+
4357
+ :root[data-motion='1'] .msg.enter,
4358
+ :root[data-motion='1'] .plan-card {
4359
+ animation: motionIn var(--motion-dur-slow) var(--motion-spring) both;
4360
+ }
4361
+
4362
+ :root[data-motion='1'] .btn:active,
4363
+ :root[data-motion='1'] .icon-btn:active,
4364
+ :root[data-motion='1'] .chip-btn:active,
4365
+ :root[data-motion='1'] .send-btn:not(:disabled):active,
4366
+ :root[data-motion='1'] .session-item:active {
4367
+ transform: scale(var(--motion-press));
4368
+ transition-duration: 90ms;
4369
+ }
4370
+
4371
+ :root[data-motion='1'] .review.is-opening {
4372
+ animation: reviewIn var(--motion-dur) var(--motion-spring) both;
4373
+ }
4374
+ :root[data-motion='1'] .model-pop,
4375
+ :root[data-motion='1'] .reasoning-pop {
4376
+ animation: pop var(--motion-dur) var(--motion-spring) both;
4377
+ }
4378
+ :root[data-motion='1'] .sidebar {
4379
+ transition-timing-function: var(--motion-spring);
4380
+ transition-duration: var(--motion-dur);
4381
+ }
4382
+
4383
+ :root[data-motion='1'] .todo-bar i,
4384
+ :root[data-motion='1'] .task-chip-bar i {
4385
+ transition: width var(--motion-dur) var(--motion-spring);
4386
+ }
4387
+
4388
+ /* 去掉模板感:输入区和主卡片不再抬高 */
4389
+ .composer { box-shadow: none; }
4390
+ .composer:focus-within { box-shadow: none; }
4391
+ .chat-card { box-shadow: none; }
4392
+
4329
4393
  /* 顶栏和聊天头部:少一点装饰,多一点边界 */
4330
4394
  .topbar { height: 50px; }
4331
4395
  .chat-head { height: 46px; }