diff --git a/android/app/src/main/kotlin/com/driftinblock/zvmanager/MainActivity.kt b/android/app/src/main/kotlin/com/driftinblock/zvmanager/MainActivity.kt index 2b058b4..b164529 100644 --- a/android/app/src/main/kotlin/com/driftinblock/zvmanager/MainActivity.kt +++ b/android/app/src/main/kotlin/com/driftinblock/zvmanager/MainActivity.kt @@ -44,6 +44,21 @@ class MainActivity : FlutterActivity() { downloadAndInstall(url, filename ?: "latest.apk", result) } } + "openUrl" -> { + val url = call.argument(ARG_URL) + if (url.isNullOrBlank()) { + result.error("BAD_ARGS", "链接为空", null) + } else { + try { + startActivity( + Intent(Intent.ACTION_VIEW, android.net.Uri.parse(url)) + ) + result.success(true) + } catch (e: ActivityNotFoundException) { + result.error("NO_BROWSER", "无法打开链接", null) + } + } + } else -> result.notImplemented() } } diff --git a/lib/core/l10n/strings.dart b/lib/core/l10n/strings.dart index 082a5c2..91e7535 100644 --- a/lib/core/l10n/strings.dart +++ b/lib/core/l10n/strings.dart @@ -414,6 +414,8 @@ class S { '我知道了': 'Got it', '创造者': 'Creators', 'ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。': 'ZV Manager is a remote management tool for Minecraft servers. Not affiliated with Mojang or Microsoft.', + '开发者 · Gitee: DriftinBlock': 'Developer · Gitee: DriftinBlock', + '协作者 · Gitee: venti1112': 'Collaborator · Gitee: venti1112', }; static String t(String zh) => en ? (_en[zh] ?? zh) : zh; diff --git a/lib/core/utils/update_service.dart b/lib/core/utils/update_service.dart index ec641d8..21f701b 100644 --- a/lib/core/utils/update_service.dart +++ b/lib/core/utils/update_service.dart @@ -35,6 +35,13 @@ class UpdateService { /// 是否正在下载,用于防止重复触发并发下载到同一文件。 static bool _downloading = false; + /// 调用系统浏览器打开外部链接。 + static Future openUrl(String url) async { + try { + await _channel.invokeMethod('openUrl', {'url': url}); + } catch (_) {} + } + /// 从 Gitee 拉取最新发布信息;接口异常返回 null(调用方决定是否静默处理)。 static Future fetchInfo({String userAgent = ''}) async { final client = HttpClient(); diff --git a/lib/features/settings/about_page.dart b/lib/features/settings/about_page.dart index 09f5eb4..63adffc 100644 --- a/lib/features/settings/about_page.dart +++ b/lib/features/settings/about_page.dart @@ -80,10 +80,21 @@ class _AboutPageState extends State { onTap: _checkingUpdate ? null : _checkUpdate, ), const Divider(), - const ListTile( - leading: Icon(Icons.person_outline), - title: T('创造者'), - subtitle: T('开发者:Z有3笔,协作者:venti1112'), + Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 4), + child: T('创造者', style: Theme.of(context).textTheme.titleSmall), + ), + _CreatorTile( + name: 'Z有3笔', + role: S.t('开发者 · Gitee: DriftinBlock'), + avatarUrl: 'https://gitee.com/driftinblock.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( @@ -106,3 +117,40 @@ class _AboutPageState extends State { ); } } + +/// 创造者条目:头像 + 名称 + 角色,点击打开 Gitee 主页。 +class _CreatorTile extends StatelessWidget { + final String name; + final String role; + final String avatarUrl; + final String homeUrl; + + const _CreatorTile({ + required this.name, + required this.role, + required this.avatarUrl, + required this.homeUrl, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: ClipOval( + child: SizedBox( + width: 44, + height: 44, + child: Image.network( + avatarUrl, + fit: BoxFit.cover, + errorBuilder: (_, __, ___) => + const ColoredBox(color: Color(0xFFDDDDDD), child: Icon(Icons.person)), + ), + ), + ), + title: Text(name), + subtitle: Text(role, overflow: TextOverflow.ellipsis), + trailing: const Icon(Icons.open_in_new, size: 18), + onTap: () => UpdateService.openUrl(homeUrl), + ); + } +}