parent
5f0a7b3a22
commit
31834b320d
|
|
@ -135,7 +135,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
LaunchedEffect(generalViewModel.serverTime.value) {
|
LaunchedEffect(generalViewModel.serverTime.value) {
|
||||||
if (generalViewModel.serverTime.value != null){
|
if (generalViewModel.serverTime.value != null){
|
||||||
// 获取用户配置
|
// 获取用户配置
|
||||||
loginViewModel.requestUserConfig()
|
loginViewModel.requestUserConfig(isInitConfig = true)
|
||||||
initUM()
|
initUM()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -328,6 +328,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
desc = PreferenceUtil.getUserConfig()?.config?.versionEntity?.description?:"",
|
desc = PreferenceUtil.getUserConfig()?.config?.versionEntity?.description?:"",
|
||||||
url = PreferenceUtil.getUserConfig()?.config?.versionEntity?.url?:"",
|
url = PreferenceUtil.getUserConfig()?.config?.versionEntity?.url?:"",
|
||||||
scope = coroutineScope,
|
scope = coroutineScope,
|
||||||
|
isForce = PreferenceUtil.getUserConfig()?.config?.versionEntity?.force?:false,
|
||||||
isStartDown = isStartDownload,
|
isStartDown = isStartDownload,
|
||||||
downProgress = progressState
|
downProgress = progressState
|
||||||
){ state, isCancel, url ->
|
){ state, isCancel, url ->
|
||||||
|
|
@ -351,8 +352,12 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
filePath?.let {
|
filePath?.let {
|
||||||
UpdateUtils.install(context,it)
|
UpdateUtils.install(context,it)
|
||||||
}
|
}
|
||||||
|
if(PreferenceUtil.getUserConfig()?.config?.versionEntity?.force == false) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
GlobalStateManager(context).storeGlobalUpdateNotify(state)
|
GlobalStateManager(context).storeGlobalUpdateNotify(
|
||||||
|
state
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ fun UpdateDialog(
|
||||||
desc: String = "修复了一些问题,新增了一些功能",
|
desc: String = "修复了一些问题,新增了一些功能",
|
||||||
url: String,
|
url: String,
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
|
isForce: Boolean = false,
|
||||||
isStartDown: MutableState<Boolean>,
|
isStartDown: MutableState<Boolean>,
|
||||||
downProgress: MutableState<Float>,
|
downProgress: MutableState<Float>,
|
||||||
onStatusChange: (state: Boolean, isCancel: Boolean, url:String) -> Unit
|
onStatusChange: (state: Boolean, isCancel: Boolean, url:String) -> Unit
|
||||||
|
|
@ -170,6 +171,7 @@ fun UpdateDialog(
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
if(!isForce){
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
@ -208,6 +210,7 @@ fun UpdateDialog(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(11.dp)
|
.width(11.dp)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,7 @@ fun MineScreen(
|
||||||
val versionConfig =
|
val versionConfig =
|
||||||
PreferenceUtil.getUserConfig()?.config?.versionEntity
|
PreferenceUtil.getUserConfig()?.config?.versionEntity
|
||||||
|
|
||||||
AppUpdate.checkUpdate(versionConfig) { isUpdate, tips ->
|
AppUpdate.checkUpdate(versionConfig) { isUpdate, _, tips ->
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
//提示执行更新
|
//提示执行更新
|
||||||
//startUpdate(result, fragment)
|
//startUpdate(result, fragment)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import com.img.rabbit.BuildConfig
|
||||||
import com.img.rabbit.bean.response.VersionEntity
|
import com.img.rabbit.bean.response.VersionEntity
|
||||||
|
|
||||||
object AppUpdate {
|
object AppUpdate {
|
||||||
fun checkUpdate(versionInfo: VersionEntity?, onResult: (isUpdate: Boolean, tips: String) -> Unit) {
|
fun checkUpdate(versionInfo: VersionEntity?, onResult: (isUpdate: Boolean, isForce: Boolean, tips: String) -> Unit) {
|
||||||
|
|
||||||
if(versionInfo == null){
|
if(versionInfo == null){
|
||||||
onResult.invoke(false, "已是最新版本")
|
onResult.invoke(false, false, "已是最新版本")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
versionInfo.apply {
|
versionInfo.apply {
|
||||||
|
|
@ -18,11 +18,11 @@ object AppUpdate {
|
||||||
} else if (checkVersion(last_version_force, BuildConfig.VERSION_NAME)) {
|
} else if (checkVersion(last_version_force, BuildConfig.VERSION_NAME)) {
|
||||||
force = true
|
force = true
|
||||||
}
|
}
|
||||||
onResult.invoke(true, "检测到新版本")
|
onResult.invoke(true, force, "检测到新版本")
|
||||||
//提示执行更新
|
//提示执行更新
|
||||||
//startUpdate(result, fragment)
|
//startUpdate(result, fragment)
|
||||||
} else {
|
} else {
|
||||||
onResult.invoke(false, "当前版本为最新版本")
|
onResult.invoke(false, force, "当前版本为最新版本")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.util.Log
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.alipay.sdk.app.AuthTask
|
import com.alipay.sdk.app.AuthTask
|
||||||
import com.img.rabbit.pages.LoginScreenType
|
import com.img.rabbit.pages.LoginScreenType
|
||||||
import com.g.gysdk.GYManager
|
import com.g.gysdk.GYManager
|
||||||
|
|
@ -27,13 +28,17 @@ import com.img.rabbit.provider.storage.GlobalStateManager
|
||||||
import com.img.rabbit.provider.storage.PreferenceUtil
|
import com.img.rabbit.provider.storage.PreferenceUtil
|
||||||
import com.img.rabbit.provider.utils.HeadParamUtils.applicationContext
|
import com.img.rabbit.provider.utils.HeadParamUtils.applicationContext
|
||||||
import com.img.rabbit.utils.AppEventBus
|
import com.img.rabbit.utils.AppEventBus
|
||||||
|
import com.img.rabbit.utils.AppUpdate
|
||||||
import com.img.rabbit.utils.LoginBindEvent
|
import com.img.rabbit.utils.LoginBindEvent
|
||||||
import com.img.rabbit.utils.MMKVUtils
|
import com.img.rabbit.utils.MMKVUtils
|
||||||
import com.img.rabbit.utils.StringUtils
|
import com.img.rabbit.utils.StringUtils
|
||||||
import com.tencent.mm.opensdk.modelmsg.SendAuth
|
import com.tencent.mm.opensdk.modelmsg.SendAuth
|
||||||
import com.tencent.mm.opensdk.openapi.IWXAPI
|
import com.tencent.mm.opensdk.openapi.IWXAPI
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
|
@ -102,7 +107,7 @@ class LoginViewModel : BaseViewModel() {
|
||||||
errorState.value = null
|
errorState.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestUserConfig(){
|
fun requestUserConfig(isInitConfig: Boolean = false){
|
||||||
mLaunch {
|
mLaunch {
|
||||||
//先置空配置
|
//先置空配置
|
||||||
PreferenceUtil.saveUserConfig(null)
|
PreferenceUtil.saveUserConfig(null)
|
||||||
|
|
@ -114,6 +119,16 @@ class LoginViewModel : BaseViewModel() {
|
||||||
PreferenceUtil.saveUserConfig(response.data)
|
PreferenceUtil.saveUserConfig(response.data)
|
||||||
userConfigResult.value = response
|
userConfigResult.value = response
|
||||||
|
|
||||||
|
if(isInitConfig){
|
||||||
|
AppUpdate.checkUpdate(response.data.config?.versionEntity) { isUpdate, isForce, _ ->
|
||||||
|
if(isUpdate && isForce){
|
||||||
|
//强制更新
|
||||||
|
viewModelScope.launch{
|
||||||
|
applicationContext?.let { GlobalStateManager(it) }?.storeGlobalUpdateNotify(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//以下是刷新状态
|
//以下是刷新状态
|
||||||
applicationContext?.let { GlobalStateManager(it) }?.storeGlobalUserConfigNotify(true)
|
applicationContext?.let { GlobalStateManager(it) }?.storeGlobalUserConfigNotify(true)
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue