api修改和更新检查器修改
modrinth_api.dart:拦截器改为只替换 options.baseUrl,path 保持相对 /v2/search、query 留在 queryParameters,避免"整串写回 path"导致的 host 缺失 + query 重复拼接。mirror_service.dart:新增 apiBase getter,返回当前镜像的 API base(official→api.modrinth.com、mcim→modrinth-api.mcimirror.top、custom→自定义 base) Signed-off-by: driftinblock <3480428251@qq.com>
This commit is contained in:
35 files changed
+4171
-1325
No files matched your search
@@ -1,9 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/l10n/strings.dart';
|
||||
import '../../core/utils/update_service.dart';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
|
||||
/// 关于软件页:版本与检查更新 + 开发者信息 + 开源许可。
|
||||
///
|
||||
/// 版式:顶部 Logo 区 → 「应用」面板(检查更新 / 开源许可)→
|
||||
/// 「创造者」面板(头像行)→ 底部免责说明。
|
||||
class AboutPage extends StatefulWidget {
|
||||
const AboutPage({super.key});
|
||||
|
||||
@@ -55,68 +62,70 @@ class _AboutPageState extends State<AboutPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final st = ZStyle.of(context, hasWallpaper: hasWallpaper);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: T('关于软件')),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
appBar: ZAppBar(
|
||||
title: T('关于软件'),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
|
||||
children: [
|
||||
const SizedBox(height: 24),
|
||||
Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Image.asset('assets/logo.png', width: 96, height: 96),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
T('ZV Manager', style: Theme.of(context).textTheme.titleLarge),
|
||||
Text(S.f('版本 {0}', [_currentVersion]),
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.system_update_outlined),
|
||||
title: T('检查更新'),
|
||||
trailing: _checkingUpdate
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: const Icon(Icons.chevron_right),
|
||||
onTap: _checkingUpdate ? null : _checkUpdate,
|
||||
),
|
||||
const Divider(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||
child: T('创造者', style: Theme.of(context).textTheme.titleSmall),
|
||||
),
|
||||
const _CreatorTile(
|
||||
name: 'Z有3笔',
|
||||
role: '开发者 · Gitee: DriftinBlock',
|
||||
assetAvatar: 'assets/creator_zavatar.png',
|
||||
homeUrl: 'https://gitee.com/driftinblock',
|
||||
),
|
||||
_CreatorTile(
|
||||
name: 'Ventiの酒',
|
||||
role: S.t('协作者 · Gitee: venti1112'),
|
||||
avatarUrl: 'https://gitee.com/venti1112.png',
|
||||
homeUrl: 'https://gitee.com/venti1112',
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.fact_check_outlined),
|
||||
title: T('开源许可'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => showLicensePage(context: context),
|
||||
),
|
||||
const Divider(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
S.t('ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。'),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
textAlign: TextAlign.center,
|
||||
_Header(version: _currentVersion, style: st),
|
||||
const SizedBox(height: 20),
|
||||
ZPanel(style: st, children: [
|
||||
ZRow(
|
||||
title: '检查更新',
|
||||
subtitle: '从 Gitee 获取最新版本',
|
||||
style: st,
|
||||
leading: Icon(Icons.system_update_outlined,
|
||||
size: 20, color: st.subColor),
|
||||
trailing: _checkingUpdate
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: null,
|
||||
onTap: _checkingUpdate ? null : _checkUpdate,
|
||||
),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '开源许可',
|
||||
subtitle: '查看本应用使用的第三方库许可',
|
||||
style: st,
|
||||
leading: Icon(Icons.fact_check_outlined,
|
||||
size: 20, color: st.subColor),
|
||||
onTap: () => showLicensePage(context: context),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 14),
|
||||
_SectionLabel('创造者', style: st),
|
||||
ZPanel(style: st, children: [
|
||||
_CreatorRow(
|
||||
style: st,
|
||||
name: 'Z有3笔',
|
||||
role: S.t('开发者 · Gitee: DriftinBlock'),
|
||||
assetAvatar: 'assets/creator_zavatar.png',
|
||||
homeUrl: 'https://gitee.com/driftinblock',
|
||||
),
|
||||
ZDivider(style: st),
|
||||
_CreatorRow(
|
||||
style: st,
|
||||
name: 'Ventiの酒',
|
||||
role: S.t('协作者 · Gitee: venti1112'),
|
||||
avatarUrl: 'https://gitee.com/venti1112.png',
|
||||
homeUrl: 'https://gitee.com/venti1112',
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 22),
|
||||
Text(
|
||||
S.t('ZV Manager 是一款 Minecraft 服务器远程管理工具,'
|
||||
'本软件与 Mojang、微软无任何隶属关系。'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 12, height: 1.6, color: st.subColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -124,8 +133,65 @@ class _AboutPageState extends State<AboutPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 创造者条目:头像 + 名称 + 角色,点击打开 Gitee 主页。
|
||||
class _CreatorTile extends StatelessWidget {
|
||||
/// 顶部品牌区:Logo + 名称 + 版本号。
|
||||
class _Header extends StatelessWidget {
|
||||
final String version;
|
||||
final ZStyle style;
|
||||
const _Header({required this.version, required this.style});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
child: Image.asset('assets/logo.png', width: 88, height: 88),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'ZV Manager',
|
||||
style: TextStyle(
|
||||
fontSize: 19,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: style.titleColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
S.f('版本 {0}', [version]),
|
||||
style: TextStyle(fontSize: 12.5, color: style.subColor),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 分组小标题(面板外的灰色小字)。
|
||||
class _SectionLabel extends StatelessWidget {
|
||||
final String text;
|
||||
final ZStyle style;
|
||||
const _SectionLabel(this.text, {required this.style});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 8),
|
||||
child: Text(
|
||||
S.t(text),
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.2,
|
||||
color: style.subColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 创造者行:头像 + 名称 + 角色,点击打开 Gitee 主页。
|
||||
class _CreatorRow extends StatelessWidget {
|
||||
final ZStyle style;
|
||||
final String name;
|
||||
final String role;
|
||||
final String homeUrl;
|
||||
@@ -134,7 +200,8 @@ class _CreatorTile extends StatelessWidget {
|
||||
final String? assetAvatar;
|
||||
final String? avatarUrl;
|
||||
|
||||
const _CreatorTile({
|
||||
const _CreatorRow({
|
||||
required this.style,
|
||||
required this.name,
|
||||
required this.role,
|
||||
required this.homeUrl,
|
||||
@@ -144,24 +211,27 @@ class _CreatorTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
return ZRow(
|
||||
style: style,
|
||||
title: name,
|
||||
subtitle: role,
|
||||
leading: ClipOval(
|
||||
child: SizedBox(
|
||||
width: 44,
|
||||
height: 44,
|
||||
width: 38,
|
||||
height: 38,
|
||||
child: assetAvatar != null
|
||||
? Image.asset(assetAvatar!, fit: BoxFit.cover)
|
||||
: Image.network(
|
||||
avatarUrl!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => const ColoredBox(
|
||||
color: Color(0xFFDDDDDD), child: Icon(Icons.person)),
|
||||
errorBuilder: (_, __, ___) => ColoredBox(
|
||||
color: style.scheme.surfaceContainerHighest,
|
||||
child: Icon(Icons.person,
|
||||
size: 20, color: style.scheme.onSurfaceVariant),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(name),
|
||||
subtitle: Text(role, overflow: TextOverflow.ellipsis),
|
||||
trailing: const Icon(Icons.open_in_new, size: 18),
|
||||
onTap: () => UpdateService.openUrl(homeUrl),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../providers/download_provider.dart';
|
||||
|
||||
import '../../core/l10n/strings.dart';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
import '../../providers/download_provider.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
|
||||
/// 下载与镜像设置页:镜像线路选择、测速自动选线、并发数(原下载页内设置移入此处)。
|
||||
///
|
||||
/// 版式:两组 ZL2 圆角面板。镜像线路用尾部圆形勾选钮表达单选,
|
||||
/// 比 RadioListTile 更紧凑,也与其他设置页的选中态语言一致。
|
||||
class DownloadSettingsPage extends StatefulWidget {
|
||||
const DownloadSettingsPage({super.key});
|
||||
|
||||
@@ -24,87 +30,102 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final dp = context.watch<DownloadProvider>();
|
||||
final mirror = dp.mirror;
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final st = ZStyle.of(context, hasWallpaper: hasWallpaper);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: T('下载与镜像设置')),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
appBar: ZAppBar(
|
||||
title: T('下载与镜像设置'),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 28),
|
||||
children: [
|
||||
const SectionHeader('镜像线路'),
|
||||
RadioListTile<String>(
|
||||
title: T('MCIM 国内镜像(推荐)'),
|
||||
subtitle: T('modrinth.mcimirror.top,无需科学上网'),
|
||||
value: 'mcim',
|
||||
groupValue: mirror.currentId,
|
||||
onChanged: (v) async {
|
||||
await mirror.select(v!);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
RadioListTile<String>(
|
||||
title: T('Modrinth 官方'),
|
||||
subtitle: T('直连官方源,适合海外网络'),
|
||||
value: 'official',
|
||||
groupValue: mirror.currentId,
|
||||
onChanged: (v) async {
|
||||
await mirror.select(v!);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
RadioListTile<String>(
|
||||
title: T('自定义镜像'),
|
||||
subtitle: Text(mirror.currentId == 'custom' && mirror.customUrl.isNotEmpty
|
||||
? mirror.customUrl
|
||||
: '使用自建/第三方镜像地址'),
|
||||
value: 'custom',
|
||||
groupValue: mirror.currentId,
|
||||
onChanged: (v) async => {await _editCustomUrl(), setState(() {})},
|
||||
),
|
||||
ListTile(
|
||||
leading: _testing
|
||||
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: const Icon(Icons.speed),
|
||||
title: T('一键测速并选择最快线路'),
|
||||
subtitle: Text(mirror.lastSpeedMs > 0
|
||||
? S.f('上次测速:{0}ms({1})', [mirror.lastSpeedMs, mirror.currentName])
|
||||
: '自动在官方与镜像之间选择延迟最低的线路'),
|
||||
onTap: _testing
|
||||
? null
|
||||
: () async {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
setState(() => _testing = true);
|
||||
await mirror.autoSelect();
|
||||
if (!mounted) return;
|
||||
setState(() => _testing = false);
|
||||
messenger.showSnackBar(SnackBar(
|
||||
content: Text(S.f('已选择最快线路:{0}({1}ms)', [mirror.currentName, mirror.lastSpeedMs])),
|
||||
));
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
const SectionHeader('下载队列'),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.playlist_play),
|
||||
title: T('同时下载任务数'),
|
||||
subtitle: Text(S.f('当前:{0} 个(越大越占带宽,建议 1-3)', [dp.concurrency])),
|
||||
trailing: DropdownButton<int>(
|
||||
value: dp.concurrency,
|
||||
underline: const SizedBox.shrink(),
|
||||
items: const [1, 2, 3, 4, 5, 6]
|
||||
.map((n) => DropdownMenuItem(value: n, child: Text('$n')))
|
||||
.toList(),
|
||||
onChanged: (n) async {
|
||||
if (n == null) return;
|
||||
await dp.setConcurrency(n);
|
||||
// ---------- 镜像线路 ----------
|
||||
ZPanel(style: st, children: [
|
||||
_MirrorRow(
|
||||
style: st,
|
||||
title: 'MCIM 国内镜像(推荐)',
|
||||
subtitle: 'mod.mcimirror.top,无需科学上网',
|
||||
selected: mirror.currentId == 'mcim',
|
||||
onTap: () async {
|
||||
await mirror.select('mcim');
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
ZDivider(style: st),
|
||||
_MirrorRow(
|
||||
style: st,
|
||||
title: 'Modrinth 官方',
|
||||
subtitle: '直连官方源,适合海外网络',
|
||||
selected: mirror.currentId == 'official',
|
||||
onTap: () async {
|
||||
await mirror.select('official');
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
ZDivider(style: st),
|
||||
_MirrorRow(
|
||||
style: st,
|
||||
title: '自定义镜像',
|
||||
subtitle: mirror.currentId == 'custom' && mirror.customUrl.isNotEmpty
|
||||
? mirror.customUrl
|
||||
: '使用自建/第三方镜像地址',
|
||||
selected: mirror.currentId == 'custom',
|
||||
onTap: () async {
|
||||
await _editCustomUrl();
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '一键测速并选择最快线路',
|
||||
subtitle: mirror.lastSpeedMs > 0
|
||||
? S.f('上次测速:{0}ms({1})',
|
||||
[mirror.lastSpeedMs, mirror.currentName])
|
||||
: '自动在官方与镜像之间选择延迟最低的线路',
|
||||
style: st,
|
||||
leading: Icon(Icons.speed, size: 20, color: st.subColor),
|
||||
trailing: _testing
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: null,
|
||||
onTap: _testing ? null : _autoSelect,
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 14),
|
||||
// ---------- 下载队列 ----------
|
||||
ZPanel(style: st, children: [
|
||||
ZRow(
|
||||
title: '同时下载任务数',
|
||||
subtitle: S.f('当前:{0} 个(越大越占带宽,建议 1-3)', [dp.concurrency]),
|
||||
style: st,
|
||||
leading: Icon(Icons.playlist_play, size: 20, color: st.subColor),
|
||||
trailing: DropdownButton<int>(
|
||||
value: dp.concurrency,
|
||||
underline: const SizedBox.shrink(),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
items: const [1, 2, 3, 4, 5, 6]
|
||||
.map((n) => DropdownMenuItem(value: n, child: Text('$n')))
|
||||
.toList(),
|
||||
onChanged: (n) async {
|
||||
if (n == null) return;
|
||||
await dp.setConcurrency(n);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Text(
|
||||
'说明:下载完成的文件保存在应用目录 downloads/ 下;'
|
||||
'若服务器配置了 SSH,会自动上传到对应服务器的 mods/plugins 目录。',
|
||||
style: TextStyle(fontSize: 13),
|
||||
S.t('说明:下载完成的文件保存在应用目录 downloads/ 下;'
|
||||
'若服务器配置了 SSH,会自动上传到对应服务器的 mods/plugins 目录。'),
|
||||
style: TextStyle(fontSize: 12, height: 1.6, color: st.subColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -112,6 +133,21 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 测速并自动选线:过程中禁用点击,完成后用 SnackBar 告知结果。
|
||||
Future<void> _autoSelect() async {
|
||||
final dp = context.read<DownloadProvider>();
|
||||
final mirror = dp.mirror;
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
setState(() => _testing = true);
|
||||
await mirror.autoSelect();
|
||||
if (!mounted) return;
|
||||
setState(() => _testing = false);
|
||||
messenger.showSnackBar(SnackBar(
|
||||
content: Text(S.f('已选择最快线路:{0}({1}ms)',
|
||||
[mirror.currentName, mirror.lastSpeedMs])),
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _editCustomUrl() async {
|
||||
final dp = context.read<DownloadProvider>();
|
||||
final ctrl = TextEditingController(text: dp.mirror.customUrl);
|
||||
@@ -125,7 +161,9 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
|
||||
FilledButton(onPressed: () => Navigator.pop(context, ctrl.text.trim()), child: T('确定')),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, ctrl.text.trim()),
|
||||
child: T('确定')),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -135,19 +173,36 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
class SectionHeader extends StatelessWidget {
|
||||
final String text;
|
||||
const SectionHeader(this.text, {super.key});
|
||||
/// 镜像线路单选行:右侧用圆形勾选钮表示当前生效线路。
|
||||
class _MirrorRow extends StatelessWidget {
|
||||
final ZStyle style;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final bool selected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _MirrorRow({
|
||||
required this.style,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 6),
|
||||
child: Text(text,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall
|
||||
?.copyWith(color: Theme.of(context).colorScheme.primary)),
|
||||
return ZRow(
|
||||
style: style,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
onTap: onTap,
|
||||
trailing: ZToggle(
|
||||
value: selected,
|
||||
size: 30,
|
||||
borderColor: style.subColor,
|
||||
// 单选:只允许从未选变选中,再点已选项不做取消
|
||||
onChanged: (_) => onTap(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/l10n/strings.dart';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
|
||||
/// 使用教程页:教用户如何开启 RCON、SSH、使用模组管理/下载/终端等功能。
|
||||
///
|
||||
/// 版式:顶部一段说明块 + 每组教程一个 ZL2 圆角面板(标题行可展开正文)。
|
||||
/// 展开后步骤按序号排列,末尾的「提示」用浅色说明块与步骤区分开。
|
||||
class HelpPage extends StatelessWidget {
|
||||
const HelpPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final st = ZStyle.of(context, hasWallpaper: hasWallpaper);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(S.t('使用教程'))),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
appBar: ZAppBar(
|
||||
title: T('使用教程'),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
children: const [
|
||||
_Intro(),
|
||||
_TutorialCard(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 28),
|
||||
children: [
|
||||
_Intro(style: st),
|
||||
const SizedBox(height: 14),
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.settings_ethernet,
|
||||
title: '一、如何开启 RCON(必配,控制台/玩家管理需要)',
|
||||
steps: [
|
||||
steps: const [
|
||||
'在服务器目录找到 server.properties 文件(与启动 jar 同目录)',
|
||||
'修改/添加以下三行:',
|
||||
' enable-rcon=true',
|
||||
@@ -25,74 +41,79 @@ class HelpPage extends StatelessWidget {
|
||||
'保存后重启服务器生效',
|
||||
'回到 ZV Manager:服务器页 → 添加/编辑服务器,填入主机地址、端口(默认 25575)和 RCON 密码',
|
||||
],
|
||||
tips: [
|
||||
tips: const [
|
||||
'云服务器/虚拟主机需在防火墙或安全组放行 rcon.port 端口',
|
||||
'不建议把 25575 端口直接暴露公网,强烈建议设置强密码',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.vpn_key,
|
||||
title: '二、如何开启 SSH(模组管理 / 终端 / 下载自动上传需要)',
|
||||
steps: [
|
||||
steps: const [
|
||||
'SSH 是服务器自带的远程管理服务,绝大多数独立服务器默认已开启(端口 22)',
|
||||
'不确定的话:用电脑终端执行 ssh 用户名@服务器IP 试试能否登录',
|
||||
'拿到 SSH 用户名(如 root)和密码',
|
||||
'ZV Manager:服务器页 → 编辑服务器 → 打开「SSH 连接」开关 → 填端口(默认 22)、用户名、密码 → 保存',
|
||||
],
|
||||
tips: [
|
||||
tips: const [
|
||||
'部分面板服 / 虚拟主机只提供网页面板,不提供 SSH,此时模组和终端功能不可用(入口会提示)',
|
||||
'有的托管商需要先在控制台开启 SSH/SFTP 功能',
|
||||
'SSH 拥有服务器完全控制权,请勿随意执行不熟悉的命令',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.extension,
|
||||
title: '三、模组 / 插件管理怎么用',
|
||||
steps: [
|
||||
steps: const [
|
||||
'前提:该服务器已配置 SSH',
|
||||
'进入「模组」页签,顶部切换 mods(模组)/ plugins(插件)目录',
|
||||
'点「上传 jar」从手机选择文件上传;长按/点菜单可删除、重命名',
|
||||
'点击文件名可查看详情:模组名、版本、作者、依赖',
|
||||
'上传后需重启服务器才会加载新模组(可在终端执行,或控制台发 stop 后重开)',
|
||||
],
|
||||
tips: [
|
||||
tips: const [
|
||||
'Fabric 模组放 mods 目录;Paper/Spigot 插件放 plugins 目录',
|
||||
'版本要和 MC 版本、加载器匹配,否则服务器起不来',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.download,
|
||||
title: '四、下载中心与镜像加速',
|
||||
steps: [
|
||||
steps: const [
|
||||
'进入「服务器」页 → 下载中心(或首页快捷入口)',
|
||||
'输入关键词搜索 Modrinth 上的模组/插件,可用 MC 版本、加载器筛选',
|
||||
'点结果选版本即可加入下载队列,支持暂停/继续/取消',
|
||||
'下载完成且配置了 SSH 时,会自动上传到服务器的 mods/plugins 目录',
|
||||
],
|
||||
tips: [
|
||||
tips: const [
|
||||
'国内网络慢时:点右上角测速图标 →「一键测速并选择最快线路」,或改用自定义镜像地址',
|
||||
'默认使用 MCIM 国内镜像,无需科学上网',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.terminal,
|
||||
title: '五、远程终端',
|
||||
steps: [
|
||||
steps: const [
|
||||
'前提:该服务器已配置 SSH',
|
||||
'进入「终端」页签,点右上角 + 新建会话并选择服务器',
|
||||
'等同于电脑上的 SSH 终端,可以执行任意命令',
|
||||
'底部快捷键栏:Tab 补全、Ctrl+C 中断、Ctrl+D 退出、↑↓ 调历史,以及 htop / df -h / screen -r 常用命令',
|
||||
'screen -r 可以进入服务器控制台会话(开服时用了 screen 的话)',
|
||||
],
|
||||
tips: [
|
||||
tips: const [
|
||||
'断网会自动重连(最多 3 次)',
|
||||
'命令历史只保存在手机本地,可放心使用',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.account_tree,
|
||||
title: '六、依赖仓库(查询模组依赖)',
|
||||
steps: [
|
||||
steps: const [
|
||||
'进入「模组」页签 → 右上角依赖仓库',
|
||||
'点「同步」扫描服务器 mods/plugins,建立本地依赖索引',
|
||||
'点击任意模组查看:它依赖什么、被谁依赖、缺失哪些依赖',
|
||||
@@ -100,10 +121,11 @@ class HelpPage extends StatelessWidget {
|
||||
'点右上角重复检测按钮重复安装 / 版本冲突的 jar',
|
||||
],
|
||||
),
|
||||
_TutorialCard(
|
||||
_TutorialPanel(
|
||||
style: st,
|
||||
icon: Icons.help_outline,
|
||||
title: '七、常见问题',
|
||||
steps: [
|
||||
steps: const [
|
||||
'Q:连接失败?→ 检查防火墙是否放行端口、地址端口是否填对、服务器是否在线',
|
||||
'Q:控制台能连但模组页提示无 SSH?→ 编辑服务器开启 SSH 并填好账号密码',
|
||||
'Q:TPS 显示 —?→ 原版服务端不支持 tps 命令,Paper/Purpur 等服务端才支持',
|
||||
@@ -116,30 +138,40 @@ class HelpPage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 顶部说明块。
|
||||
class _Intro extends StatelessWidget {
|
||||
const _Intro();
|
||||
final ZStyle style;
|
||||
const _Intro({required this.style});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
return ZPanel(style: style, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
'''${S.t('本页教您一步步开启并使用 ZV Manager 的各项功能。')}\n${S.t('首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。')}''',
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
'${S.t('本页教您一步步开启并使用 ZV Manager 的各项功能。')}\n'
|
||||
'${S.t('首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。')}',
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
height: 1.6,
|
||||
color: style.hasWallpaper ? Colors.white : style.scheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class _TutorialCard extends StatelessWidget {
|
||||
/// 单组教程:标题行(图标 + 粗标题 + 序号说明)+ 可展开的正文。
|
||||
class _TutorialPanel extends StatelessWidget {
|
||||
final ZStyle style;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final List<String> steps;
|
||||
final List<String> tips;
|
||||
|
||||
const _TutorialCard({
|
||||
const _TutorialPanel({
|
||||
required this.style,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.steps,
|
||||
@@ -148,49 +180,109 @@ class _TutorialCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: ExpansionTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(S.t(title), style: theme.textTheme.titleSmall),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 14),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...steps.asMap().entries.map((e) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('${e.key + 1}. ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.primary)),
|
||||
Expanded(child: Text(S.t(e.value))),
|
||||
],
|
||||
),
|
||||
)),
|
||||
if (tips.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final textColor =
|
||||
style.hasWallpaper ? Colors.white.withOpacity(0.92) : scheme.onSurface;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Theme(
|
||||
// 去掉 ExpansionTile 展开时的默认高亮背景,保持面板底色一致
|
||||
data: Theme.of(context).copyWith(
|
||||
dividerColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
),
|
||||
child: ZPanel(style: style, children: [
|
||||
ExpansionTile(
|
||||
tilePadding: const EdgeInsets.fromLTRB(16, 4, 12, 4),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
||||
iconColor: style.subColor,
|
||||
collapsedIconColor: style.subColor,
|
||||
leading: Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.secondaryContainer.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: kZAccent.withOpacity(0.16),
|
||||
borderRadius: BorderRadius.circular(11),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: tips
|
||||
.map((t) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Text(S.t(t), style: theme.textTheme.bodySmall),
|
||||
))
|
||||
.toList(),
|
||||
child: Icon(icon, size: 19, color: kZAccent),
|
||||
),
|
||||
title: Text(
|
||||
S.t(title),
|
||||
style: TextStyle(
|
||||
fontSize: 14.5,
|
||||
height: 1.35,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: style.titleColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
children: [
|
||||
...steps.asMap().entries.map((e) {
|
||||
final raw = S.t(e.value);
|
||||
// 以空格开头的行是配置片段(如 " enable-rcon=true"),用等宽字体
|
||||
final isCode = e.value.startsWith(' ');
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 7),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${e.key + 1}.',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kZAccent,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
isCode ? raw.trim() : raw,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.5,
|
||||
color: textColor,
|
||||
fontFamily: isCode ? 'monospace' : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
if (tips.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: kZAccent.withOpacity(0.10),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: tips
|
||||
.map((t) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Text(
|
||||
S.t(t),
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
height: 1.5,
|
||||
color: style.subColor,
|
||||
),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:provider/provider.dart';
|
||||
import '../../core/services/sftp_service.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
import '../../providers/server_provider.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
import '../dashboard/server_picker_bar.dart';
|
||||
|
||||
/// 服务器日志页(设置内入口):通过 SFTP 读取服务器 logs 目录,
|
||||
@@ -157,108 +159,163 @@ class _ServerLogPageState extends State<ServerLogPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final servers = context.watch<ServerProvider>().servers;
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final st = ZStyle.of(context, hasWallpaper: hasWallpaper);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: T('服务器日志')),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
appBar: ZAppBar(
|
||||
title: T('服务器日志'),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// ---------- 顶部:服务器 + 路径 + 自动刷新 ----------
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: DropdownButtonFormField<ServerConfig>(
|
||||
value: _server != null && servers.any((s) => s.id == _server!.id)
|
||||
? _server
|
||||
: null,
|
||||
decoration: InputDecoration(
|
||||
labelText: S.t('选择服务器(需开启 SSH)'),
|
||||
border: const OutlineInputBorder(),
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
|
||||
child: ZPanel(style: st, children: [
|
||||
ZRow(
|
||||
title: '服务器',
|
||||
subtitle: _server == null
|
||||
? S.t('请选择一台已配置 SSH 的服务器')
|
||||
: '${_server!.name} · ${_server!.sshUser}@${_server!.host}',
|
||||
style: st,
|
||||
leading: Icon(Icons.dns_outlined, size: 20, color: st.subColor),
|
||||
trailing: DropdownButton<String>(
|
||||
value: _server != null && servers.any((s) => s.id == _server!.id)
|
||||
? _server!.id
|
||||
: null,
|
||||
underline: const SizedBox.shrink(),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
hint: T('选择'),
|
||||
items: servers
|
||||
.map((s) => DropdownMenuItem(
|
||||
value: s.id,
|
||||
child: SizedBox(
|
||||
width: 110,
|
||||
child: Text(s.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.right),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (id) {
|
||||
final s = servers.where((e) => e.id == id).firstOrNull;
|
||||
setState(() {
|
||||
_server = s;
|
||||
_files = [];
|
||||
_error = null;
|
||||
_pathCtrl.text = _defaultLogsDir(s);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
items: servers
|
||||
.map((s) => DropdownMenuItem(value: s, child: Text(s.name)))
|
||||
.toList(),
|
||||
onChanged: (s) {
|
||||
setState(() {
|
||||
_server = s;
|
||||
_files = [];
|
||||
_error = null;
|
||||
_pathCtrl.text = _defaultLogsDir(s);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '日志目录',
|
||||
subtitle: '默认按 SSH 用户推导,可手动修改',
|
||||
style: st,
|
||||
leading: Icon(Icons.folder_outlined, size: 20, color: st.subColor),
|
||||
trailing: SizedBox(
|
||||
width: 150,
|
||||
child: TextField(
|
||||
controller: _pathCtrl,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
labelText: S.t('日志目录路径'),
|
||||
hintText: S.t('例如 /root/logs'),
|
||||
border: const OutlineInputBorder(),
|
||||
hintStyle: TextStyle(fontSize: 12, color: st.subColor),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton.filled(
|
||||
onPressed: _loading ? null : _refresh,
|
||||
tooltip: S.t('刷新'),
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '自动刷新',
|
||||
subtitle: '每 5 秒重新读取目录列表',
|
||||
style: st,
|
||||
leading: Icon(Icons.autorenew, size: 20, color: st.subColor),
|
||||
trailing: ZToggle(
|
||||
value: _autoRefresh,
|
||||
size: 40,
|
||||
borderColor: st.subColor,
|
||||
onChanged: _toggleAuto,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
SwitchListTile(
|
||||
title: T('自动刷新(每 5 秒)'),
|
||||
value: _autoRefresh,
|
||||
onChanged: _toggleAuto,
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(child: _buildList()),
|
||||
// ---------- 文件列表 ----------
|
||||
Expanded(child: _buildList(st)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildList() {
|
||||
/// 日志文件列表:整块一个圆角面板,文件行之间用细线分隔。
|
||||
Widget _buildList(ZStyle st) {
|
||||
if (_loading && _files.isEmpty) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (_error != null) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
padding: const EdgeInsets.all(28),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(_error!, textAlign: TextAlign.center),
|
||||
const SizedBox(height: 12),
|
||||
FilledButton(onPressed: _refresh, child: T('重试')),
|
||||
Icon(Icons.cloud_off_outlined, size: 40, color: st.subColor),
|
||||
const SizedBox(height: 14),
|
||||
Text(_error!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 13, height: 1.5, color: st.subColor)),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.tonal(onPressed: _refresh, child: T('重试')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (_files.isEmpty) {
|
||||
return Center(child: T('目录下没有日志文件'));
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.description_outlined, size: 40, color: st.subColor),
|
||||
const SizedBox(height: 12),
|
||||
Text(S.t('目录下没有日志文件'),
|
||||
style: TextStyle(fontSize: 13, color: st.subColor)),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.tonal(
|
||||
onPressed: _loading ? null : _refresh,
|
||||
child: T('刷新'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return RefreshIndicator(
|
||||
onRefresh: _refresh,
|
||||
child: ListView.builder(
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: _files.length,
|
||||
itemBuilder: (_, i) {
|
||||
final f = _files[i];
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.description_outlined),
|
||||
title: Text(f.name, overflow: TextOverflow.ellipsis),
|
||||
subtitle: Text(
|
||||
'${_fmtSize(f.size)} · ${f.mtime.toLocal()}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => _viewFile(f),
|
||||
);
|
||||
},
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
children: [
|
||||
ZPanel(style: st, children: [
|
||||
for (var i = 0; i < _files.length; i++) ...[
|
||||
if (i > 0) ZDivider(style: st),
|
||||
ZRow(
|
||||
title: _files[i].name,
|
||||
subtitle: '${_fmtSize(_files[i].size)} · '
|
||||
'${_files[i].mtime.toLocal().toString().substring(0, 19)}',
|
||||
style: st,
|
||||
leading: Icon(Icons.description_outlined,
|
||||
size: 20, color: st.subColor),
|
||||
onTap: () => _viewFile(_files[i]),
|
||||
),
|
||||
],
|
||||
]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -342,7 +399,7 @@ class _LogViewerPageState extends State<_LogViewerPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final lines = _content.split('\n');
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
appBar: ZAppBar(
|
||||
title: Text(widget.title, overflow: TextOverflow.ellipsis),
|
||||
actions: [
|
||||
IconButton(
|
||||
@@ -352,10 +409,36 @@ class _LogViewerPageState extends State<_LogViewerPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: SwitchListTile(
|
||||
title: T('自动刷新并跟随底部(每 5 秒)'),
|
||||
value: _autoRefresh,
|
||||
onChanged: _toggleAuto,
|
||||
// 底部工具条:自动刷新开关 + 回到底部,两者都是长日志场景的高频操作
|
||||
bottomNavigationBar: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
S.t('自动刷新并跟随底部(每 5 秒)'),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: _jumpBottom,
|
||||
icon: const Icon(Icons.vertical_align_bottom, size: 18),
|
||||
label: T('底部'),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
ZToggle(
|
||||
value: _autoRefresh,
|
||||
size: 40,
|
||||
borderColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
onChanged: _toggleAuto,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body: NotificationListener<ScrollNotification>(
|
||||
onNotification: (n) {
|
||||
@@ -367,10 +450,14 @@ class _LogViewerPageState extends State<_LogViewerPage> {
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
controller: _controller,
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: SelectableText(
|
||||
lines.join('\n'),
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 12),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 12,
|
||||
height: 1.45,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:path_provider/path_provider.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
import '../../core/utils/background_service.dart';
|
||||
import '../../core/widgets/background_widget.dart';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
import '../../providers/theme_provider.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
import 'help_page.dart';
|
||||
@@ -55,39 +56,49 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
void _showBackgroundPicker() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Wrap(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.photo, color: Colors.blue),
|
||||
title: T('选择图片'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_pickImage();
|
||||
},
|
||||
builder: (ctx) {
|
||||
final st = ZStyle.of(ctx, hasWallpaper: false);
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ZPanel(
|
||||
style: st,
|
||||
children: [
|
||||
ZSheetRow(
|
||||
icon: Icons.photo,
|
||||
iconColor: Colors.blue,
|
||||
title: '选择图片',
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_pickImage();
|
||||
},
|
||||
),
|
||||
ZDivider(style: st),
|
||||
ZSheetRow(
|
||||
icon: Icons.videocam,
|
||||
title: '选择视频',
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_pickVideo();
|
||||
},
|
||||
),
|
||||
if (_currentBgPath != null) ...[
|
||||
ZDivider(style: st),
|
||||
ZSheetRow(
|
||||
icon: Icons.delete,
|
||||
danger: true,
|
||||
title: '清除背景',
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_clearBackground();
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.videocam, color: Colors.green),
|
||||
title: T('选择视频'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_pickVideo();
|
||||
},
|
||||
),
|
||||
if (_currentBgPath != null) ...[
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete, color: Colors.red),
|
||||
title: T('清除背景', style: TextStyle(color: Colors.red)),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_clearBackground();
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,18 +125,40 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
final provider = context.read<LanguageProvider>();
|
||||
final mode = await showDialog<LanguageMode>(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
title: T('语言 / Language'),
|
||||
children: [
|
||||
for (final m in LanguageMode.values)
|
||||
RadioListTile<LanguageMode>(
|
||||
title: Text(_languageName(m)),
|
||||
value: m,
|
||||
groupValue: provider.mode,
|
||||
onChanged: (v) => Navigator.pop(context, v),
|
||||
builder: (ctx) {
|
||||
final st = ZStyle.of(ctx, hasWallpaper: false);
|
||||
return Dialog(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),
|
||||
child: T('语言 / Language', style: Theme.of(ctx).textTheme.titleMedium),
|
||||
),
|
||||
ZPanel(
|
||||
style: st,
|
||||
children: [
|
||||
for (final m in LanguageMode.values) ...[
|
||||
if (m != LanguageMode.values.first) ZDivider(style: st),
|
||||
ZSheetRow(
|
||||
icon: Icons.language,
|
||||
title: _languageName(m),
|
||||
trailing: provider.mode == m
|
||||
? Icon(Icons.check_circle_rounded, color: kZAccent, size: 22)
|
||||
: Icon(Icons.circle_outlined, color: st.subColor, size: 22),
|
||||
onTap: () => Navigator.pop(ctx, m),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (mode != null) await provider.setMode(mode);
|
||||
}
|
||||
@@ -226,133 +259,134 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeProvider = context.watch<ThemeProvider>();
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final st = ZStyle(hasWallpaper: hasWallpaper, scheme: scheme);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: T('设置')),
|
||||
backgroundColor: hasWallpaper ? Colors.transparent : null,
|
||||
// 透明 AppBar,让壁纸延伸到顶
|
||||
appBar: ZAppBar(
|
||||
title: T('设置'),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
||||
children: [
|
||||
// ---------- 外观主题 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.palette_outlined),
|
||||
title: T('外观主题'),
|
||||
trailing: SegmentedButton<AppThemeMode>(
|
||||
segments: const [
|
||||
ButtonSegment(value: AppThemeMode.light, icon: Icon(Icons.light_mode, size: 18)),
|
||||
ButtonSegment(value: AppThemeMode.dark, icon: Icon(Icons.dark_mode, size: 18)),
|
||||
ButtonSegment(value: AppThemeMode.system, icon: Icon(Icons.brightness_auto, size: 18)),
|
||||
],
|
||||
selected: {themeProvider.themeMode},
|
||||
onSelectionChanged: (v) => themeProvider.setThemeMode(v.first),
|
||||
style: SegmentedButton.styleFrom(visualDensity: VisualDensity.compact),
|
||||
ZPanel(style: st, children: [
|
||||
// ---------- 外观主题 ----------
|
||||
ZRow(
|
||||
title: '外观主题',
|
||||
subtitle: '亮色、暗色或跟随系统',
|
||||
style: st,
|
||||
trailing: ZSegmentedCircles<AppThemeMode>(
|
||||
value: themeProvider.themeMode,
|
||||
onChanged: (m) => themeProvider.setThemeMode(m),
|
||||
onSurface: st.titleColor,
|
||||
options: const [
|
||||
ZCircleOption(value: AppThemeMode.light, icon: Icons.light_mode),
|
||||
ZCircleOption(value: AppThemeMode.dark, icon: Icons.dark_mode),
|
||||
ZCircleOption(
|
||||
value: AppThemeMode.system, icon: Icons.brightness_auto),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 应用背景(新增) ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.wallpaper),
|
||||
title: T('应用背景'),
|
||||
subtitle: Text(
|
||||
_currentBgPath == null
|
||||
? '未设置'
|
||||
: S.f('已设置 {0}', [_currentBgType == 'video' ? S.t('视频') : S.t('图片')]),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '应用背景',
|
||||
subtitle: '选择一张图片或一段视频作为应用背景',
|
||||
style: st,
|
||||
value: _currentBgPath == null
|
||||
? S.t('未设置')
|
||||
: S.f('{0}',
|
||||
[_currentBgType == 'video' ? S.t('视频') : S.t('图片')]),
|
||||
onTap: _showBackgroundPicker,
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onTap: _showBackgroundPicker,
|
||||
),
|
||||
// ---------- 视频声音开关 ----------
|
||||
if (_currentBgType == 'video') ...[
|
||||
SwitchListTile(
|
||||
secondary: const Icon(Icons.volume_up),
|
||||
title: T('视频声音'),
|
||||
subtitle: T('开启后背景视频将播放声音'),
|
||||
value: _videoSoundEnabled,
|
||||
onChanged: (value) async {
|
||||
await BackgroundService.setVideoSound(value);
|
||||
setState(() => _videoSoundEnabled = value);
|
||||
// 立即应用到正在播放的背景视频,无需重建图层
|
||||
backgroundWidgetKey.currentState?.applyVideoSound(value);
|
||||
},
|
||||
if (_currentBgType == 'video') ...[
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '视频声音',
|
||||
subtitle: '开启后背景视频将播放声音',
|
||||
style: st,
|
||||
trailing: ZToggle(
|
||||
value: _videoSoundEnabled,
|
||||
borderColor: st.subColor,
|
||||
onChanged: (value) async {
|
||||
await BackgroundService.setVideoSound(value);
|
||||
setState(() => _videoSoundEnabled = value);
|
||||
// 立即应用到正在播放的背景视频,无需重建图层
|
||||
backgroundWidgetKey.currentState?.applyVideoSound(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
]),
|
||||
const SizedBox(height: 14),
|
||||
ZPanel(style: st, children: [
|
||||
// ---------- 语言 ----------
|
||||
ZRow(
|
||||
title: '语言 / Language',
|
||||
subtitle: '界面显示语言',
|
||||
style: st,
|
||||
value: _languageName(context.watch<LanguageProvider>().mode),
|
||||
onTap: _pickLanguage,
|
||||
),
|
||||
],
|
||||
const Divider(),
|
||||
|
||||
// ---------- 语言 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.language),
|
||||
title: T('语言 / Language'),
|
||||
subtitle: Text(_languageName(context.watch<LanguageProvider>().mode)),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => _pickLanguage(),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 下载与镜像 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download_outlined),
|
||||
title: T('下载与镜像设置'),
|
||||
subtitle: T('镜像线路、测速选线、同时下载任务数'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const DownloadSettingsPage()),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '下载与镜像设置',
|
||||
subtitle: '镜像线路、测速选线、同时下载任务数',
|
||||
style: st,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const DownloadSettingsPage()),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 服务器日志 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.receipt_long_outlined),
|
||||
title: T('服务器日志'),
|
||||
subtitle: T('通过 SSH 查看服务器 logs 目录日志输出'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ServerLogPage()),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '服务器日志',
|
||||
subtitle: '通过 SSH 查看服务器 logs 目录日志输出',
|
||||
style: st,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ServerLogPage()),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 使用教程 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.menu_book_outlined),
|
||||
title: T('使用教程'),
|
||||
subtitle: T('如何开启 RCON / SSH、模组管理、下载与终端'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const HelpPage()),
|
||||
]),
|
||||
const SizedBox(height: 14),
|
||||
ZPanel(style: st, children: [
|
||||
ZRow(
|
||||
title: '使用教程',
|
||||
subtitle: '如何开启 RCON / SSH、模组管理、下载与终端',
|
||||
style: st,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const HelpPage()),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 用户须知 ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.gavel_outlined),
|
||||
title: T('用户须知'),
|
||||
subtitle: T('查看用户守则全部条款'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (_) => UserAgreementDialog.readView(),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '用户须知',
|
||||
subtitle: '查看用户守则全部条款',
|
||||
style: st,
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (_) => UserAgreementDialog.readView(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// ---------- 关于软件(检查更新 + 创造者 + 开源许可) ----------
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: T('关于软件'),
|
||||
subtitle: T('版本、检查更新、创造者与开源许可'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const AboutPage()),
|
||||
ZDivider(style: st),
|
||||
ZRow(
|
||||
title: '关于软件',
|
||||
subtitle: '版本、检查更新、创造者与开源许可',
|
||||
style: st,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const AboutPage()),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
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';
|
||||
import '../../core/widgets/z_widgets.dart';
|
||||
|
||||
class WallpaperSettings extends StatelessWidget {
|
||||
const WallpaperSettings({super.key});
|
||||
@@ -15,10 +17,14 @@ class WallpaperSettings extends StatelessWidget {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
appBar: ZAppBar(
|
||||
title: T('壁纸设置'),
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
systemOverlayStyle: const SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarBrightness: Brightness.dark,
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
|
||||
Reference in new issue
Block a user