新增网络工具,修改bug

This commit is contained in:
weber
2025-08-27 16:37:53 +08:00
parent 52e571da01
commit 2a7d310be5
14 changed files with 382 additions and 226 deletions

View File

@@ -19,6 +19,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -86,6 +87,13 @@ fun AddAgentScreen() {
}
// 页面退出时清空数据
DisposableEffect(Unit) {
onDispose {
model.clearData()
}
}
Column(
modifier = Modifier
.fillMaxSize()
@@ -230,10 +238,8 @@ fun AddAgentScreen() {
val result = model.createAgent(context)
if (result != null) {
println("AddAgent: Agent created successfully, closing page")
// 创建成功,关闭页面
model.name = ""
model.desc = ""
model.isFromAddAgent = false // 重置标志
// 创建成功,清空数据并关闭页面
model.clearData()
navController.popBackStack()
}
} catch (e: Exception) {

View File

@@ -81,4 +81,15 @@ object AddAgentViewModel : ViewModel() {
else -> null
}
}
/**
* 清空所有页面数据
*/
fun clearData() {
name = ""
desc = ""
croppedBitmap = null
isUpdating = false
isFromAddAgent = false
}
}