1、修正部分性能问题代码
This commit is contained in:
shenzuqiang 2026-03-11 17:56:33 +08:00
parent 8ebaad0144
commit 7546fdfd53
1 changed files with 14 additions and 13 deletions

View File

@ -113,14 +113,15 @@ class MainActivity : ComponentActivity(), LoadingCallback {
val reportViewModel:ReportViewModel = viewModel()
generalViewModel = ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(application))[GeneralViewModel::class.java]
val updateAppNotify by GlobalStateManager(context).globalUpdateNotifyFlow().collectAsState(initial = false)
val updateUniDownloadNotify by GlobalStateManager(context).globalUniDownloadNotifyFlow().collectAsState(initial = false)
val updateUserConfigNotify by GlobalStateManager(context).globalUserConfigNotifyFlow().collectAsState(initial = false)
val updateUniUpdateNotify by GlobalStateManager(context).globalUniUpdateNotifyFlow().collectAsState(initial = false)
val updateGlobalLoadingNotify by GlobalStateManager(context).isGlobalLoadingFlow().collectAsState(initial = false)
val globalStateManager = remember { GlobalStateManager(context) }
val updateAppNotify by globalStateManager.globalUpdateNotifyFlow().collectAsState(initial = false)
val updateUniDownloadNotify by globalStateManager.globalUniDownloadNotifyFlow().collectAsState(initial = false)
val updateUserConfigNotify by globalStateManager.globalUserConfigNotifyFlow().collectAsState(initial = false)
val updateUniUpdateNotify by globalStateManager.globalUniUpdateNotifyFlow().collectAsState(initial = false)
val updateGlobalLoadingNotify by globalStateManager.isGlobalLoadingFlow().collectAsState(initial = false)
//重置状态信息(防止异常退出导致状态失效)
LaunchedEffect(Unit) {
GlobalStateManager(context).apply {
globalStateManager.apply {
storeGlobalUpdateNotify(false)
storeGlobalUniDownloadNotify(false)
storeGlobalUserConfigNotify(false)
@ -179,13 +180,13 @@ class MainActivity : ComponentActivity(), LoadingCallback {
delay(300)
if(updateUserConfigNotify == true){
coroutineScope.launch {
GlobalStateManager(context).storeGlobalUserConfigNotify(false)
globalStateManager.storeGlobalUserConfigNotify(false)
}
}
}
//提示下载小程序资源(在跳转指定页面时,未下载资源需要提示)
val progressWGTToPageState = mutableFloatStateOf(0f)
val progressWGTToPageState = remember { mutableFloatStateOf(0f) }
LaunchedEffect(updateUniDownloadNotify) {
if(updateUniDownloadNotify == true) {
UniAppUtils.currentDownloadUniMp?.let{
@ -205,7 +206,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
progressWGTToPageState.floatValue = 1f
Log.i("HomeScreen", "DOWNLOAD_FINISH")
coroutineScope.launch {
GlobalStateManager(context).storeGlobalUniDownloadNotify(
globalStateManager.storeGlobalUniDownloadNotify(
false
)
}
@ -216,7 +217,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
progressWGTToPageState.floatValue = -1f
Log.i("HomeScreen", "DOWNLOAD_FAIL")
coroutineScope.launch {
GlobalStateManager(context).storeGlobalUniDownloadNotify(
globalStateManager.storeGlobalUniDownloadNotify(
false
)
}
@ -331,7 +332,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
if(!isUpdateFinish && !isCancel && data != null){
isDownloadingWGT.value = true
}else{
coroutineScope.launch { GlobalStateManager(context).storeGlobalUniUpdateNotify(false) }
coroutineScope.launch { globalStateManager.storeGlobalUniUpdateNotify(false) }
}
}
)
@ -354,7 +355,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
){ state, isCancel, url ->
if(isCancel) {
coroutineScope.launch {
GlobalStateManager(context).storeGlobalUpdateNotify(state)
globalStateManager.storeGlobalUpdateNotify(state)
}
}
if(!isCancel){
@ -374,7 +375,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
}
if(PreferenceUtil.getUserConfig()?.config?.versionEntity?.force == false) {
coroutineScope.launch {
GlobalStateManager(context).storeGlobalUpdateNotify(
globalStateManager.storeGlobalUpdateNotify(
state
)
}