@vincentbanana/banana-gui 0.4.5 → 0.4.6

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 +46 -3
  3. package/ui/style.css +47 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/banana-gui",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Banana 的图形界面:本地服务 + 浏览器。黑白主题,自绘图标,无第三方 UI 依赖",
5
5
  "type": "module",
6
6
  "engines": {
@@ -71,7 +71,7 @@
71
71
  "electron-builder": "^25.0.0"
72
72
  },
73
73
  "dependencies": {
74
- "@vincentbanana/bananacli": "^0.4.3"
74
+ "@vincentbanana/bananacli": "^0.4.4"
75
75
  },
76
76
  "license": "MIT",
77
77
  "publishConfig": {
package/ui/app.js CHANGED
@@ -510,7 +510,7 @@ async function send() {
510
510
  renderEmpty();
511
511
 
512
512
  const userMsg = document.createElement('article');
513
- userMsg.className = 'msg user';
513
+ userMsg.className = 'msg user enter';
514
514
  userMsg.innerHTML = '<div class="msg-role">你</div>';
515
515
  const userBody = document.createElement('div');
516
516
  userBody.className = 'msg-body';
@@ -519,7 +519,7 @@ async function send() {
519
519
  THREAD.appendChild(userMsg);
520
520
 
521
521
  const botMsg = document.createElement('article');
522
- botMsg.className = 'msg assistant';
522
+ botMsg.className = 'msg assistant enter';
523
523
  botMsg.innerHTML = '<div class="msg-role">Banana</div>';
524
524
  const toolWrap = document.createElement('div');
525
525
  toolWrap.className = 'tool-group';
@@ -822,7 +822,7 @@ async function runCommand(text) {
822
822
  THREAD.appendChild(userMsg);
823
823
 
824
824
  const botMsg = document.createElement('article');
825
- botMsg.className = 'msg assistant';
825
+ botMsg.className = 'msg assistant enter';
826
826
  const role = document.createElement('div');
827
827
  role.className = 'msg-role';
828
828
  role.textContent = '命令输出';
@@ -945,6 +945,49 @@ function renderSettings() {
945
945
  });
946
946
  body.appendChild(keyField);
947
947
 
948
+ // 工作区:换目录后所有文件工具和命令都跟着换,所以放显眼位置
949
+ const workspaceField = document.createElement('div');
950
+ workspaceField.className = 'field';
951
+ workspaceField.innerHTML =
952
+ '<label>工作区</label>' +
953
+ `<div class="row"><input value="${escapeHtml(info.workspace ?? '')}" spellcheck="false" /><button class="btn">切换</button></div>` +
954
+ '<div class="hint">Banana 只能读写这个目录下的文件,命令也在这里执行。绝对路径,例如 D:\\project。</div>';
955
+ workspaceField.querySelector('button').addEventListener('click', async () => {
956
+ const input = workspaceField.querySelector('input');
957
+ const value = input.value.trim();
958
+ if (!value) {
959
+ toast('请填写目录路径');
960
+ return;
961
+ }
962
+ try {
963
+ await post('action', { action: 'workspace', value });
964
+ await refreshSettings();
965
+ renderHeader();
966
+ toast('工作区已切换到 ' + value);
967
+ } catch (error) {
968
+ toast('切换失败:' + (error?.message ?? error));
969
+ }
970
+ });
971
+ workspaceField.querySelector('input').addEventListener('keydown', (event) => {
972
+ if (event.key === 'Enter') workspaceField.querySelector('button').click();
973
+ });
974
+ body.appendChild(workspaceField);
975
+
976
+ const terminalField = document.createElement('div');
977
+ terminalField.className = 'field';
978
+ terminalField.innerHTML =
979
+ '<label>终端</label><div class="row"><button class="btn">在工作区打开终端</button></div>' +
980
+ '<div class="hint">会弹出一个系统终端窗口,已切到当前工作区,方便你手动跑命令。</div>';
981
+ terminalField.querySelector('button').addEventListener('click', async () => {
982
+ try {
983
+ await post('action', { action: 'terminal' });
984
+ toast('终端已打开');
985
+ } catch (error) {
986
+ toast('打开终端失败:' + (error?.message ?? error));
987
+ }
988
+ });
989
+ body.appendChild(terminalField);
990
+
948
991
  const permField = document.createElement('div');
949
992
  permField.className = 'field';
950
993
  permField.innerHTML = '<label>权限</label>';
package/ui/style.css CHANGED
@@ -13,6 +13,8 @@
13
13
  --radius: 12px;
14
14
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
15
15
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
16
+ /* 带一点点回弹,用于按压力气和弹出层,别过量 */
17
+ --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
16
18
  --dur: 220ms;
17
19
  --sidebar: 274px;
18
20
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
@@ -262,7 +264,48 @@ button, input, textarea, select { font: inherit; color: inherit; }
262
264
  contain-intrinsic-size: auto 120px;
263
265
  }
264
266
 
265
- /* 切换会话时给一点即时反馈,避免点了像没反应 */
267
+ /* ---------- 轻微回弹 ----------
268
+ 只给「按下去」和「弹出来」加一点过冲,不影响滚动手感。 */
269
+ .btn,
270
+ .icon-btn,
271
+ .send-btn,
272
+ .s-act,
273
+ .popover button,
274
+ .session-item {
275
+ transition:
276
+ background 140ms var(--ease),
277
+ color 140ms var(--ease),
278
+ border-color 140ms var(--ease),
279
+ transform 180ms var(--spring);
280
+ }
281
+
282
+ .btn:active,
283
+ .popover button:active,
284
+ .s-act:active {
285
+ transform: scale(0.95);
286
+ }
287
+
288
+ .btn:hover,
289
+ .icon-btn:hover {
290
+ transform: translateY(-1px);
291
+ }
292
+
293
+ .send-btn:not(:disabled):hover {
294
+ transform: translateY(-1px) scale(1.04);
295
+ }
296
+
297
+ .send-btn:not(:disabled):active {
298
+ transform: scale(0.93);
299
+ }
300
+
301
+ .session-item:active {
302
+ transform: scale(0.985);
303
+ }
304
+
305
+ /* 新消息轻轻上浮,只有真正新产生的消息走这条 */
306
+ .msg.enter {
307
+ animation: rise 240ms var(--spring) both;
308
+ }
266
309
  .thread { transition: opacity 120ms var(--ease); }
267
310
  body.switching .thread { opacity: 0.45; }
268
311
  body.switching { cursor: progress; }
@@ -520,7 +563,7 @@ pre.code code { border: 0; background: none; padding: 0; font-size: 12.6px; line
520
563
  box-shadow: var(--shadow-lg);
521
564
  display: flex;
522
565
  flex-direction: column;
523
- animation: slide var(--dur) var(--ease) both;
566
+ animation: slide 250ms var(--spring) both;
524
567
  will-change: transform;
525
568
  }
526
569
  @keyframes slide {
@@ -774,7 +817,8 @@ pre.code code { border: 0; background: none; padding: 0; font-size: 12.6px; line
774
817
  border-radius: 10px;
775
818
  background: var(--bg);
776
819
  box-shadow: var(--shadow-lg);
777
- animation: pop 160ms var(--ease) both;
820
+ animation: pop 190ms var(--spring) both;
821
+ transform-origin: top right;
778
822
  }
779
823
  .popover button {
780
824
  display: block;