16 changed files with 406 additions and 203 deletions
@ -0,0 +1,93 @@ |
|||
const Map<String, String> 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?", |
|||
}; |
|||
@ -0,0 +1,91 @@ |
|||
const Map<String, String> 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": "你想结束录音吗?", |
|||
}; |
|||
@ -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<String, Map<String, String>> get keys => {'en_US': enUS, 'zh_CN': zhCN}; |
|||
} |
|||
@ -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<StartLogic>().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<String>("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); |
|||
} |
|||
} |
|||
|
|||
@ -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, |
|||
); |
|||
} |
|||
} |
|||
@ -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<T>( |
|||
NWMethod method, |
|||
String path, { |
|||
Map? params, |
|||
Map<String, dynamic>? queryParameters, |
|||
}) async { |
|||
Response response = await dio.request( |
|||
path, |
|||
data: params, |
|||
queryParameters: queryParameters, |
|||
options: Options(method: nwMethodValues[method]), |
|||
); |
|||
return response.data; |
|||
} |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
class NWApi { |
|||
// static const baseApi = "https://www.deapsound.com"; |
|||
static const baseApi = "https://www.deapsound.com"; |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
enum NWMethod { get, post, delete, put } |
|||
|
|||
const nwMethodValues = { |
|||
NWMethod.get: "get", |
|||
NWMethod.post: "post", |
|||
NWMethod.delete: "delete", |
|||
NWMethod.put: "put" |
|||
}; |
|||
Loading…
Reference in new issue