new & opt.

- new: support suspend and WOL #172
- opt.: `execWithPwd` when cancel
- opt.: extentions
This commit is contained in:
lollipopkit
2023-09-25 18:51:14 +08:00
parent df84aeb8b2
commit 4d06a52e99
45 changed files with 251 additions and 176 deletions

View File

@@ -18,6 +18,7 @@ enum ShellFunc {
process,
shutdown,
reboot,
suspend,
;
String get flag {
@@ -32,6 +33,8 @@ enum ShellFunc {
return 'sd';
case ShellFunc.reboot:
return 'r';
case ShellFunc.suspend:
return 'sp';
}
}
@@ -51,10 +54,12 @@ enum ShellFunc {
return 'ShutDown';
case ShellFunc.reboot:
return 'Reboot';
case ShellFunc.suspend:
return 'Suspend';
}
}
String get cmd {
String get _cmd {
switch (this) {
case ShellFunc.status:
return '''
@@ -96,6 +101,13 @@ if [ "\$userId" = "0" ]; then
\treboot
else
\tsudo -S reboot
fi''';
case ShellFunc.suspend:
return '''
if [ "\$userId" = "0" ]; then
\tsystemctl suspend
else
\tsudo -S systemctl suspend
fi''';
}
}
@@ -123,7 +135,7 @@ userId=\$(id -u)
for (final func in values) {
sb.write('''
${func.name}() {
${func.cmd.split('\n').map((e) => '\t$e').join('\n')}
${func._cmd.split('\n').map((e) => '\t$e').join('\n')}
}
''');

View File

@@ -1,4 +1,3 @@
import '../../../core/extension/stringx.dart';
import '../../res/misc.dart';
class Conn {
@@ -22,10 +21,10 @@ Conn? parseConn(String raw) {
if (idx != '') {
final vals = idx.split(Miscs.numReg);
return Conn(
maxConn: vals[5].i,
active: vals[6].i,
passive: vals[7].i,
fail: vals[8].i,
maxConn: int.tryParse(vals[5]) ?? 0,
active: int.tryParse(vals[6]) ?? 0,
passive: int.tryParse(vals[7]) ?? 0,
fail: int.tryParse(vals[8]) ?? 0,
);
}
return null;

View File

@@ -70,7 +70,7 @@ class ServerPrivateInfo {
return data;
}
Server? get server => Providers.server.pick(spi: this);
Server? get server => Pros.server.pick(spi: this);
bool shouldReconnect(ServerPrivateInfo old) {
return id != old.id ||