feat: 全量英文界面(i18n 翻译表接入全部页面与服务层文案)

This commit is contained in:
ZV Team committed 2026-10-24 09:39:51 +08:00
1 parent 2eb3f42731
commit 71e76b1c2b
26 files changed
+775 -325

No files matched your search

+25 -24
View File
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import '../../core/utils/command_preset_service.dart';
import '../../core/utils/rcon_client.dart';
import '../player_management/player_list_page.dart';
import '../../core/l10n/strings.dart';
class ConsolePage extends StatefulWidget {
final RconClient rconClient;
@@ -30,12 +31,12 @@ class _ConsolePageState extends State<ConsolePage> {
super.initState();
widget.rconClient.onDisconnected = () {
if (mounted) {
setState(() => _outputLines.add(_LogLine(text: '[警告] 连接断开,正在重连...', isError: true)));
setState(() => _outputLines.add(_LogLine(text: S.t('[警告] 连接断开,正在重连...'), isError: true)));
}
};
widget.rconClient.onReconnected = () {
if (mounted) {
setState(() => _outputLines.add(_LogLine(text: '[信息] 重连成功', isCommand: false)));
setState(() => _outputLines.add(_LogLine(text: S.t('[信息] 重连成功'), isCommand: false)));
}
};
_loadPresets();
@@ -85,13 +86,13 @@ class _ConsolePageState extends State<ConsolePage> {
final response = await widget.rconClient.executeCommand(cmd);
setState(() {
_outputLines.add(_LogLine(
text: stripMinecraftCodes(response ?? '(无响应)'),
text: stripMinecraftCodes(response ?? S.t('(无响应)')),
isCommand: false,
));
});
} catch (e) {
setState(() {
_outputLines.add(_LogLine(text: '[错误] $e', isCommand: false, isError: true));
_outputLines.add(_LogLine(text: S.f('[错误] {0}', [e.toString()]), isCommand: false, isError: true));
});
}
_scrollToBottom();
@@ -107,7 +108,7 @@ class _ConsolePageState extends State<ConsolePage> {
_controller.selection = TextSelection.fromPosition(TextPosition(offset: matches.first.length));
} else if (matches.length > 1) {
setState(() {
_outputLines.add(_LogLine(text: '建议:${matches.join(", ")}', isCommand: false));
_outputLines.add(_LogLine(text: S.f('建议:{0}', [matches.join(", ")]), isCommand: false));
});
_scrollToBottom();
}
@@ -148,11 +149,11 @@ class _ConsolePageState extends State<ConsolePage> {
return Scaffold(
appBar: AppBar(
title: const Text('服务器控制台'),
title: T('服务器控制台'),
actions: [
IconButton(
icon: const Icon(Icons.people_outline),
tooltip: '玩家管理',
tooltip: S.t('玩家管理'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => PlayerListPage(rconClient: widget.rconClient)),
@@ -212,7 +213,7 @@ class _ConsolePageState extends State<ConsolePage> {
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: '输入命令...',
hintText: S.t('输入命令...'),
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
),
style: const TextStyle(fontFamily: 'monospace', fontSize: 14),
@@ -224,7 +225,7 @@ class _ConsolePageState extends State<ConsolePage> {
FilledButton.icon(
onPressed: _executeCommand,
icon: const Icon(Icons.send_rounded, size: 18),
label: const Text('发送'),
label: T('发送'),
),
],
),
@@ -298,7 +299,7 @@ class _PresetBar extends StatelessWidget {
),
IconButton(
icon: const Icon(Icons.tune_rounded, size: 20),
tooltip: '管理快速命令',
tooltip: S.t('管理快速命令'),
onPressed: onManage,
),
const SizedBox(width: 4),
@@ -350,15 +351,15 @@ class _PresetManageSheetState extends State<_PresetManageSheet> {
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Text('快速命令', style: theme.textTheme.titleMedium),
child: T('快速命令', style: theme.textTheme.titleMedium),
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text('点击标签一键发送,点击右侧按钮编辑'),
child: T('点击标签一键发送,点击右侧按钮编辑'),
),
Expanded(
child: _presets.isEmpty
? const Center(child: Text('暂无预设,点击下方按钮添加'))
? const Center(child: T('暂无预设,点击下方按钮添加'))
: ListView.builder(
itemCount: _presets.length,
itemBuilder: (context, i) {
@@ -377,17 +378,17 @@ class _PresetManageSheetState extends State<_PresetManageSheet> {
children: [
IconButton(
icon: const Icon(Icons.send_rounded, size: 20),
tooltip: '发送',
tooltip: S.t('发送'),
onPressed: () => widget.onSend(preset.command),
),
IconButton(
icon: const Icon(Icons.edit_outlined, size: 20),
tooltip: '编辑',
tooltip: S.t('编辑'),
onPressed: () => _editPreset(preset: preset),
),
IconButton(
icon: const Icon(Icons.delete_outline, size: 20),
tooltip: '删除',
tooltip: S.t('删除'),
onPressed: () => setState(() => _presets.removeAt(i)),
),
],
@@ -403,12 +404,12 @@ class _PresetManageSheetState extends State<_PresetManageSheet> {
OutlinedButton.icon(
onPressed: () => _editPreset(),
icon: const Icon(Icons.add, size: 18),
label: const Text('新增'),
label: T('新增'),
),
const Spacer(),
FilledButton(
onPressed: () => Navigator.pop(context, _presets),
child: const Text('完成'),
child: T('完成'),
),
],
),
@@ -448,19 +449,19 @@ class _PresetEditDialogState extends State<_PresetEditDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(widget.preset == null ? '新增预设' : '编辑预设'),
title: Text(widget.preset == null ? S.t('新增预设') : S.t('编辑预设')),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: _labelController,
decoration: const InputDecoration(labelText: '标签', hintText: '例如:立即存档'),
decoration: InputDecoration(labelText: S.t('标签'), hintText: S.t('例如:立即存档')),
autofocus: true,
),
const SizedBox(height: 12),
TextField(
controller: _commandController,
decoration: const InputDecoration(labelText: '命令', hintText: '例如:save-all'),
decoration: InputDecoration(labelText: S.t('命令'), hintText: S.t('例如:save-all')),
style: const TextStyle(fontFamily: 'monospace'),
),
],
@@ -468,7 +469,7 @@ class _PresetEditDialogState extends State<_PresetEditDialog> {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消'),
child: T('取消'),
),
FilledButton(
onPressed: () {
@@ -476,13 +477,13 @@ class _PresetEditDialogState extends State<_PresetEditDialog> {
final command = _commandController.text.trim();
if (label.isEmpty || command.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('标签和命令都不能为空')),
const SnackBar(content: T('标签和命令都不能为空')),
);
return;
}
Navigator.pop(context, _PresetEditResult(label: label, command: command));
},
child: const Text('保存'),
child: T('保存'),
),
],
);
+25 -25
View File
@@ -10,6 +10,7 @@ import '../download/download_page.dart';
import '../mod_manager/mod_list_page.dart';
import '../terminal/terminal_page.dart';
import 'server_picker_bar.dart';
import '../../core/l10n/strings.dart';
/// 服务器 Dashboard:卡片式布局展示选中服务器的
/// 在线状态 / 延迟 / 在线人数 / TPS / 磁盘(后续 Shell 采集)+ 快捷入口(M4)。
@@ -96,14 +97,14 @@ class _DashboardPageState extends State<DashboardPage> {
final confirmed = await showDialog<bool>(
context: context,
builder: (_) => AlertDialog(
title: const Text('删除服务器'),
content: Text('确定要删除「${s.name}」吗?仅删除本应用中的连接配置,不影响服务器本身。'),
title: T('删除服务器'),
content: Text(S.f('确定要删除「{0}」吗?仅删除本应用中的连接配置,不影响服务器本身。', [s.name])),
actions: [
TextButton(onPressed: () => Navigator.pop(context, false), child: const Text('取消')),
TextButton(onPressed: () => Navigator.pop(context, false), child: T('取消')),
FilledButton(
style: FilledButton.styleFrom(backgroundColor: Colors.red),
onPressed: () => Navigator.pop(context, true),
child: const Text('删除'),
child: T('删除'),
),
],
),
@@ -132,11 +133,11 @@ class _DashboardPageState extends State<DashboardPage> {
children: [
const Icon(Icons.warning_amber_rounded, color: Colors.white),
const SizedBox(width: 8),
Expanded(child: Text('服务器「$serverName」已断开连接!')),
Expanded(child: Text(S.f('服务器「{0}」已断开连接!', [serverName]))),
],
),
action: SnackBarAction(
label: '知道了',
label: S.t('知道了'),
textColor: Colors.white,
onPressed: messenger.hideCurrentSnackBar,
),
@@ -159,19 +160,19 @@ class _DashboardPageState extends State<DashboardPage> {
actions: [
IconButton(
icon: const Icon(Icons.refresh),
tooltip: '刷新状态',
tooltip: S.t('刷新状态'),
onPressed: _refreshAll,
),
IconButton(
icon: const Icon(Icons.add),
tooltip: '添加服务器',
tooltip: S.t('添加服务器'),
onPressed: _addServer,
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: _addServer,
tooltip: '添加服务器',
tooltip: S.t('添加服务器'),
child: const Icon(Icons.add),
),
body: servers.isEmpty
@@ -179,11 +180,11 @@ class _DashboardPageState extends State<DashboardPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('还没有服务器,点击下方按钮添加吧'),
T('还没有服务器,点击下方按钮添加吧'),
const SizedBox(height: 16),
FilledButton.icon(
icon: const Icon(Icons.add),
label: const Text('添加服务器'),
label: T('添加服务器'),
onPressed: _addServer,
),
],
@@ -200,7 +201,7 @@ class _DashboardPageState extends State<DashboardPage> {
subtitle: Text('${selected?.host ?? '-'}:${selected?.port ?? '-'}'),
trailing: DropdownButton<ServerConfig>(
underline: const SizedBox.shrink(),
hint: const Text('切换'),
hint: T('切换'),
items: servers
.map((s) => DropdownMenuItem(value: s, child: Text(s.name)))
.toList(),
@@ -230,7 +231,7 @@ class _DashboardPageState extends State<DashboardPage> {
_statusCard(
icon: Icons.person,
color: Colors.blue,
label: '在线人数',
label: S.t('在线人数'),
sub: '${status?.playerCount ?? 0}',
),
_statusCard(
@@ -242,14 +243,14 @@ class _DashboardPageState extends State<DashboardPage> {
_statusCard(
icon: Icons.storage,
color: Colors.purple,
label: '磁盘',
label: S.t('磁盘'),
sub: '需 SSH 终端',
),
],
),
const SizedBox(height: 8),
// 服务器卡片列表(点击选中)
Text('服务器', style: Theme.of(context).textTheme.titleMedium),
T('服务器', style: Theme.of(context).textTheme.titleMedium),
...servers.map((s) {
final st = _status[s.id];
final isSel = selected?.id == s.id;
@@ -264,9 +265,8 @@ class _DashboardPageState extends State<DashboardPage> {
title: Text(s.name),
subtitle: Text(
st?.online == true
? '在线 · ${st!.latencyMs}ms · ${st.playerCount} 人'
'${st.tps != null ? " · TPS ${st.tps!.toStringAsFixed(1)}" : ""}'
: '离线',
? S.f('在线 · {0}ms · {1} 人', [st!.latencyMs, st.playerCount]) + (st.tps != null ? ' · TPS ${st.tps!.toStringAsFixed(1)}' : '')
: S.t('离线'),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
@@ -275,8 +275,8 @@ class _DashboardPageState extends State<DashboardPage> {
PopupMenuButton<String>(
onSelected: (a) => _onServerAction(context, s, a),
itemBuilder: (_) => const [
PopupMenuItem(value: 'edit', child: Text('编辑')),
PopupMenuItem(value: 'delete', child: Text('删除')),
PopupMenuItem(value: 'edit', child: T('编辑')),
PopupMenuItem(value: 'delete', child: T('删除')),
],
),
],
@@ -295,8 +295,8 @@ class _DashboardPageState extends State<DashboardPage> {
children: [
ListTile(
leading: const Icon(Icons.download_outlined),
title: const Text('下载中心'),
subtitle: const Text('Modrinth 搜索 · 镜像加速'),
title: T('下载中心'),
subtitle: T('Modrinth 搜索 · 镜像加速'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
@@ -305,7 +305,7 @@ class _DashboardPageState extends State<DashboardPage> {
),
ListTile(
leading: const Icon(Icons.terminal),
title: const Text('远程终端'),
title: T('远程终端'),
subtitle: const Text('SSH Shell'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
@@ -315,8 +315,8 @@ class _DashboardPageState extends State<DashboardPage> {
),
ListTile(
leading: const Icon(Icons.extension_outlined),
title: const Text('模组管理'),
subtitle: const Text('上传 / 删除 / 查看依赖'),
title: T('模组管理'),
subtitle: T('上传 / 删除 / 查看依赖'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
+19 -18
View File
@@ -5,6 +5,7 @@ import '../../core/services/modrinth_api.dart';
import '../../providers/download_provider.dart';
import '../../core/services/download_manager.dart';
import '../settings/download_settings_page.dart';
import '../../core/l10n/strings.dart';
/// 下载中心:Modrinth 搜索 + 镜像线路选择 + 下载任务队列(M2)。
class DownloadPage extends StatefulWidget {
@@ -54,7 +55,7 @@ class _DownloadPageState extends State<DownloadPage> {
} catch (e) {
if (!mounted) return;
setState(() => _searching = false);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('搜索失败:$e')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(S.f('搜索失败:{0}', [e]))));
}
}
@@ -67,11 +68,11 @@ class _DownloadPageState extends State<DownloadPage> {
child: Scaffold(
backgroundColor: hasWallpaper ? Colors.transparent : null,
appBar: AppBar(
title: const Text('下载中心'),
title: T('下载中心'),
actions: [
IconButton(
icon: const Icon(Icons.settings_outlined),
tooltip: '下载与镜像设置',
tooltip: S.t('下载与镜像设置'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const DownloadSettingsPage()),
@@ -95,8 +96,8 @@ class _DownloadPageState extends State<DownloadPage> {
Expanded(
child: TextField(
controller: _searchCtrl,
decoration: const InputDecoration(
hintText: '搜索 Modrinth 模组/插件,如 sodium',
decoration: InputDecoration(
hintText: S.t('搜索 Modrinth 模组/插件,如 sodium'),
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(),
isDense: true,
@@ -105,7 +106,7 @@ class _DownloadPageState extends State<DownloadPage> {
),
),
const SizedBox(width: 8),
FilledButton(onPressed: _searching ? null : _search, child: const Text('搜索')),
FilledButton(onPressed: _searching ? null : _search, child: T('搜索')),
],
),
),
@@ -139,9 +140,9 @@ class _DownloadPageState extends State<DownloadPage> {
child: _searching
? const Center(child: CircularProgressIndicator())
: _results == null
? const Center(child: Text('输入关键词开始搜索'))
? const Center(child: T('输入关键词开始搜索'))
: _results!.isEmpty
? const Center(child: Text('没有结果'))
? const Center(child: T('没有结果'))
: ListView.builder(
itemCount: _results!.length,
itemBuilder: (context, i) {
@@ -184,7 +185,7 @@ class _DownloadPageState extends State<DownloadPage> {
Future<void> _showVersionSheet(ModrinthSearchResult r) async {
final dp = context.read<DownloadProvider>();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('正在获取版本列表...'), duration: Duration(seconds: 1)),
SnackBar(content: T('正在获取版本列表...'), duration: Duration(seconds: 1)),
);
try {
final versions = await dp.versions(r.projectId);
@@ -197,7 +198,7 @@ class _DownloadPageState extends State<DownloadPage> {
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Text('选择 ${r.title} 的版本', style: Theme.of(context).textTheme.titleMedium),
child: Text(S.f('选择 {0} 的版本', [r.title]), style: Theme.of(context).textTheme.titleMedium),
),
...versions.take(15).map((v) => ListTile(
title: Text(v.versionNumber),
@@ -211,7 +212,7 @@ class _DownloadPageState extends State<DownloadPage> {
);
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('获取版本失败:$e')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(S.f('获取版本失败:{0}', [e]))));
}
}
}
@@ -222,7 +223,7 @@ class _DownloadPageState extends State<DownloadPage> {
// 取主 jar 文件
final files = v.files;
if (files.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('该版本没有可用文件')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: T('该版本没有可用文件')));
return;
}
final primary = files.firstWhere((f) => f['primary'] == true, orElse: () => files.first);
@@ -230,7 +231,7 @@ class _DownloadPageState extends State<DownloadPage> {
final fileName = primary['filename'] as String;
await dp.download(url: url, fileName: fileName, projectType: _projectType);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('已加入下载队列:$fileName')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(S.f('已加入下载队列:{0}', [fileName]))));
}
}
@@ -239,7 +240,7 @@ class _DownloadPageState extends State<DownloadPage> {
animation: dp.manager,
builder: (context, _) {
final tasks = dp.manager.tasks;
if (tasks.isEmpty) return const Center(child: Text('暂无下载任务'));
if (tasks.isEmpty) return const Center(child: T('暂无下载任务'));
return ListView.builder(
itemCount: tasks.length,
itemBuilder: (context, i) {
@@ -271,24 +272,24 @@ class _DownloadPageState extends State<DownloadPage> {
if (t.status == DownloadStatus.running)
IconButton(
icon: const Icon(Icons.pause),
tooltip: '暂停',
tooltip: S.t('暂停'),
onPressed: () => dp.manager.pause(t.id),
),
if (t.status == DownloadStatus.paused)
IconButton(
icon: const Icon(Icons.play_arrow),
tooltip: '继续',
tooltip: S.t('继续'),
onPressed: () => dp.manager.resume(t.id),
),
if (t.status == DownloadStatus.failed)
IconButton(
icon: const Icon(Icons.replay),
tooltip: '重试',
tooltip: S.t('重试'),
onPressed: () => dp.manager.retry(t.id),
),
IconButton(
icon: const Icon(Icons.close),
tooltip: '取消',
tooltip: S.t('取消'),
onPressed: () => dp.manager.cancel(t.id),
),
],
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
import '../../core/services/dependency_index_service.dart';
import '../../providers/download_provider.dart';
import '../../providers/server_provider.dart';
import '../../core/l10n/strings.dart';
/// 依赖仓库页:服务器本地仓库增量同步 + 依赖树查询 + 缺失依赖一键补齐 + 重复检测。
class DependencyTreePage extends StatefulWidget {
@@ -48,7 +49,7 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
if (!mounted) return;
setState(() {
_syncing = false;
_syncInfo = '同步失败:$e';
_syncInfo = S.f('同步失败:{0}', [e]);
});
}
}
@@ -66,24 +67,24 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
Text('${tree.mod.name ?? tree.mod.fileName} ${tree.mod.version ?? ''}',
style: Theme.of(context).textTheme.titleMedium),
const Divider(),
const Text('该模组依赖:'),
T('该模组依赖:'),
...tree.dependsOn.map((m) => ListTile(
dense: true,
leading: const Icon(Icons.link, size: 18),
title: Text('${m.name ?? m.fileName} ${m.version ?? ''}'),
)),
if (tree.dependsOn.isEmpty) const Text('无', style: TextStyle(color: Colors.grey)),
if (tree.dependsOn.isEmpty) T('无', style: TextStyle(color: Colors.grey)),
const SizedBox(height: 8),
const Text('被以下模组依赖:'),
T('被以下模组依赖:'),
...tree.dependents.map((m) => ListTile(
dense: true,
leading: const Icon(Icons.link, size: 18),
title: Text('${m.name ?? m.fileName} ${m.version ?? ''}'),
)),
if (tree.dependents.isEmpty) const Text('无', style: TextStyle(color: Colors.grey)),
if (tree.dependents.isEmpty) T('无', style: TextStyle(color: Colors.grey)),
if (tree.missing.isNotEmpty) ...[
const SizedBox(height: 8),
const Text('缺失依赖(可一键补齐):',
T('缺失依赖(可一键补齐):',
style: TextStyle(color: Colors.red, fontWeight: FontWeight.w600)),
...tree.missing.map((d) => ListTile(
dense: true,
@@ -91,7 +92,7 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
title: Text(d),
trailing: TextButton(
onPressed: () => _fetchMissing(d),
child: const Text('从 Modrinth 补齐'),
child: T('从 Modrinth 补齐'),
),
)),
],
@@ -105,21 +106,21 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
final dp = context.read<DownloadProvider>();
try {
final results = await dp.search(name, projectType: 'mod', limit: 1);
if (results.isEmpty) throw '未找到 $name';
if (results.isEmpty) throw S.f('未找到 {0}', [name]);
final project = results.first;
final versions = await dp.versions(project.projectId);
if (versions.isEmpty) throw '该项目没有可用版本';
if (versions.isEmpty) throw S.t('该项目没有可用版本');
final v = versions.first;
if (v.files.isEmpty) throw '没有可用文件';
if (v.files.isEmpty) throw S.t('没有可用文件');
final primary = v.files.firstWhere((f) => f['primary'] == true, orElse: () => v.files.first);
await dp.download(url: primary['url'], fileName: primary['filename'], projectType: 'mod');
if (mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('已下载 $name(${v.versionNumber})')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(S.f('已下载 {0}({1})', [name, v.versionNumber]))));
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('补齐失败:$e')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(S.f('补齐失败:{0}', [e]))));
}
}
}
@@ -134,18 +135,18 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
shrinkWrap: true,
padding: const EdgeInsets.all(16),
children: [
Text('版本冲突 / 重复 jar', style: Theme.of(context).textTheme.titleMedium),
Text(S.t('版本冲突 / 重复 jar'), style: Theme.of(context).textTheme.titleMedium),
const Divider(),
if (dups.isEmpty) const Text('未发现重复'),
if (dups.isEmpty) T('未发现重复'),
...dups.map((g) => ExpansionTile(
title: Text(g.modId,
style: const TextStyle(color: Colors.orange, fontWeight: FontWeight.w600)),
subtitle: Text('${g.items.length} 个版本共存'),
subtitle: Text(S.f('{0} 个版本共存', [g.items.length])),
children: g.items
.map((m) => ListTile(
dense: true,
title: Text(m.fileName),
subtitle: Text('版本 ${m.version ?? '未知'} · ${m.remotePath}'),
subtitle: Text('${m.version ?? S.t('未知')} · ${m.remotePath}'),
))
.toList(),
)),
@@ -159,11 +160,11 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('依赖仓库'),
title: T('依赖仓库'),
actions: [
IconButton(
icon: const Icon(Icons.rule),
tooltip: '重复检测',
tooltip: S.t('重复检测'),
onPressed: _checkDuplicates,
),
],
@@ -181,7 +182,7 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
icon: _syncing
? const SizedBox(width: 16, height: 16, child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.sync),
label: const Text('同步'),
label: T('同步'),
onPressed: _syncing ? null : _sync,
),
],
@@ -195,11 +196,11 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('索引为空,先点击「同步」'),
T('索引为空,先点击「同步」'),
if (!widget.server.hasSsh)
const Padding(
padding: EdgeInsets.all(8),
child: Text('(该服务器未配置 SSH,无法同步)',
child: T('(该服务器未配置 SSH,无法同步)',
style: TextStyle(color: Colors.red)),
),
],
@@ -213,7 +214,7 @@ class _DependencyTreePageState extends State<DependencyTreePage> {
leading: const Icon(Icons.inventory_2_outlined),
title: Text('${m.name ?? m.fileName} ${m.version ?? ''}'),
subtitle: Text(
'${m.fileName} · 依赖 ${m.depends.length} · 软依赖 ${m.softDepends.length}',
S.f('{0} · 依赖 {1} · 软依赖 {2}', [m.fileName, m.depends.length, m.softDepends.length]),
),
trailing: const Icon(Icons.account_tree_outlined),
onTap: () => _showTree(m),
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../mod_manager/mod_provider.dart';
import '../../core/l10n/strings.dart';
/// 模组详情页:展示 jar 元数据(名称 / 版本 / 作者 / 依赖 / 描述)。
class ModDetailPage extends StatelessWidget {
@@ -18,9 +19,9 @@ class ModDetailPage extends StatelessWidget {
children: [
ListTile(
leading: const Icon(Icons.extension),
title: Text(meta.name ?? '未知名称',
title: Text(meta.name ?? S.t('未知名称'),
style: Theme.of(context).textTheme.titleLarge),
subtitle: Text('版本 ${meta.version ?? '未知'}'),
subtitle: Text(S.f('版本 {0}', [meta.version ?? '未知'])),
),
const Divider(),
_kv('文件名', file.fileName),
@@ -30,10 +31,10 @@ class ModDetailPage extends StatelessWidget {
_kv('元数据来源', meta.source),
if (meta.description != null) _kv('描述', meta.description!),
const Divider(),
Text('硬依赖', style: Theme.of(context).textTheme.titleMedium),
T('硬依赖', style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 4),
if (meta.depends.isEmpty)
const Text('无')
T('无')
else
Wrap(
spacing: 6,
@@ -42,10 +43,10 @@ class ModDetailPage extends StatelessWidget {
.toList(),
),
const SizedBox(height: 12),
Text('软依赖', style: Theme.of(context).textTheme.titleMedium),
T('软依赖', style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 4),
if (meta.softDepends.isEmpty)
const Text('无')
T('无')
else
Wrap(spacing: 6, children: meta.softDepends.map((d) => Chip(label: Text(d))).toList()),
],
+23 -22
View File
@@ -7,6 +7,7 @@ import '../dashboard/server_picker_bar.dart';
import 'mod_provider.dart';
import 'mod_detail_page.dart';
import 'dependency_tree_page.dart';
import '../../core/l10n/strings.dart';
/// 模组/插件管理页:列出服务器 mods / plugins 目录中的 jar 文件,
/// 支持上传 / 删除 / 重命名 / 查看详情(M1)。
@@ -53,7 +54,7 @@ class _ModListPageState extends State<ModListPage>
super.build(context);
final server = context.watch<SelectedServerHolder>().server;
if (server == null) {
return const Center(child: Text('请先在「服务器」页选择一台服务器'));
return const Center(child: T('请先在「服务器」页选择一台服务器'));
}
if (!server.hasSsh) {
return _NoSshHint(serverName: server.name);
@@ -67,16 +68,16 @@ class _ModListPageState extends State<ModListPage>
return Scaffold(
backgroundColor: hasWallpaper ? Colors.transparent : null,
appBar: AppBar(
title: const Text('模组管理'),
title: T('模组管理'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: mod.loading ? null : mod.refresh,
tooltip: '刷新',
tooltip: S.t('刷新'),
),
IconButton(
icon: const Icon(Icons.account_tree_outlined),
tooltip: '依赖仓库',
tooltip: S.t('依赖仓库'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
@@ -107,9 +108,9 @@ class _ModListPageState extends State<ModListPage>
icon: const Icon(Icons.sort),
onSelected: (m) => mod.setSortMode(m),
itemBuilder: (_) => const [
PopupMenuItem(value: ModSortMode.name, child: Text('按名称')),
PopupMenuItem(value: ModSortMode.size, child: Text('按大小')),
PopupMenuItem(value: ModSortMode.mtime, child: Text('按修改时间')),
PopupMenuItem(value: ModSortMode.name, child: T('按名称')),
PopupMenuItem(value: ModSortMode.size, child: T('按大小')),
PopupMenuItem(value: ModSortMode.mtime, child: T('按修改时间')),
],
),
],
@@ -119,12 +120,12 @@ class _ModListPageState extends State<ModListPage>
if (mod.error != null)
Padding(
padding: const EdgeInsets.all(12),
child: Text('加载失败:${mod.error}',
child: Text(S.f('加载失败:{0}', [mod.error.toString()]),
style: TextStyle(color: Theme.of(context).colorScheme.error)),
),
Expanded(
child: mod.files.isEmpty && !mod.loading
? const Center(child: Text('目录下没有 .jar 文件'))
? const Center(child: T('目录下没有 .jar 文件'))
: ListView.builder(
itemCount: mod.files.length,
itemBuilder: (context, i) {
@@ -139,9 +140,9 @@ class _ModListPageState extends State<ModListPage>
trailing: PopupMenuButton<String>(
onSelected: (a) => _onAction(context, mod, f, a),
itemBuilder: (_) => const [
PopupMenuItem(value: 'detail', child: Text('详情')),
PopupMenuItem(value: 'rename', child: Text('重命名')),
PopupMenuItem(value: 'delete', child: Text('删除')),
PopupMenuItem(value: 'detail', child: T('详情')),
PopupMenuItem(value: 'rename', child: T('重命名')),
PopupMenuItem(value: 'delete', child: T('删除')),
],
),
onTap: () => Navigator.push(
@@ -158,7 +159,7 @@ class _ModListPageState extends State<ModListPage>
),
floatingActionButton: FloatingActionButton.extended(
icon: const Icon(Icons.upload_file),
label: const Text('上传 jar'),
label: T('上传 jar'),
onPressed: mod.loading ? null : () => _upload(context, mod),
),
);
@@ -177,7 +178,7 @@ class _ModListPageState extends State<ModListPage>
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('上传失败:$e')));
.showSnackBar(SnackBar(content: Text(S.f('上传失败:{0}', [e.toString()]))));
}
}
}
@@ -189,11 +190,11 @@ class _ModListPageState extends State<ModListPage>
final ok = await showDialog<bool>(
context: context,
builder: (_) => AlertDialog(
title: const Text('确认删除'),
content: Text('确定要删除 ${f.fileName} 吗?此操作不可恢复。'),
title: T('确认删除'),
content: Text(S.f('确定要删除 {0} 吗?此操作不可恢复。', [f.fileName])),
actions: [
TextButton(onPressed: () => Navigator.pop(context, false), child: const Text('取消')),
FilledButton(onPressed: () => Navigator.pop(context, true), child: const Text('删除')),
TextButton(onPressed: () => Navigator.pop(context, false), child: T('取消')),
FilledButton(onPressed: () => Navigator.pop(context, true), child: T('删除')),
],
),
);
@@ -204,13 +205,13 @@ class _ModListPageState extends State<ModListPage>
final newName = await showDialog<String>(
context: context,
builder: (_) => AlertDialog(
title: const Text('重命名'),
title: T('重命名'),
content: TextField(controller: ctrl, autofocus: true),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
FilledButton(
onPressed: () => Navigator.pop(context, ctrl.text.trim()),
child: const Text('确定')),
child: T('确定')),
],
),
);
@@ -242,7 +243,7 @@ class _NoSshHint extends StatelessWidget {
children: [
const Icon(Icons.no_encryption_outlined, size: 56),
const SizedBox(height: 12),
Text('$serverName 未配置 SSH'),
Text(S.f('{0} 未配置 SSH', [serverName])),
const SizedBox(height: 8),
const Text(
'模组管理需要 SSH 连接。请在「服务器」页编辑该服务器,\n开启 SSH 并填写用户名和密码。',
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '../../core/utils/rcon_client.dart';
import 'player_service.dart';
import '../../core/l10n/strings.dart';
/// 玩家管理页:展示当前在线玩家的完整列表(含 UUID)。
class PlayerListPage extends StatefulWidget {
@@ -52,12 +53,12 @@ class _PlayerListPageState extends State<PlayerListPage> {
final result = await action();
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('$actionName:${stripMinecraftCodes(result ?? '无响应')}'), duration: const Duration(seconds: 2)));
.showSnackBar(SnackBar(content: Text(S.f('{0}:{1}', [actionName, stripMinecraftCodes(result ?? S.t('无响应'))])), duration: const Duration(seconds: 2)));
await _load();
} catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('$actionName失败:$e'), backgroundColor: Colors.red));
.showSnackBar(SnackBar(content: Text(S.f('{0}失败:{1}', [actionName, e.toString()])), backgroundColor: Colors.red));
}
}
@@ -101,11 +102,11 @@ class _PlayerListPageState extends State<PlayerListPage> {
});
}
static const _actionLabels = {
'op': '给予OP',
'deop': '取消OP',
'kick': '踢出',
'ban': '封禁',
static Map<String, String> get _actionLabels => {
'op': S.t('给予OP'),
'deop': S.t('取消OP'),
'kick': S.t('踢出'),
'ban': S.t('封禁'),
};
/// 对选中的所有玩家执行批量操作。
@@ -118,7 +119,7 @@ class _PlayerListPageState extends State<PlayerListPage> {
String? reason;
if (action == 'kick' || action == 'ban') {
reason = await _showReasonDialog(_actionLabels[action]!, '${names.length}名玩家');
reason = await _showReasonDialog(_actionLabels[action]!, S.f('{0} 名玩家', [names.length]));
if (reason == null) return; // 用户取消
}
@@ -144,7 +145,7 @@ class _PlayerListPageState extends State<PlayerListPage> {
if (!mounted) return;
final label = _actionLabels[action]!;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('$label完成:成功 $success 人${fail > 0 ? ',失败 $fail 人' : ''}'),
content: Text(S.f('{0}完成:成功 {1} 人', [label, success]) + (fail > 0 ? S.f(',失败 {0} 人', [fail]) : '')),
duration: const Duration(seconds: 2),
));
await _load();
@@ -163,20 +164,20 @@ class _PlayerListPageState extends State<PlayerListPage> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('将对「$player」执行该操作'),
Text(S.f('将对「{0}」执行该操作', [player])),
const SizedBox(height: 12),
TextField(
controller: controller,
autofocus: true,
decoration: const InputDecoration(hintText: '原因(可选)'),
decoration: InputDecoration(hintText: S.t('原因(可选)')),
),
],
),
actions: [
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
TextButton(onPressed: () => Navigator.pop(ctx, false), child: T('取消')),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('确认', style: TextStyle(color: Colors.red)),
child: T('确认', style: TextStyle(color: Colors.red)),
),
],
),
@@ -196,16 +197,16 @@ class _PlayerListPageState extends State<PlayerListPage> {
leading: _selecting
? IconButton(
icon: const Icon(Icons.close),
tooltip: '退出选择',
tooltip: S.t('退出选择'),
onPressed: _exitSelection,
)
: null,
title: Text(_selecting ? '已选 ${_selected.length} 人' : '玩家管理'),
title: Text(_selecting ? S.f('已选 {0} 人', [_selected.length]) : S.t('玩家管理')),
actions: [
if (_selecting) ...[
IconButton(
icon: const Icon(Icons.select_all),
tooltip: '全选',
tooltip: S.t('全选'),
onPressed: () {
setState(() => _selected
..clear()
@@ -215,12 +216,12 @@ class _PlayerListPageState extends State<PlayerListPage> {
] else
IconButton(
icon: const Icon(Icons.checklist_outlined),
tooltip: '批量操作',
tooltip: S.t('批量操作'),
onPressed: _loading ? null : _enterSelection,
),
IconButton(
icon: const Icon(Icons.refresh),
tooltip: '刷新',
tooltip: S.t('刷新'),
onPressed: _loading ? null : _load,
),
],
@@ -238,10 +239,10 @@ class _PlayerListPageState extends State<PlayerListPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildBatchButton('op', Icons.admin_panel_settings_outlined, '给予OP', Colors.green),
_buildBatchButton('deop', Icons.remove_moderator_outlined, '取消OP', Colors.orange),
_buildBatchButton('kick', Icons.logout, '踢出', Colors.blue),
_buildBatchButton('ban', Icons.block, '封禁', Colors.red),
_buildBatchButton('op', Icons.admin_panel_settings_outlined, S.t('给予OP'), Colors.green),
_buildBatchButton('deop', Icons.remove_moderator_outlined, S.t('取消OP'), Colors.orange),
_buildBatchButton('kick', Icons.logout, S.t('踢出'), Colors.blue),
_buildBatchButton('ban', Icons.block, S.t('封禁'), Colors.red),
],
),
),
@@ -276,16 +277,16 @@ class _PlayerListPageState extends State<PlayerListPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('加载失败:$_error', textAlign: TextAlign.center),
Text(S.f('加载失败:{0}', [_error.toString()]), textAlign: TextAlign.center),
const SizedBox(height: 12),
FilledButton(onPressed: _load, child: const Text('重试')),
FilledButton(onPressed: _load, child: T('重试')),
],
),
);
}
final players = _players ?? [];
if (players.isEmpty) {
return Center(child: Text('暂无在线玩家', style: theme.textTheme.bodyLarge));
return Center(child: T('暂无在线玩家', style: theme.textTheme.bodyLarge));
}
return RefreshIndicator(
onRefresh: _load,
@@ -320,13 +321,13 @@ class _PlayerListPageState extends State<PlayerListPage> {
visualDensity: VisualDensity.compact,
),
PopupMenuButton<String>(
tooltip: '操作',
tooltip: S.t('操作'),
onSelected: (action) => _handleAction(p, action),
itemBuilder: (_) => [
const PopupMenuItem(value: 'op', child: Text('给予 OP')),
const PopupMenuItem(value: 'deop', child: Text('取消 OP')),
const PopupMenuItem(value: 'kick', child: Text('踢出')),
const PopupMenuItem(value: 'ban', child: Text('封禁')),
const PopupMenuItem(value: 'op', child: T('给予 OP')),
const PopupMenuItem(value: 'deop', child: T('取消 OP')),
const PopupMenuItem(value: 'kick', child: T('踢出')),
const PopupMenuItem(value: 'ban', child: T('封禁')),
],
),
],
+12 -11
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../core/l10n/strings.dart';
/// 服务器卡片的数据状态。
enum ServerCardState {
@@ -75,7 +76,7 @@ class ServerCard extends StatelessWidget {
case ServerCardState.offline:
return '离线';
case ServerCardState.loading:
return '检测中';
return S.t('检测中');
}
}
@@ -192,7 +193,7 @@ class ServerCard extends StatelessWidget {
Widget _buildMenu(BuildContext context, ColorScheme scheme) {
return PopupMenuButton<String>(
tooltip: '更多操作',
tooltip: S.t('更多操作'),
icon: Icon(Icons.more_vert, size: 20, color: scheme.onSurfaceVariant),
padding: EdgeInsets.zero,
itemBuilder: (context) => [
@@ -203,7 +204,7 @@ class ServerCard extends StatelessWidget {
children: [
Icon(Icons.edit_outlined, size: 19),
SizedBox(width: 12),
Text('编辑'),
T('编辑'),
],
),
),
@@ -214,7 +215,7 @@ class ServerCard extends StatelessWidget {
children: [
Icon(Icons.delete_outline, size: 19, color: scheme.error),
const SizedBox(width: 12),
Text('删除', style: TextStyle(color: scheme.error)),
T('删除', style: TextStyle(color: scheme.error)),
],
),
),
@@ -255,9 +256,9 @@ class ServerCard extends StatelessWidget {
if (state == ServerCardState.loading) {
return _pillRow(context, [
const _Pill(
_Pill(
icon: Icons.autorenew_rounded,
label: '正在获取状态',
label: S.t('正在获取状态'),
color: Color(0xFF94A3B8),
),
]);
@@ -266,16 +267,16 @@ class ServerCard extends StatelessWidget {
if (!online) {
return Row(
children: [
const Flexible(
Flexible(
child: _Pill(
icon: Icons.cloud_off_outlined,
label: '无法连接',
label: S.t('无法连接'),
color: Color(0xFFF87171),
),
),
const Spacer(),
Text(
'点击重试',
S.t('点击重试'),
style: theme.textTheme.labelSmall?.copyWith(
color: scheme.onSurfaceVariant,
fontWeight: FontWeight.w600,
@@ -291,7 +292,7 @@ class ServerCard extends StatelessWidget {
icon: Icons.people_alt_outlined,
label: maxPlayers != null
? '${playerCount ?? 0}/$maxPlayers'
: '${playerCount ?? 0} 人',
: S.f('{0} 人', [playerCount ?? 0]),
color: scheme.primary,
emphasized: true,
),
@@ -313,7 +314,7 @@ class ServerCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
'进入控制台',
S.t('进入控制台'),
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: scheme.primary,
fontWeight: FontWeight.w600,
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../providers/server_provider.dart';
import '../../core/l10n/strings.dart';
class ServerFormDialog extends StatefulWidget {
final ServerConfig? existingServer;
@@ -53,14 +54,14 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
}
String? _validateRequired(String? value, String field) {
if (value == null || value.trim().isEmpty) return '$field不能为空';
if (value == null || value.trim().isEmpty) return S.f('{0}不能为空', [field]);
return null;
}
String? _validatePort(String? value) {
if (value == null || value.trim().isEmpty) return '端口不能为空';
if (value == null || value.trim().isEmpty) return S.t('端口不能为空');
final port = int.tryParse(value.trim());
if (port == null || port < 1 || port > 65535) return '端口范围 1-65535';
if (port == null || port < 1 || port > 65535) return S.t('端口范围 1-65535');
return null;
}
@@ -94,21 +95,21 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
children: [
TextFormField(
controller: _nameCtrl,
decoration: const InputDecoration(labelText: '服务器名称', hintText: '例如: 我的生存服'),
decoration: InputDecoration(labelText: S.t('服务器名称'), hintText: S.t('例如: 我的生存服')),
validator: (v) => _validateRequired(v, '服务器名称'),
textInputAction: TextInputAction.next,
),
const SizedBox(height: 12),
TextFormField(
controller: _hostCtrl,
decoration: const InputDecoration(labelText: '主机地址', hintText: 'IP 或域名'),
decoration: InputDecoration(labelText: S.t('主机地址'), hintText: S.t('IP 或域名')),
validator: (v) => _validateRequired(v, '主机地址'),
textInputAction: TextInputAction.next,
),
const SizedBox(height: 12),
TextFormField(
controller: _portCtrl,
decoration: const InputDecoration(labelText: 'RCON 端口', hintText: '默认 25575'),
decoration: InputDecoration(labelText: S.t('RCON 端口'), hintText: S.t('默认 25575')),
keyboardType: TextInputType.number,
validator: _validatePort,
textInputAction: TextInputAction.next,
@@ -118,7 +119,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
controller: _passCtrl,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'RCON 密码',
labelText: S.t('RCON 密码'),
suffixIcon: IconButton(
icon: Icon(_obscurePassword ? Icons.visibility_off_outlined : Icons.visibility_outlined),
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
@@ -131,15 +132,15 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
const SizedBox(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: const Text('SSH 连接(可选)'),
subtitle: const Text('用于模组插件管理与远程终端'),
title: T('SSH 连接(可选)'),
subtitle: T('用于模组插件管理与远程终端'),
value: _sshEnabled,
onChanged: (v) => setState(() => _sshEnabled = v),
),
if (_sshEnabled) ...[
TextFormField(
controller: _sshPortCtrl,
decoration: const InputDecoration(labelText: 'SSH 端口', hintText: '默认 22'),
decoration: InputDecoration(labelText: S.t('SSH 端口'), hintText: S.t('默认 22')),
keyboardType: TextInputType.number,
validator: (v) {
if (!_sshEnabled) return null;
@@ -150,7 +151,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
const SizedBox(height: 12),
TextFormField(
controller: _sshUserCtrl,
decoration: const InputDecoration(labelText: 'SSH 用户名', hintText: '例如 root'),
decoration: InputDecoration(labelText: S.t('SSH 用户名'), hintText: S.t('例如 root')),
validator: (v) => _sshEnabled ? _validateRequired(v, 'SSH 用户名') : null,
textInputAction: TextInputAction.next,
),
@@ -159,7 +160,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
controller: _sshPasswordCtrl,
obscureText: _obscureSshPassword,
decoration: InputDecoration(
labelText: 'SSH 密码',
labelText: S.t('SSH 密码'),
suffixIcon: IconButton(
icon: Icon(_obscureSshPassword
? Icons.visibility_off_outlined
@@ -178,7 +179,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
),
),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
FilledButton(onPressed: _submit, child: Text(isEditing ? '保存' : '添加')),
],
);
+12 -11
View File
@@ -9,6 +9,7 @@ import '../console/console_page.dart';
import '../settings/settings_page.dart';
import 'server_card.dart';
import 'server_form_dialog.dart';
import '../../core/l10n/strings.dart';
class ServerListPage extends StatefulWidget {
const ServerListPage({super.key});
@@ -101,7 +102,7 @@ class _ServerListPageState extends State<ServerListPage> {
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('正在连接...'),
T('正在连接...'),
],
),
),
@@ -128,7 +129,7 @@ class _ServerListPageState extends State<ServerListPage> {
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('连接失败:$error')),
SnackBar(content: Text(S.f('连接失败:{0}', [error.toString()]))),
);
}
}
@@ -165,16 +166,16 @@ class _ServerListPageState extends State<ServerListPage> {
final confirmed = await showDialog<bool>(
context: context,
builder: (_) => AlertDialog(
title: const Text('确认删除'),
content: Text('确定要删除服务器「${server.name}」吗?'),
title: T('确认删除'),
content: Text(S.f('确定要删除服务器「{0}」吗?', [server.name])),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('取消'),
child: T('取消'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('删除', style: TextStyle(color: Colors.red)),
child: T('删除', style: TextStyle(color: Colors.red)),
),
],
),
@@ -198,7 +199,7 @@ class _ServerListPageState extends State<ServerListPage> {
actions: [
IconButton(
icon: const Icon(Icons.settings_outlined),
tooltip: '设置',
tooltip: S.t('设置'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const SettingsPage()),
@@ -239,7 +240,7 @@ class _ServerListPageState extends State<ServerListPage> {
floatingActionButton: FloatingActionButton.extended(
onPressed: _addServer,
icon: const Icon(Icons.add),
label: const Text('添加服务器'),
label: T('添加服务器'),
),
);
}
@@ -274,14 +275,14 @@ class _EmptyState extends StatelessWidget {
),
const SizedBox(height: 20),
Text(
'还没有添加服务器',
S.t('还没有添加服务器'),
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
Text(
'填入主机地址与 RCON 密码,即可在手机上管理',
S.t('填入主机地址与 RCON 密码,即可在手机上管理'),
textAlign: TextAlign.center,
style: theme.textTheme.bodySmall?.copyWith(
color: scheme.onSurfaceVariant,
@@ -291,7 +292,7 @@ class _EmptyState extends StatelessWidget {
FilledButton.icon(
onPressed: onAdd,
icon: const Icon(Icons.add),
label: const Text('添加服务器'),
label: T('添加服务器'),
),
],
),
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../providers/download_provider.dart';
import '../../core/l10n/strings.dart';
/// 下载与镜像设置页:镜像线路选择、测速自动选线、并发数(原下载页内设置移入此处)。
class DownloadSettingsPage extends StatefulWidget {
@@ -24,13 +25,13 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
final dp = context.watch<DownloadProvider>();
final mirror = dp.mirror;
return Scaffold(
appBar: AppBar(title: const Text('下载与镜像设置')),
appBar: AppBar(title: T('下载与镜像设置')),
body: ListView(
children: [
const SectionHeader('镜像线路'),
RadioListTile<String>(
title: const Text('MCIM 国内镜像(推荐)'),
subtitle: const Text('modrinth.mcimirror.top,无需科学上网'),
title: T('MCIM 国内镜像(推荐)'),
subtitle: T('modrinth.mcimirror.top,无需科学上网'),
value: 'mcim',
groupValue: mirror.currentId,
onChanged: (v) async {
@@ -39,8 +40,8 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
},
),
RadioListTile<String>(
title: const Text('Modrinth 官方'),
subtitle: const Text('直连官方源,适合海外网络'),
title: T('Modrinth 官方'),
subtitle: T('直连官方源,适合海外网络'),
value: 'official',
groupValue: mirror.currentId,
onChanged: (v) async {
@@ -49,7 +50,7 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
},
),
RadioListTile<String>(
title: const Text('自定义镜像'),
title: T('自定义镜像'),
subtitle: Text(mirror.currentId == 'custom' && mirror.customUrl.isNotEmpty
? mirror.customUrl
: '使用自建/第三方镜像地址'),
@@ -61,9 +62,9 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
leading: _testing
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.speed),
title: const Text('一键测速并选择最快线路'),
title: T('一键测速并选择最快线路'),
subtitle: Text(mirror.lastSpeedMs > 0
? '上次测速:${mirror.lastSpeedMs}ms(${mirror.currentName})'
? S.f('上次测速:{0}ms({1})', [mirror.lastSpeedMs, mirror.currentName])
: '自动在官方与镜像之间选择延迟最低的线路'),
onTap: _testing
? null
@@ -74,7 +75,7 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
if (!mounted) return;
setState(() => _testing = false);
messenger.showSnackBar(SnackBar(
content: Text('已选择最快线路:${mirror.currentName}(${mirror.lastSpeedMs}ms)'),
content: Text(S.f('已选择最快线路:{0}({1}ms)', [mirror.currentName, mirror.lastSpeedMs])),
));
},
),
@@ -82,8 +83,8 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
const SectionHeader('下载队列'),
ListTile(
leading: const Icon(Icons.playlist_play),
title: const Text('同时下载任务数'),
subtitle: Text('当前:${dp.concurrency} 个(越大越占带宽,建议 1-3)'),
title: T('同时下载任务数'),
subtitle: Text(S.f('当前:{0} 个(越大越占带宽,建议 1-3)', [dp.concurrency])),
trailing: DropdownButton<int>(
value: dp.concurrency,
underline: const SizedBox.shrink(),
@@ -117,14 +118,14 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
final url = await showDialog<String>(
context: context,
builder: (_) => AlertDialog(
title: const Text('自定义镜像地址'),
title: T('自定义镜像地址'),
content: TextField(
controller: ctrl,
decoration: const InputDecoration(hintText: 'https://your-mirror.example.com'),
decoration: InputDecoration(hintText: 'https://your-mirror.example.com'),
),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
FilledButton(onPressed: () => Navigator.pop(context, ctrl.text.trim()), child: const Text('确定')),
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
FilledButton(onPressed: () => Navigator.pop(context, ctrl.text.trim()), child: T('确定')),
],
),
);
+6 -6
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../core/l10n/strings.dart';
/// 使用教程页:教用户如何开启 RCON、SSH、使用模组管理/下载/终端等功能。
class HelpPage extends StatelessWidget {
@@ -7,7 +8,7 @@ class HelpPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('使用教程')),
appBar: AppBar(title: Text(S.t('使用教程'))),
body: ListView(
padding: const EdgeInsets.all(12),
children: const [
@@ -124,8 +125,7 @@ class _Intro extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(14),
child: Text(
'本页教您一步步开启并使用 ZV Manager 的各项功能。\n'
'首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。',
'''${S.t('本页教您一步步开启并使用 ZV Manager 的各项功能。')}\n${S.t('首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。')}''',
style: Theme.of(context).textTheme.bodyMedium,
),
),
@@ -153,7 +153,7 @@ class _TutorialCard extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 6),
child: ExpansionTile(
leading: Icon(icon),
title: Text(title, style: theme.textTheme.titleSmall),
title: Text(S.t(title), style: theme.textTheme.titleSmall),
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 14),
expandedCrossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -166,7 +166,7 @@ class _TutorialCard extends StatelessWidget {
style: TextStyle(
fontWeight: FontWeight.w600,
color: theme.colorScheme.primary)),
Expanded(child: Text(e.value)),
Expanded(child: Text(S.t(e.value))),
],
),
)),
@@ -184,7 +184,7 @@ class _TutorialCard extends StatelessWidget {
children: tips
.map((t) => Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Text(t, style: theme.textTheme.bodySmall),
child: Text(S.t(t), style: theme.textTheme.bodySmall),
))
.toList(),
),
+26 -25
View File
@@ -14,6 +14,7 @@ import '../../providers/wallpaper_provider.dart';
import 'help_page.dart';
import 'download_settings_page.dart';
import '../../providers/language_provider.dart';
import '../../core/l10n/strings.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@@ -65,7 +66,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (updateInfo == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('获取更新信息失败')),
SnackBar(content: T('获取更新信息失败')),
);
return;
}
@@ -75,7 +76,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (!mounted) return;
setState(() => _checkingUpdate = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('检查更新失败:$e')),
SnackBar(content: Text(S.f('检查更新失败:{0}', [e]))),
);
}
}
@@ -90,7 +91,7 @@ class _SettingsPageState extends State<SettingsPage> {
children: [
ListTile(
leading: const Icon(Icons.photo, color: Colors.blue),
title: const Text('选择图片'),
title: T('选择图片'),
onTap: () {
Navigator.pop(ctx);
_pickImage();
@@ -98,7 +99,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
ListTile(
leading: const Icon(Icons.videocam, color: Colors.green),
title: const Text('选择视频'),
title: T('选择视频'),
onTap: () {
Navigator.pop(ctx);
_pickVideo();
@@ -108,7 +109,7 @@ class _SettingsPageState extends State<SettingsPage> {
const Divider(),
ListTile(
leading: const Icon(Icons.delete, color: Colors.red),
title: const Text('清除背景', style: TextStyle(color: Colors.red)),
title: T('清除背景', style: TextStyle(color: Colors.red)),
onTap: () {
Navigator.pop(ctx);
_clearBackground();
@@ -145,7 +146,7 @@ class _SettingsPageState extends State<SettingsPage> {
final mode = await showDialog<LanguageMode>(
context: context,
builder: (_) => SimpleDialog(
title: const Text('语言 / Language'),
title: T('语言 / Language'),
children: [
for (final m in LanguageMode.values)
RadioListTile<LanguageMode>(
@@ -184,7 +185,7 @@ class _SettingsPageState extends State<SettingsPage> {
debugPrint('保存壁纸设置失败: $e');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('壁纸设置保存失败,请重试')),
SnackBar(content: T('壁纸设置保存失败,请重试')),
);
}
return false;
@@ -209,7 +210,7 @@ class _SettingsPageState extends State<SettingsPage> {
debugPrint('保存失败: $e');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('保存失败,请重试')),
SnackBar(content: T('保存失败,请重试')),
);
}
return null;
@@ -244,7 +245,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(_currentBgPath == null ? '已清除背景' : '背景已更新 '),
content: Text(_currentBgPath == null ? S.t('已清除背景') : S.t('背景已更新')),
duration: const Duration(seconds: 1),
),
);
@@ -258,13 +259,13 @@ class _SettingsPageState extends State<SettingsPage> {
final themeProvider = context.watch<ThemeProvider>();
return Scaffold(
appBar: AppBar(title: const Text('设置')),
appBar: AppBar(title: T('设置')),
body: ListView(
children: [
// ---------- 外观主题 ----------
ListTile(
leading: const Icon(Icons.palette_outlined),
title: const Text('外观主题'),
title: T('外观主题'),
trailing: SegmentedButton<AppThemeMode>(
segments: const [
ButtonSegment(value: AppThemeMode.light, icon: Icon(Icons.light_mode, size: 18)),
@@ -281,11 +282,11 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 应用背景(新增) ----------
ListTile(
leading: const Icon(Icons.wallpaper),
title: const Text('应用背景'),
title: T('应用背景'),
subtitle: Text(
_currentBgPath == null
? '未设置'
: '已设置 ${_currentBgType == 'video' ? ' 视频' : ' 图片'}',
: S.f('已设置 {0}', [_currentBgType == 'video' ? S.t('视频') : S.t('图片')]),
),
trailing: const Icon(Icons.arrow_forward_ios, size: 16),
onTap: _showBackgroundPicker,
@@ -294,8 +295,8 @@ class _SettingsPageState extends State<SettingsPage> {
if (_currentBgType == 'video') ...[
SwitchListTile(
secondary: const Icon(Icons.volume_up),
title: const Text('视频声音'),
subtitle: const Text('开启后背景视频将播放声音'),
title: T('视频声音'),
subtitle: T('开启后背景视频将播放声音'),
value: _videoSoundEnabled,
onChanged: (value) async {
await BackgroundService.setVideoSound(value);
@@ -310,7 +311,7 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 语言 ----------
ListTile(
leading: const Icon(Icons.language),
title: const Text('语言 / Language'),
title: T('语言 / Language'),
subtitle: Text(_languageName(context.watch<LanguageProvider>().mode)),
trailing: const Icon(Icons.chevron_right),
onTap: () => _pickLanguage(),
@@ -320,8 +321,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 下载与镜像 ----------
ListTile(
leading: const Icon(Icons.download_outlined),
title: const Text('下载与镜像设置'),
subtitle: const Text('镜像线路、测速选线、同时下载任务数'),
title: T('下载与镜像设置'),
subtitle: T('镜像线路、测速选线、同时下载任务数'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
@@ -333,8 +334,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 使用教程 ----------
ListTile(
leading: const Icon(Icons.menu_book_outlined),
title: const Text('使用教程'),
subtitle: const Text('如何开启 RCON / SSH、模组管理、下载与终端'),
title: T('使用教程'),
subtitle: T('如何开启 RCON / SSH、模组管理、下载与终端'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
@@ -346,8 +347,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 检查更新 ----------
ListTile(
leading: const Icon(Icons.system_update_outlined),
title: const Text('检查更新'),
subtitle: Text('当前版本: $_currentVersion'),
title: T('检查更新'),
subtitle: Text(S.f('当前版本: {0}', [_currentVersion])),
trailing: _checkingUpdate
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.chevron_right),
@@ -358,15 +359,15 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 关于 ----------
const ListTile(
leading: Icon(Icons.info_outline),
title: Text('关于'),
subtitle: Text('开发者:Z有3笔,协作者:venti1112'),
title: T('关于'),
subtitle: T('开发者:Z有3笔,协作者:venti1112'),
),
const Divider(),
// ---------- 开源许可 ----------
ListTile(
leading: const Icon(Icons.fact_check_outlined),
title: const Text('开源许可'),
title: T('开源许可'),
onTap: () => showLicensePage(context: context),
),
],
+18 -17
View File
@@ -4,6 +4,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import '../../providers/wallpaper_provider.dart';
import '../../core/l10n/strings.dart';
class WallpaperSettings extends StatelessWidget {
const WallpaperSettings({super.key});
@@ -15,7 +16,7 @@ class WallpaperSettings extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('壁纸设置'),
title: T('壁纸设置'),
backgroundColor: theme.colorScheme.primary,
foregroundColor: Colors.white,
),
@@ -42,8 +43,8 @@ class WallpaperSettings extends StatelessWidget {
children: [
Icon(Icons.wallpaper, size: 48, color: Colors.grey),
SizedBox(height: 8),
Text('当前为默认壁纸', style: TextStyle(color: Colors.grey)),
Text('点击下方「选择图片」自定义', style: TextStyle(color: Colors.grey, fontSize: 12)),
T('当前为默认壁纸', style: TextStyle(color: Colors.grey)),
T('点击下方「选择图片」自定义', style: TextStyle(color: Colors.grey, fontSize: 12)),
],
),
)
@@ -53,7 +54,7 @@ class WallpaperSettings extends StatelessWidget {
children: [
Icon(Icons.check_circle, size: 48, color: Colors.white),
SizedBox(height: 8),
Text('自定义壁纸已应用', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
T('自定义壁纸已应用', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
],
),
),
@@ -61,9 +62,9 @@ class WallpaperSettings extends StatelessWidget {
const SizedBox(height: 24),
// 选择图片
const Text('选择壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
T('选择壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
const SizedBox(height: 4),
const Text('从相册选择图片作为应用背景', style: TextStyle(fontSize: 12, color: Colors.grey)),
T('从相册选择图片作为应用背景', style: TextStyle(fontSize: 12, color: Colors.grey)),
const SizedBox(height: 12),
FilledButton.icon(
onPressed: () async {
@@ -77,14 +78,14 @@ class WallpaperSettings extends StatelessWidget {
await provider.setCustomWallpaper(savedPath);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('壁纸已更新'), backgroundColor: Colors.green),
const SnackBar(content: T('壁纸已更新'), backgroundColor: Colors.green),
);
}
}
}
},
icon: const Icon(Icons.photo_library),
label: const Text('选择图片'),
label: T('选择图片'),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
@@ -93,16 +94,16 @@ class WallpaperSettings extends StatelessWidget {
const SizedBox(height: 24),
// 重置
const Text('重置壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
T('重置壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
const SizedBox(height: 4),
const Text('恢复默认壁纸', style: TextStyle(fontSize: 12, color: Colors.grey)),
T('恢复默认壁纸', style: TextStyle(fontSize: 12, color: Colors.grey)),
const SizedBox(height: 12),
OutlinedButton.icon(
onPressed: () {
_showResetDialog(context, provider);
},
icon: const Icon(Icons.restore),
label: const Text('恢复默认'),
label: T('恢复默认'),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
side: const BorderSide(color: Colors.red),
@@ -131,7 +132,7 @@ class WallpaperSettings extends StatelessWidget {
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('保存失败,请重试')),
const SnackBar(content: T('保存失败,请重试')),
);
}
return null;
@@ -159,12 +160,12 @@ class WallpaperSettings extends StatelessWidget {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('确认重置'),
content: const Text('确定要恢复默认壁纸吗?'),
title: T('确认重置'),
content: T('确定要恢复默认壁纸吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消'),
child: T('取消'),
),
FilledButton(
onPressed: () async {
@@ -172,12 +173,12 @@ class WallpaperSettings extends StatelessWidget {
if (context.mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('已恢复默认壁纸'), backgroundColor: Colors.green),
const SnackBar(content: T('已恢复默认壁纸'), backgroundColor: Colors.green),
);
}
},
style: FilledButton.styleFrom(backgroundColor: Colors.red),
child: const Text('重置'),
child: T('重置'),
),
],
),
+10 -9
View File
@@ -11,6 +11,7 @@ import '../mod_manager/mod_list_page.dart';
import '../player_management/player_list_page.dart';
import '../settings/settings_page.dart';
import '../terminal/terminal_page.dart';
import '../../core/l10n/strings.dart';
/// 主导航壳:底部导航「服务器 · 控制台 · 玩家 · 模组 · 终端 · 我的」(M4)。
class MainShell extends StatefulWidget {
@@ -111,23 +112,23 @@ class _ConsoleTab extends StatelessWidget {
final rcon = context.read<RconProvider>();
final server = holder.server;
if (server == null) {
return const _TabScaffold(title: '控制台', child: _NeedServerHint());
return _TabScaffold(title: S.t('控制台'), child: const _NeedServerHint());
}
return FutureBuilder<RconClient>(
future: rcon.getClient(server),
builder: (context, snap) {
if (snap.connectionState != ConnectionState.done) {
return _TabScaffold(
title: '控制台',
title: S.t('控制台'),
subtitle: server.name,
child: const Center(child: CircularProgressIndicator()),
);
}
if (snap.hasError) {
return _TabScaffold(
title: '控制台',
title: S.t('控制台'),
subtitle: server.name,
child: Center(child: Text('RCON 连接失败:${snap.error}')),
child: Center(child: Text(S.f('RCON 连接失败:{0}', [snap.error.toString()]))),
);
}
return ConsolePage(rconClient: snap.data!); // 自带 AppBar
@@ -146,23 +147,23 @@ class _PlayerTab extends StatelessWidget {
final rcon = context.read<RconProvider>();
final server = holder.server;
if (server == null) {
return const _TabScaffold(title: '玩家', child: _NeedServerHint());
return _TabScaffold(title: S.t('玩家'), child: const _NeedServerHint());
}
return FutureBuilder<RconClient>(
future: rcon.getClient(server),
builder: (context, snap) {
if (snap.connectionState != ConnectionState.done) {
return _TabScaffold(
title: '玩家',
title: S.t('玩家'),
subtitle: server.name,
child: const Center(child: CircularProgressIndicator()),
);
}
if (snap.hasError) {
return _TabScaffold(
title: '玩家',
title: S.t('玩家'),
subtitle: server.name,
child: Center(child: Text('RCON 连接失败:${snap.error}')),
child: Center(child: Text(S.f('RCON 连接失败:{0}', [snap.error.toString()]))),
);
}
return PlayerListPage(rconClient: snap.data!); // 自带 AppBar
@@ -176,6 +177,6 @@ class _NeedServerHint extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Center(child: Text('请先在「服务器」页选择一台服务器'));
return const Center(child: T('请先在「服务器」页选择一台服务器'));
}
}
+5 -4
View File
@@ -6,6 +6,7 @@ import 'package:xterm/ui.dart' show TerminalView;
import '../../core/services/ssh_shell_service.dart';
import '../../providers/server_provider.dart';
import '../../core/l10n/strings.dart';
/// SSH 终端页:xterm 终端 + 快捷键栏 + 多服务器会话标签(M3)。
@@ -83,7 +84,7 @@ class _TerminalPageState extends State<TerminalPage>
return const Center(
child: Padding(
padding: EdgeInsets.all(24),
child: Text('没有配置 SSH 的服务器。\n\n请在「服务器」页编辑服务器,开启 SSH 后即可使用终端。',
child: T('没有配置 SSH 的服务器。\n\n请在「服务器」页编辑服务器,开启 SSH 后即可使用终端。',
textAlign: TextAlign.center),
),
);
@@ -93,11 +94,11 @@ class _TerminalPageState extends State<TerminalPage>
return Scaffold(
backgroundColor: hasWallpaper ? Colors.transparent : null,
appBar: AppBar(
title: const Text('终端'),
title: T('终端'),
actions: [
PopupMenuButton<ServerConfig>(
icon: const Icon(Icons.add),
tooltip: '新会话',
tooltip: S.t('新会话'),
onSelected: _openSession,
itemBuilder: (_) => _sshServers
.map((s) => PopupMenuItem(value: s, child: Text(s.name)))
@@ -128,7 +129,7 @@ class _TerminalPageState extends State<TerminalPage>
),
),
body: active == null
? const Center(child: Text('选择一台服务器开始会话'))
? const Center(child: T('选择一台服务器开始会话'))
: Column(
children: [
Expanded(