fix desktop stop-service

This commit is contained in:
csf 2022-08-09 20:50:45 +08:00
parent cb88a3abb6
commit 42f27922bf
2 changed files with 17 additions and 5 deletions

View File

@ -376,13 +376,20 @@ class _ConnectionPageState extends State<ConnectionPage> {
width: 8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.green,
color: svcStopped.value ? Colors.redAccent : Colors.green,
),
).paddingSymmetric(horizontal: 8.0);
).paddingSymmetric(horizontal: 10.0);
if (svcStopped.value) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [light, Text(translate("Service is not running"))],
children: [
light,
Text(translate("Service is not running")),
TextButton(
onPressed: () =>
bind.mainSetOption(key: "stop-service", value: ""),
child: Text(translate("Start Service")))
],
);
} else {
if (svcStatusCode.value == 0) {
@ -425,7 +432,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
}
updateStatus() async {
svcStopped.value = bind.mainGetOption(key: "stop-service") == "Y";
svcStopped.value = await bind.mainGetOption(key: "stop-service") == "Y";
final status =
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
svcStatusCode.value = status["status_num"];

View File

@ -513,7 +513,12 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Future<PopupMenuItem<String>> genEnablePopupMenuItem(
String label, String key) async {
final v = await bind.mainGetOption(key: key);
bool enable = v != "N";
bool enable;
if (key == "stop-service") {
enable = v != "Y";
} else {
enable = v != "N";
}
return PopupMenuItem(
child: Row(