feat: multi-language interface (zh-CN/zh-TW/en/ja), multilingual offline changelog, settings robustness
i18n - shared/i18n: dependency-free t() with flat per-namespace dictionaries (common/settings/workspace/terminal/ssh/panels/main), zh-CN fallback - language picker in Settings -> System; antd ConfigProvider locale follows it - main process tracks the language too: tray menu, close prompt, ssh/sftp/ zmodem errors and the log TUI marker are translated; tray rebuilds on change changelog - CHANGELOG.md (zh-CN canonical) + .zh-TW/.en/.ja, bundled via ?raw and read per interface language with per-version fallback to zh-CN (no network) - sync-changelog.cjs merges RELEASE_NOTES[.<lang>].md per release; release.cjs refuses to publish without a zh-CN entry for the version settings robustness - closeAction 'ask' survives the sanitizer (was silently coerced to 'tray', which made the 'ask every time' option dead) - highlight rules are repaired instead of dropped: string priority, 0/1 enabled, missing fg colour; unknown fields preserved - load-time warnings are written to settings-warnings.log (deduped, capped) terminal/UI - configurable terminal toolbar: open working directory (default on), session log recording (off), open logs folder (off) - global shortcut field records key combos (modifier or F-key required) - input suggestions + command history default to off, with a one-time reset migration for existing installs - settings dialog scrolling fixed (antd v6 renamed the tabs container), theme gallery nested scrollbar removed, joined segmented pickers with readable selected-state text tests: settings-store.mjs (15 checks) added; commands-store.mjs updated for the new off-by-default history setting
This commit is contained in:
1 parent
34094d607b
commit
4c6a29ef28
82 files changed
+3342
-608
No files matched your search
+28
-13
@@ -1,5 +1,6 @@
|
||||
import { app, BrowserWindow, dialog, Menu, nativeImage, Tray } from 'electron'
|
||||
import type { SystemSettings } from '@shared/settings'
|
||||
import { t } from '@shared/i18n'
|
||||
import { loadSettings, mutateSettings } from './settingsStore'
|
||||
import trayIconPath from './assets/tray.png?asset'
|
||||
|
||||
@@ -8,6 +9,8 @@ export type CloseAction = NonNullable<SystemSettings['closeAction']>
|
||||
let tray: Tray | null = null
|
||||
let quitting = false
|
||||
let balloonShown = false
|
||||
/** Window-restore callback handed to initTray; kept so the menu can be rebuilt. */
|
||||
let showOrCreateRef: (() => void) | null = null
|
||||
|
||||
/** Once true, window close events pass through and the app really quits. */
|
||||
export function markQuitting(): void {
|
||||
@@ -42,17 +45,19 @@ function refreshContextMenu(showOrCreate: () => void): void {
|
||||
persistCloseAction(value)
|
||||
refreshContextMenu(showOrCreate)
|
||||
}
|
||||
// Labels are resolved while the template is built, so rebuilding the menu
|
||||
// after a language change picks up the new strings.
|
||||
tray.setContextMenu(
|
||||
Menu.buildFromTemplate([
|
||||
{ label: '显示主窗口', click: (): void => showMainWindow(showOrCreate) },
|
||||
{ label: t('main.tray.showWindow'), click: (): void => showMainWindow(showOrCreate) },
|
||||
{ type: 'separator' },
|
||||
{ label: '关闭按钮行为', enabled: false },
|
||||
{ label: '每次询问', type: 'radio', checked: action === 'ask', click: setAction('ask') },
|
||||
{ label: '最小化到托盘', type: 'radio', checked: action === 'tray', click: setAction('tray') },
|
||||
{ label: '直接退出', type: 'radio', checked: action === 'exit', click: setAction('exit') },
|
||||
{ label: t('main.tray.closeAction'), enabled: false },
|
||||
{ label: t('main.tray.askEveryTime'), type: 'radio', checked: action === 'ask', click: setAction('ask') },
|
||||
{ label: t('main.tray.minimizeToTray'), type: 'radio', checked: action === 'tray', click: setAction('tray') },
|
||||
{ label: t('main.tray.exitDirectly'), type: 'radio', checked: action === 'exit', click: setAction('exit') },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: '退出',
|
||||
label: t('main.tray.exit'),
|
||||
click: (): void => {
|
||||
markQuitting()
|
||||
app.quit()
|
||||
@@ -62,10 +67,20 @@ function refreshContextMenu(showOrCreate: () => void): void {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the tray menu (after a language change, or any time the labels must
|
||||
* be current). Safe to call before the tray exists.
|
||||
*/
|
||||
export function refreshTrayMenu(): void {
|
||||
if (!tray || !showOrCreateRef) return
|
||||
refreshContextMenu(showOrCreateRef)
|
||||
}
|
||||
|
||||
/** Create the tray icon and wire left-click to window restore. */
|
||||
export function initTray(showOrCreate: () => void): void {
|
||||
const icon = nativeImage.createFromPath(trayIconPath)
|
||||
tray = new Tray(icon)
|
||||
showOrCreateRef = showOrCreate
|
||||
tray.setToolTip('OpenTerminal')
|
||||
tray.on('click', (): void => showMainWindow(showOrCreate))
|
||||
refreshContextMenu(showOrCreate)
|
||||
@@ -79,8 +94,8 @@ function hideToTray(win: BrowserWindow): void {
|
||||
iconType: 'info',
|
||||
// The Windows toast already prints the app name as its header, so the
|
||||
// balloon title carries the state only — no "OpenTerminal" twice.
|
||||
title: '已最小化到托盘',
|
||||
content: '终端会话仍在后台运行,点击托盘图标可恢复窗口。'
|
||||
title: t('main.tray.balloonTitle'),
|
||||
content: t('main.tray.balloonContent')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -101,13 +116,13 @@ export async function onMainWindowClose(win: BrowserWindow, e: Electron.Event, s
|
||||
e.preventDefault()
|
||||
const { response, checkboxChecked } = await dialog.showMessageBox(win, {
|
||||
type: 'question',
|
||||
title: '关闭 OpenTerminal',
|
||||
message: '最小化到托盘,还是直接退出?',
|
||||
detail: '最小化到托盘时终端会话保持运行。',
|
||||
buttons: ['最小化到托盘', '直接退出'],
|
||||
title: t('main.tray.closeTitle'),
|
||||
message: t('main.tray.closeMessage'),
|
||||
detail: t('main.tray.closeDetail'),
|
||||
buttons: [t('main.tray.minimizeToTray'), t('main.tray.exitDirectly')],
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
checkboxLabel: '记住我的选择,不再询问',
|
||||
checkboxLabel: t('main.tray.rememberChoice'),
|
||||
checkboxChecked: false,
|
||||
noLink: true
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user