Files
zn-ai/electron/utils/index.ts
duanshuwen eb9acae071 feat(build): add icon generation and external binary bundling
- Add scripts to generate application icons in multiple formats (ICO, ICNS, PNG)
- Implement download scripts for uv and Node.js binaries for cross-platform support
- Update build configuration to use new icon resources and bundled binaries
- Remove old loading screen and unused build configurations
- Fix application icon path resolution to use app resources directory
2026-04-08 07:25:25 +08:00

41 lines
1.1 KiB
TypeScript

import { CONFIG_KEYS } from '@lib/constants'
import logManager from '@electron/service/logger'
import configManager from '@electron/service/config-service'
import path from 'node:path'
import { app } from 'electron'
import en from '@locales/en.json'
import zh from '@locales/zh.json'
type MessageSchema = typeof zh;
const messages: Record<string, MessageSchema> = { en, zh }
export function createTranslator() {
return (key?: string) => {
if (!key) return void 0;
try {
const keys = key?.split('.');
let result: any = messages[configManager.get(CONFIG_KEYS.LANGUAGE)];
for (const _key of keys) {
result = result[_key];
}
return result as string;
} catch (e) {
logManager.error('failed to translate key:', key, e);
return key
}
}
}
let logo: string | void = void 0;
export function createLogo() {
if (logo != null) {
return logo;
}
// Use app.getAppPath() to get the application root directory
const appPath = app.getAppPath();
const iconPath = path.join(appPath, 'resources', 'icons', 'icon.ico');
logo = iconPath;
return logo;
}