mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-01 05:45:04 +01:00
new: kill process
This commit is contained in:
@@ -9,6 +9,7 @@ enum PlatformType {
|
||||
macos,
|
||||
windows,
|
||||
web,
|
||||
fuchsia,
|
||||
unknown,
|
||||
}
|
||||
|
||||
@@ -31,6 +32,9 @@ final _p = () {
|
||||
if (Platform.isWindows) {
|
||||
return PlatformType.windows;
|
||||
}
|
||||
if (Platform.isFuchsia) {
|
||||
return PlatformType.fuchsia;
|
||||
}
|
||||
return PlatformType.unknown;
|
||||
}();
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
"sureDelete": "Soll [{name}] wirklich gelöscht werden?",
|
||||
"sureDirEmpty": "Stelle sicher, dass der Ordner leer ist.",
|
||||
"sureNoPwd": "Bist du sicher, dass du kein Passwort verwenden willst?",
|
||||
"sureStop": "Sind Sie sicher, dass Sie [{item}] stoppen möchten?",
|
||||
"sureToDeleteServer": "Bist du sicher, dass du [{server}] löschen willst?",
|
||||
"system": "Systeme",
|
||||
"tag": "Tags",
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
"sureDelete": "Are you sure to delete [{name}]?",
|
||||
"sureDirEmpty": "Make sure dir is empty.",
|
||||
"sureNoPwd": "Are you sure to use no password?",
|
||||
"sureStop": "Sure to stop [{item}] ?",
|
||||
"sureToDeleteServer": "Are you sure to delete server [{server}]?",
|
||||
"system": "System",
|
||||
"tag": "Tags",
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
"sureDelete": "Apakah Anda pasti akan menghapus [{name}]?",
|
||||
"sureDirEmpty": "Pastikan dir kosong.",
|
||||
"sureNoPwd": "Apakah Anda pasti tidak menggunakan kata sandi?",
|
||||
"sureStop": "Anda yakin ingin menghentikan [{item}]?",
|
||||
"sureToDeleteServer": "Apakah Anda pasti akan menghapus server [{server}]?",
|
||||
"system": "Sistem",
|
||||
"tag": "Tag",
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
"sureDelete": "确定删除 [{name}]?",
|
||||
"sureDirEmpty": "请确保文件夹为空",
|
||||
"sureNoPwd": "确认使用无密码?",
|
||||
"sureStop": "确定要停止 [{item}] 吗?",
|
||||
"sureToDeleteServer": "你确定要删除服务器 [{server}] 吗?",
|
||||
"system": "系统",
|
||||
"tag": "标签",
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
"sureDelete": "確定刪除 [{name}]?",
|
||||
"sureDirEmpty": "請確保文件夾為空",
|
||||
"sureNoPwd": "確認使用無密碼?",
|
||||
"sureStop": "確定要停止 [{item}] 嗎?",
|
||||
"sureToDeleteServer": "你確定要刪除服務器 [{server}] 嗎?",
|
||||
"system": "系統",
|
||||
"tag": "标签",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/utils/ui.dart';
|
||||
@@ -25,6 +27,7 @@ class ProcessPage extends StatefulWidget {
|
||||
class _ProcessPageState extends State<ProcessPage> {
|
||||
late S _s;
|
||||
late Timer _timer;
|
||||
SSHClient? _client;
|
||||
|
||||
PsResult _result = PsResult(procs: []);
|
||||
int? _lastFocusId;
|
||||
@@ -35,24 +38,27 @@ class _ProcessPageState extends State<ProcessPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final client = _serverProvider.servers[widget.spi.id]?.client;
|
||||
if (client == null) {
|
||||
_client = _serverProvider.servers[widget.spi.id]?.client;
|
||||
if (_client == null) {
|
||||
showSnackBar(context, Text(_s.noClient));
|
||||
return;
|
||||
}
|
||||
_timer = Timer.periodic(const Duration(seconds: 3), (_) async {
|
||||
if (mounted) {
|
||||
final result = await client.run('ps -aux'.withLangExport).string;
|
||||
if (result.isEmpty) {
|
||||
showSnackBar(context, Text(_s.noResult));
|
||||
return;
|
||||
}
|
||||
_result = PsResult.parse(result, sort: _procSortMode);
|
||||
setState(() {});
|
||||
} else {
|
||||
_timer.cancel();
|
||||
_timer =
|
||||
Timer.periodic(const Duration(seconds: 3), (_) => _refresh());
|
||||
}
|
||||
|
||||
Future<void> _refresh() async {
|
||||
if (mounted) {
|
||||
final result = await _client?.run('ps -aux'.withLangExport).string;
|
||||
if (result == null || result.isEmpty) {
|
||||
showSnackBar(context, Text(_s.noResult));
|
||||
return;
|
||||
}
|
||||
});
|
||||
_result = PsResult.parse(result, sort: _procSortMode);
|
||||
setState(() {});
|
||||
} else {
|
||||
_timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -140,6 +146,24 @@ class _ProcessPageState extends State<ProcessPage> {
|
||||
],
|
||||
),
|
||||
onTap: () => _lastFocusId = proc.pid,
|
||||
onLongPress: () {
|
||||
showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.sureStop(proc.pid)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await _client?.run('kill ${proc.pid}');
|
||||
await _refresh();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
selected: _lastFocusId == proc.pid,
|
||||
autofocus: _lastFocusId == proc.pid,
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user