0ce50d4b8d
- 工具栏新增检查更新按钮:启动静默检查,发现新版本时显示红色角标; 未检测到新版本或安装包时弹窗提示「当前已是最新版本」 - 更新源:Gitea Releases(说明 = Release 正文 Markdown;安装包 = 附件, 不进入 git 历史,仓库保持精简) - 安卓:下载 APK → FileProvider + 系统安装器直接覆盖安装(签名一致) - Windows:下载绿色版 zip → 解压 → 生成替换脚本,主程序退出后原地覆盖并自动重启 - 新增 lib/update/update_service.dart、lib/ui/update_dialog.dart、lib/version.dart - 安卓侧:REQUEST_INSTALL_PACKAGES + FileProvider + installApk/getCacheDir 通道 + androidx.core - 发版工具:scripts/publish_release.ps1(打包 dist、创建 Release、上传附件) - 测试:test/update_version_test.dart(版本比较 4 组);启动检查在测试环境自动跳过 - 版本号 1.2.0+12;BUILD-NOTES 补充应用内更新与发版流程
80 lines
2.8 KiB
Kotlin
80 lines
2.8 KiB
Kotlin
import java.io.FileInputStream
|
|
import java.util.Properties
|
|
|
|
plugins {
|
|
id("com.android.application")
|
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
|
id("dev.flutter.flutter-gradle-plugin")
|
|
}
|
|
|
|
// 正式签名配置:android/key.properties(不入库)提供密钥信息;
|
|
// 缺失时回退 debug 签名,保证无密钥环境也能构建。
|
|
val keystoreProperties = Properties()
|
|
val keystorePropertiesFile = rootProject.file("key.properties")
|
|
if (keystorePropertiesFile.exists()) {
|
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
|
}
|
|
|
|
android {
|
|
namespace = "cc.sincos.sequence_diagram"
|
|
compileSdk = flutter.compileSdkVersion
|
|
ndkVersion = flutter.ndkVersion
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
defaultConfig {
|
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
|
applicationId = "cc.sincos.sequence_diagram"
|
|
// You can update the following values to match your application needs.
|
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
|
minSdk = flutter.minSdkVersion
|
|
targetSdk = flutter.targetSdkVersion
|
|
// Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION
|
|
// is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions)
|
|
// You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true`
|
|
// flag during build.
|
|
versionCode = flutter.versionCode
|
|
versionName = flutter.versionName
|
|
}
|
|
|
|
signingConfigs {
|
|
create("release") {
|
|
if (keystorePropertiesFile.exists()) {
|
|
keyAlias = keystoreProperties["keyAlias"] as String
|
|
keyPassword = keystoreProperties["keyPassword"] as String
|
|
storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
|
|
storePassword = keystoreProperties["storePassword"] as String
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
// 有 key.properties 时使用正式签名;否则回退 debug 签名。
|
|
signingConfig = if (keystorePropertiesFile.exists()) {
|
|
signingConfigs.getByName("release")
|
|
} else {
|
|
signingConfigs.getByName("debug")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
|
}
|
|
}
|
|
|
|
flutter {
|
|
source = "../.."
|
|
}
|
|
|
|
dependencies {
|
|
// 应用内更新:FileProvider(把缓存中的新版本 APK 以 content:// 提供给系统安装器)。
|
|
implementation("androidx.core:core-ktx:1.13.1")
|
|
}
|