Skip to content

Commit

Permalink
增加 BuildConfig 插件,更新版本更加方便。
Browse files Browse the repository at this point in the history
  • Loading branch information
tangshimin committed Mar 10, 2024
1 parent a1f1081 commit 067bfd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
kotlin("plugin.serialization") version "1.8.0"
id("com.github.gmazzo.buildconfig") version "5.3.5"
}

group = "com.movcontext"
version = "2.2.16"

buildConfig {
buildConfigField("APP_NAME", provider { "幕境" })
buildConfigField("APP_VERSION", provider { "v${project.version}" })
}

repositories {
google()
mavenCentral()
Expand Down
11 changes: 4 additions & 7 deletions src/jvmMain/kotlin/ui/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.*
import com.darkrockstudios.libraries.mpfilepicker.FilePicker
import com.movcontext.MuJing.BuildConfig
import data.*
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -51,10 +52,6 @@ import javax.swing.JOptionPane
import kotlin.concurrent.schedule


// build.gradle.kts 的版本也需要更改
const val version = "v2.2.16"


@ExperimentalFoundationApi
@ExperimentalAnimationApi
@OptIn(
Expand Down Expand Up @@ -251,7 +248,7 @@ fun App() {
LaunchedEffect(Unit){
if( appState.global.autoUpdate){
Timer("update",false).schedule(5000){
val result = autoDetectingUpdates(version)
val result = autoDetectingUpdates(BuildConfig.APP_VERSION)
if(result.first && result.second != appState.global.ignoreVersion){
appState.showUpdateDialog = true
appState.latestVersion = result.second
Expand Down Expand Up @@ -686,7 +683,7 @@ private fun FrameWindowScope.WindowMenuBar(
Item("关于(A)", mnemonic = 'A', onClick = { aboutDialogVisible = true })
if (aboutDialogVisible) {
AboutDialog(
version = version,
version = BuildConfig.APP_VERSION,
close = { aboutDialogVisible = false }
)
}
Expand Down Expand Up @@ -982,7 +979,7 @@ fun MenuDialogs(state: AppState) {
if(state.showUpdateDialog){
UpdateDialog(
close = {state.showUpdateDialog = false},
version = version,
version =BuildConfig.APP_VERSION,
autoUpdate = state.global.autoUpdate,
setAutoUpdate = {
state.global.autoUpdate = it
Expand Down

0 comments on commit 067bfd4

Please sign in to comment.