|
|
|
@ -18,8 +18,8 @@ import 'core/translations/app_translations.dart'; |
|
|
|
import 'core/themes/app_theme.dart'; |
|
|
|
import 'core/themes/theme_service.dart'; |
|
|
|
import 'core/bindings/initial_binding.dart'; |
|
|
|
import 'core/utils/logger.dart'; |
|
|
|
import 'data/services/login_service.dart'; |
|
|
|
import 'dart:ui' as ui; |
|
|
|
import 'modules/meeting/controllers/meeting_home_controller.dart'; |
|
|
|
import 'modules/splash/controllers/splash_controller.dart'; |
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ void main() async { |
|
|
|
|
|
|
|
// 加载环境变量 |
|
|
|
await dotenv.load(fileName: ".env"); |
|
|
|
print("环境变量加载成功"); |
|
|
|
Logger.i("Main", "环境变量加载成功"); |
|
|
|
|
|
|
|
// 初始化登录服务 |
|
|
|
Get.put(LoginService()); |
|
|
|
@ -53,20 +53,20 @@ void _initDeepLinkHandler() { |
|
|
|
if (_deepLinkHandlerInitialized) return; |
|
|
|
_deepLinkHandlerInitialized = true; |
|
|
|
|
|
|
|
print("🔗 初始化深链接处理器"); |
|
|
|
Logger.d("DeepLink", "初始化深链接处理器"); |
|
|
|
|
|
|
|
const platform = MethodChannel('com.saitong.voitrans/deeplink'); |
|
|
|
|
|
|
|
platform.setMethodCallHandler((call) async { |
|
|
|
print("🔗 Flutter 收到深链接调用: ${call.method}"); |
|
|
|
Logger.d("DeepLink", "Flutter 收到深链接调用: ${call.method}"); |
|
|
|
|
|
|
|
if (call.method == 'handleDeepLink') { |
|
|
|
final arguments = call.arguments as Map<dynamic, dynamic>; |
|
|
|
print("🔗 深链接参数: $arguments"); |
|
|
|
Logger.d("DeepLink", "深链接参数: $arguments"); |
|
|
|
|
|
|
|
final url = arguments['url'] as String?; |
|
|
|
if (url != null) { |
|
|
|
print("🔗 处理深链接 URL: $url"); |
|
|
|
Logger.d("DeepLink", "处理深链接 URL: $url"); |
|
|
|
await _handleDeepLinkNavigation(url); |
|
|
|
} |
|
|
|
return; |
|
|
|
@ -81,19 +81,20 @@ void _initDeepLinkHandler() { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
print("✅ 深链接处理器初始化完成"); |
|
|
|
Logger.i("DeepLink", "深链接处理器初始化完成"); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理深链接导航 |
|
|
|
Future<void> _handleDeepLinkNavigation(String url) async { |
|
|
|
print("🔗 开始处理深链接导航: $url"); |
|
|
|
Logger.d("DeepLink", "开始处理深链接导航: $url"); |
|
|
|
|
|
|
|
try { |
|
|
|
final uri = Uri.parse(url); |
|
|
|
print("🔗 解析URI: scheme=${uri.scheme}, host=${uri.host}, path=${uri.path}"); |
|
|
|
Logger.d("DeepLink", |
|
|
|
"解析URI: scheme=${uri.scheme}, host=${uri.host}, path=${uri.path}"); |
|
|
|
|
|
|
|
if (uri.scheme == 'deepvoice' && uri.host == 'qqmusic') { |
|
|
|
print("🔗 检测到QQ音乐登录回调"); |
|
|
|
Logger.i("DeepLink", "检测到QQ音乐登录回调"); |
|
|
|
|
|
|
|
// 等待SplashController注册 |
|
|
|
int retryCount = 0; |
|
|
|
@ -102,31 +103,31 @@ Future<void> _handleDeepLinkNavigation(String url) async { |
|
|
|
while (retryCount < maxRetries) { |
|
|
|
try { |
|
|
|
if (Get.isRegistered<SplashController>()) { |
|
|
|
print("🔗 找到SplashController,处理QQ音乐登录"); |
|
|
|
Logger.i("DeepLink", "找到SplashController,处理QQ音乐登录"); |
|
|
|
final controller = Get.find<SplashController>(); |
|
|
|
controller.handleQQMusicLogin(); |
|
|
|
return; |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
print("🔗 获取SplashController失败: $e"); |
|
|
|
Logger.e("DeepLink", "获取SplashController失败", e); |
|
|
|
} |
|
|
|
|
|
|
|
retryCount++; |
|
|
|
print("🔗 等待SplashController注册 ($retryCount/$maxRetries)"); |
|
|
|
Logger.d("DeepLink", "等待SplashController注册 ($retryCount/$maxRetries)"); |
|
|
|
await Future.delayed(const Duration(milliseconds: 500)); |
|
|
|
} |
|
|
|
|
|
|
|
print("❌ 超时等待SplashController注册"); |
|
|
|
Logger.w("DeepLink", "超时等待SplashController注册"); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
print("❌ 处理深链接时出错: $e"); |
|
|
|
Logger.e("DeepLink", "处理深链接时出错", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> _handleSharedAudioFile(String filePath) async { |
|
|
|
try { |
|
|
|
if (!File(filePath).existsSync()) { |
|
|
|
print("❌ 分享文件不存在: $filePath"); |
|
|
|
Logger.w("DeepLink", "分享文件不存在: $filePath"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -153,7 +154,7 @@ Future<void> _handleSharedAudioFile(String filePath) async { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
print("❌ 处理分享文件失败: $e"); |
|
|
|
Logger.e("DeepLink", "处理分享文件失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|