mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: add copy btn for ask ai (#975)
This commit is contained in:
@@ -292,7 +292,7 @@ class ServerNotifier extends _$ServerNotifier {
|
||||
|
||||
try {
|
||||
final statusCmd = ShellFunc.status.exec(spi.id, systemType: state.status.system, customDir: spi.custom?.scriptDir);
|
||||
Loggers.app.info('Running status command for ${spi.name} (${state.status.system.name}): $statusCmd');
|
||||
// Loggers.app.info('Running status command for ${spi.name} (${state.status.system.name}): $statusCmd');
|
||||
final execResult = await state.client?.run(statusCmd);
|
||||
if (execResult != null) {
|
||||
raw = SSHDecoder.decode(
|
||||
@@ -300,7 +300,7 @@ class ServerNotifier extends _$ServerNotifier {
|
||||
isWindows: state.status.system == SystemType.windows,
|
||||
context: 'GetStatus<${spi.name}>',
|
||||
);
|
||||
Loggers.app.info('Status response length for ${spi.name}: ${raw.length} bytes');
|
||||
// Loggers.app.info('Status response length for ${spi.name}: ${raw.length} bytes');
|
||||
} else {
|
||||
raw = '';
|
||||
Loggers.app.warning('No status result from ${spi.name}');
|
||||
|
||||
@@ -250,6 +250,13 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
context.showSnackBar(libL10n.success);
|
||||
}
|
||||
|
||||
Future<void> _copyText(BuildContext context, String text) async {
|
||||
if (text.trim().isEmpty) return;
|
||||
await Clipboard.setData(ClipboardData(text: text));
|
||||
if (!mounted) return;
|
||||
context.showSnackBar(libL10n.success);
|
||||
}
|
||||
|
||||
void _sendMessage() {
|
||||
if (_isStreaming) return;
|
||||
final text = _inputController.text.trim();
|
||||
@@ -310,7 +317,23 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
streaming ? l10n.askAiAwaitingResponse : l10n.askAiNoResponse,
|
||||
style: theme.textTheme.bodySmall,
|
||||
)
|
||||
: SimpleMarkdown(data: content);
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SimpleMarkdown(data: content),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () => _copyText(context, content),
|
||||
icon: const Icon(Icons.copy, size: 18),
|
||||
label: Text(libL10n.copy),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: CardX(
|
||||
|
||||
@@ -252,7 +252,7 @@ class SSHPageState extends ConsumerState<SSHPage>
|
||||
deleteDetection: isMobile,
|
||||
autofocus: false,
|
||||
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
|
||||
showToolbar: isMobile,
|
||||
showToolbar: true,
|
||||
viewOffset: Offset(2 * _horizonPadding, CustomAppBar.sysStatusBarHeight),
|
||||
hideScrollBar: false,
|
||||
focusNode: widget.args.focusNode,
|
||||
|
||||
Reference in New Issue
Block a user