diff --git a/GoogleService-Info.plist b/GoogleService-Info.plist
new file mode 100644
index 000000000..c90ada3a3
--- /dev/null
+++ b/GoogleService-Info.plist
@@ -0,0 +1,36 @@
+
+
+
+
+ CLIENT_ID
+ 907754492821-oc9e77svgmmlgouo0op7vv00e1hb8278.apps.googleusercontent.com
+ REVERSED_CLIENT_ID
+ com.googleusercontent.apps.907754492821-oc9e77svgmmlgouo0op7vv00e1hb8278
+ ANDROID_CLIENT_ID
+ 907754492821-9jakqvathu61e6b8g95i41ssi7o4dnka.apps.googleusercontent.com
+ API_KEY
+ AIzaSyAvyBQcOXuO_q851vevqZIufsPRTMCe808
+ GCM_SENDER_ID
+ 907754492821
+ PLIST_VERSION
+ 1
+ BUNDLE_ID
+ com.yunqiinnovation.deepsound
+ PROJECT_ID
+ deepsound-e0e3d
+ STORAGE_BUCKET
+ deepsound-e0e3d.firebasestorage.app
+ IS_ADS_ENABLED
+
+ IS_ANALYTICS_ENABLED
+
+ IS_APPINVITE_ENABLED
+
+ IS_GCM_ENABLED
+
+ IS_SIGNIN_ENABLED
+
+ GOOGLE_APP_ID
+ 1:907754492821:ios:246794fc44b23174145c9c
+
+
\ No newline at end of file
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 6879ee469..9fe85f007 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -1,3 +1,5 @@
+import java.util.Properties
+import java.io.FileInputStream
repositories {
google()
mavenCentral()
@@ -11,10 +13,14 @@ plugins {
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
+ id("com.google.gms.google-services")version "4.3.13"
+}
+val keystorePropertiesFile = rootProject.file("app/sign/DeepSound.properties")
+val keystoreProperties =Properties().apply {
+ load(FileInputStream(keystorePropertiesFile)) // 使用 Kotlin 扩展方法
}
-
android {
- namespace = "com.example.deep_voice"
+ namespace = "com.yunqiinnovation.deepsound"
compileSdk = 35
ndkVersion = "28.0.13004108"
@@ -31,7 +37,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId = "com.example.deep_voice"
+ applicationId = "com.yunqiinnovation.deepsound"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 24 // Updated to meet azure_speech_recognition_null_safety requirements
@@ -39,12 +45,34 @@ android {
versionCode = flutter.versionCode
versionName = flutter.versionName
}
+ signingConfigs {
+
+create("release") {
+
+keyAlias = keystoreProperties.getProperty("keyAlias")
+
+keyPassword = keystoreProperties.getProperty("keyPassword")
+
+storeFile = file(keystoreProperties.getProperty("storeFile"))
+
+storePassword = keystoreProperties.getProperty("storePassword")
+enableV1Signing = true
+
+enableV2Signing = true
+
+}
+
+}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig = signingConfigs.getByName("debug")
+ isMinifyEnabled = false
+ isShrinkResources = false
+
+ signingConfig = signingConfigs.getByName("release")
+ //signingConfig = signingConfigs.getByName("debug")
}
}
}
diff --git a/android/app/google-services.json b/android/app/google-services.json
new file mode 100644
index 000000000..4cbe172f9
--- /dev/null
+++ b/android/app/google-services.json
@@ -0,0 +1,47 @@
+{
+ "project_info": {
+ "project_number": "907754492821",
+ "project_id": "deepsound-e0e3d",
+ "storage_bucket": "deepsound-e0e3d.firebasestorage.app"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:907754492821:android:2deffc5aa1037ae2145c9c",
+ "android_client_info": {
+ "package_name": "com.yunqiinnovation.deepsound"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "907754492821-9jakqvathu61e6b8g95i41ssi7o4dnka.apps.googleusercontent.com",
+ "client_type": 1,
+ "android_info": {
+ "package_name": "com.yunqiinnovation.deepsound",
+ "certificate_hash": "5a9520045bc16fb4f09fb97668a8b0fc4babd376"
+ }
+ },
+ {
+ "client_id": "907754492821-15btgolbd7thaa8fpt7s8hs8hq3jl0lg.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyAj0_-nS3ygc8VFe1azotSE3-HGZYClkTs"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "907754492821-15btgolbd7thaa8fpt7s8hs8hq3jl0lg.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/android/app/sign/DeepSound.properties b/android/app/sign/DeepSound.properties
new file mode 100644
index 000000000..43f28dcac
--- /dev/null
+++ b/android/app/sign/DeepSound.properties
@@ -0,0 +1,7 @@
+ storePassword=13071376716
+
+ keyPassword=13071376716
+
+ keyAlias=DeepSound
+
+ storeFile=sign/DeepSound.keystore
\ No newline at end of file
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 88f1fef92..f120cc1f7 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -29,7 +29,7 @@
-
+
+
+
+ 3829022037361855
+ fb3829022037361855
+ 193d0a2b1757c41cfa557ea8e8f21c33
+
\ No newline at end of file
diff --git a/android/build.gradle.kts b/android/build.gradle.kts
index 89176ef44..35365df1a 100644
--- a/android/build.gradle.kts
+++ b/android/build.gradle.kts
@@ -3,6 +3,7 @@ allprojects {
google()
mavenCentral()
}
+
}
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
diff --git a/firebase.json b/firebase.json
new file mode 100644
index 000000000..a2b0f41a5
--- /dev/null
+++ b/firebase.json
@@ -0,0 +1 @@
+{"flutter":{"platforms":{"android":{"default":{"projectId":"deepsound-e0e3d","appId":"1:907754492821:android:2deffc5aa1037ae2145c9c","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"deepsound-e0e3d","configurations":{"android":"1:907754492821:android:2deffc5aa1037ae2145c9c","ios":"1:907754492821:ios:8c1d7d1b583aec22145c9c","macos":"1:907754492821:ios:8c1d7d1b583aec22145c9c","web":"1:907754492821:web:99451e7efd7d120a145c9c","windows":"1:907754492821:web:e3e8040111db6871145c9c"}}}}}}
\ No newline at end of file
diff --git a/lib/core/translations/app_translations.dart b/lib/core/translations/app_translations.dart
index 71bf8b7a0..2d498993a 100644
--- a/lib/core/translations/app_translations.dart
+++ b/lib/core/translations/app_translations.dart
@@ -3,79 +3,80 @@ import 'package:get/get.dart';
class AppTranslations extends Translations {
@override
Map> get keys => {
- 'zh_CN': {
- // 通用
- 'app_name': 'i深音',
- 'confirm': '确认',
- 'cancel': '取消',
- 'retry': '重试',
- 'error': '错误',
- 'success': '成功',
-
- // 主页
- 'add_device': '添加设备',
- 'searching': '搜索中',
- 'searching_hint': '请将设备放在手机附近',
- 'connected': '已连接',
- 'device_ready': '设备已就绪',
- 'connection_failed': '连接失败',
- 'connection_failed_hint': '未找到设备。请确保蓝牙已开启且设备在5米范围内。尝试重启设备。',
- 'disconnect': '断开连接',
-
- // 聊天页面
- 'clear_chat': '清空对话',
- 'thinking': '正在思考...',
- 'type_message': '发消息...',
- 'voice_enabled': '语音已开启',
- 'voice_disabled': '语音已关闭',
-
- // 设置页面
- 'settings': '设置',
- 'language_settings': '语言设置',
- 'about': '关于',
- 'check_update': '检查更新',
- 'clear_cache': '清除缓存',
- 'home': '首页',
- 'explore': '发现',
- 'profile': '我的',
- 'device': '设备',
- },
- 'en_US': {
- // General
- 'app_name': 'iDeep Voice',
- 'confirm': 'Confirm',
- 'cancel': 'Cancel',
- 'retry': 'Retry',
- 'error': 'Error',
- 'success': 'Success',
-
- // Home
- 'add_device': '+ Add Device',
- 'searching': 'Searching',
- 'searching_hint': 'Please place the device near your phone',
- 'connected': 'Connected!',
- 'device_ready': 'Your device is ready',
- 'connection_failed': 'Connection Failed',
- 'connection_failed_hint': 'Device not found. Please ensure Bluetooth is enabled and the device is within 5 meters. Try turning the device off and on again.',
- 'disconnect': 'Disconnect',
-
- // Chat
- 'clear_chat': 'Clear Chat',
- 'thinking': 'Thinking...',
- 'type_message': 'Type a message...',
- 'voice_enabled': 'Voice Enabled',
- 'voice_disabled': 'Voice Disabled',
-
- // Settings
- 'settings': 'Settings',
- 'language_settings': 'Language Settings',
- 'about': 'About',
- 'check_update': 'Check for Updates',
- 'clear_cache': 'Clear Cache',
- 'home': 'Home',
- 'explore': 'Explore',
- 'profile': 'Profile',
- 'device': 'Device',
- },
- };
-}
\ No newline at end of file
+ 'zh_CN': {
+ // 通用
+ 'app_name': 'i深音',
+ 'confirm': '确认',
+ 'cancel': '取消',
+ 'retry': '重试',
+ 'error': '错误',
+ 'success': '成功',
+
+ // 主页
+ 'add_device': '添加设备',
+ 'searching': '搜索中',
+ 'searching_hint': '请将设备放在手机附近',
+ 'connected': '已连接',
+ 'device_ready': '设备已就绪',
+ 'connection_failed': '连接失败',
+ 'connection_failed_hint': '未找到设备。请确保蓝牙已开启且设备在5米范围内。尝试重启设备。',
+ 'disconnect': '断开连接',
+
+ // 聊天页面
+ 'clear_chat': '清空对话',
+ 'thinking': '正在思考...',
+ 'type_message': '发消息...',
+ 'voice_enabled': '语音已开启',
+ 'voice_disabled': '语音已关闭',
+
+ // 设置页面
+ 'settings': '设置',
+ 'language_settings': '语言设置',
+ 'about': '关于',
+ 'check_update': '检查更新',
+ 'clear_cache': '清除缓存',
+ 'home': '首页',
+ 'explore': '发现',
+ 'profile': '我的',
+ 'device': '设备',
+ },
+ 'en_US': {
+ // General
+ 'app_name': 'iDeep Voice',
+ 'confirm': 'Confirm',
+ 'cancel': 'Cancel',
+ 'retry': 'Retry',
+ 'error': 'Error',
+ 'success': 'Success',
+
+ // Home
+ 'add_device': '+ Add Device',
+ 'searching': 'Searching',
+ 'searching_hint': 'Please place the device near your phone',
+ 'connected': 'Connected!',
+ 'device_ready': 'Your device is ready',
+ 'connection_failed': 'Connection Failed',
+ 'connection_failed_hint':
+ 'Device not found. Please ensure Bluetooth is enabled and the device is within 5 meters. Try turning the device off and on again.',
+ 'disconnect': 'Disconnect',
+
+ // Chat
+ 'clear_chat': 'Clear Chat',
+ 'thinking': 'Thinking...',
+ 'type_message': 'Type a message...',
+ 'voice_enabled': 'Voice Enabled',
+ 'voice_disabled': 'Voice Disabled',
+
+ // Settings
+ 'settings': 'Settings',
+ 'language_settings': 'Language Settings',
+ 'about': 'About',
+ 'check_update': 'Check for Updates',
+ 'clear_cache': 'Clear Cache',
+ 'home': 'Home',
+ 'explore': 'Explore',
+ 'profile': 'Profile',
+ 'device': 'Device',
+ },
+ };
+}
diff --git a/lib/data/services/audio_service.dart b/lib/data/services/audio_service.dart
index a9ad58a4c..398695ea7 100644
--- a/lib/data/services/audio_service.dart
+++ b/lib/data/services/audio_service.dart
@@ -13,13 +13,13 @@ class AudioServiceManager extends GetxService {
// 添加一个标志,表示是否已经尝试过初始化
bool _hasAttemptedInit = false;
-
+
// 添加一个计时器,用于定期检查服务状态
Timer? _serviceCheckTimer;
Future init() async {
print('初始化 AudioServiceManager');
-
+
if (_isInitialized) {
print('AudioServiceManager 已经初始化');
return this;
@@ -38,12 +38,13 @@ class AudioServiceManager extends GetxService {
// 使用锁确保初始化的原子性
await _lock.synchronized(() async {
if (_isInitialized) return;
-
+
// 使用 AudioService.init 初始化音频服务
_audioHandler = await AudioService.init(
builder: () => MyAudioHandler(),
config: AudioServiceConfig(
- androidNotificationChannelId: 'com.example.deep_voice.channel.audio',
+ androidNotificationChannelId:
+ 'com.yunqiinnovation.deepsound.channel.audio',
androidNotificationChannelName: 'Deep Voice Audio Service',
// 使用应用图标作为通知图标,确保这个图标存在
androidNotificationIcon: 'mipmap/ic_launcher',
@@ -58,13 +59,13 @@ class AudioServiceManager extends GetxService {
preloadArtwork: false,
),
);
-
+
// 注册自定义音频处理器
await Get.put(_audioHandler!, permanent: true);
-
+
_isInitialized = true;
print('AudioServiceManager 初始化成功');
-
+
// 启动定期检查服务状态的计时器
_startServiceCheckTimer();
});
@@ -73,18 +74,18 @@ class AudioServiceManager extends GetxService {
} catch (e) {
print('AudioServiceManager初始化失败: $e');
_isInitialized = false; // 确保失败时重置状态
-
+
// 延迟5秒后尝试重新初始化
Future.delayed(Duration(seconds: 5), () {
print('尝试重新初始化 AudioServiceManager');
_hasAttemptedInit = false;
init();
});
-
+
return this; // 即使失败也返回实例,避免空指针异常
}
}
-
+
// 启动定期检查服务状态的计时器
void _startServiceCheckTimer() {
_serviceCheckTimer?.cancel();
@@ -92,7 +93,7 @@ class AudioServiceManager extends GetxService {
_checkAndRestartServiceIfNeeded();
});
}
-
+
// 检查服务状态,如果需要则重启服务
Future _checkAndRestartServiceIfNeeded() async {
if (!_isInitialized || _audioHandler == null) {
@@ -115,7 +116,7 @@ class AudioServiceManager extends GetxService {
await _audioHandler!.customAction('media_button');
} catch (e) {
print('发送媒体按钮事件失败: $e');
-
+
// 如果发送失败,尝试重新初始化服务
_isInitialized = false;
_hasAttemptedInit = false;
@@ -129,7 +130,7 @@ class AudioServiceManager extends GetxService {
await init();
}
}
-
+
// 手动触发媒体按钮事件(用于测试)
Future triggerMediaButtonEvent() async {
print('手动触发媒体按钮事件');
@@ -153,4 +154,4 @@ class AudioServiceManager extends GetxService {
super.onClose();
}
-}
\ No newline at end of file
+}
diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart
new file mode 100644
index 000000000..1f8b9593e
--- /dev/null
+++ b/lib/firebase_options.dart
@@ -0,0 +1,92 @@
+// File generated by FlutterFire CLI.
+// ignore_for_file: type=lint
+import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
+import 'package:flutter/foundation.dart'
+ show defaultTargetPlatform, kIsWeb, TargetPlatform;
+
+/// Default [FirebaseOptions] for use with your Firebase apps.
+///
+/// Example:
+/// ```dart
+/// import 'firebase_options.dart';
+/// // ...
+/// await Firebase.initializeApp(
+/// options: DefaultFirebaseOptions.currentPlatform,
+/// );
+/// ```
+class DefaultFirebaseOptions {
+ static FirebaseOptions get currentPlatform {
+ if (kIsWeb) {
+ return web;
+ }
+ switch (defaultTargetPlatform) {
+ case TargetPlatform.android:
+ return android;
+ case TargetPlatform.iOS:
+ return ios;
+ case TargetPlatform.macOS:
+ return macos;
+ case TargetPlatform.windows:
+ return windows;
+ case TargetPlatform.linux:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for linux - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ default:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions are not supported for this platform.',
+ );
+ }
+ }
+
+ static const FirebaseOptions web = FirebaseOptions(
+ apiKey: 'AIzaSyBJXQTXsEmY_XA7ZEOusxG6VF5CaKtjHCA',
+ appId: '1:907754492821:web:99451e7efd7d120a145c9c',
+ messagingSenderId: '907754492821',
+ projectId: 'deepsound-e0e3d',
+ authDomain: 'deepsound-e0e3d.firebaseapp.com',
+ storageBucket: 'deepsound-e0e3d.firebasestorage.app',
+ measurementId: 'G-ETX6DF35J3',
+ );
+
+ static const FirebaseOptions android = FirebaseOptions(
+ apiKey: 'AIzaSyAj0_-nS3ygc8VFe1azotSE3-HGZYClkTs',
+ appId: '1:907754492821:android:2deffc5aa1037ae2145c9c',
+ messagingSenderId: '907754492821',
+ projectId: 'deepsound-e0e3d',
+ storageBucket: 'deepsound-e0e3d.firebasestorage.app',
+ );
+
+ static const FirebaseOptions ios = FirebaseOptions(
+ apiKey: 'AIzaSyAvyBQcOXuO_q851vevqZIufsPRTMCe808',
+ appId: '1:907754492821:ios:8c1d7d1b583aec22145c9c',
+ messagingSenderId: '907754492821',
+ projectId: 'deepsound-e0e3d',
+ storageBucket: 'deepsound-e0e3d.firebasestorage.app',
+ androidClientId: '907754492821-9jakqvathu61e6b8g95i41ssi7o4dnka.apps.googleusercontent.com',
+ iosClientId: '907754492821-ej6j6pfto66jfhpj47b9bjs9amvo9dde.apps.googleusercontent.com',
+ iosBundleId: 'com.example.client',
+ );
+
+ static const FirebaseOptions macos = FirebaseOptions(
+ apiKey: 'AIzaSyAvyBQcOXuO_q851vevqZIufsPRTMCe808',
+ appId: '1:907754492821:ios:8c1d7d1b583aec22145c9c',
+ messagingSenderId: '907754492821',
+ projectId: 'deepsound-e0e3d',
+ storageBucket: 'deepsound-e0e3d.firebasestorage.app',
+ androidClientId: '907754492821-9jakqvathu61e6b8g95i41ssi7o4dnka.apps.googleusercontent.com',
+ iosClientId: '907754492821-ej6j6pfto66jfhpj47b9bjs9amvo9dde.apps.googleusercontent.com',
+ iosBundleId: 'com.example.client',
+ );
+
+ static const FirebaseOptions windows = FirebaseOptions(
+ apiKey: 'AIzaSyBJXQTXsEmY_XA7ZEOusxG6VF5CaKtjHCA',
+ appId: '1:907754492821:web:e3e8040111db6871145c9c',
+ messagingSenderId: '907754492821',
+ projectId: 'deepsound-e0e3d',
+ authDomain: 'deepsound-e0e3d.firebaseapp.com',
+ storageBucket: 'deepsound-e0e3d.firebasestorage.app',
+ measurementId: 'G-SKGXEK5TJM',
+ );
+}
diff --git a/lib/main.dart b/lib/main.dart
index e374b1554..69f1f51ad 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -11,26 +11,50 @@ import 'package:window_size/window_size.dart';
import 'core/translations/app_translations.dart';
import 'core/themes/app_theme.dart';
import 'core/themes/theme_service.dart';
+import 'modules/login/controllers/weixinLogin.dart';
+import 'package:firebase_core/firebase_core.dart';
+import 'firebase_options.dart';
void main() async {
// 确保Flutter绑定初始化
WidgetsFlutterBinding.ensureInitialized();
-
+
// 初始化存储 - 在创建应用之前初始化
await GetStorage.init();
-
+
// 初始化环境变量
await dotenv.load();
-
+
+ FlWX().register(
+ appSecret: '4cfde33bc22b6cc6b1f8b225dd97d255',
+ appId: 'wx5bbb7be9324f3e2d',
+ params: FlWXCallbackParams(onHttp: (url) async {
+ return '';
+ }));
+ var err = FlWX().isInstalled;
+ String msg = err.toString() == 'false' ? '请先下载微信app' : '请授权登录';
+
+ print(msg);
+
+ if (Firebase.apps.isEmpty) {
+ await Firebase.initializeApp(
+ name: 'DeepSound',
+ options: DefaultFirebaseOptions.currentPlatform,
+ //demoProjectId:'1:907754492821:android:2deffc5aa1037ae2145c9c'
+ ).then((value) {
+ // logger.i('Firebase Initialized:${value.options}');
+ print('Firebase Initialized:${value.options}');
+ });
+ }
// 设置窗口大小(仅在 macOS 下生效)
if (Platform.isMacOS) {
const double width = 375.0;
const double height = 812.0;
-
+
setWindowTitle('Deep Voice');
setWindowMinSize(const Size(width, height));
setWindowMaxSize(const Size(width, height));
-
+
// 居中显示窗口
final screen = await getCurrentScreen();
if (screen != null) {
@@ -43,7 +67,7 @@ void main() async {
setWindowFrame(windowFrame);
}
}
-
+
// 运行应用
runApp(const MainApp());
}
@@ -55,7 +79,7 @@ class MainApp extends StatelessWidget {
Widget build(BuildContext context) {
// 获取保存的主题设置
final themeMode = ThemeService().getThemeMode();
-
+
return ScreenUtilInit(
designSize: const Size(375, 812),
minTextAdapt: true,
@@ -73,7 +97,6 @@ class MainApp extends StatelessWidget {
translations: AppTranslations(),
locale: const Locale('zh', 'CN'),
fallbackLocale: const Locale('en', 'US'),
-
);
},
);
diff --git a/lib/modules/login/controllers/facebookLogin.dart b/lib/modules/login/controllers/facebookLogin.dart
new file mode 100644
index 000000000..d77ae2177
--- /dev/null
+++ b/lib/modules/login/controllers/facebookLogin.dart
@@ -0,0 +1,39 @@
+import 'package:firebase_auth/firebase_auth.dart';
+import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
+import 'package:get/get.dart';
+
+class Facebook {
+ String token = '';
+ // FaceBook登录
+ // 修改后的 signInWithFacebook
+ Future signInWithFacebook() async {
+ try {
+ print("开始 Facebook 登录");
+ final LoginResult result = await FacebookAuth.instance.login();
+ print("Facebook 登录结果:$result");
+
+ if (result.status == LoginStatus.success) {
+ token = result.accessToken!.tokenString;
+ print("Facebook Token: $token");
+
+ final credential = FacebookAuthProvider.credential(token);
+ print("Facebook Token: $credential");
+ final userData = await FacebookAuth.instance.getUserData();
+ print("user login facebook ${userData..values}");
+
+ return true;
+ } else {
+ print("登录失败,状态:${result.status},消息:${result.message}");
+ return false;
+ }
+ } catch (e) {
+ print("Facebook 登录异常:$e");
+ return false;
+ }
+ }
+
+ // 退出Google登录
+ Future signOutFacebook() async {
+ await FacebookAuth.instance.logOut();
+ }
+}
diff --git a/lib/modules/login/controllers/googleLogin.dart b/lib/modules/login/controllers/googleLogin.dart
new file mode 100644
index 000000000..3e118e6f8
--- /dev/null
+++ b/lib/modules/login/controllers/googleLogin.dart
@@ -0,0 +1,72 @@
+import 'package:firebase_auth/firebase_auth.dart';
+import 'package:google_sign_in/google_sign_in.dart';
+import 'package:get/get.dart';
+
+class Google {
+ String? token = '';
+ String? email = '';
+ String? displayName = '';
+ String? id = '';
+ String? accessToken = '';
+
+ // 登录并返回
+ Future signInWithGoogle() async {
+ try {
+ // 确保用户已经登录,并获取当前用户的身份验证令牌
+ final currentUser = FirebaseAuth.instance.currentUser;
+ print('Future响应数据: $currentUser');
+ if (currentUser != null) {
+ // 这里处理您需要使用这个JWT令牌的逻辑,例如将它存储到本地存储中作为凭据。
+
+ token != await currentUser.getIdToken();
+
+ print('Future响应数据tokenResult: $token');
+
+ return true;
+ } else {
+ UserCredential userCredential = await loginGoogle();
+ if (token != "") {
+ return true;
+ } else {
+ return false;
+ }
+
+ // logger.d("user login google: ${userCredential.user?.displayName}");
+ }
+ } catch (e) {
+ print("Google 登录异常:$e");
+ return false;
+ }
+ }
+
+ // Google登录
+ Future loginGoogle() async {
+ print('loginGoogle:');
+ final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
+ email = googleUser?.email;
+ id = googleUser?.id;
+ displayName = googleUser?.displayName;
+ print('loginGoogle: $googleUser');
+ // Obtain the auth details from the request
+ final GoogleSignInAuthentication? googleAuth =
+ await googleUser?.authentication;
+ accessToken = googleAuth?.accessToken;
+ token = googleAuth?.idToken;
+ print('loginGoogle:googleAuth?.idToken= ${token}');
+ print('loginGoogle:googleAuth?.accessToken= ${accessToken}');
+ // Create a new credential,
+ final credential = GoogleAuthProvider.credential(
+ accessToken: googleAuth?.accessToken,
+ idToken: googleAuth?.idToken,
+ );
+
+ // Once signed in, return the UserCredential
+ return await FirebaseAuth.instance.signInWithCredential(credential);
+ }
+
+ // 退出Google登录
+ Future signOutGoogle() async {
+ await FirebaseAuth.instance.signOut();
+ await GoogleSignIn().signOut();
+ }
+}
diff --git a/lib/modules/login/controllers/weixinLogin.dart b/lib/modules/login/controllers/weixinLogin.dart
new file mode 100644
index 000000000..214c5a663
--- /dev/null
+++ b/lib/modules/login/controllers/weixinLogin.dart
@@ -0,0 +1,889 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+import 'dart:typed_data';
+import 'package:fluwx/fluwx.dart';
+export 'package:fluwx/fluwx.dart';
+import 'package:http/http.dart' as http;
+import 'package:get/get.dart';
+
+typedef FlWeChatResponseCallback = void Function(WeChatResponse response);
+
+/// 支持成功
+typedef FlWeChatPayResponseResultCallback = void Function();
+
+/// 支付结果回调
+typedef FlWeChatPayResponseCallback = void Function(
+ WeChatPaymentResponse response);
+
+/// LaunchFromWX 回调
+typedef FlWeChatLaunchFromWXRequestCallback = void Function(
+ WeChatLaunchFromWXRequest response);
+
+/// OpenBusinessWebView 回调
+typedef FlWeChatOpenBusinessWebViewResponseCallback = void Function(
+ WeChatOpenBusinessWebviewResponse response);
+
+/// WeChatOpenBusinessView 回调
+typedef FlWeChatOpenBusinessViewResponseCallback = void Function(
+ WeChatOpenBusinessViewResponse response);
+
+/// Share 回调
+typedef FlWeChatShareResponseCallback = void Function(
+ WeChatShareResponse response);
+
+/// Auth 回调
+typedef FlWeChatAuthResponseCallback = Function(WeChatAuthResponse response);
+
+/// Auth token 回调
+typedef FlWeChatAuthResponseTokenCallback = Function(
+ WeChatAuthResponse response, WXTokenModel token);
+
+/// Auth userinfo 回调
+typedef FlWeChatAuthResponseUserinfoCallback = Function(
+ WeChatAuthResponse response,
+ WXTokenModel token,
+ WXUserModel userInfo,
+);
+
+/// 显示 toast
+typedef FlWXToastCallback = void Function(String msg);
+
+/// 日志 打印
+typedef FlWXLogCallback = void Function(String msg);
+
+/// http 请求
+typedef FlWXHTTPCallback = Future Function(String url);
+
+class FlWX {
+ factory FlWX() => _singleton ??= FlWX._();
+
+ FlWX._();
+
+ static FlWX? _singleton;
+
+ final Fluwx fluwx = Fluwx();
+
+ String? _appId;
+
+ /// 获取当前设置的 appId
+ String? get appId => _appId;
+
+ String? _appSecret;
+
+ /// 获取当前设置的 appSecret
+ String? get appSecret => _appSecret;
+
+ String _appName = '';
+ String token = '';
+ String refresh_token = '';
+ String openid = '';
+ // 参数 说明
+ // access_token 接口调用凭证
+ // expires_in access_token 接口调用凭证超时时间,单位(秒)
+ // refresh_token 用户刷新 access_token
+ // openid 授权用户唯一标识
+ // scope 用户授权的作用域(snsapi_userinfo)
+ // unionid 当且仅当该移动应用已获得该用户的 userinfo 授权时,才会出现该字段
+ /// callback params
+ FlWXCallbackParams? _params;
+
+ /// 分享时的缩略图
+ Uint8List? _shareThumbnail;
+
+ /// register
+ bool _isRegister = false;
+
+ Future register({
+ required String appId,
+ required FlWXCallbackParams params,
+ String? universalLink,
+ bool doOnIOS = true,
+ bool doOnAndroid = true,
+
+ /// 用于获取用户信息
+ String? appSecret,
+
+ /// app名称(用于分享时使用)
+ String appName = '',
+
+ /// 分享时的缩略图
+ Uint8List? shareThumbnail,
+ }) {
+ assert(appId.isNotEmpty);
+ if (universalLink != null) assert(universalLink.isNotEmpty);
+ if (appSecret != null) {
+ assert(appSecret.isNotEmpty);
+ }
+ _isRegister = true;
+ _appId = appId;
+ _appSecret = appSecret;
+ _appName = appName;
+ _shareThumbnail = shareThumbnail;
+ _params = params;
+ return fluwx.registerApi(
+ appId: appId,
+ doOnAndroid: doOnAndroid,
+ doOnIOS: doOnIOS,
+ universalLink: universalLink,
+ );
+ }
+
+ /// 获取微信 用户token
+ String _getTokenUrl(String code) {
+ print("_getTokenUrl 数据获取${_appId},${_appSecret}");
+ assert(
+ _appId != null &&
+ _appId!.isNotEmpty &&
+ _appSecret != null &&
+ _appSecret!.isNotEmpty,
+ );
+ return 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=$_appId&secret=$_appSecret&code=$code&grant_type=authorization_code';
+ }
+
+ /// 获取微信 用户token
+ String _getRefreshTokenUrl(String code) {
+ print("_getRefreshTokenUrl 数据获取${_appId},${_appSecret}");
+ assert(
+ _appId != null &&
+ _appId!.isNotEmpty &&
+ _appSecret != null &&
+ _appSecret!.isNotEmpty,
+ );
+ return 'https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=$_appId&grant_type=refresh_token&&refresh_token=$refresh_token';
+ }
+
+ // GET请求示例
+ Future