feat: 关于软件页创造者显示 Gitee 头像并点击跳转主页(新增 openUrl 原生通道)
This commit is contained in:
1 parent
4277dc9f84
commit
211680b9ae
4 files changed
+76
-4
No files matched your search
@@ -44,6 +44,21 @@ class MainActivity : FlutterActivity() {
|
|||||||
downloadAndInstall(url, filename ?: "latest.apk", result)
|
downloadAndInstall(url, filename ?: "latest.apk", result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"openUrl" -> {
|
||||||
|
val url = call.argument<String>(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()
|
else -> result.notImplemented()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,6 +414,8 @@ class S {
|
|||||||
'我知道了': 'Got it',
|
'我知道了': 'Got it',
|
||||||
'创造者': 'Creators',
|
'创造者': 'Creators',
|
||||||
'ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。': 'ZV Manager is a remote management tool for Minecraft servers. Not affiliated with Mojang or Microsoft.',
|
'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;
|
static String t(String zh) => en ? (_en[zh] ?? zh) : zh;
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ class UpdateService {
|
|||||||
/// 是否正在下载,用于防止重复触发并发下载到同一文件。
|
/// 是否正在下载,用于防止重复触发并发下载到同一文件。
|
||||||
static bool _downloading = false;
|
static bool _downloading = false;
|
||||||
|
|
||||||
|
/// 调用系统浏览器打开外部链接。
|
||||||
|
static Future<void> openUrl(String url) async {
|
||||||
|
try {
|
||||||
|
await _channel.invokeMethod('openUrl', {'url': url});
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
/// 从 Gitee 拉取最新发布信息;接口异常返回 null(调用方决定是否静默处理)。
|
/// 从 Gitee 拉取最新发布信息;接口异常返回 null(调用方决定是否静默处理)。
|
||||||
static Future<UpdateInfo?> fetchInfo({String userAgent = ''}) async {
|
static Future<UpdateInfo?> fetchInfo({String userAgent = ''}) async {
|
||||||
final client = HttpClient();
|
final client = HttpClient();
|
||||||
|
|||||||
@@ -80,10 +80,21 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
onTap: _checkingUpdate ? null : _checkUpdate,
|
onTap: _checkingUpdate ? null : _checkUpdate,
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const ListTile(
|
Padding(
|
||||||
leading: Icon(Icons.person_outline),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||||
title: T('创造者'),
|
child: T('创造者', style: Theme.of(context).textTheme.titleSmall),
|
||||||
subtitle: T('开发者:Z有3笔,协作者:venti1112'),
|
),
|
||||||
|
_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(),
|
const Divider(),
|
||||||
ListTile(
|
ListTile(
|
||||||
@@ -106,3 +117,40 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 创造者条目:头像 + 名称 + 角色,点击打开 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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user