c3d32a476e
- channel_launch: @→t.me / 邮箱→mailto / 域名→https,外部打开 - 联系页(桌面)/联系&兑换子页(移动)渠道卡接上 onTap - account_desktop_nav_test: 证明桌面设置/兑换/联系/订单导航正常(231 全绿) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
22 lines
746 B
Dart
22 lines
746 B
Dart
// channel_launch.dart — 联系/购买渠道点击:按 handle(sub)推导 URL 并外部打开。
|
|
// @xxx → https://t.me/xxx (Telegram)
|
|
// a@b.com → mailto:a@b.com
|
|
// x.yanmei... → https://x.yanmei...
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
String channelUrl(String sub) {
|
|
if (sub.startsWith('@')) return 'https://t.me/${sub.substring(1)}';
|
|
if (sub.contains('@')) return 'mailto:$sub';
|
|
return 'https://$sub';
|
|
}
|
|
|
|
/// 点击渠道卡:外部打开对应 URL。失败静默(不炸 UI)。
|
|
Future<void> launchChannel(String sub) async {
|
|
final uri = Uri.parse(channelUrl(sub));
|
|
try {
|
|
if (await canLaunchUrl(uri)) {
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
}
|
|
} catch (_) {}
|
|
}
|