parent
fefe0ec8b7
commit
decdad3de1
|
|
@ -4,7 +4,7 @@
|
||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-03-11T06:38:33.168759600Z">
|
<DropdownSelection timestamp="2026-03-11T08:00:19.371243300Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=Y5DELZR46DZTCI9D" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=Y5DELZR46DZTCI9D" />
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
val reportViewModel:ReportViewModel = viewModel()
|
val reportViewModel:ReportViewModel = viewModel()
|
||||||
generalViewModel = ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(application))[GeneralViewModel::class.java]
|
generalViewModel = ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(application))[GeneralViewModel::class.java]
|
||||||
|
|
||||||
var updateAppNotify by mutableStateOf(GlobalStateManager(context).globalUpdateNotifyFlow().collectAsState(initial = false))
|
val updateAppNotify by GlobalStateManager(context).globalUpdateNotifyFlow().collectAsState(initial = false)
|
||||||
val updateUniDownloadNotify by GlobalStateManager(context).globalUniDownloadNotifyFlow().collectAsState(initial = false)
|
val updateUniDownloadNotify by GlobalStateManager(context).globalUniDownloadNotifyFlow().collectAsState(initial = false)
|
||||||
val updateUserConfigNotify by GlobalStateManager(context).globalUserConfigNotifyFlow().collectAsState(initial = false)
|
val updateUserConfigNotify by GlobalStateManager(context).globalUserConfigNotifyFlow().collectAsState(initial = false)
|
||||||
val updateUniUpdateNotify by GlobalStateManager(context).globalUniUpdateNotifyFlow().collectAsState(initial = false)
|
val updateUniUpdateNotify by GlobalStateManager(context).globalUniUpdateNotifyFlow().collectAsState(initial = false)
|
||||||
|
|
@ -317,7 +317,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
//App更新提示
|
//App更新提示
|
||||||
val isStartDownload = mutableStateOf(false)
|
val isStartDownload = mutableStateOf(false)
|
||||||
val progressState = mutableFloatStateOf(0f)
|
val progressState = mutableFloatStateOf(0f)
|
||||||
if(updateAppNotify.value == true){
|
if(updateAppNotify == true){
|
||||||
UpdateDialog(
|
UpdateDialog(
|
||||||
title = PreferenceUtil.getUserConfig()?.config?.versionEntity?.title?:"新版本,更新提示",
|
title = PreferenceUtil.getUserConfig()?.config?.versionEntity?.title?:"新版本,更新提示",
|
||||||
newVersion = "V${PreferenceUtil.getUserConfig()?.config?.versionEntity?.version}",
|
newVersion = "V${PreferenceUtil.getUserConfig()?.config?.versionEntity?.version}",
|
||||||
|
|
@ -397,7 +397,6 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showLoading() {
|
override fun showLoading() {
|
||||||
Log.i("HomeScreen","isStartOn--->${System.currentTimeMillis()}")
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
GlobalStateManager(this@MainActivity).storeGlobalLoading(true)
|
GlobalStateManager(this@MainActivity).storeGlobalLoading(true)
|
||||||
}
|
}
|
||||||
|
|
@ -405,7 +404,6 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideLoading() {
|
override fun hideLoading() {
|
||||||
Log.i("HomeScreen","isStartOff--->${System.currentTimeMillis()}")
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
delay(3000L)
|
delay(3000L)
|
||||||
GlobalStateManager(this@MainActivity).storeGlobalLoading(false)
|
GlobalStateManager(this@MainActivity).storeGlobalLoading(false)
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,14 @@ import org.json.JSONObject
|
||||||
fun HomeScreen(
|
fun HomeScreen(
|
||||||
navController: NavHostController,
|
navController: NavHostController,
|
||||||
generalViewModel: GeneralViewModel,
|
generalViewModel: GeneralViewModel,
|
||||||
|
reportViewModel: ReportViewModel = viewModel(),
|
||||||
loadingCallback: LoadingCallback?
|
loadingCallback: LoadingCallback?
|
||||||
) {
|
) {
|
||||||
val TAG = "Rabbit_HomeScreen"
|
val TAG = "Rabbit_HomeScreen"
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope: CoroutineScope = rememberCoroutineScope()
|
val scope: CoroutineScope = rememberCoroutineScope()
|
||||||
val reportViewModel = viewModel<ReportViewModel>()
|
// val progressPair = mutableStateMapOf<String, Float>()
|
||||||
val progressPair = mutableStateMapOf<String, Float>()
|
val progressPair = remember { mutableStateMapOf<String, Float>() }
|
||||||
|
|
||||||
// 获取当前路由状态
|
// 获取当前路由状态
|
||||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
|
|
@ -1492,7 +1493,7 @@ fun HomeScreen(
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
@Composable
|
@Composable
|
||||||
private fun PreviewHomeScreen() {
|
private fun PreviewHomeScreen() {
|
||||||
HomeScreen(navController = rememberNavController(), generalViewModel = viewModel(), object: LoadingCallback{
|
HomeScreen(navController = rememberNavController(), generalViewModel = viewModel(), reportViewModel = viewModel(), object: LoadingCallback{
|
||||||
override fun showLoading() {
|
override fun showLoading() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ object UniAppUtils {
|
||||||
|
|
||||||
private fun getWgtFile(uniMpId: String): File{
|
private fun getWgtFile(uniMpId: String): File{
|
||||||
val wgtName = getWgtName(uniMpId)
|
val wgtName = getWgtName(uniMpId)
|
||||||
return File(FileUtils.instance?.cacheUniAppDir?.absolutePath?:"", wgtName)
|
return File(FileUtils.instance?.cacheUniAppDir?.absolutePath, wgtName)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*获取当前前台运行的UniMp小程序实体
|
*获取当前前台运行的UniMp小程序实体
|
||||||
|
|
@ -123,6 +123,7 @@ object UniAppUtils {
|
||||||
if(originVersions.size != 3){
|
if(originVersions.size != 3){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
for (i in 0..2) {
|
for (i in 0..2) {
|
||||||
if (Integer.parseInt(newVersions[i]) > Integer.parseInt(originVersions[i])) {
|
if (Integer.parseInt(newVersions[i]) > Integer.parseInt(originVersions[i])) {
|
||||||
return true
|
return true
|
||||||
|
|
@ -130,6 +131,10 @@ object UniAppUtils {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch (e: Exception){
|
||||||
|
e.printStackTrace()
|
||||||
|
Log.w(TAG, "checkUpdate: 解析版本号时,版本号格式错误 $version")
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,37 +180,25 @@ object UniAppUtils {
|
||||||
* 启动小程序并直达指定页面
|
* 启动小程序并直达指定页面
|
||||||
*/
|
*/
|
||||||
fun startUniMpPage(context: Context, uniMpId: String, uniMpType: String, pagePath: String, reportViewModel: ReportViewModel){
|
fun startUniMpPage(context: Context, uniMpId: String, uniMpType: String, pagePath: String, reportViewModel: ReportViewModel){
|
||||||
if(isRelease(uniMpId)){
|
if(!isRelease(uniMpId)){
|
||||||
releaseWgt(uniMpId,reportViewModel){
|
releaseWgt(uniMpId,reportViewModel){
|
||||||
|
if(it){
|
||||||
// 启动直达页面
|
// 启动直达页面
|
||||||
startUniMpToPage(context, uniMpId, uniMpType, pagePath)
|
startUniMpToPage(context, uniMpId, uniMpType, pagePath)
|
||||||
}
|
}
|
||||||
}else if(DCUniMPSDK.getInstance().isExistsApp(uniMpId)){
|
}
|
||||||
|
}else {
|
||||||
val uniMp = _uniMpFlow.value[uniMpId]
|
val uniMp = _uniMpFlow.value[uniMpId]
|
||||||
if(uniMp?.isRuning == true){
|
if(uniMp?.isRuning == true){
|
||||||
uniMp.showUniMP()
|
uniMp.showUniMP()
|
||||||
}
|
}
|
||||||
// 启动直达页面
|
// 启动直达页面
|
||||||
startUniMpToPage(context, uniMpId, uniMpType, pagePath)
|
startUniMpToPage(context, uniMpId, uniMpType, pagePath)
|
||||||
}else{
|
|
||||||
CenterToast.show("加载失败,请重试或联系客服!")
|
|
||||||
//事件提交
|
|
||||||
reportViewModel.requestReport(
|
|
||||||
ReportRequest(
|
|
||||||
ReportType.ERROR,
|
|
||||||
ReportKey.EVENT_CLIENT_UNI_SPEC_PAGE_LOAD,
|
|
||||||
uniMpId,
|
|
||||||
"加载指定页面"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun startUniMpToPage(context: Context, uniMpId: String, uniMpType: String, pagePath: String){
|
private fun startUniMpToPage(context: Context, uniMpId: String, uniMpType: String, pagePath: String){
|
||||||
// 启动直达页面
|
// 启动直达页面
|
||||||
val configuration = getUniMPOpenConfiguration()
|
val configuration = getUniMPOpenConfiguration()
|
||||||
if(uniMpType == "wx"){
|
|
||||||
configuration.splashClass = UniMPWxSplashView::class.java
|
|
||||||
}
|
|
||||||
if(uniMpType == "wx"){
|
if(uniMpType == "wx"){
|
||||||
configuration.splashClass = UniMPWxSplashView::class.java
|
configuration.splashClass = UniMPWxSplashView::class.java
|
||||||
}else if("alipay" == uniMpType){
|
}else if("alipay" == uniMpType){
|
||||||
|
|
@ -413,35 +406,38 @@ object UniAppUtils {
|
||||||
api.sendReq(req)
|
api.sendReq(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun isFileDownloadable(url: String): Boolean = withContext(Dispatchers.IO) {
|
suspend fun isFileDownloadable(url: String): Boolean = withContext(Dispatchers.IO) {val client = OkHttpClient()
|
||||||
val client = OkHttpClient()
|
|
||||||
val request = Request.Builder().url(url).build()
|
val request = Request.Builder().url(url).build()
|
||||||
try {
|
try {
|
||||||
val response = client.newCall(request).execute()
|
client.newCall(request).execute().use { response ->
|
||||||
val fileSize = response.body.contentLength()
|
val body = response.body ?: return@withContext false
|
||||||
//下载文件小于1KB,需要判断Url是否可靠
|
val fileSize = body.contentLength()
|
||||||
if(fileSize < 1024){
|
|
||||||
|
// 下载文件小于1KB,需要判断Url是否可靠
|
||||||
|
if (fileSize < 1024) {
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
val errorBody = response.body.string()
|
val errorBody = body.string() // string() 会内部读取并关闭 body,但外层有 .use 更保险
|
||||||
if (response.header("Content-Type")?.contains("application/json") == true) {
|
if (response.header("Content-Type")?.contains("application/json") == true) {
|
||||||
Log.i(TAG, "下载失败...$errorBody")
|
Log.i(TAG, "下载失败...$errorBody")
|
||||||
}else{
|
} else {
|
||||||
Log.i(TAG, "服务器错误...$errorBody")
|
Log.i(TAG, "服务器错误...$errorBody")
|
||||||
}
|
}
|
||||||
return@withContext false
|
return@withContext false
|
||||||
}else{
|
} else {
|
||||||
Log.i(TAG, "文件正常,可以下载!${response.body.string()}")
|
Log.i(TAG, "文件正常,可以下载!")
|
||||||
return@withContext true
|
return@withContext true
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
return@withContext true
|
return@withContext true
|
||||||
}
|
}
|
||||||
}catch (e: Exception) {
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
Log.i(TAG, "异常:${e.message}")
|
Log.i(TAG, "异常:${e.message}")
|
||||||
}
|
}
|
||||||
return@withContext false
|
return@withContext false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class UniMpUpdate{
|
enum class UniMpUpdate{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue