feat: 初始化船长·HeiXiu 桌面应用项目(错误是svg的问题)
Electron + React 19 + TypeScript + Ant Design 6 + Tailwind CSS 4 【核心架构】 - Electron 主进程(窗口管理、平台检测、图标适配) - Vite 构建链(双产物 dist/ + dist-electron/) - 共享层 shared/(类型、常量、工具函数) - IPC 通信框架 + 安全守卫 【主题系统】 - 蓝紫渐变主题(亮色/暗色双模式) - Ant Design ConfigProvider 适配(lightAlgorithm / darkAlgorithm) - Tailwind CSS 4 @theme 指令 + CSS 变量 - 设计令牌三处同步(tokens.ts / globals.css / antd-theme.ts) 【导航栏】 - 自定义 H5 导航栏替代系统菜单 - 个人版/企业版双布局 - 未登录拦截 + 事件总线驱动登录弹窗 【登录注册】 - Modal 弹层(Portal)+ Tabs 切换 - 登录/注册表单动态字段渲染 - 记住密码 / 自动登录 / 用户协议 【更新系统】 - 自定义 API 版本检查(替代 electron-updater generic provider) - 手动下载 + SHA512 校验 + spawn NSIS 安装 - 渲染进程更新状态机 Hook(useUpdater) - 检查更新按钮 + 下载进度展示 【构建工具链】 - build.mjs 构建总管(--win/--mac/--linux --personal/--enterprise --build/--clean/--sign/--upload/--publish) - scripts/ 自动化脚本(clean / generate-update-info / upload-oss / publish-release) - electron-builder NSIS 安装器(可选路径、多版本打包) - update-info.json 自动生成(fileSize/sha512/changelog/releaseDate) 【代码质量】 - ESLint + TypeScript strict + Prettier - husky + lint-staged(提交前自动检查) - commitlint(规范提交信息) - Playwright E2E + Vitest 单元测试框架 - rollup-plugin-visualizer 打包体积分析 【文档】 - README.md(快速开始 + 目录结构 + 命令速查) - UpdateA.md(发布手册:API/签名/发版流程/数据库) - CHANGELOG.md(更新日志) - .env.example(构建环境变量模板)
This commit is contained in:
100
electron/main/utils/logo.ts
Normal file
100
electron/main/utils/logo.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
// ============================================================
|
||||
// 主进程 Logo 自适应工具
|
||||
// 根据平台返回正确的图标路径,处理 .ico / .png / .icns 格式差异
|
||||
// ============================================================
|
||||
|
||||
import path from 'node:path';
|
||||
import { isMacOS, isWindows } from './platform';
|
||||
|
||||
// Logo 资源目录(相对于构建后的 dist-electron 目录或开发时的 electron/ 目录)
|
||||
// 开发时 app.getAppPath() 指向项目根目录
|
||||
// 生产时指向 app.asar 所在目录
|
||||
|
||||
/** Logo 目录在项目中的相对路径 */
|
||||
const LOGO_DIR = 'src/assets/logo';
|
||||
|
||||
/**
|
||||
* 获取 Logo 资源目录的绝对路径
|
||||
* @param appPath - Electron app.getAppPath() 的返回值
|
||||
*/
|
||||
export function getLogoDir(appPath: string): string {
|
||||
return path.join(appPath, LOGO_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按平台获取窗口图标路径
|
||||
*
|
||||
* 平台格式要求:
|
||||
* Windows → .ico(支持多尺寸)
|
||||
* macOS → .icns(首选)或 .png(回退)
|
||||
* Linux → .png
|
||||
*
|
||||
* @param appPath - Electron app.getAppPath()
|
||||
* @returns 图标文件的绝对路径
|
||||
*/
|
||||
export function getWindowIconPath(appPath: string): string {
|
||||
const logoDir = path.join(appPath, LOGO_DIR);
|
||||
|
||||
if (isWindows()) {
|
||||
// Windows 首选 .ico
|
||||
return path.join(logoDir, 'heixiu.ico');
|
||||
}
|
||||
|
||||
if (isMacOS()) {
|
||||
return path.join(logoDir, 'heixiu.icns');
|
||||
}
|
||||
|
||||
// Linux 使用 .png
|
||||
return path.join(logoDir, 'HX.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按平台获取系统托盘图标路径
|
||||
* 托盘图标通常用 .png(跨平台通用),且尺寸较小
|
||||
*
|
||||
* @param appPath - Electron app.getAppPath()
|
||||
* @returns 托盘图标绝对路径
|
||||
*/
|
||||
export function getTrayIconPath(appPath: string): string {
|
||||
const logoDir = path.join(appPath, LOGO_DIR);
|
||||
|
||||
if (isWindows()) {
|
||||
// Windows 托盘可用 .ico 或小尺寸 .png
|
||||
return path.join(logoDir, 'heixiu.ico');
|
||||
}
|
||||
|
||||
// macOS / Linux 托盘用 .png
|
||||
return path.join(logoDir, 'HX.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按平台获取应用安装包图标路径
|
||||
* electron-builder 打包时使用,各平台格式不同:
|
||||
* Windows → .ico
|
||||
* macOS → .icns
|
||||
* Linux → .png(通常 256x256 或 512x512)
|
||||
*
|
||||
* @param appPath - 应用根目录路径
|
||||
* @returns 安装包图标的绝对路径
|
||||
*/
|
||||
export function getInstallerIconPath(appPath: string): string {
|
||||
const logoDir = path.join(appPath, LOGO_DIR);
|
||||
|
||||
if (isWindows()) {
|
||||
return path.join(logoDir, 'heixiu.ico');
|
||||
}
|
||||
|
||||
if (isMacOS()) {
|
||||
return path.join(logoDir, 'heixiu.icns');
|
||||
}
|
||||
|
||||
// Linux
|
||||
return path.join(logoDir, 'HX.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通用 PNG Logo(不区分平台,用于 About 对话框等)
|
||||
*/
|
||||
export function getPngLogoPath(appPath: string): string {
|
||||
return path.join(appPath, LOGO_DIR, 'HX.png');
|
||||
}
|
||||
Reference in New Issue
Block a user