mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-19 14:44:41 +01:00
fix & opt
- apt/yum if not root, auto try saved pwd - ServerPrivateInfo.authorization: Object => String pwd - fix apt parse: caused by irrelevant output - serverprovider replace _servers[idx] with s
This commit is contained in:
@@ -71,11 +71,14 @@ class _AptManagePageState extends State<AptManagePage>
|
||||
};
|
||||
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
PwdRequestFunc onPwdRequest = (lastTime, user) async {
|
||||
PwdRequestFunc onPwdRequest = (triedTimes, user) async {
|
||||
if (!mounted) return '';
|
||||
if (triedTimes == 1) {
|
||||
return widget.spi.pwd;
|
||||
}
|
||||
await showRoundDialog(
|
||||
context,
|
||||
lastTime ? s.lastTry : (user ?? s.unknown),
|
||||
triedTimes == 3 ? s.lastTry : (user ?? s.unknown),
|
||||
TextField(
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
@@ -105,7 +108,7 @@ class _AptManagePageState extends State<AptManagePage>
|
||||
() =>
|
||||
scrollController.jumpTo(scrollController.position.maxScrollExtent),
|
||||
() => scrollControllerUpdate
|
||||
.jumpTo(scrollControllerUpdate.position.maxScrollExtent),
|
||||
.jumpTo(scrollControllerUpdate.positions.last.maxScrollExtent),
|
||||
onPwdRequest);
|
||||
_aptProvider.refreshInstalled();
|
||||
}
|
||||
@@ -130,9 +133,19 @@ class _AptManagePageState extends State<AptManagePage>
|
||||
const SizedBox(
|
||||
height: 37,
|
||||
),
|
||||
Text(
|
||||
apt.error!,
|
||||
textAlign: TextAlign.center,
|
||||
SizedBox(
|
||||
height: _media.size.height * 0.4,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(17),
|
||||
child: RoundRectCard(
|
||||
SingleChildScrollView(
|
||||
padding: EdgeInsets.all(17),
|
||||
child: Text(
|
||||
apt.error!,
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -214,18 +214,13 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
_keyInfo ??= locator<PrivateKeyStore>().get(widget.spi!.pubKeyId!);
|
||||
}
|
||||
|
||||
final authorization = usePublicKey
|
||||
? {
|
||||
"privateKey": _keyInfo!.privateKey,
|
||||
"passphrase": _keyInfo!.password
|
||||
}
|
||||
: passwordController.text;
|
||||
final authorization = passwordController.text;
|
||||
final spi = ServerPrivateInfo(
|
||||
name: nameController.text,
|
||||
ip: ipController.text,
|
||||
port: int.parse(portController.text),
|
||||
user: usernameController.text,
|
||||
authorization: authorization,
|
||||
pwd: authorization,
|
||||
pubKeyId: usePublicKey ? _keyInfo!.id : null);
|
||||
|
||||
if (widget.spi == null) {
|
||||
@@ -260,10 +255,10 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
ipController.text = widget.spi?.ip ?? '';
|
||||
portController.text = (widget.spi?.port ?? 22).toString();
|
||||
usernameController.text = widget.spi?.user ?? '';
|
||||
if (widget.spi?.authorization is String) {
|
||||
passwordController.text = widget.spi?.authorization as String? ?? '';
|
||||
if (widget.spi?.pwd is String) {
|
||||
passwordController.text = widget.spi?.pwd ?? '';
|
||||
} else {
|
||||
final auth = widget.spi?.authorization as Map;
|
||||
final auth = widget.spi?.pwd as Map;
|
||||
passwordController.text = auth['passphrase'];
|
||||
keyController.text = auth['privateKey'];
|
||||
usePublicKey = true;
|
||||
|
||||
Reference in New Issue
Block a user