feat: implement launch at startup functionality in zn-ai
- Added a new setting for "launch at startup" in the GeneralSettingsPanel. - Integrated the setting with the existing settings store and IPC mechanisms. - Implemented platform-specific logic for enabling/disabling startup behavior in the main process. - Created a new service for managing launch at startup settings, including Linux desktop entry creation. - Added unit tests for the new functionality and ensured existing tests are updated accordingly. - Updated i18n messages for the new setting in English, Chinese, and Japanese.
This commit is contained in:
@@ -14,6 +14,7 @@ import { onProviderChange } from '@electron/service/provider-api-service';
|
||||
import { gatewayManager } from '@electron/gateway/manager';
|
||||
import { dispatchLocalHostApi } from '@electron/api/router';
|
||||
import { syncProviderRuntimeSnapshot } from '@electron/service/provider-runtime-sync';
|
||||
import { applyLaunchAtStartupSetting, syncLaunchAtStartupSettingFromConfig } from '@electron/service/launch-at-startup';
|
||||
import { ensureBuiltinSkillsInstalled, ensurePreinstalledSkillsInstalled } from '@electron/utils/skill-config';
|
||||
|
||||
// 初始化 updater,确保在 app ready 之前或者之中注册好 IPC
|
||||
@@ -113,8 +114,24 @@ if (started) {
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
await configManager.init();
|
||||
await syncLaunchAtStartupSettingFromConfig();
|
||||
await themeManager.init();
|
||||
|
||||
let launchAtStartup = Boolean(configManager.get(CONFIG_KEYS.LAUNCH_AT_STARTUP));
|
||||
const stopLaunchAtStartupSync = configManager.onConfigChange((config) => {
|
||||
const nextLaunchAtStartup = Boolean(config[CONFIG_KEYS.LAUNCH_AT_STARTUP]);
|
||||
if (nextLaunchAtStartup === launchAtStartup) {
|
||||
return;
|
||||
}
|
||||
|
||||
launchAtStartup = nextLaunchAtStartup;
|
||||
void applyLaunchAtStartupSetting(nextLaunchAtStartup);
|
||||
});
|
||||
|
||||
app.once('will-quit', () => {
|
||||
stopLaunchAtStartupSync();
|
||||
});
|
||||
|
||||
void ensureBuiltinSkillsInstalled().catch((error) => {
|
||||
log.warn('Failed to install built-in skills:', error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user