feat: 清空日志弹窗选择范围(仅日志 / 日志+计数器)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,14 +78,8 @@ class LogStore(private val context: Context, scope: CoroutineScope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun clearLogs() {
|
suspend fun clearLogs() {
|
||||||
ds.edit {
|
ds.edit { it.remove(K.LOGS) }
|
||||||
it.remove(K.LOGS)
|
|
||||||
it[K.SENT] = 0
|
|
||||||
it[K.FILTERED] = 0
|
|
||||||
it[K.FAILED] = 0
|
|
||||||
}
|
|
||||||
logs.value = emptyList()
|
logs.value = emptyList()
|
||||||
sentCount.value = 0; filteredCount.value = 0; failedCount.value = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun resetCounters() {
|
suspend fun resetCounters() {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import androidx.compose.foundation.lazy.items
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -25,7 +26,9 @@ import androidx.compose.material3.TextButton
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -51,6 +54,7 @@ fun LogScreen(onBack: () -> Unit) {
|
|||||||
val logs by app.logStore.logs.collectAsState()
|
val logs by app.logStore.logs.collectAsState()
|
||||||
val pending by app.logStore.pending.collectAsState()
|
val pending by app.logStore.pending.collectAsState()
|
||||||
val df = remember { SimpleDateFormat("MM-dd HH:mm:ss", Locale.getDefault()) }
|
val df = remember { SimpleDateFormat("MM-dd HH:mm:ss", Locale.getDefault()) }
|
||||||
|
var showClearDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(Modifier.fillMaxSize()) {
|
Column(Modifier.fillMaxSize()) {
|
||||||
Surface(
|
Surface(
|
||||||
@@ -66,7 +70,7 @@ fun LogScreen(onBack: () -> Unit) {
|
|||||||
Text("转发日志", style = MaterialTheme.typography.titleLarge)
|
Text("转发日志", style = MaterialTheme.typography.titleLarge)
|
||||||
Text("最近 300 条通知处理记录", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
Text("最近 300 条通知处理记录", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
}
|
}
|
||||||
TextButton(onClick = { app.appScope.launch { app.logStore.clearLogs() } }) { Text("清空") }
|
TextButton(onClick = { showClearDialog = true }) { Text("清空") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +107,29 @@ fun LogScreen(onBack: () -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showClearDialog) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { showClearDialog = false },
|
||||||
|
title = { Text("清空日志") },
|
||||||
|
text = { Text("选择清空范围:") },
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showClearDialog = false
|
||||||
|
app.appScope.launch { app.logStore.clearLogs() }
|
||||||
|
}) { Text("仅清空日志") }
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showClearDialog = false
|
||||||
|
app.appScope.launch {
|
||||||
|
app.logStore.clearLogs()
|
||||||
|
app.logStore.resetCounters()
|
||||||
|
}
|
||||||
|
}) { Text("日志+计数器") }
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user