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:
Ventiの酒 committed 2026-11-04 17:43:57 +08:00
1 parent ddd72c43fb
commit e32125aa8e
35 files changed
+4171 -1325

No files matched your search

+19 -54
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../core/l10n/strings.dart';
import '../../core/widgets/z_widgets.dart';
/// 服务器卡片的数据状态。
enum ServerCardState {
@@ -49,7 +50,6 @@ class ServerCard extends StatelessWidget {
this.tps,
});
static const double _radius = 20;
/// TPS 分档着色:≥16 流畅,≥10 偏低,否则卡顿。
static Color tpsColor(double tps) {
@@ -86,11 +86,10 @@ class ServerCard extends StatelessWidget {
final scheme = theme.colorScheme;
final online = state == ServerCardState.online;
// 卡片底色跟随主题表面色,浮一层极淡的品牌色,避免纯白/纯黑显得生硬。
final Color base = Color.alphaBlend(
scheme.primary.withOpacity(online ? 0.06 : 0.02),
scheme.surface,
);
// 在线态用品牌色描边强调,离线态退成中性描边,避免整屏红框太吵
final borderColor = online
? kZAccent.withOpacity(0.45)
: scheme.outlineVariant.withOpacity(0.7);
return Semantics(
button: true,
@@ -99,24 +98,12 @@ class ServerCard extends StatelessWidget {
color: Colors.transparent,
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(_radius),
color: base,
border: Border.all(
color: online
? scheme.primary.withOpacity(0.38)
: scheme.outlineVariant.withOpacity(0.55),
width: online ? 1.4 : 1,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(online ? 0.08 : 0.04),
blurRadius: online ? 18 : 10,
offset: const Offset(0, 6),
),
],
borderRadius: BorderRadius.circular(kZRadius),
color: scheme.surfaceContainerLow,
border: Border.all(color: borderColor, width: online ? 1.4 : 1),
),
child: InkWell(
borderRadius: BorderRadius.circular(_radius),
borderRadius: BorderRadius.circular(kZRadius),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 14, 8, 14),
@@ -150,41 +137,18 @@ class ServerCard extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.titleMedium?.copyWith(
fontSize: 15.5,
fontWeight: FontWeight.w700,
letterSpacing: -0.2,
),
),
),
// 状态胶囊
Container(
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
decoration: BoxDecoration(
color: _statusColor.withOpacity(0.13),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: _statusColor.withOpacity(0.28)),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
_statusLabel,
style: theme.textTheme.labelSmall?.copyWith(
color: _statusColor,
fontWeight: FontWeight.w600,
),
),
if (online && latencyMs != null) ...[
const SizedBox(width: 6),
Text(
'${latencyMs}ms',
style: theme.textTheme.labelSmall?.copyWith(
color: _statusColor.withOpacity(0.75),
fontFeatures: const [FontFeature.tabularFigures()],
),
),
],
],
),
// 状态胶囊(与 ZL2 的标签样式统一)
ZBadge(
label: online && latencyMs != null
? '$_statusLabel · ${latencyMs}ms'
: _statusLabel,
color: _statusColor,
),
_buildMenu(context, scheme),
],
@@ -242,6 +206,7 @@ class ServerCard extends StatelessWidget {
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: scheme.onSurfaceVariant,
fontSize: 12,
letterSpacing: 0.1,
),
),
@@ -259,7 +224,7 @@ class ServerCard extends StatelessWidget {
_Pill(
icon: Icons.autorenew_rounded,
label: S.t('正在获取状态'),
color: Color(0xFF94A3B8),
color: const Color(0xFF94A3B8),
),
]);
}
@@ -271,7 +236,7 @@ class ServerCard extends StatelessWidget {
child: _Pill(
icon: Icons.cloud_off_outlined,
label: S.t('无法连接'),
color: Color(0xFFF87171),
color: const Color(0xFFF87171),
),
),
const Spacer(),
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '../../providers/server_provider.dart';
import '../../core/l10n/strings.dart';
import '../../core/widgets/z_widgets.dart';
/// 新增 / 编辑服务器的表单弹窗。
///
@@ -92,6 +93,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
@override
Widget build(BuildContext context) {
final st = ZStyle.of(context, hasWallpaper: false);
return AlertDialog(
title: Text(isEditing ? '编辑服务器' : '添加服务器'),
content: SingleChildScrollView(
@@ -137,12 +139,19 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
onFieldSubmitted: (_) => _submit(),
),
const SizedBox(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: T('SSH 连接(可选)'),
subtitle: T('用于模组插件管理与远程终端'),
value: _sshEnabled,
onChanged: (v) => setState(() => _sshEnabled = v),
ZPanel(
style: st,
children: [
ZRow(
style: st,
title: 'SSH 连接(可选)',
subtitle: '用于模组插件管理与远程终端',
trailing: ZToggle(
value: _sshEnabled,
onChanged: (v) => setState(() => _sshEnabled = v),
),
),
],
),
if (_sshEnabled) ...[
TextFormField(
@@ -10,6 +10,7 @@ import '../settings/settings_page.dart';
import 'server_card.dart';
import 'server_form_dialog.dart';
import '../../core/l10n/strings.dart';
import '../../core/widgets/z_widgets.dart';
class ServerListPage extends StatefulWidget {
const ServerListPage({super.key});
@@ -192,7 +193,7 @@ class _ServerListPageState extends State<ServerListPage> {
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
return Scaffold(
appBar: AppBar(
appBar: ZAppBar(
title: const Text('ZV Manager'),
backgroundColor: hasWallpaper ? Colors.transparent : null,
elevation: hasWallpaper ? 0 : null,