PoE Overlay Community Fork 项目使用教程
1. 项目目录结构及介绍
PoE Overlay Community Fork 项目的主要目录结构如下:
PoE-Overlay-Community-Fork/
├── .github/ # GitHub 工作流和模板文件
├── .vscode/ # Visual Studio Code 项目设置
├── doc/ # 文档目录
├── electron/ # Electron 相关文件
├── img/ # 图片资源目录
├── src/ # 源代码目录
├── .dockerignore # Docker 忽略文件
├── .editorconfig # 编辑器配置文件
├── .gitignore # Git 忽略文件
├── .prettierrc # Prettier 配置文件
├── CHANGELOG.md # 更改日志
├── CONTRIBUTING.md # 贡献指南
├── DEVELOPERS.md # 开发者信息
├── Dockerfile # Docker 构建文件
├── LICENSE.md # 许可证信息
├── LINUXSETUP.md # Linux 安装指南
├── README.md # 项目说明文件
├── RELEASEINSTRUCTIONS.md # 发布指南
├── SignPath-Artifact-Configuration.xml # 签名配置文件
├── angular.json # Angular 配置文件
├── appveyor.yml # AppVeyor CI 配置文件
├── browserslist # 支持的浏览器列表
├── dev-app-update.yml # 开发环境应用更新配置文件
├── electron-builder.json # Electron 打包配置文件
├── karma-base.conf.js # Karma 基础配置文件
├── karma-ci.conf.js # Karma CI 配置文件
├── karma.conf.js # Karma 配置文件
├── main.ts # 主程序文件
├── overlay.babel # Babel 配置文件
├── package-lock.json # 包锁定文件
├── package.json # 包管理文件
├── prep-release # 准备发布脚本
├── tsconfig.app.json # TypeScript 应用配置文件
├── tsconfig.json # TypeScript 配置文件
├── tsconfig.serve.json # TypeScript 服务配置文件
├── tsconfig.spec.json # TypeScript 测试配置文件
├── tslint.json # TSLint 配置文件
2. 项目的启动文件介绍
项目的启动文件是 main.ts
,这是 Electron 应用的入口点。以下是 main.ts
的主要功能:
- 创建 Electron 应用程序实例。
- 设置应用的主窗口和菜单。
- 处理应用程序的生命周期事件,如启动和关闭。
import { app, BrowserWindow } from 'electron';
let mainWindow: BrowserWindow | null = null;
function createWindow() {
// 创建浏览器窗口
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
});
// 并加载应用的 index.html
mainWindow.loadFile('index.html');
// 当窗口关闭时触发
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.on('ready', () => {
createWindow();
app.on('activate', () => {
// 在 macOS 上,当点击 dock 图标并且没有其他窗口打开时,通常会在应用程序中重新创建一个窗口
if (mainWindow === null) {
createWindow();
}
});
});
app.on('window-all-closed', () => {
// 在 macOS 上,除非用户用 Cmd + Q 确定地退出,否则绝大部分应用及其菜单栏会保持激活
if (process.platform !== 'darwin') {
app.quit();
}
});
3. 项目的配置文件介绍
项目中有多个配置文件,以下是一些主要的配置文件及其功能:
angular.json
: Angular 项目配置文件,包含项目构建、测试和打包的配置信息。package.json
: Node.js 项目配置文件,包含项目依赖、脚本和元数据。tsconfig.json
: TypeScript 配置文件,定义了项目的 TypeScript 编译选项。karma.conf.js
: Karma 测试框架配置文件,用于配置单元测试和端到端测试的运行。
例如,tsconfig.json
文件可能包含以下内容:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
这个配置文件指定了 TypeScript 应该编译到哪个 ECMAScript 版本(ES5),使用哪个模块系统(CommonJS),以及一些其他的编译选项。它还包括了要编译的文件和要排除的文件的模式。