@vincentbanana/banana-gui 1.0.5 → 1.0.7
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/bin/banana-gui-desktop.mjs +12 -4
- package/bin/banana-gui.mjs +12 -4
- package/desktop/main.cjs +27 -2
- package/package.json +4 -4
- package/ui/app.js +558 -67
- package/ui/index.html +5 -1
- package/ui/style.css +237 -240
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// 桌面版启动器:等价于 `banana-gui --desktop`,保留独立命令方便记忆。
|
|
3
3
|
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -10,10 +10,18 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
10
10
|
const require_ = createRequire(import.meta.url);
|
|
11
11
|
const args = process.argv.slice(2);
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// Electron 缓存优先放 D 盘;没有 D 盘或不可写就交给系统默认位置。
|
|
14
|
+
// BANANA_HOME 只在用户显式设置时生效,不在这里强制覆盖。
|
|
14
15
|
if (process.platform === 'win32') {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
try {
|
|
17
|
+
if (existsSync('D:\\')) {
|
|
18
|
+
const cache = join('D:\\BananaCLI-data', 'electron-cache');
|
|
19
|
+
mkdirSync(cache, { recursive: true });
|
|
20
|
+
process.env.ELECTRON_CACHE ??= cache;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
// 忽略,继续用默认缓存目录
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
if (args.includes('--help') || args.includes('-h')) {
|
|
19
27
|
console.log('banana-gui-desktop — Banana 的桌面版(独立窗口)');
|
package/bin/banana-gui.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// 安装:npm install -g @vincentbanana/banana-gui
|
|
4
4
|
// 启动:banana-gui(首次会进配置向导)
|
|
5
5
|
import { spawn, spawnSync } from 'node:child_process';
|
|
6
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
@@ -12,10 +12,18 @@ const require = createRequire(import.meta.url);
|
|
|
12
12
|
const pkg = require('../package.json');
|
|
13
13
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
|
|
15
|
-
// Electron
|
|
15
|
+
// Electron 缓存优先放 D 盘;没有 D 盘或不可写就交给系统默认位置。
|
|
16
|
+
// 不再强制 BANANA_HOME,避免没有 D 盘的机器保存不了配置和会话。
|
|
16
17
|
if (process.platform === 'win32') {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
try {
|
|
19
|
+
if (existsSync('D:\\')) {
|
|
20
|
+
const cache = join('D:\\BananaCLI-data', 'electron-cache');
|
|
21
|
+
mkdirSync(cache, { recursive: true });
|
|
22
|
+
process.env.ELECTRON_CACHE ??= cache;
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// 忽略,继续用默认缓存目录
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
/** CLI 内核入口。依赖可能被 npm 提升到上层 node_modules,用 require 解析更稳。 */
|
package/desktop/main.cjs
CHANGED
|
@@ -4,11 +4,36 @@ const { app, BrowserWindow, Menu, shell, dialog, ipcMain, nativeTheme } = requir
|
|
|
4
4
|
const { spawn, spawnSync } = require('node:child_process');
|
|
5
5
|
const { createRequire } = require('node:module');
|
|
6
6
|
const { join } = require('node:path');
|
|
7
|
+
const { homedir } = require('node:os');
|
|
7
8
|
const { mkdirSync, writeFileSync } = require('node:fs');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
/** 优先用显式 BANANA_HOME,其次可写的 D 盘目录,最后回退到家目录。 */
|
|
11
|
+
function resolveDataRoot() {
|
|
12
|
+
const explicit = process.env.BANANA_HOME?.trim();
|
|
13
|
+
if (explicit) {
|
|
14
|
+
try {
|
|
15
|
+
mkdirSync(explicit, { recursive: true });
|
|
16
|
+
return explicit;
|
|
17
|
+
} catch {
|
|
18
|
+
// 显式目录不可写时继续尝试后面的位置
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (process.platform === 'win32') {
|
|
22
|
+
for (const candidate of ['D:\\BananaCLI-data', 'D:\\BananaData']) {
|
|
23
|
+
try {
|
|
24
|
+
mkdirSync(candidate, { recursive: true });
|
|
25
|
+
return candidate;
|
|
26
|
+
} catch {
|
|
27
|
+
// 没有 D 盘或没有写权限,试下一个
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return join(homedir(), '.banana');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 用户数据、Electron 缓存优先放 D 盘;没有 D 盘时回退到家目录。
|
|
10
35
|
try {
|
|
11
|
-
const dataRoot =
|
|
36
|
+
const dataRoot = resolveDataRoot();
|
|
12
37
|
for (const [name, sub] of [['userData', 'electron'], ['sessionData', 'electron-session'], ['cache', 'cache']]) {
|
|
13
38
|
const target = join(dataRoot, sub);
|
|
14
39
|
mkdirSync(target, { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
2
|
"name": "@vincentbanana/banana-gui",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Banana
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Banana 鐨勫浘褰㈢晫闈細鏈湴鏈嶅姟 + 娴忚鍣ㄣ€傞粦鐧戒富棰橈紝鑷粯鍥炬爣锛屾棤绗笁鏂?UI 渚濊禆",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.0.0"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"electron-builder": "^25.0.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@vincentbanana/bananacli": "^0.8.
|
|
75
|
+
"@vincentbanana/bananacli": "^0.8.7"
|
|
76
76
|
},
|
|
77
77
|
"license": "MIT",
|
|
78
78
|
"publishConfig": {
|