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,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(),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user