344 lines
12 KiB
Markdown
344 lines
12 KiB
Markdown
# BearVPN 项目结构说明
|
|
|
|
## 📁 项目概览
|
|
|
|
这是一个基于 Flutter 的跨平台 VPN 应用项目,支持 iOS、macOS、Android、Windows、Linux 和 Web 平台。
|
|
|
|
## 🗂️ 目录结构
|
|
|
|
```
|
|
OmnAPP/
|
|
├── 📱 核心源代码
|
|
│ ├── lib/ # Dart 源代码目录
|
|
│ │ ├── main.dart # 应用入口点
|
|
│ │ ├── app/ # 应用核心模块
|
|
│ │ │ ├── modules/ # 功能模块
|
|
│ │ │ │ ├── kr_home/ # 首页模块
|
|
│ │ │ │ ├── kr_user_info/ # 用户信息模块
|
|
│ │ │ │ ├── kr_setting/ # 设置模块
|
|
│ │ │ │ ├── kr_statistics/ # 统计模块
|
|
│ │ │ │ ├── kr_webview/ # WebView 模块
|
|
│ │ │ │ └── kr_splash/ # 启动页模块
|
|
│ │ │ ├── services/ # 服务层
|
|
│ │ │ ├── routes/ # 路由配置
|
|
│ │ │ ├── themes/ # 主题配置
|
|
│ │ │ ├── utils/ # 工具类
|
|
│ │ │ └── widgets/ # 通用组件
|
|
│ │ ├── core/ # 核心功能
|
|
│ │ ├── features/ # 功能特性
|
|
│ │ ├── singbox/ # SingBox 集成
|
|
│ │ └── utils/ # 工具函数
|
|
│ │
|
|
│ ├── assets/ # 资源文件
|
|
│ │ ├── images/ # 图片资源
|
|
│ │ ├── fonts/ # 字体文件
|
|
│ │ └── translations/ # 多语言文件
|
|
│ │
|
|
│ └── libcore/ # 核心库文件
|
|
│ └── bin/ # 二进制文件
|
|
│
|
|
├── 🍎 iOS 平台
|
|
│ ├── ios/
|
|
│ │ ├── Runner/ # iOS 应用配置
|
|
│ │ │ ├── Info.plist # 应用信息配置
|
|
│ │ │ └── Assets.xcassets/ # 应用图标和资源
|
|
│ │ ├── PacketTunnel/ # 网络扩展
|
|
│ │ ├── Flutter/ # Flutter 配置
|
|
│ │ └── Podfile # CocoaPods 依赖
|
|
│ │
|
|
├── 🖥️ macOS 平台
|
|
│ ├── macos/
|
|
│ │ ├── Runner/ # macOS 应用配置
|
|
│ │ │ ├── Configs/ # 配置文件
|
|
│ │ │ │ ├── AppInfo.xcconfig # 应用信息
|
|
│ │ │ │ ├── Signing.xcconfig # 签名配置
|
|
│ │ │ │ ├── Debug.xcconfig # 调试配置
|
|
│ │ │ │ └── Release.xcconfig # 发布配置
|
|
│ │ │ ├── Info.plist # 应用信息
|
|
│ │ │ └── Assets.xcassets/ # 应用图标
|
|
│ │ ├── Flutter/ # Flutter 配置
|
|
│ │ └── Podfile # CocoaPods 依赖
|
|
│ │
|
|
├── 🤖 Android 平台
|
|
│ ├── android/
|
|
│ │ ├── app/
|
|
│ │ │ ├── src/main/
|
|
│ │ │ │ ├── AndroidManifest.xml # Android 清单文件
|
|
│ │ │ │ ├── kotlin/ # Kotlin 代码
|
|
│ │ │ │ └── res/ # Android 资源
|
|
│ │ │ └── build.gradle # 应用构建配置
|
|
│ │ ├── build.gradle # 项目构建配置
|
|
│ │ └── gradle.properties # Gradle 属性
|
|
│ │
|
|
├── 🪟 Windows 平台
|
|
│ ├── windows/
|
|
│ │ ├── runner/ # Windows 应用配置
|
|
│ │ └── CMakeLists.txt # CMake 配置
|
|
│ │
|
|
├── 🐧 Linux 平台
|
|
│ ├── linux/
|
|
│ │ ├── runner/ # Linux 应用配置
|
|
│ │ └── CMakeLists.txt # CMake 配置
|
|
│ │
|
|
├── 🌐 Web 平台
|
|
│ ├── web/
|
|
│ │ ├── index.html # Web 入口文件
|
|
│ │ ├── manifest.json # Web 应用清单
|
|
│ │ └── icons/ # Web 图标
|
|
│ │
|
|
├── 🔧 构建脚本
|
|
│ ├── build_ios.sh # iOS 构建脚本
|
|
│ ├── build_ios_appstore.sh # iOS App Store 构建
|
|
│ ├── build_ios_dmg.sh # iOS DMG 打包
|
|
│ ├── build_macos_dmg.sh # macOS DMG 打包
|
|
│ ├── build_macos_simple.sh # macOS 简单构建
|
|
│ ├── create_dmg.sh # DMG 创建脚本
|
|
│ └── create_dmg_with_installer.sh # 带安装脚本的 DMG
|
|
│ │
|
|
├── 🔐 签名和公证脚本
|
|
│ ├── ios_signing_config.sh # iOS 签名配置
|
|
│ ├── macos_signing_config.sh # macOS 签名配置
|
|
│ ├── sign_and_package.sh # 签名和打包
|
|
│ ├── sign_and_notarize.sh # 签名和公证
|
|
│ ├── notarize_only.sh # 仅公证脚本
|
|
│ ├── notarize_async.sh # 异步公证
|
|
│ ├── complete_notarization.sh # 完成公证
|
|
│ └── check_notarization_status.sh # 检查公证状态
|
|
│ │
|
|
├── 🛠️ 工具脚本
|
|
│ ├── debug_connection.sh # 连接调试
|
|
│ ├── test_connection.sh # 连接测试
|
|
│ ├── install_bearvpn.sh # 安装脚本
|
|
│ ├── get_team_id.sh # 获取团队 ID
|
|
│ └── update_team_id.sh # 更新团队 ID
|
|
│ │
|
|
└── 📄 配置文件
|
|
├── pubspec.yaml # Flutter 项目配置
|
|
├── analysis_options.yaml # Dart 分析配置
|
|
├── .gitignore # Git 忽略文件
|
|
├── README.md # 项目说明
|
|
└── PROJECT_STRUCTURE.md # 项目结构说明(本文件)
|
|
```
|
|
|
|
## ⚙️ 重要配置文件说明
|
|
|
|
### 🔧 核心配置
|
|
|
|
#### 1. **pubspec.yaml** - Flutter 项目配置
|
|
```yaml
|
|
# 位置: /pubspec.yaml
|
|
# 用途: 定义项目依赖、版本、资源等
|
|
# 修改内容:
|
|
name: your_app_name # 应用名称
|
|
description: Your app description # 应用描述
|
|
version: 1.0.0+1 # 版本号
|
|
dependencies: # 依赖包
|
|
flutter: sdk: '>=3.19.0' # Flutter SDK 版本
|
|
```
|
|
|
|
#### 2. **main.dart** - 应用入口
|
|
```dart
|
|
// 位置: /lib/main.dart
|
|
// 用途: 应用启动入口,初始化配置
|
|
// 修改内容: 应用初始化逻辑、全局配置
|
|
```
|
|
|
|
#### 3. **app_config.dart** - 域名和网络配置 ⭐ 重要
|
|
```dart
|
|
// 位置: /lib/app/common/app_config.dart
|
|
// 用途: API 域名、网络配置、应用配置
|
|
// 修改内容:
|
|
class KRDomain {
|
|
// 主域名列表 - 修改这里来更改API服务器域名
|
|
static List<String> kr_baseDomains = [
|
|
"apicn.bearvpn.top", // 主域名1
|
|
"apibear.nsdsox.com" // 主域名2
|
|
];
|
|
|
|
// 当前使用的域名
|
|
static String kr_currentDomain = "apicn.bearvpn.top";
|
|
|
|
// 备用域名获取地址列表
|
|
static List<String> kr_backupDomainUrls = [
|
|
"https://your-backup-server.com/domains.txt",
|
|
// 更多备用地址...
|
|
];
|
|
}
|
|
```
|
|
|
|
### 🍎 iOS 配置
|
|
|
|
#### 1. **Info.plist** - iOS 应用信息
|
|
```xml
|
|
<!-- 位置: /ios/Runner/Info.plist -->
|
|
<!-- 用途: iOS 应用基本信息和权限 -->
|
|
<!-- 修改内容: -->
|
|
<key>CFBundleDisplayName</key>
|
|
<string>Your App Name</string> <!-- 应用显示名称 -->
|
|
<key>CFBundleIdentifier</key>
|
|
<string>com.yourcompany.yourapp</string> <!-- 包标识符 -->
|
|
```
|
|
|
|
#### 2. **Base.xcconfig** - iOS 基础配置
|
|
```bash
|
|
# 位置: /ios/Base.xcconfig
|
|
# 用途: iOS 构建基础配置
|
|
# 修改内容:
|
|
BASE_BUNDLE_IDENTIFIER=com.yourcompany.yourapp # 包标识符
|
|
```
|
|
|
|
### 🖥️ macOS 配置
|
|
|
|
#### 1. **AppInfo.xcconfig** - macOS 应用信息
|
|
```bash
|
|
# 位置: /macos/Runner/Configs/AppInfo.xcconfig
|
|
# 用途: macOS 应用基本信息
|
|
# 修改内容:
|
|
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.yourapp # 包标识符
|
|
PRODUCT_NAME = Your App Name # 应用名称
|
|
```
|
|
|
|
#### 2. **Signing.xcconfig** - macOS 签名配置
|
|
```bash
|
|
# 位置: /macos/Runner/Configs/Signing.xcconfig
|
|
# 用途: macOS 代码签名配置
|
|
# 修改内容:
|
|
CODE_SIGN_IDENTITY = Developer ID Application: Your Company Name (XXXXXXXXXX)
|
|
DEVELOPMENT_TEAM = XXXXXXXXXX
|
|
```
|
|
|
|
### 🤖 Android 配置
|
|
|
|
#### 1. **build.gradle** - Android 构建配置
|
|
```gradle
|
|
// 位置: /android/app/build.gradle
|
|
// 用途: Android 应用构建配置
|
|
// 修改内容:
|
|
android {
|
|
compileSdk 34 // 编译 SDK 版本
|
|
defaultConfig {
|
|
applicationId "com.yourcompany.yourapp" // 应用 ID
|
|
minSdkVersion 21 // 最低 SDK 版本
|
|
targetSdkVersion 34 // 目标 SDK 版本
|
|
}
|
|
}
|
|
```
|
|
|
|
#### 2. **AndroidManifest.xml** - Android 清单文件
|
|
```xml
|
|
<!-- 位置: /android/app/src/main/AndroidManifest.xml -->
|
|
<!-- 用途: Android 应用权限和组件声明 -->
|
|
<!-- 修改内容: -->
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
package="com.yourcompany.yourapp"> <!-- 包名 -->
|
|
```
|
|
|
|
### 🌐 Web 配置
|
|
|
|
#### 1. **index.html** - Web 入口文件
|
|
```html
|
|
<!-- 位置: /web/index.html -->
|
|
<!-- 用途: Web 应用入口页面 -->
|
|
<!-- 修改内容: -->
|
|
<title>Your App Name</title> <!-- 页面标题 -->
|
|
```
|
|
|
|
#### 2. **manifest.json** - Web 应用清单
|
|
```json
|
|
// 位置: /web/manifest.json
|
|
// 用途: Web 应用 PWA 配置
|
|
// 修改内容:
|
|
{
|
|
"name": "Your App Name", // 应用名称
|
|
"short_name": "YourApp", // 短名称
|
|
"start_url": "/", // 启动 URL
|
|
"display": "standalone" // 显示模式
|
|
}
|
|
```
|
|
|
|
## 🔐 签名和公证配置
|
|
|
|
### 1. **iOS 签名配置**
|
|
```bash
|
|
# 文件: ios_signing_config.sh
|
|
# 用途: iOS 应用签名配置
|
|
# 修改内容:
|
|
export APPLE_ID="your-apple-id@example.com" # Apple ID
|
|
export APPLE_PASSWORD="your-app-specific-password" # App 专用密码
|
|
export TEAM_ID="YOUR_TEAM_ID" # 团队 ID
|
|
export BUNDLE_ID="com.yourcompany.yourapp" # 包标识符
|
|
```
|
|
|
|
### 2. **macOS 签名配置**
|
|
```bash
|
|
# 文件: macos_signing_config.sh
|
|
# 用途: macOS 应用签名配置
|
|
# 修改内容:
|
|
export APPLE_ID="your-apple-id@example.com" # Apple ID
|
|
export APPLE_PASSWORD="your-app-specific-password" # App 专用密码
|
|
export TEAM_ID="YOUR_TEAM_ID" # 团队 ID
|
|
export SIGNING_IDENTITY="Developer ID Application: Your Name (YOUR_TEAM_ID)"
|
|
```
|
|
|
|
## 🌍 多语言配置
|
|
|
|
### 翻译文件位置
|
|
```
|
|
assets/translations/
|
|
├── strings_zh.i18n.json # 简体中文
|
|
├── strings_zh_Hant.i18n.json # 繁体中文
|
|
├── strings_en.i18n.json # 英文
|
|
├── strings_ja.i18n.json # 日文
|
|
├── strings_es.i18n.json # 西班牙文
|
|
├── strings_ru.i18n.json # 俄文
|
|
└── strings_et.i18n.json # 爱沙尼亚文
|
|
```
|
|
|
|
## 🚀 构建和部署
|
|
|
|
### 1. **Flutter 构建命令**
|
|
```bash
|
|
# 构建所有平台
|
|
flutter build apk # Android APK
|
|
flutter build ios # iOS
|
|
flutter build macos # macOS
|
|
flutter build windows # Windows
|
|
flutter build linux # Linux
|
|
flutter build web # Web
|
|
```
|
|
|
|
### 2. **使用构建脚本**
|
|
```bash
|
|
# iOS 构建
|
|
./build_ios.sh
|
|
|
|
# macOS 构建
|
|
./build_macos_simple.sh
|
|
|
|
# 签名和打包
|
|
./sign_and_package.sh
|
|
|
|
# 公证
|
|
./notarize_only.sh
|
|
```
|
|
|
|
## 📝 开发注意事项
|
|
|
|
1. **敏感信息**: 所有敏感信息已替换为占位符,使用前请修改为实际值
|
|
2. **包标识符**: 确保所有平台的包标识符一致
|
|
3. **签名证书**: 需要有效的 Apple Developer 证书
|
|
4. **版本管理**: 更新版本时同步修改所有配置文件
|
|
5. **多语言**: 添加新语言时更新所有翻译文件
|
|
|
|
## 🔗 相关文档
|
|
|
|
- [Flutter 官方文档](https://flutter.dev/docs)
|
|
- [iOS 开发指南](https://developer.apple.com/ios/)
|
|
- [macOS 开发指南](https://developer.apple.com/macos/)
|
|
- [Android 开发指南](https://developer.android.com/)
|
|
- [Web 开发指南](https://web.dev/)
|
|
|
|
---
|
|
|
|
**最后更新**: 2024年9月23日
|