1
This commit is contained in:
1 parent
87e03ce0d8
commit
e932c60dbd
47 files changed
+4417
-923
No files matched your search
@@ -0,0 +1,163 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/services/distro_installer.dart';
|
||||
import 'package:code_editor/utils/dialog_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 同步前台解压进度弹窗(模态不可遮罩忽略,关闭或取消直接导致导入失败并回滚)
|
||||
class DistroExtractDialog extends StatefulWidget {
|
||||
final String systemName;
|
||||
final Future<void> Function(InstallProgressCallback onProgress, bool Function() isCancelled) task;
|
||||
|
||||
const DistroExtractDialog({
|
||||
super.key,
|
||||
required this.systemName,
|
||||
required this.task,
|
||||
});
|
||||
|
||||
/// 快速拉起解压进程模态弹窗
|
||||
/// 返回 true 表示导入成功,false 表示取消或失败
|
||||
static Future<bool> show({
|
||||
required BuildContext context,
|
||||
required String systemName,
|
||||
required Future<void> Function(InstallProgressCallback onProgress, bool Function() isCancelled) task,
|
||||
}) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => DistroExtractDialog(
|
||||
systemName: systemName,
|
||||
task: task,
|
||||
),
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
State<DistroExtractDialog> createState() => _DistroExtractDialogState();
|
||||
}
|
||||
|
||||
class _DistroExtractDialogState extends State<DistroExtractDialog> {
|
||||
double _progress = 0.0;
|
||||
String? _message;
|
||||
bool _isCancelled = false;
|
||||
bool _isFinished = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_startTask();
|
||||
}
|
||||
|
||||
Future<void> _startTask() async {
|
||||
try {
|
||||
await widget.task(
|
||||
(prog, msg) {
|
||||
if (mounted && !_isCancelled) {
|
||||
setState(() {
|
||||
_progress = prog;
|
||||
_message = msg;
|
||||
});
|
||||
}
|
||||
},
|
||||
() => _isCancelled,
|
||||
);
|
||||
|
||||
if (mounted && !_isCancelled) {
|
||||
_isFinished = true;
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
if (e is DistroInstallCancelledException || _isCancelled) {
|
||||
DialogUtils.showToast(context, l10n.cancelledImportSystem(widget.systemName));
|
||||
} else {
|
||||
DialogUtils.showErrorToast(context, l10n.importFailed(e.toString()));
|
||||
}
|
||||
Navigator.of(context).pop(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _handleCancel() {
|
||||
if (_isFinished) return;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
setState(() {
|
||||
_isCancelled = true;
|
||||
_message = l10n.cancellingAndCleaning;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final percentInt = (_progress * 100).clamp(0, 100).toInt();
|
||||
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (didPop) return;
|
||||
_handleCancel();
|
||||
},
|
||||
child: AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.archive_outlined, size: 22, color: Colors.blueAccent),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.importingSystemTitle(widget.systemName),
|
||||
style: const TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_message ?? l10n.preparingInitialization,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
LinearProgressIndicator(
|
||||
value: _progress > 0 ? _progress : null,
|
||||
minHeight: 6,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'$percentInt%',
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isCancelled ? null : _handleCancel,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.error,
|
||||
),
|
||||
child: Text(_isCancelled ? l10n.interrupting : l10n.cancelImport),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
import 'dart:io';
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/providers/distro_provider.dart';
|
||||
import 'package:code_editor/providers/terminal_provider.dart';
|
||||
import 'package:code_editor/utils/dialog_utils.dart';
|
||||
import 'package:code_editor/widgets/distro_extract_dialog.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// 独立的 Linux 系统选择与管理对话框
|
||||
class DistroSelectorDialog extends StatelessWidget {
|
||||
const DistroSelectorDialog({super.key});
|
||||
|
||||
/// 打开系统选择与管理对话框
|
||||
static Future<void> show(BuildContext context) {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (ctx) => const DistroSelectorDialog(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final distroProvider = context.watch<DistroProvider>();
|
||||
final systems = distroProvider.installedSystems;
|
||||
final selectedSystem = distroProvider.selectedSystem;
|
||||
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
titlePadding: const EdgeInsets.fromLTRB(20.0, 16.0, 12.0, 8.0),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.dns_outlined, size: 22, color: Colors.blueAccent),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.systemManagement,
|
||||
style: const TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
// 导入按钮与下拉选项
|
||||
PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.add_circle_outline, color: Colors.blueAccent),
|
||||
tooltip: l10n.importNewSystem,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
onSelected: (action) => _handleImportAction(context, action),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'builtin',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.layers_outlined, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.importBuiltinAlpine),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'external',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.folder_open_outlined, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.importExternalTarGz),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
l10n.selectSystemDefaultPrompt,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Flexible(
|
||||
child: systems.isEmpty
|
||||
? Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 32.0),
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.layers_clear_outlined,
|
||||
size: 40,
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.noSystemsPrompt,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
itemCount: systems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final system = systems[index];
|
||||
final isSelected = system == selectedSystem;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary.withValues(alpha: 0.5)
|
||||
: theme.colorScheme.outlineVariant.withValues(alpha: 0.4),
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primaryContainer.withValues(alpha: 0.4)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 2.0),
|
||||
title: Text(
|
||||
system,
|
||||
style: TextStyle(
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected ? theme.colorScheme.primary : null,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete_outline,
|
||||
color: theme.colorScheme.error,
|
||||
size: 20,
|
||||
),
|
||||
tooltip: l10n.deleteSystemTooltip,
|
||||
onPressed: () => _handleDeleteSystem(context, system),
|
||||
),
|
||||
onTap: () {
|
||||
distroProvider.selectSystem(system);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(l10n.done),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 处理导入菜单操作
|
||||
Future<void> _handleImportAction(BuildContext context, String action) async {
|
||||
final distroProvider = context.read<DistroProvider>();
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
if (action == 'builtin') {
|
||||
// 1. 从内置 Alpine 导入
|
||||
final defaultName = _generateUniqueSystemName('alpine', distroProvider.installedSystems);
|
||||
final systemName = await DialogUtils.showInputDialog(
|
||||
context,
|
||||
title: l10n.importBuiltinAlpineTitle,
|
||||
hintText: l10n.systemNameHintWithDefault(defaultName),
|
||||
initialValue: defaultName,
|
||||
);
|
||||
|
||||
if (systemName == null || systemName.trim().isEmpty || !context.mounted) return;
|
||||
final cleanName = systemName.trim();
|
||||
|
||||
// 模态同步解压
|
||||
final success = await DistroExtractDialog.show(
|
||||
context: context,
|
||||
systemName: cleanName,
|
||||
task: (onProgress, isCancelled) {
|
||||
return distroProvider.importBuiltinAlpine(
|
||||
systemName: cleanName,
|
||||
onProgress: onProgress,
|
||||
isCancelled: isCancelled,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (success && context.mounted) {
|
||||
DialogUtils.showSuccessToast(context, l10n.systemImportSuccess(cleanName));
|
||||
}
|
||||
} else if (action == 'external') {
|
||||
// 2. 从外部选择 .tar.gz 压缩包导入
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.any,
|
||||
);
|
||||
|
||||
if (result == null || result.files.single.path == null || !context.mounted) return;
|
||||
final filePath = result.files.single.path!;
|
||||
final file = File(filePath);
|
||||
|
||||
// 提取默认名称(去掉 .tar.gz, .tgz 等后缀)
|
||||
String baseName = p.basename(filePath);
|
||||
if (baseName.endsWith('.tar.gz')) {
|
||||
baseName = baseName.substring(0, baseName.length - 7);
|
||||
} else if (baseName.endsWith('.tgz')) {
|
||||
baseName = baseName.substring(0, baseName.length - 4);
|
||||
} else {
|
||||
baseName = p.basenameWithoutExtension(filePath);
|
||||
}
|
||||
baseName = baseName.replaceAll(RegExp(r'[^a-zA-Z0-9_\-]'), '_');
|
||||
if (baseName.isEmpty) baseName = 'custom_linux';
|
||||
|
||||
final defaultName = _generateUniqueSystemName(baseName, distroProvider.installedSystems);
|
||||
|
||||
final systemName = await DialogUtils.showInputDialog(
|
||||
context,
|
||||
title: l10n.importExternalSystemTitle,
|
||||
hintText: l10n.systemNameHint,
|
||||
initialValue: defaultName,
|
||||
);
|
||||
|
||||
if (systemName == null || systemName.trim().isEmpty || !context.mounted) return;
|
||||
final cleanName = systemName.trim();
|
||||
|
||||
// 模态同步解压
|
||||
final success = await DistroExtractDialog.show(
|
||||
context: context,
|
||||
systemName: cleanName,
|
||||
task: (onProgress, isCancelled) {
|
||||
return distroProvider.importFromCustomTarGz(
|
||||
systemName: cleanName,
|
||||
tarGzFile: file,
|
||||
onProgress: onProgress,
|
||||
isCancelled: isCancelled,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (success && context.mounted) {
|
||||
DialogUtils.showSuccessToast(context, l10n.externalSystemImportSuccess(cleanName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 高危操作:二次确认删除系统
|
||||
Future<void> _handleDeleteSystem(BuildContext context, String systemName) async {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final confirmed = await DialogUtils.showDestructiveConfirmDialog(
|
||||
context,
|
||||
title: l10n.deleteSystemConfirmTitle,
|
||||
message: l10n.deleteSystemConfirmMessage(systemName),
|
||||
confirmText: l10n.permanentDelete,
|
||||
);
|
||||
|
||||
if (confirmed && context.mounted) {
|
||||
final distroProvider = context.read<DistroProvider>();
|
||||
final terminalProvider = context.read<TerminalProvider?>();
|
||||
try {
|
||||
await distroProvider.deleteSystem(systemName);
|
||||
terminalProvider?.removeSessionsForDistro(systemName);
|
||||
if (!distroProvider.hasAnySystem) {
|
||||
terminalProvider?.clearAllSessions();
|
||||
}
|
||||
if (context.mounted) {
|
||||
DialogUtils.showToast(context, l10n.deleteSystemSuccess(systemName));
|
||||
}
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
DialogUtils.showErrorToast(context, l10n.deleteSystemFailed(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 自动生成不重复的系统实例名
|
||||
String _generateUniqueSystemName(String prefix, List<String> existingSystems) {
|
||||
if (!existingSystems.contains(prefix)) return prefix;
|
||||
int index = 1;
|
||||
while (existingSystems.contains('${prefix}_$index')) {
|
||||
index++;
|
||||
}
|
||||
return '${prefix}_$index';
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/providers/distro_provider.dart';
|
||||
import 'package:code_editor/providers/terminal_provider.dart';
|
||||
import 'package:code_editor/utils/dialog_utils.dart';
|
||||
import 'package:code_editor/widgets/terminal_session_item_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -10,6 +13,7 @@ class TerminalDrawer extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final provider = context.watch<TerminalProvider>();
|
||||
final sessions = provider.sessions;
|
||||
final activeIndex = provider.activeIndex;
|
||||
@@ -30,7 +34,7 @@ class TerminalDrawer extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'会话',
|
||||
l10n.sessionDrawerTitle,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.onSurface,
|
||||
@@ -39,10 +43,20 @@ class TerminalDrawer extends StatelessWidget {
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
tooltip: '添加终端',
|
||||
tooltip: l10n.addTerminalTooltip,
|
||||
onPressed: () {
|
||||
// 直接添加终端,但不跳转
|
||||
provider.createSession(name: '会话', distroId: 'alpine', activate: false);
|
||||
final distroProvider = context.read<DistroProvider?>();
|
||||
final currentSystem = distroProvider?.selectedSystem;
|
||||
if (currentSystem == null) {
|
||||
DialogUtils.showToast(context, l10n.noSystemSelectedWarning);
|
||||
return;
|
||||
}
|
||||
// 基于当前选择的系统创建新终端
|
||||
provider.createSession(
|
||||
name: l10n.sessionDefaultName,
|
||||
distroId: currentSystem,
|
||||
activate: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -56,7 +70,7 @@ class TerminalDrawer extends StatelessWidget {
|
||||
child: sessions.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'暂无会话,请点击右上角添加',
|
||||
l10n.noSessionsInDrawerPrompt,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
fontSize: 13.0,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/terminal_session.dart';
|
||||
import 'package:code_editor/providers/terminal_provider.dart';
|
||||
import 'package:code_editor/utils/dialog_utils.dart';
|
||||
@@ -22,8 +23,8 @@ class TerminalSessionItemWidget extends StatelessWidget {
|
||||
final theme = Theme.of(context);
|
||||
final displayIndex = index + 1; // 索引从 1 开始
|
||||
final titleText = '($displayIndex) ${session.name}';
|
||||
final badgeLabel = session.distroId;
|
||||
final isHost = session.distroId == 'host';
|
||||
final badgeLabel = isHost ? 'Host' : 'Alpine';
|
||||
|
||||
final textStyle = theme.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
@@ -122,6 +123,7 @@ class TerminalSessionItemWidget extends StatelessWidget {
|
||||
);
|
||||
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final onSurfaceColor = theme.colorScheme.onSurface;
|
||||
|
||||
final selectedAction = await showMenu<String>(
|
||||
@@ -141,14 +143,14 @@ class TerminalSessionItemWidget extends StatelessWidget {
|
||||
_buildMenuItem(
|
||||
value: 'rename',
|
||||
icon: Icons.edit_outlined,
|
||||
title: '重命名',
|
||||
title: l10n.rename,
|
||||
color: onSurfaceColor,
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
_buildMenuItem(
|
||||
value: 'delete',
|
||||
icon: Icons.delete_outline,
|
||||
title: '删除',
|
||||
title: l10n.delete,
|
||||
color: theme.colorScheme.error,
|
||||
isDestructive: true,
|
||||
),
|
||||
@@ -184,13 +186,14 @@ class TerminalSessionItemWidget extends StatelessWidget {
|
||||
|
||||
void _handleMenuAction(BuildContext context, String action, int displayIndex) async {
|
||||
final provider = context.read<TerminalProvider>();
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
switch (action) {
|
||||
case 'rename':
|
||||
final newName = await DialogUtils.showInputDialog(
|
||||
context,
|
||||
title: '重命名',
|
||||
hintText: '新名称',
|
||||
title: l10n.rename,
|
||||
hintText: l10n.newName,
|
||||
initialValue: session.name,
|
||||
);
|
||||
if (newName != null && newName.trim().isNotEmpty && newName.trim() != session.name) {
|
||||
@@ -201,8 +204,8 @@ class TerminalSessionItemWidget extends StatelessWidget {
|
||||
case 'delete':
|
||||
final confirmed = await DialogUtils.showDestructiveConfirmDialog(
|
||||
context,
|
||||
title: '确认删除',
|
||||
message: '确定要删除终端 "($displayIndex) ${session.name}" 吗?',
|
||||
title: l10n.confirmDelete,
|
||||
message: l10n.confirmDeleteTerminalSession(displayIndex, session.name),
|
||||
);
|
||||
if (confirmed && context.mounted) {
|
||||
provider.removeSession(session.id);
|
||||
|
||||
Reference in new issue
Block a user