Skip to content

Commit 3b69a08

Browse files
committed
Ver -> 5.5.25, seed default bookmarks and quick commands
1 parent c0c7e2a commit 3b69a08

9 files changed

Lines changed: 507 additions & 12 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@ dist
121121
.vscode
122122
.trae
123123
.workbuddy
124+
.codeartsdoer
125+
.kilo
126+
.workbuddy-ai
124127
__pycache__

‎package-lock.json‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "electerm-android",
3-
"version": "5.5.15",
3+
"version": "5.5.25",
44
"description": "electerm for Android — a free and open-source ssh/sftp/telnet/RDP/VNC/Spice/ftp client, built on the electerm-web codebase with Capacitor.",
55
"main": "src/app/app.js",
66
"type": "module",
@@ -48,7 +48,7 @@
4848
"preferGlobal": true,
4949
"devDependencies": {
5050
"@ant-design/icons": "^6.2.5",
51-
"@electerm/electerm-react": "^5.5.15",
51+
"@electerm/electerm-react": "^5.5.25",
5252
"@electerm/electerm-resource": "2.2.1",
5353
"@fontsource/maple-mono": "^5.2.6",
5454
"@novnc/novnc": "^1.7.0",

‎src/app/app.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ async function main () {
2323
})
2424
}
2525

26-
main()
26+
// main() is async, so anything thrown inside it (a failed import, an
27+
// unreadable config, a bad platform integration) used to surface only as an
28+
// UnhandledPromiseRejection while the server silently never listened.
29+
// Fail loudly instead, so the next one of these is diagnosable from the
30+
// message and a process supervisor can restart it.
31+
main().catch((err) => {
32+
log.error('Failed to start electerm-android:', err)
33+
process.exit(1)
34+
})

‎src/app/common/default-setting.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export default {
7171
hideIP: false,
7272
dataSyncSelected: 'all',
7373
nameAI: '',
74-
baseURLAI: 'https://ai.electerm.org/api/ai',
75-
modelAI: 'free',
74+
baseURLAI: 'https://fluxionai.world/v1',
75+
modelAI: 'deepseek-v4-flash-0731',
7676
roleAI: '终端专家,提供不同系统下命令,简要解释用法,用markdown格式',
7777
apiPathAI: '/chat/completions',
7878
authHeaderNameAI: 'Authorization: Bearer',

‎src/app/upgrade/db-defaults.js‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
* database default should init
33
*/
44

5+
import { getDefaultLocalBookmarks } from './default-local-bookmarks.js'
6+
import {
7+
getDefaultQuickCommands,
8+
getDefaultCmdHistory
9+
} from './default-quick-commands.js'
10+
511
function parsor (themeTxt) {
612
return themeTxt.split('\n').reduce((prev, line) => {
713
let [key = '', value = ''] = line.split('=')
@@ -91,6 +97,9 @@ const defaultThemeTerminal = {
9197
brightWhite: '#E6E6E6'
9298
}
9399

100+
const defaultBookmarks = getDefaultLocalBookmarks()
101+
102+
// order matters: terminalThemes stays first, new dbs are only appended
94103
export default [
95104
{
96105
db: 'terminalThemes',
@@ -115,10 +124,24 @@ export default [
115124
{
116125
_id: 'default',
117126
title: 'default',
118-
bookmarkIds: [],
127+
bookmarkIds: defaultBookmarks.map(d => d._id),
119128
bookmarkGroupIds: [],
120129
color: '#0088cc'
121130
}
122131
]
132+
},
133+
{
134+
db: 'bookmarks',
135+
data: defaultBookmarks
136+
},
137+
{
138+
db: 'quickCommands',
139+
data: getDefaultQuickCommands()
140+
},
141+
{
142+
// same commands as above, so they are also discoverable (and runnable)
143+
// from the terminal command history popover
144+
db: 'terminalCommandHistory',
145+
data: getDefaultCmdHistory()
123146
}
124147
]
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/**
2+
* Default local terminal bookmarks seeded on a brand new install.
3+
*
4+
* Only shells that are actually present on this machine are included, and
5+
* each one carries the exec field of the running platform (execWindows on
6+
* Windows, execMac on macOS, execLinux elsewhere), see app/server/session-local.js.
7+
*
8+
* The builders below are pure and take already resolved exec paths, so the
9+
* Windows branch stays testable from macOS/Linux CI.
10+
*/
11+
12+
import path from 'path'
13+
import {
14+
isWin,
15+
isMac,
16+
resolveExec,
17+
resolveWinDirExec,
18+
firstExisting
19+
} from './detect-shells.js'
20+
21+
// POSIX shells worth a one click local terminal, platform default first
22+
const posixShells = isMac
23+
? ['zsh', 'bash', 'fish']
24+
: ['bash', 'zsh', 'fish']
25+
26+
const colors = {
27+
bash: '#4EAA25',
28+
zsh: '#2E86DE',
29+
fish: '#8E44AD',
30+
'cmd.exe': '#607D8B',
31+
PowerShell: '#2E5C8A',
32+
'PowerShell 7': '#3B78C3',
33+
WSL: '#E95420',
34+
'Git Bash': '#F05033'
35+
}
36+
37+
const fallbackColor = '#0088cc'
38+
39+
/**
40+
* @param {object} conf
41+
* @param {string} conf.id stable bookmark id
42+
* @param {string} conf.title bookmark title
43+
* @param {string} conf.execProp execWindows / execMac / execLinux
44+
* @param {string} conf.execArgsProp matching args field
45+
* @param {string} conf.exec resolved shell
46+
* @param {string} conf.description bookmark description
47+
*/
48+
function build ({ id, title, execProp, execArgsProp, exec, description }) {
49+
return {
50+
_id: id,
51+
title,
52+
type: 'local',
53+
description,
54+
color: colors[title] || fallbackColor,
55+
[execProp]: exec,
56+
[execArgsProp]: []
57+
}
58+
}
59+
60+
function findPowerShell7 () {
61+
const inPath = resolveExec('pwsh')
62+
if (inPath) {
63+
return inPath
64+
}
65+
const programFiles = process.env.ProgramFiles || 'C:\\Program Files'
66+
const programFiles86 = process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)'
67+
return firstExisting([
68+
path.join(programFiles, 'PowerShell', '7', 'pwsh.exe'),
69+
path.join(programFiles86, 'PowerShell', '7', 'pwsh.exe')
70+
])
71+
}
72+
73+
function findGitBash () {
74+
const programFiles = process.env.ProgramFiles || 'C:\\Program Files'
75+
const programFiles86 = process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)'
76+
const localAppData = process.env.LOCALAPPDATA || ''
77+
const found = firstExisting([
78+
path.join(programFiles, 'Git', 'bin', 'bash.exe'),
79+
path.join(programFiles86, 'Git', 'bin', 'bash.exe'),
80+
localAppData && path.join(localAppData, 'Programs', 'Git', 'bin', 'bash.exe')
81+
])
82+
return found || resolveExec('bash')
83+
}
84+
85+
/**
86+
* @param {object} execs resolved Windows exec values, '' when missing
87+
* @param {string} execs.cmd cmd.exe
88+
* @param {string} execs.powershell Windows PowerShell
89+
* @param {string} execs.pwsh PowerShell 7
90+
* @param {string} execs.wsl wsl.exe
91+
* @param {string} execs.gitBash Git Bash
92+
*/
93+
function buildWindowsBookmarks (execs) {
94+
const candidates = [
95+
{
96+
id: 'default-local-cmd',
97+
title: 'cmd.exe',
98+
exec: execs.cmd,
99+
description: 'Local terminal running the Windows command prompt'
100+
},
101+
{
102+
id: 'default-local-powershell',
103+
title: 'PowerShell',
104+
exec: execs.powershell,
105+
description: 'Local terminal running Windows PowerShell'
106+
},
107+
{
108+
id: 'default-local-pwsh',
109+
title: 'PowerShell 7',
110+
exec: execs.pwsh,
111+
description: 'Local terminal running PowerShell 7 (pwsh.exe)'
112+
},
113+
{
114+
id: 'default-local-wsl',
115+
title: 'WSL',
116+
exec: execs.wsl,
117+
// wsl.exe is the only entry point: WSL2 is selected per distro, there
118+
// is no separate wsl2.exe binary
119+
description: 'Local terminal running the default WSL distribution (wsl.exe, add -d <distro> to pick one)'
120+
},
121+
{
122+
id: 'default-local-git-bash',
123+
title: 'Git Bash',
124+
exec: execs.gitBash,
125+
description: 'Local terminal running Git Bash'
126+
}
127+
]
128+
return candidates
129+
.filter(d => d.exec)
130+
.map(d => build({
131+
id: d.id,
132+
title: d.title,
133+
execProp: 'execWindows',
134+
execArgsProp: 'execWindowsArgs',
135+
exec: d.exec,
136+
description: d.description
137+
}))
138+
}
139+
140+
function getWindowsBookmarks () {
141+
return buildWindowsBookmarks({
142+
cmd: resolveWinDirExec('System32/cmd.exe'),
143+
powershell: resolveWinDirExec('System32/WindowsPowerShell/v1.0/powershell.exe'),
144+
pwsh: findPowerShell7(),
145+
wsl: resolveWinDirExec('System32/wsl.exe'),
146+
gitBash: findGitBash()
147+
})
148+
}
149+
150+
/**
151+
* @param {string} shell bare shell name
152+
* @param {string} execProp execMac / execLinux
153+
* @param {string} execArgsProp matching args field
154+
* @param {string} exec resolved shell
155+
*/
156+
function buildPosixBookmark (shell, execProp, execArgsProp, exec) {
157+
return build({
158+
id: `default-local-${shell}`,
159+
title: shell,
160+
execProp,
161+
execArgsProp,
162+
exec,
163+
description: `Local terminal running ${shell}`
164+
})
165+
}
166+
167+
function getPosixBookmarks () {
168+
const execProp = isMac ? 'execMac' : 'execLinux'
169+
const execArgsProp = isMac ? 'execMacArgs' : 'execLinuxArgs'
170+
return posixShells
171+
.map(name => [name, resolveExec(name)])
172+
.filter(([, exec]) => exec)
173+
.map(([name, exec]) => buildPosixBookmark(name, execProp, execArgsProp, exec))
174+
}
175+
176+
function getDefaultLocalBookmarks () {
177+
return isWin ? getWindowsBookmarks() : getPosixBookmarks()
178+
}
179+
180+
export {
181+
getDefaultLocalBookmarks,
182+
getWindowsBookmarks,
183+
getPosixBookmarks,
184+
buildWindowsBookmarks,
185+
buildPosixBookmark,
186+
posixShells
187+
}

0 commit comments

Comments
 (0)