mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: sftp dl
This commit is contained in:
@@ -4,10 +4,7 @@ extension _Init on SSHPageState {
|
||||
void _initStoredCfg() {
|
||||
final fontFamilly = Stores.setting.fontPath.fetch().getFileName();
|
||||
final textSize = Stores.setting.termFontSize.fetch();
|
||||
final textStyle = TextStyle(
|
||||
fontFamily: fontFamilly,
|
||||
fontSize: textSize,
|
||||
);
|
||||
final textStyle = TextStyle(fontFamily: fontFamilly, fontSize: textSize);
|
||||
|
||||
_terminalStyle = TerminalStyle.fromTextStyle(textStyle);
|
||||
}
|
||||
@@ -37,15 +34,12 @@ extension _Init on SSHPageState {
|
||||
onStatus: (p0) {
|
||||
_writeLn(p0.toString());
|
||||
},
|
||||
onKeyboardInteractive: _onKeyboardInteractive,
|
||||
onKeyboardInteractive: (_) => KeybordInteractive.defaultHandle(widget.args.spi, ctx: context),
|
||||
);
|
||||
|
||||
_writeLn('${libL10n.execute}: Shell');
|
||||
final session = await _client?.shell(
|
||||
pty: SSHPtyConfig(
|
||||
width: _terminal.viewWidth,
|
||||
height: _terminal.viewHeight,
|
||||
),
|
||||
pty: SSHPtyConfig(width: _terminal.viewWidth, height: _terminal.viewHeight),
|
||||
environment: widget.args.spi.envs,
|
||||
);
|
||||
|
||||
@@ -98,30 +92,30 @@ extension _Init on SSHPageState {
|
||||
return;
|
||||
}
|
||||
|
||||
stream.cast<List<int>>().transform(const Utf8Decoder()).listen(
|
||||
_terminal.write,
|
||||
onError: (Object error, StackTrace stack) {
|
||||
// _terminal.write('Stream error: $error\n');
|
||||
Loggers.root.warning('Error in SSH stream', error, stack);
|
||||
},
|
||||
cancelOnError: false,
|
||||
);
|
||||
stream
|
||||
.cast<List<int>>()
|
||||
.transform(const Utf8Decoder())
|
||||
.listen(
|
||||
_terminal.write,
|
||||
onError: (Object error, StackTrace stack) {
|
||||
// _terminal.write('Stream error: $error\n');
|
||||
Loggers.root.warning('Error in SSH stream', error, stack);
|
||||
},
|
||||
cancelOnError: false,
|
||||
);
|
||||
}
|
||||
|
||||
void _setupDiscontinuityTimer() {
|
||||
_discontinuityTimer = Timer.periodic(
|
||||
const Duration(seconds: 5),
|
||||
(_) async {
|
||||
var throwTimeout = true;
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (throwTimeout) {
|
||||
_catchTimeout();
|
||||
}
|
||||
});
|
||||
await _client?.ping();
|
||||
throwTimeout = false;
|
||||
},
|
||||
);
|
||||
_discontinuityTimer = Timer.periodic(const Duration(seconds: 5), (_) async {
|
||||
var throwTimeout = true;
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (throwTimeout) {
|
||||
_catchTimeout();
|
||||
}
|
||||
});
|
||||
await _client?.ping();
|
||||
throwTimeout = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _catchTimeout() {
|
||||
|
||||
@@ -164,8 +164,4 @@ extension _VirtKey on SSHPageState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<List<String>?> _onKeyboardInteractive(SSHUserInfoRequest req) {
|
||||
return KeybordInteractive.defaultHandle(widget.args.spi, ctx: context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,11 +73,24 @@ class _LocalFilePageState extends State<LocalFilePage> with AutomaticKeepAliveCl
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
if (!isMobile)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: MaterialLocalizations.of(context).refreshIndicatorSemanticLabel,
|
||||
onPressed: () => setState(() {}),
|
||||
),
|
||||
if (!isPickFile) _buildMissionBtn(),
|
||||
_buildSortBtn(),
|
||||
],
|
||||
),
|
||||
body: _sortType.listen(_buildBody),
|
||||
body: isMobile
|
||||
? RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
setState(() {});
|
||||
},
|
||||
child: _sortType.listen(_buildBody),
|
||||
)
|
||||
: _sortType.listen(_buildBody),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ extension _Actions on _SftpPageState {
|
||||
|
||||
/// Local file dir + server id + remote path
|
||||
String _getLocalPath(String remotePath) {
|
||||
return Paths.file.joinPath(widget.args.spi.id).joinPath(remotePath);
|
||||
return Paths.file.joinPath(widget.args.spi.oldId).joinPath(remotePath);
|
||||
}
|
||||
|
||||
/// Only return true if the path is changed
|
||||
|
||||
Reference in New Issue
Block a user