diff --git a/lib/core/themes/language/lang/en_us.dart b/lib/core/themes/language/lang/en_us.dart new file mode 100644 index 000000000..a767d5d7d --- /dev/null +++ b/lib/core/themes/language/lang/en_us.dart @@ -0,0 +1,93 @@ +const Map enUS = { + "bottomNavHome": "home", + "bottomNavSleep": "sleep", + "bottomNavProfile": "profile", + "requestCancellation": "Request cancellation", + "connectionTimeout": "Connection timeout", + "requestTimeout": "Request timeout", + "responseTimeout": "Response timeout", + "unknownError": "Unknown error", + "welcomeHint": "DeepSound makes communication smoother", + "loginTitle": "Login/Register", + "contactCustomerService": "Connection", + "phoneHint": "Please enter your phone number", + "phoneError": "Wrong phone number!", + "emailHint": "Please enter email", + "emailError": "Email input error, please re-enter!", + "codeHint": "Please enter the verification code", + "codeError": "Verification code error", + "pleaseAgreeToTerms": + "Please check the box to agree to our Terms and Privacy Policy", + "getCode": "Get code", + "reacquireCode": "S Reacquire", + "bind": "Deterministic binding", + "login": "Login", + "otherLogin": "Other login methods", + "readAndAgree": "I have read and agree", + "serviceAgreement": " User Service Agreement ", + "and": "And", + "privacyAgreement": " User Privacy Agreement ", + "codeSend": "Verification code has been sent, please check email!", + "connectHeadphones": "Connect headphones", + "bindHeadphones": "Bind headphones", + "intelligentTool": "Intelligent tool", + "sessionMode": "AI conversation mode", + "translation": "Simultaneous translation", + "together": "Face-to-face translation", + "telephoneVoice": "Telephone translation", + "translationRecord": "Translation record", + "bindDevice": "Bind device", + "bound": "Bound", + "appVersion": "APP version", + "languageSetting": "Language setting", + "followingSystem": "Following system", + "userAgreement": "User agreement", + "privacyDeal": "Privacy agreement", + "chinese": "Chinese", + "english": "English", + "chineseComplex": "Chinese (Traditional)", + "japanese": "Japanese", + "korean": "Korean", + "russian": "Russian", + "french": "French", + "qrCode": "Authorization code or QR code", + "link": "Link", + "copy": "Copy", + "successfulReplication": "Successful replication", + "edit": "Edit", + "delete": "Delete", + "aiDialogue": "AI dialogue", + "initialChatMessage": + "Hi, I'm your new friend! Nice to meet you for the first time. I can answer your various questions, provide help with your work and studies, and even chat with you anytime. So, what would you like to ask?", + "defaultContent1": "Help me write a Python web scraper code", + "defaultContent2": "Help me plan a short video script", + "defaultContent3": "Help me design a mind-exercising game", + "defaultContent4": "Recommend a cost-effective phone", + "defaultContent5": "Come up with a creative name for my Honor of Kings ID", + "defaultContent6": + "Guide me on using Python to scrape real-time weather data", + "defaultContent7": "Tell me daily habits to boost kidney qi", + "defaultContent8": "Help me understand the basics of CNC programming", + "defaultContent9": "Help me find a short folk story", + "defaultContent10": "Recommend a cost-effective SUV", + "defaultContent11": "Teach me to make a small game using Python", + "defaultContent12": "Introduce some free-to-play mobile games", + "holdToSpeak": "Hold to speak", + "tapToSpeak": "Click to talk", + "hangUp": "Hang up", + "holdToStartSpeak": "Hold down and start talking", + "tapToStartSpeak": "Click to start Talking", + "sendMessage": "Ask me anything you want", + "beTalking": "Be talking ...", + "headphonesBeTalking": "Talking through headphones...", + "interlanguage": "Cannot choose the same language", + "notice": "Look out", + "connectingDevice": "Please set up the connected device first", + "bindDeviceTips": "Unbind the device first", + "cancel": "Cancel", + "confirm": "Confirm", + "goToSettings": "Go to Settings", + "goToBind": "Unbind", + "scanQrCode": "Scan the QR code", + "endRecording": "Do you want to end the recording?", +}; diff --git a/lib/core/themes/language/lang/zh_cn.dart b/lib/core/themes/language/lang/zh_cn.dart new file mode 100644 index 000000000..07806c5cb --- /dev/null +++ b/lib/core/themes/language/lang/zh_cn.dart @@ -0,0 +1,91 @@ +const Map zhCN = { + "bottomNavHome": "首页", + "bottomNavSleep": "睡眠", + "bottomNavProfile": "我的", + "requestCancellation": "请求取消", + "connectionTimeout": "连接超时", + "requestTimeout": "请求超时", + "responseTimeout": "响应超时", + "unknownError": "未知错误", + "welcomeHint": "DeepSound让沟通更顺畅", + "loginTitle": "登录/注册账号", + "contactCustomerService": "联系客服", + "phoneHint": "请输入手机号", + "phoneError": "手机号码错误!", + "emailHint": "请输入邮箱", + "emailError": "邮箱输入错误,请重新输入!", + "codeHint": "请输入验证码", + "codeError": "验证码错误", + "pleaseAgreeToTerms": "请勾选以同意用户协议和隐私政策", + "getCode": "获取验证码", + "reacquireCode": "S后重新获取", + "bind": "确定绑定", + "login": "登录", + "otherLogin": "其他登录方式", + "readAndAgree": "我已阅读并同意", + "serviceAgreement": "《用户服务协议》", + "and": "和", + "privacyAgreement": "《用户隐私协议》", + "codeSend": "验证码已发送,请到邮箱查看!", + "connectHeadphones": "请连接耳机", + "bindHeadphones": "请绑定耳机", + "intelligentTool": "智能工具", + "sessionMode": "AI对话模式", + "translation": "同声传译", + "together": "面对面翻译", + "telephoneVoice": "通话语音翻译", + "translationRecord": "翻译记录", + "bindDevice": "绑定设备", + "bound": "已绑定", + "appVersion": "APP版本", + "languageSetting": "语言设置", + "followingSystem": "跟随系统", + "userAgreement": "用户协议", + "privacyDeal": "隐私协议", + "chinese": "中文", + "english": "英语", + "chineseComplex": "中文(繁体)", + "japanese": "日语", + "korean": "韩语", + "russian": "俄语", + "french": "法语", + "qrCode": "授权码或二维码", + "link": "链接", + "copy": "复制", + "successfulReplication": "复制成功", + "edit": "编辑", + "delete": "删除", + "aiDialogue": "AI对话", + "initialChatMessage": + "嗨,我是你的新朋友!初次见面很开心。我呢,可以回答你的各种问题,给你工作学习上提供帮助,还能随时陪你聊天。嗯,你想问点什么呢?", + "defaultContent1": "请帮我写个Python爬虫代码", + "defaultContent2": "帮我策划一个短视频脚本", + "defaultContent3": "请帮我设计一个锻炼思维的小游戏", + "defaultContent4": "请推荐一部性价比高的手机", + "defaultContent5": "帮我想一个王者ID的创意名称", + "defaultContent6": "请指导我使用Python爬取实时天气数据", + "defaultContent7": "告诉我补肾气的日常习惯", + "defaultContent8": "帮我了解CNC编程的基础知识", + "defaultContent9": "帮我找一个简短的民间故事", + "defaultContent10": "给我推荐一辆性价比高的SUV", + "defaultContent11": "教我用Python制作小游戏", + "defaultContent12": "介绍一些适合零氪玩家的手游", + "holdToSpeak": "按住说话", + "tapToSpeak": "点击说话", + "hangUp": "挂断", + "holdToStartSpeak": "按住开始说话", + "tapToStartSpeak": "点击开始说话", + "sendMessage": "有什么问的尽管问我", + "beTalking": "正在说话...", + "headphonesBeTalking": "正在使用耳机说话...", + "interlanguage": "不能选择同语种", + "notice": "注意", + "connectingDevice": "请先去设置连接设备", + "bindDeviceTips": "请先去绑定设备", + "cancel": "取消", + "confirm": "确定", + "goToSettings": "去设置", + "goToBind": "去绑定", + "scanQrCode": "扫描二维码", + "endRecording": "你想结束录音吗?", +}; diff --git a/lib/core/themes/language/translation_service.dart b/lib/core/themes/language/translation_service.dart new file mode 100644 index 000000000..6ca44bda0 --- /dev/null +++ b/lib/core/themes/language/translation_service.dart @@ -0,0 +1,18 @@ +import 'dart:ui'; + +import 'package:get/get.dart'; + +import 'lang/en_us.dart'; +import 'lang/zh_cn.dart'; + +class TranslationService extends Translations { + static Locale? get locale => Get.deviceLocale; + static final fallbackLocale = Locale('zh', 'CN'); + static final supportedLocales = [ + const Locale('zh', 'CN'), + const Locale('en', 'US'), + ]; + + @override + Map> get keys => {'en_US': enUS, 'zh_CN': zhCN}; +} diff --git a/lib/data/models/user_Info.dart b/lib/data/models/user_Info.dart index 32662c615..ecbbaf33e 100644 --- a/lib/data/models/user_Info.dart +++ b/lib/data/models/user_Info.dart @@ -70,6 +70,30 @@ class User { // createtime: _parseTimestamp(userData['createtime']), // wxopenid: (userData?['wxopenid'] as String?) ?? '', // googleopenid: (userData?['googleopenid'] as String?) ?? '', +// facebookopenid: (userData?['facebookopenid'] as String?) ?? '', + ); + } + factory User.fronTokenJson(Map json) { + // 修复1:安全获取嵌套的 user 字段 + final userData = json['user'] as Map?; // 允许空值 + final token = ''; + // 更新单例实例 + return _instance = User._( + token: token as String? ?? '', + name: (userData?['name'] as String?) ?? '默认名称', // 提供默认值 + uid: (userData?['uid'] as String?) ?? '', + avatar: (userData?['avatar'] as String?) ?? '', + deviceid: (userData?['deviceid'] as String?) ?? '', + language: (userData?['language'] as String?) ?? 'en', + + mail: (userData?['mail'] as String?) ?? '', + phone: (userData?['phone'] as String?) ?? '', + phonemac: (userData?['phonemac'] as String?) ?? '', + password: (userData?['password'] as String?) ?? '', +// lastbettime: _parseTimestamp(userData['lastbettime']), +// createtime: _parseTimestamp(userData['createtime']), +// wxopenid: (userData?['wxopenid'] as String?) ?? '', +// googleopenid: (userData?['googleopenid'] as String?) ?? '', // facebookopenid: (userData?['facebookopenid'] as String?) ?? '', ); } diff --git a/lib/data/services/network/api.dart b/lib/data/services/network/api.dart index 84ff33446..48e3758c1 100644 --- a/lib/data/services/network/api.dart +++ b/lib/data/services/network/api.dart @@ -4,6 +4,7 @@ import 'nw_method.dart'; class Api { // 登录 static login([params]) { + print("请求后台数据params=${params}"); return DioManager().request( NWMethod.post, '/api/home/user_sgin', @@ -20,6 +21,15 @@ class Api { ); } + static tokenlogin([params]) { + print("请求后台数据params=${params}"); + return DioManager().request( + NWMethod.post, + '/api/home/user_getinfo', + params: params, + ); + } + // 获取阿里token static getAliToken([params]) { return DioManager().request( diff --git a/lib/data/services/network/auth_interceptor.dart b/lib/data/services/network/auth_interceptor.dart index 655751e4c..4fceb6d4e 100644 --- a/lib/data/services/network/auth_interceptor.dart +++ b/lib/data/services/network/auth_interceptor.dart @@ -1,65 +1,66 @@ -// import 'package:dio/dio.dart'; -// import 'package:flutter_easyloading/flutter_easyloading.dart'; -// import 'package:get/get.dart' hide Response; +import 'package:dio/dio.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:get/get.dart' hide Response; -// import '../scenes/start/start_logic.dart'; -// import 'entity/base_entity.dart'; +import 'package:get_storage/get_storage.dart'; +import 'entity/base_entity.dart'; -// class AuthInterceptor extends Interceptor { -// final state = Get.find().state; +class AuthInterceptor extends Interceptor { + final GetStorage _storage = GetStorage(); -// @override -// void onRequest(RequestOptions options, RequestInterceptorHandler handler) { -// options.headers['Authorization'] = state.loginModel.token; -// handler.next(options); -// } + @override + void onRequest(RequestOptions options, RequestInterceptorHandler handler) { + var jsonString = _storage.read("logintoken"); + options.headers['Authorization'] = jsonString; + handler.next(options); + } -// @override -// void onResponse(Response response, ResponseInterceptorHandler handler) async { -// BaseEntity entity = BaseEntity.fromJson(response.data); -// if (entity.code == 0) { -// response.data = entity.data ?? {}; -// handler.resolve(response); -// } else { -// response.data = null; -// handler.next(response); -// return EasyLoading.showError(entity.message ?? 'unknownError'.tr); -// } -// } + @override + void onResponse(Response response, ResponseInterceptorHandler handler) async { + BaseEntity entity = BaseEntity.fromJson(response.data); + if (entity.code == 0) { + response.data = entity.data ?? {}; + handler.resolve(response); + } else { + response.data = null; + handler.next(response); + return EasyLoading.showError(entity.message ?? 'unknownError'.tr); + } + } -// @override -// void onError(DioException err, ErrorInterceptorHandler handler) { -// switch (err.type) { -// case DioExceptionType.cancel: -// { -// EasyLoading.showError('requestCancellation'.tr); -// } -// case DioExceptionType.connectionTimeout: -// { -// EasyLoading.showError('connectionTimeout'.tr); -// } -// case DioExceptionType.sendTimeout: -// { -// EasyLoading.showError('requestTimeout'.tr); -// } -// case DioExceptionType.receiveTimeout: -// { -// EasyLoading.showError('responseTimeout'.tr); -// } -// case DioExceptionType.badResponse: -// { -// try { -// String? errMsg = err.response?.statusMessage; -// EasyLoading.showError(errMsg ?? 'unknownError'.tr); -// } on Exception catch (_) { -// EasyLoading.showError('unknownError'.tr); -// } -// } -// default: -// { -// EasyLoading.showError(err.message ?? 'unknownError'.tr); -// } -// } -// handler.next(err); -// } -// } + @override + void onError(DioException err, ErrorInterceptorHandler handler) { + switch (err.type) { + case DioExceptionType.cancel: + { + EasyLoading.showError('requestCancellation'.tr); + } + case DioExceptionType.connectionTimeout: + { + EasyLoading.showError('connectionTimeout'.tr); + } + case DioExceptionType.sendTimeout: + { + EasyLoading.showError('requestTimeout'.tr); + } + case DioExceptionType.receiveTimeout: + { + EasyLoading.showError('responseTimeout'.tr); + } + case DioExceptionType.badResponse: + { + try { + String? errMsg = err.response?.statusMessage; + EasyLoading.showError(errMsg ?? 'unknownError'.tr); + } on Exception catch (_) { + EasyLoading.showError('unknownError'.tr); + } + } + default: + { + EasyLoading.showError(err.message ?? 'unknownError'.tr); + } + } + handler.next(err); + } +} diff --git a/lib/data/services/network/dio_manager.dart b/lib/data/services/network/dio_manager.dart index a41e81228..10952e905 100644 --- a/lib/data/services/network/dio_manager.dart +++ b/lib/data/services/network/dio_manager.dart @@ -20,7 +20,7 @@ class DioManager { ); dio = Dio(options); - +//fdp // dio.interceptors.add(AuthInterceptor()); } diff --git a/lib/modules/login/controllers/googleLogin.dart b/lib/modules/login/controllers/googleLogin.dart index 36a080cc6..196699b15 100644 --- a/lib/modules/login/controllers/googleLogin.dart +++ b/lib/modules/login/controllers/googleLogin.dart @@ -6,6 +6,7 @@ class Google { String? token = ''; String? email = ''; String? displayName = ''; + String? pictureurl = ''; String? id = ''; String? accessToken = ''; @@ -21,6 +22,8 @@ class Google { email = currentUser.email; displayName = currentUser.displayName; id = currentUser.uid; + pictureurl = currentUser.photoURL; + print('Future响应数据pictureurl: $pictureurl'); token = await currentUser.getIdToken(); print('Future响应数据tokenResult: $token'); @@ -51,6 +54,7 @@ class Google { email = googleUser?.email; id = googleUser?.id; displayName = googleUser?.displayName; + pictureurl = googleUser?.photoUrl; print('loginGoogle: $googleUser'); print("user login loginGoogle ${email}${id}${displayName}"); diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index 142c71ca7..2f8720cc7 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -3,11 +3,10 @@ import 'package:flutter/material.dart'; import '../../../routes/app_routes.dart'; import 'dart:convert'; import 'dart:ffi'; -import '../../settings/controllers/settings_controller.dart'; import 'facebookLogin.dart'; import 'googleLogin.dart'; import 'weixinLogin.dart'; -import '../entity/api.dart'; +import '../../../data/services/network/api.dart'; import '../../../../data/models/user_Info.dart'; //import 'package:shared_preferences/shared_preferences.dart'; import 'package:get_storage/get_storage.dart'; @@ -155,6 +154,7 @@ class LoginController extends GetxController { } else { _displayContact.value = contact; } + loginType = 0; } else if (RegExp(r'^\d+$').hasMatch(contact)) { // 手机号 if (contact.length > 7) { @@ -165,6 +165,7 @@ class LoginController extends GetxController { } else { _displayContact.value = contact; } + loginType = 1; } else { _displayContact.value = contact; } @@ -181,9 +182,18 @@ class LoginController extends GetxController { } // 发送验证码 - void _sendVerificationCode() { + Future _sendVerificationCode() async { // 这里应该是实际发送验证码的逻辑 // 为了演示,我们只是模拟发送 + var response = await Api.getCode({ + "addr": contactController.text, + "vtype": 0, + }); + if (response != null) { + print("请求后台数据验证码params=${response}"); + //短信已发送 + //EasyLoading.showInfo('codeSend'.tr); + } } // 重新发送验证码 @@ -212,6 +222,21 @@ class LoginController extends GetxController { return !_verificationCode.contains(''); } + Future getLoginToken() async { + // 使用正确语法创建请求头 + var response = await Api.tokenlogin(); + if (response != null) { + if (response?["code"] == null) { + final user = User.fronTokenJson(response); + await _storage.write( + 'user', jsonEncode(user.toJson())); // 使用 user.toJson() + Get.offAllNamed(Routes.pairing); + } + } else { + login(); + } + } + // 登录 Future login() async { // 暂时关闭验证码验证 @@ -229,10 +254,37 @@ class LoginController extends GetxController { _isLoading.value = true; try { - // 模拟验证过程 await Future.delayed(const Duration(seconds: 2)); + // 模拟验证过程 + switch (loginType) { - case 1: + case 0 || 1: + { + // if (!isVerificationCodeComplete()) { + // Get.snackbar( + // '提示', + // '请输入完整的验证码', + // snackPosition: SnackPosition.TOP, + // backgroundColor: Colors.red.withOpacity(0.1), + // colorText: Colors.red, + // ); + // break; + // } + requestLogin({ + "mail": contactController.text, + "phone": "", + "stype": loginType, + "vcode": verificationCodeController.text, + "ttoken": "", + "phonemodel": "", + "phonemac": "", + "name": "", + "avatar": "", + }); + break; + } + + case 4: { print("数据获取Facebook"); final facebook = Facebook(); @@ -240,6 +292,8 @@ class LoginController extends GetxController { print("数据获取Facebook().token${authResult}"); if (authResult) { print("数据获取_Facebook.token${facebook.token}"); + print("数据获取_Facebook.pictureurl${facebook.pictureurl}"); + print("数据获取_Facebook.pictureurl${facebook.email}"); // SettingsController().userName = Facebook().name; // SettingsController().avatar = Facebook().pictureurl; // SettingsController().userId = Facebook().id; @@ -247,37 +301,50 @@ class LoginController extends GetxController { // 验证成功,跳转到配对页面 requestLogin({ - "email": facebook.email, + "mail": facebook.email, + "phone": "", + "stype": loginType, + "vcode": "", + "ttoken": facebook.token, + "phonemodel": "", + "phonemac": "", "name": facebook.name, "avatar": facebook.pictureurl, - "stype": 4, - "ttoken": facebook.token, }); } break; } - case 2: + case 3: { print("数据获取_Google()"); final google = Google(); bool authResult = await google.signInWithGoogle(); print("数据获取_Google().token${authResult}"); if (authResult) { + print("数据获取_Google.token${google.token}"); + print("数据获取_Google.pictureurl${google.pictureurl}"); + print("数据获取_Google.email${google.email}"); + print("数据获取_Google.email${google.displayName}"); // 验证成功,跳转到配对页面 // SettingsController().userName = Google().displayName!; // //SettingsController().avatar = Google().email; // SettingsController().userId = Google().id!; requestLogin({ - "name": google.displayName, - "email": google.email, - "stype": 3, + "mail": google.email, + "phone": "", + "stype": loginType, + "vcode": "", "ttoken": google.token, + "phonemodel": "", + "phonemac": "", + "name": google.displayName, + "avatar": google.pictureurl, }); } break; } - case 3: + case 2: { print("数据获取_FlWX()"); @@ -297,10 +364,15 @@ class LoginController extends GetxController { // SettingsController().avatar = FlWX().headimgurl; // SettingsController().userId = FlWX().openid; requestLogin({ + "mail": "", + "phone": "", + "stype": loginType, + "vcode": "", + "ttoken": FlWX().code, + "phonemodel": "", + "phonemac": "", "name": FlWX().nickname, "avatar": FlWX().headimgurl, - "stype": 2, - "ttoken": FlWX().code, }); // 验证成功,跳转到配对页面 } @@ -333,35 +405,16 @@ class LoginController extends GetxController { // 使用登陆请求服务器 Future requestLogin(Map params) async { - // switch (loginType) { - // case 0: //邮箱 - // { - // String verificationCode = verificationCodeController.text; - // String contactControll22er = contactController.text; - // } - // case 1: //手机号 - // { - // String verificationCode = verificationCodeController.text; - // String contactContr22oller = contactController.text; - // } - // case 2: //微信 - // {} - // case 3: //谷歌 - // {} - // case 4: //facebook - // {} - // } - var response = await Api.login({ - "mail": params?["mail"].toString() ?? "", - "phone": params?["phone"].toString() ?? "", + "mail": params["mail"], + "phone": params["phone"], "stype": params["stype"], - "vcode": params?["vcode"].toString() ?? "", - "ttoken": params?["ttoken"].toString() ?? "", - "phonemodel": params?["phonemodel"].toString() ?? "", - "phonemac": params?["phonemac"].toString() ?? "", - "name": params?["name"].toString() ?? "", - "avatar": params?["avatar"].toString() ?? "", + "vcode": params["vcode"], + "ttoken": params["ttoken"], + "phonemodel": params["phonemodel"], + "phonemac": params["phonemac"], + "name": params["name"], + "avatar": params["avatar"], }); if (response != null) { print("请求后台数据login回复数据=${response}"); @@ -372,13 +425,12 @@ class LoginController extends GetxController { try { print('响应数据: ${response.toString()}'); // 调试输出原始数据 - if (response['code'].toString() == '0' && - response['msg'].toString() == "Success") { + if (response['code'].toString() == '0') { // 新增:检查 user 字段是否存在且类型正确 if (response.containsKey('data') && response['data'] is Map) { final user = User.fromJson(response); - print('用户初始化成功: ${user.name}'); - + print('用户初始化成功: ${user.token}'); + await _storage.write("logintoken", user.token); // 存储到 SharedPreferences (仅存储用户数据) //final prefs = await GetStorage(); await _storage.write( diff --git a/lib/modules/login/entity/api.dart b/lib/modules/login/entity/api.dart deleted file mode 100644 index 22c78ce9d..000000000 --- a/lib/modules/login/entity/api.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'dio_manager.dart'; -import 'nw_method.dart'; - -class Api { - // 登录 - static login([params]) { - print("请求后台数据params=${params}"); - return DioManager().request( - NWMethod.post, - '/api/home/user_sgin', - params: params, - ); - } - - // 获取验证码 - static getCode([params]) { - return DioManager().request( - NWMethod.post, - '/api/home/user_verification', - params: params, - ); - } - - // 获取阿里token - static getAliToken([params]) { - return DioManager().request( - NWMethod.post, - '/api/home/auth_alitoken', - params: params, - ); - } -} diff --git a/lib/modules/login/entity/dio_manager.dart b/lib/modules/login/entity/dio_manager.dart deleted file mode 100644 index 0635524c0..000000000 --- a/lib/modules/login/entity/dio_manager.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:dio/dio.dart'; - -//import 'auth_interceptor.dart'; -import 'nw_api.dart'; -import 'nw_method.dart'; - -class DioManager { - static final DioManager _shared = DioManager._internal(); - factory DioManager() => _shared; - - late Dio dio; - - DioManager._internal() { - BaseOptions options = BaseOptions( - baseUrl: NWApi.baseApi, - contentType: Headers.jsonContentType, - responseType: ResponseType.json, - connectTimeout: const Duration(seconds: 30), - receiveTimeout: const Duration(seconds: 30), - ); - - dio = Dio(options); - - //dio.interceptors.add(AuthInterceptor()); - } - - // 请求,返回参数为 T - // method:请求方法,NWMethod.POST等 - // path:请求地址 - // params:请求参数 - Future request( - NWMethod method, - String path, { - Map? params, - Map? queryParameters, - }) async { - Response response = await dio.request( - path, - data: params, - queryParameters: queryParameters, - options: Options(method: nwMethodValues[method]), - ); - return response.data; - } -} diff --git a/lib/modules/login/entity/nw_api.dart b/lib/modules/login/entity/nw_api.dart deleted file mode 100644 index 875a166b6..000000000 --- a/lib/modules/login/entity/nw_api.dart +++ /dev/null @@ -1,4 +0,0 @@ -class NWApi { - // static const baseApi = "https://www.deapsound.com"; - static const baseApi = "https://www.deapsound.com"; -} diff --git a/lib/modules/login/entity/nw_method.dart b/lib/modules/login/entity/nw_method.dart deleted file mode 100644 index f79ca96e3..000000000 --- a/lib/modules/login/entity/nw_method.dart +++ /dev/null @@ -1,8 +0,0 @@ -enum NWMethod { get, post, delete, put } - -const nwMethodValues = { - NWMethod.get: "get", - NWMethod.post: "post", - NWMethod.delete: "delete", - NWMethod.put: "put" -}; diff --git a/lib/modules/login/views/login_view.dart b/lib/modules/login/views/login_view.dart index 85581536e..84a3aa649 100644 --- a/lib/modules/login/views/login_view.dart +++ b/lib/modules/login/views/login_view.dart @@ -3,10 +3,6 @@ import 'package:get/get.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../controllers/login_controller.dart'; -import '../controllers/facebookLogin.dart'; -import '../controllers/googleLogin.dart'; -import '../controllers/weixinLogin.dart'; -import '../../../core/themes/app_theme.dart'; class LoginView extends GetView { const LoginView({Key? key}) : super(key: key); @@ -397,17 +393,17 @@ class LoginView extends GetView { switch (icon) { case FontAwesomeIcons.facebook: { - controller.loginType = 1; + controller.loginType = 4; break; } case FontAwesomeIcons.google: { - controller.loginType = 2; + controller.loginType = 3; break; } case FontAwesomeIcons.weixin: { - controller.loginType = 3; + controller.loginType = 2; break; } } diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index e545a083c..773d442d3 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -17,6 +17,8 @@ class SettingsView extends GetView { String get userId => User.getuserId(); String get standing => User.getstanding(); String get avatar => User.getnavatar(); + //String get avatar => + //"https://lh3.googleusercontent.com/a/ACg8ocJw96pHqo3uceyxyrWziQr8eGS-CZZ_NhRBNC_EvmGkAyf6TQ=s96-c"; @override Widget build(BuildContext context) { // 直接使用 Theme.of(context) 获取当前主题 diff --git a/lib/modules/splash/controllers/splash_controller.dart b/lib/modules/splash/controllers/splash_controller.dart index c0b4cf9fe..6883c6487 100644 --- a/lib/modules/splash/controllers/splash_controller.dart +++ b/lib/modules/splash/controllers/splash_controller.dart @@ -84,4 +84,5 @@ class SplashController extends GetxController { Get.offAllNamed(Routes.login); }); } + // fdp挑转登陆 }