Skip to content

Commit 168d26b

Browse files
committed
refactor: restructure project architecture and clean up codebase
The entire project structure has been reorganized to improve maintainability and scalability. This includes consolidating core modules, removing redundant files, and aligning the directory hierarchy with current architectural standards. These changes do not alter the external behavior of the system.
1 parent a5bbf8a commit 168d26b

103 files changed

Lines changed: 6178 additions & 2490 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.g.dart linguist-generated=true

.github/workflows/build.yml

Lines changed: 114 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,139 @@
1+
name: Fast Multi-Platform Build
2+
13
on:
24
workflow_dispatch:
35
push:
46
tags:
57
- '*'
8+
9+
permissions:
10+
contents: write
11+
612
jobs:
7-
web:
13+
prepare:
814
runs-on: ubuntu-latest
15+
outputs:
16+
tag_name: ${{ steps.vars.outputs.tag_name }}
917
steps:
1018
- uses: actions/checkout@v4
11-
with:
12-
fetch-depth: 0 # 获取完整历史,以便获取最新的提交哈希
1319
- uses: subosito/flutter-action@v2
14-
- run: flutter pub get
15-
- run: flutter build web --release
16-
- run: tar -czvf web.tar.gz -C build/web .
17-
- uses: softprops/action-gh-release@v2
1820
with:
19-
files: web.tar.gz
20-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
21-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
22-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
23-
prerelease: false
24-
linux:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/checkout@v4
21+
cache: true
22+
23+
- id: vars
24+
run: echo "tag_name=${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}" >> $GITHUB_OUTPUT
25+
26+
- name: Install dependencies
27+
run: flutter pub get
28+
29+
- name: Generate Code
30+
run: dart run build_runner build --delete-conflicting-outputs
31+
32+
- name: Upload Generated Files
33+
uses: actions/upload-artifact@v4
2834
with:
29-
fetch-depth: 0
30-
- uses: subosito/flutter-action@v2
31-
- run: |
32-
sudo apt-get update -y
33-
sudo apt-get install -y ninja-build libgtk-3-dev
34-
- run: flutter pub get
35-
- run: flutter build linux --release
36-
- run: tar -czvf linux-x64.tar.gz -C build/linux/x64/release/bundle .
37-
- uses: softprops/action-gh-release@v2
38-
with:
39-
files: linux-x64.tar.gz
40-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
41-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
42-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
43-
prerelease: false
44-
android:
45-
runs-on: ubuntu-latest
35+
name: generated-code
36+
path: |
37+
lib/**/*.g.dart
38+
.dart_tool/ # 包含 pub 缓存索引,非常重要
39+
40+
build:
41+
needs: prepare
42+
runs-on: ${{ matrix.config.os }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
config:
47+
- { os: ubuntu-latest, platform: web, name: web }
48+
- { os: ubuntu-latest, platform: apk, name: android }
49+
- { os: ubuntu-latest, platform: linux, name: linux }
50+
- { os: windows-latest, platform: windows, name: windows }
51+
- { os: macos-latest, platform: macos, name: macos }
52+
- { os: macos-latest, platform: ios, name: ios, args: "--no-codesign" }
53+
4654
steps:
4755
- uses: actions/checkout@v4
48-
with:
49-
fetch-depth: 0
50-
- uses: actions/setup-java@v4
56+
57+
# 1. 【Android 专用优化】设置 Java 和 Gradle 缓存
58+
- name: Setup Java
59+
if: matrix.config.name == 'android'
60+
uses: actions/setup-java@v4
5161
with:
5262
distribution: 'temurin'
5363
java-version: '17'
64+
65+
- name: Setup Gradle
66+
if: matrix.config.name == 'android'
67+
uses: gradle/actions/setup-gradle@v3 # 核心加速器:缓存 Gradle 依赖和构建输出
68+
69+
# 2. 设置 Flutter
5470
- uses: subosito/flutter-action@v2
55-
- run: flutter pub get
56-
- run: flutter build apk --target-platform android-arm64
57-
- uses: softprops/action-gh-release@v2
5871
with:
59-
files: build/app/outputs/flutter-apk/app-release.apk
60-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
61-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
62-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
63-
prerelease: false
64-
windows:
65-
runs-on: windows-latest
66-
steps:
67-
- uses: actions/checkout@v4
72+
cache: true
73+
74+
# 3. 下载预生成的代码
75+
- name: Download Generated Files
76+
uses: actions/download-artifact@v4
6877
with:
69-
fetch-depth: 0
70-
- uses: subosito/flutter-action@v2
71-
- run: flutter pub get
72-
- run: flutter build windows --release
73-
- run: Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath windows-x64.zip
74-
- uses: softprops/action-gh-release@v2
78+
name: generated-code
79+
80+
- name: Install System Dependencies (Linux)
81+
if: matrix.config.platform == 'linux'
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y ninja-build libgtk-3-dev
85+
86+
# 4. 编译(由于下载了 .dart_tool,pub get 会极快)
87+
- name: Build
88+
run: |
89+
flutter pub get --offline || flutter pub get # 优先尝试离线模式
90+
flutter build ${{ matrix.config.platform }} --release ${{ matrix.config.args }}
91+
92+
# 5. 产物打包(修正了路径和逻辑)
93+
- name: Package Assets
94+
shell: bash
95+
run: |
96+
if [ "${{ matrix.config.platform }}" == "web" ]; then
97+
tar -czvf web.tar.gz -C build/web .
98+
elif [ "${{ matrix.config.platform }}" == "linux" ]; then
99+
tar -czvf linux-x64.tar.gz -C build/linux/x64/release/bundle .
100+
elif [ "${{ matrix.config.platform }}" == "windows" ]; then
101+
cd build/windows/x64/runner/Release && 7z a ../../../../../windows-x64.zip *
102+
elif [ "${{ matrix.config.platform }}" == "macos" ]; then
103+
cd build/macos/Build/Products/Release && tar -czvf ../../../../../macos.tar.gz *.app
104+
elif [ "${{ matrix.config.platform }}" == "ios" ]; then
105+
cd build/ios/iphoneos && tar -czvf ../../../ios.tar.gz Runner.app
106+
elif [ "${{ matrix.config.platform }}" == "apk" ]; then
107+
cp build/app/outputs/flutter-apk/app-release.apk android-release.apk
108+
fi
109+
110+
- name: Upload Platform Artifacts
111+
uses: actions/upload-artifact@v4
75112
with:
76-
files: windows-x64.zip
77-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
78-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
79-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
80-
prerelease: false
81-
macos:
82-
runs-on: macos-latest
113+
name: build-artifacts-${{ matrix.config.name }}
114+
path: |
115+
*.tar.gz
116+
*.zip
117+
*.apk
118+
119+
publish:
120+
needs: [prepare, build]
121+
runs-on: ubuntu-latest
122+
if: startsWith(github.ref, 'refs/tags/') # 仅在有 Tag 时发布
83123
steps:
84-
- uses: actions/checkout@v4
124+
- name: Download All Artifacts
125+
uses: actions/download-artifact@v4
85126
with:
86-
fetch-depth: 0
87-
- uses: subosito/flutter-action@v2
88-
- run: flutter pub get
89-
- run: flutter build macos --release
90-
- run: tar -czvf macos.tar.gz -C build/macos/Build/Products/Release auth.app
91-
- uses: softprops/action-gh-release@v2
127+
path: release-assets
128+
pattern: build-artifacts-*
129+
merge-multiple: true
130+
131+
- name: Release
132+
uses: softprops/action-gh-release@v2
92133
with:
93-
files: macos.tar.gz
94-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
95-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
96-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
134+
files: release-assets/*
135+
tag_name: ${{ needs.prepare.outputs.tag_name }}
136+
name: Release ${{ needs.prepare.outputs.tag_name }}
137+
draft: false
97138
prerelease: false
98-
ios:
99-
runs-on: macos-latest
100-
steps:
101-
- uses: actions/checkout@v4
102-
with:
103-
fetch-depth: 0
104-
- uses: subosito/flutter-action@v2
105-
- run: flutter pub get
106-
- run: flutter build ios --release --no-codesign
107-
- run: tar -czvf ios.tar.gz -C build/ios/iphoneos Runner.app
108-
- uses: softprops/action-gh-release@v2
109-
with:
110-
files: ios.tar.gz
111-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
112-
name: Release ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}
113-
draft: ${{ startsWith(github.ref, 'refs/tags/') == false }}
114-
prerelease: false
139+
generate_release_notes: true

.metadata

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "05db9689081f091050f01aed79f04dce0c750154"
7+
revision: "67323de285b00232883f53b84095eb72be97d35c"
88
channel: "stable"
99

1010
project_type: app
@@ -13,26 +13,26 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
17-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
16+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
17+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
1818
- platform: android
19-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
20-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
19+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
20+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
2121
- platform: ios
22-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
23-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
22+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
23+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
2424
- platform: linux
25-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
26-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
25+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
26+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
2727
- platform: macos
28-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
29-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
28+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
29+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
3030
- platform: web
31-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
32-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
31+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
32+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
3333
- platform: windows
34-
create_revision: 05db9689081f091050f01aed79f04dce0c750154
35-
base_revision: 05db9689081f091050f01aed79f04dce0c750154
34+
create_revision: 67323de285b00232883f53b84095eb72be97d35c
35+
base_revision: 67323de285b00232883f53b84095eb72be97d35c
3636

3737
# User provided section
3838

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ This project is licensed under the [GPL-3.0 License](LICENSE).
216216
- [elliotwutingfeng/motp](https://github.com/elliotwutingfeng/motp)
217217
- [stratumauth](https://github.com/stratumauth/app)
218218
- [simple-icons](https://github.com/simple-icons/simple-icons)
219-
- [sembast](https://pub.dev/packages/sembast)
219+
- [drift](https://pub.dev/packages/drift)
220220
- [google_mlkit_barcode_scanning](https://pub.dev/packages/google_mlkit_barcode_scanning)
221221
- [dynamic_color](https://pub.dev/packages/dynamic_color)
222222
- [flutter_swipe_action_cell](https://pub.dev/packages/flutter_swipe_action_cell)

analysis_options.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
# The following line activates a set of recommended lints for Flutter apps,
99
# packages, and plugins designed to encourage good coding practices.
1010
include: package:flutter_lints/flutter.yaml
11-
11+
analyzer:
12+
exclude:
13+
- "**/*.g.dart"
14+
- "**/*.freezed.dart"
15+
- "lib/generated/**" # 你之前配置的 l10n 目录
1216
linter:
1317
# The lint rules applied to this project can be customized in the
1418
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
@@ -33,7 +37,8 @@ linter:
3337
prefer_typing_uninitialized_variables: true # 为未初始化的变量添加类型注解
3438
prefer_collection_literals: true # 优先使用集合字面量语法
3539
prefer_expression_function_bodies: false # 优先使用表达式函数体而不是块函数体 (已禁用)
36-
prefer_relative_imports: true # 优先使用相对导入
40+
prefer_relative_imports: false # 优先使用相对导入
41+
always_use_package_imports: true # 开启绝对路径建议 (强制使用 package: 导入)
3742
sort_constructors_first: true # 构造函数声明应该放在非构造函数声明之前
3843
sort_unnamed_constructors_first: true # 未命名构造函数应该放在命名构造函数之前
3944

@@ -163,6 +168,6 @@ linter:
163168

164169
# ========== 递归规则 ==========
165170
recursive_getters: true # 避免递归getter
166-
171+
lines_longer_than_80_chars: false
167172
# Additional information about this file can be found at
168173
# https://dart.dev/guides/language/analysis-options

android/app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ android {
2121
signingConfigs {
2222
create("release") {
2323
keyAlias = "halifox"
24-
keyPassword = System.getenv("KEY_PASSWORD")
24+
keyPassword = "halifox"
2525
storeFile = file("halifox.jks")
26-
storePassword = System.getenv("KEYSTORE_PASSWORD")
26+
storePassword = "halifox"
2727
}
2828
}
2929
defaultConfig {

assets/fonts/GothamRnd_Medium.otf

-123 KB
Binary file not shown.
129 KB
Binary file not shown.

assets/icons.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
targets:
2+
drift_target:
3+
builders:
4+
drift_dev:
5+
enabled: true
6+
riverpod_generator:
7+
enabled: false
8+
sources:
9+
- lib/db/**
10+
11+
$default:
12+
dependencies:
13+
- :drift_target
14+
builders:
15+
drift_dev:
16+
enabled: false
17+
riverpod_generator:
18+
enabled: true
19+
sources:
20+
include:
21+
- lib/**
22+
- test/**
23+
- $package$
24+
exclude:
25+
- lib/db/**

0 commit comments

Comments
 (0)