manager: Modifying the WebUI Engine Global Options
This commit is contained in:
@@ -400,14 +400,26 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
null
|
||||
}
|
||||
|
||||
val engine = config?.getWebuiEngine(context)
|
||||
val selectedEngine = when (engine) {
|
||||
val globalEngine = prefs.getString("webui_engine", "default") ?: "default"
|
||||
val moduleEngine = config?.getWebuiEngine(context)
|
||||
val selectedEngine = when (globalEngine) {
|
||||
"wx" -> wxEngine
|
||||
"ksu" -> ksuEngine
|
||||
null -> if (prefs.getBoolean("use_webuix", true) && Platform.isAlive) wxEngine else ksuEngine
|
||||
"default" -> {
|
||||
when (moduleEngine) {
|
||||
"wx" -> wxEngine
|
||||
"ksu" -> ksuEngine
|
||||
else -> {
|
||||
if (Platform.isAlive) {
|
||||
wxEngine
|
||||
} else {
|
||||
ksuEngine
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> ksuEngine
|
||||
}
|
||||
|
||||
webUILauncher.launch(selectedEngine)
|
||||
} catch (e: Exception) {
|
||||
Log.e("ModuleScreen", "Error launching WebUI: ${e.message}", e)
|
||||
|
||||
@@ -65,8 +65,6 @@ import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import com.sukisu.ultra.ui.component.KsuIsValid
|
||||
import com.dergoogler.mmrl.platform.Platform
|
||||
import com.dergoogler.mmrl.ui.component.LabelItem
|
||||
import com.dergoogler.mmrl.ui.component.text.TextRow
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -75,6 +73,13 @@ import com.dergoogler.mmrl.ui.component.text.TextRow
|
||||
fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
val snackBarHost = LocalSnackbarHost.current
|
||||
val context = LocalContext.current
|
||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
var selectedEngine by rememberSaveable {
|
||||
mutableStateOf(
|
||||
prefs.getString("webui_engine", "default") ?: "default"
|
||||
)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
@@ -243,23 +248,64 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
)
|
||||
}
|
||||
|
||||
// Web X 开关
|
||||
var useWebUIX by rememberSaveable {
|
||||
mutableStateOf(
|
||||
prefs.getBoolean("use_webuix", false)
|
||||
)
|
||||
}
|
||||
// WebUI引擎选择
|
||||
KsuIsValid {
|
||||
SwitchItem(
|
||||
beta = true,
|
||||
enabled = Platform.isAlive,
|
||||
val engineOptions = listOf(
|
||||
"default" to stringResource(id = R.string.engine_auto_select),
|
||||
"wx" to stringResource(id = R.string.engine_force_webuix),
|
||||
"ksu" to stringResource(id = R.string.engine_force_ksu)
|
||||
)
|
||||
|
||||
var showEngineDialog by remember { mutableStateOf(false) }
|
||||
|
||||
SettingItem(
|
||||
icon = Icons.Filled.WebAsset,
|
||||
title = stringResource(id = R.string.use_webuix),
|
||||
summary = stringResource(id = R.string.use_webuix_summary),
|
||||
checked = useWebUIX
|
||||
) {
|
||||
prefs.edit { putBoolean("use_webuix", it) }
|
||||
useWebUIX = it
|
||||
summary = engineOptions.find { it.first == selectedEngine }?.second
|
||||
?: stringResource(id = R.string.engine_auto_select),
|
||||
onClick = {
|
||||
showEngineDialog = true
|
||||
}
|
||||
)
|
||||
|
||||
if (showEngineDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showEngineDialog = false },
|
||||
title = { Text(stringResource(id = R.string.use_webuix)) },
|
||||
text = {
|
||||
Column {
|
||||
engineOptions.forEach { (value, label) ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
selectedEngine = value
|
||||
prefs.edit {
|
||||
putString("webui_engine", value)
|
||||
}
|
||||
showEngineDialog = false
|
||||
}
|
||||
.padding(vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
RadioButton(
|
||||
selected = selectedEngine == value,
|
||||
onClick = null
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(text = label)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = { showEngineDialog = false }
|
||||
) {
|
||||
Text(stringResource(id = R.string.cancel))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,13 +317,13 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
}
|
||||
KsuIsValid {
|
||||
AnimatedVisibility(
|
||||
visible = useWebUIX && enableWebDebugging,
|
||||
visible = enableWebDebugging && selectedEngine == "wx",
|
||||
enter = fadeIn() + expandVertically(),
|
||||
exit = fadeOut() + shrinkVertically()
|
||||
) {
|
||||
SwitchItem(
|
||||
beta = true,
|
||||
enabled = Platform.isAlive && useWebUIX && enableWebDebugging,
|
||||
enabled = Platform.isAlive && enableWebDebugging,
|
||||
icon = Icons.Filled.FormatListNumbered,
|
||||
title = stringResource(id = R.string.use_webuix_eruda),
|
||||
summary = stringResource(id = R.string.use_webuix_eruda_summary),
|
||||
|
||||
Reference in New Issue
Block a user