Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 78b40772
authored
2025-12-05 15:34:38 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
根据环境变量将一些数据区分测试数据和正式数据,以及一些其它调整
1 parent
1932b376
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
28 deletions
lib/bloc/login_main_cubit.dart
lib/bloc/login_qr_cubit.dart
lib/bloc/web_cubit.dart
lib/config/constant.dart
lib/config/locator.dart
lib/data/repositories/message/upload_file.dart
lib/data/repositories/message/upload_file2.dart
lib/bloc/login_main_cubit.dart
View file @
78b4077
...
...
@@ -39,11 +39,12 @@ class LoginMainState extends Equatable {
class
LoginMainCubit
extends
Cubit
<
LoginMainState
>
{
late
final
Fluwx
_fluwx
;
late
final
FluwxCancelable
_fluwxCancelable
;
late
final
WechatAuthRepository
_wechatAuthRepository
;
LoginMainCubit
(
super
.
initialState
)
{
_fluwx
=
getIt
.
get
<
Fluwx
>();
_fluwx
.
addSubscriber
(
_responseListener
);
_fluwx
Cancelable
=
_fluwx
.
addSubscriber
(
_responseListener
);
_wechatAuthRepository
=
getIt
.
get
<
WechatAuthRepository
>();
}
...
...
@@ -130,7 +131,7 @@ class LoginMainCubit extends Cubit<LoginMainState> {
@override
Future
<
void
>
close
()
{
_fluwx
.
clearSubscribers
();
_fluwx
Cancelable
.
cancel
();
return
super
.
close
();
}
}
lib/bloc/login_qr_cubit.dart
View file @
78b4077
...
...
@@ -43,26 +43,24 @@ class LoginQrState extends Equatable {
class
LoginQrCubit
extends
Cubit
<
LoginQrState
>
{
late
final
Fluwx
_fluwx
;
late
final
FluwxCancelable
_fluwxCancelable
;
late
final
WechatAuthRepository
_wechatAuthRepository
;
LoginQrCubit
(
super
.
initialState
)
{
_fluwx
=
getIt
.
get
<
Fluwx
>();
_fluwxCancelable
=
_fluwx
.
addSubscriber
(
_responseListener
);
_wechatAuthRepository
=
getIt
.
get
<
WechatAuthRepository
>();
init
();
}
Future
<
void
>
init
()
async
{
// sdk_ticket
var
result
=
await
_wechatAuthRepository
.
getTicket
();
// 后续添加错误处理
if
(
result
[
'resultCode'
]
!=
'001'
)
{
print
(
"获取 sdk_ticket 失败"
);
return
;
}
print
(
'获取 sdk_ticket 成功'
);
var
sdkTicket
=
result
[
'data'
];
...
...
@@ -70,8 +68,6 @@ class LoginQrCubit extends Cubit<LoginQrState> {
var
timestamp
=
DateTime
.
now
().
millisecondsSinceEpoch
;
var
signature
=
_sig
(
'wx8c32ea248f0c7765'
,
'
$timestamp
'
,
sdkTicket
,
'
$timestamp
'
);
print
(
'开始处理二维码登录'
);
_fluwx
.
addSubscriber
(
_responseListener
);
var
authResult
=
await
_fluwx
.
authBy
(
which:
QRCode
(
appId:
'wx8c32ea248f0c7765'
,
...
...
@@ -82,13 +78,10 @@ class LoginQrCubit extends Cubit<LoginQrState> {
),
);
print
(
'AuthResult
$authResult
'
);
print
(
'结束处理二维码'
);
}
void
_responseListener
(
WeChatResponse
response
)
async
{
print
(
'回调。。。。。。。。。'
);
if
(
response
is
WeChatAuthGotQRCodeResponse
)
{
print
(
'收到二维码。。。'
);
int
?
errCode
=
response
.
errCode
;
if
(
errCode
!=
null
&&
errCode
==
0
)
{
emit
(
state
.
copyWith
(
status:
1
,
image:
response
.
qrCode
,
tip:
'打开微信,扫描二维码登录'
));
...
...
@@ -96,7 +89,6 @@ class LoginQrCubit extends Cubit<LoginQrState> {
emit
(
state
.
copyWith
(
tip:
'错误
$errCode
'
));
}
}
else
if
(
response
is
WeChatQRCodeScannedResponse
)
{
print
(
'已扫描二维码。。。'
);
int
?
errCode
=
response
.
errCode
;
if
(
errCode
!=
null
&&
errCode
==
0
)
{
emit
(
state
.
copyWith
(
status:
2
,
tip:
'在微信中轻触允许即可登录'
));
...
...
@@ -104,7 +96,6 @@ class LoginQrCubit extends Cubit<LoginQrState> {
emit
(
state
.
copyWith
(
tip:
'错误
$errCode
'
));
}
}
else
if
(
response
is
WeChatAuthByQRCodeFinishedResponse
)
{
print
(
'确认二维码。。。'
);
int
?
errCode
=
response
.
errCode
;
if
(
errCode
!=
null
&&
errCode
==
0
)
{
_doLogin
(
response
.
authCode
!);
...
...
@@ -160,8 +151,8 @@ class LoginQrCubit extends Cubit<LoginQrState> {
@override
Future
<
void
>
close
()
{
_fluwxCancelable
.
cancel
();
_fluwx
.
stopAuthByQRCode
();
_fluwx
.
clearSubscribers
();
return
super
.
close
();
}
}
lib/bloc/web_cubit.dart
View file @
78b4077
...
...
@@ -63,7 +63,7 @@ class WebState extends Equatable {
final
String
h5Version
;
WebState
({
const
WebState
({
this
.
selectedIndex
=
0
,
this
.
loaded
=
false
,
this
.
isUpgrading
=
false
,
...
...
@@ -270,9 +270,7 @@ class WebCubit extends Cubit<WebState> {
String
zip
=
response
.
data
[
'zip'
]
as
String
;
return
{
'version'
:
version
,
// 'force': "0",
'force'
:
force
,
// 'zip': 'http://192.168.2.177/1.0.0.zip',
'zip'
:
'
$zip$version
.zip'
,
};
}
finally
{
...
...
lib/config/constant.dart
View file @
78b4077
import
'package:appframe/config/evn_config.dart'
;
class
Constant
{
/// local server 相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// 应用内部 http 服务
static
const
int
localServerPort
=
35982
;
...
...
@@ -15,9 +18,18 @@ class Constant {
static
const
String
localServerTest
=
'/test'
;
static
const
String
localServerTestFileUrl
=
'
$localFileUrl$localServerTest
'
;
/// obs 相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// obs文件分片上传的分片大小:5M
static
const
int
obsUploadChunkSize
=
1024
*
1024
*
5
;
/// obs文件上传的逻辑前缀
static
const
String
obsLogicPrefix
=
EnvConfig
.
env
==
'dev'
?
'd2/pridel/user/'
:
'p2/unpridel/user/'
;
/// 版本相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// app 版本号规则
static
const
String
appVersion
=
'1.0.2512021'
;
...
...
@@ -39,9 +51,19 @@ class Constant {
/// 内部 H5 dist 目录
static
const
String
h5DistDir
=
'http_dist_assets'
;
/// BASE URL 相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
static
const
String
bxeBaseUrl
=
EnvConfig
.
env
==
'dev'
?
'https://dev.banxiaoer.net'
:
''
;
static
const
String
iotAppBaseUrl
=
EnvConfig
.
env
==
'dev'
?
'https://iotapp-dev.banxiaoer.com/iotapp'
:
''
;
/// IM 相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// IM SDK
static
const
int
imSdkAppId
=
1400310691
;
static
const
String
imClientSecure
=
'kM4yqbehB3io9UiLvH6eHvM7xAhfYxoyyaO1tLoHgKltcaI7MZXkUbpFaWdeQIqe'
;
static
const
int
imSdkAppId
=
EnvConfig
.
env
==
'dev'
?
1400310691
:
0
;
static
const
String
imClientSecure
=
EnvConfig
.
env
==
'dev'
?
'kM4yqbehB3io9UiLvH6eHvM7xAhfYxoyyaO1tLoHgKltcaI7MZXkUbpFaWdeQIqe'
:
''
;
/// 测试阶段使用
static
const
bool
needIM
=
false
;
...
...
lib/config/locator.dart
View file @
78b4077
import
'dart:io'
show
Platform
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/data/repositories/message/app_info_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_player_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_recorder_handler.dart'
;
...
...
@@ -188,11 +189,11 @@ Future<void> setupLocator() async {
/// apiService
getIt
.
registerLazySingleton
<
ApiService
>(
()
=>
ApiService
(
baseUrl:
'https://dev.banxiaoer.net'
),
()
=>
ApiService
(
baseUrl:
Constant
.
bxeBaseUrl
),
instanceName:
"bxeApiService"
,
);
getIt
.
registerLazySingleton
<
ApiService
>(
()
=>
ApiService
(
baseUrl:
'https://iotapp-dev.banxiaoer.com/iotapp'
),
()
=>
ApiService
(
baseUrl:
Constant
.
iotAppBaseUrl
),
instanceName:
"appApiService"
,
);
...
...
lib/data/repositories/message/upload_file.dart
View file @
78b4077
...
...
@@ -2,6 +2,7 @@ import 'dart:convert';
import
'dart:io'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/locator.dart'
;
import
'package:appframe/services/api_service.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:appframe/utils/file_type_util.dart'
;
...
...
@@ -10,6 +11,7 @@ import 'package:dio/dio.dart';
import
'package:flutter/foundation.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:path_provider/path_provider.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:uuid/uuid.dart'
;
class
UploadFileHandler
extends
MessageHandler
{
...
...
@@ -123,7 +125,7 @@ class UploadFileHandler extends MessageHandler {
///
var
startTime1
=
DateTime
.
now
();
print
(
'====================>签名开始
$startTime1
'
);
final
bxeApiService
=
ApiService
(
baseUrl:
_bxe
BaseUrl
);
final
bxeApiService
=
ApiService
(
baseUrl:
Constant
.
iotApp
BaseUrl
);
late
String
uploadId
;
var
signUrls
=
[];
for
(
int
i
=
0
;
i
<
totalChunks
;
i
++)
{
...
...
@@ -199,8 +201,6 @@ class UploadFileHandler extends MessageHandler {
return
{
'url'
:
_addPreUrl
(
location
)};
}
static
const
_bxeBaseUrl
=
'https://iotapp-dev.banxiaoer.com/iotapp'
;
static
const
_genBaseUrl
=
'https://dev.banxiaoer.net'
;
static
const
_signatureNewUrl
=
'/api/v1/obs/multipart/signaturenew'
;
static
const
_signatureNextUrl
=
'/api/v1/obs/multipart/signaturenext'
;
static
const
_completeUrl
=
'/api/v1/obs/multipart/complete'
;
...
...
@@ -312,7 +312,9 @@ class UploadFileHandler extends MessageHandler {
var
month
=
now
.
month
;
var
day
=
now
.
day
;
return
'd2/pridel/user/
$year$month$day
/bxe/
${busi}
_
$subBusi
'
;
String
userCode
=
getIt
.
get
<
SharedPreferences
>().
getString
(
'auth_userCode'
)
??
'unknown'
;
return
'
${Constant.obsLogicPrefix}$year$month$day
/app/
$userCode
/
${busi}
_
$subBusi
'
;
}
String
_addPreUrl
(
String
location
)
{
...
...
@@ -339,7 +341,7 @@ class UploadFileHandler extends MessageHandler {
"outputSuffix"
:
"_p1"
,
};
await
dio
.
post
(
'
$
_genBaseUrl
/go/mpc/create_covers'
,
'
$
{Constant.bxeBaseUrl}
/go/mpc/create_covers'
,
data:
jsonEncode
(
params
),
options:
Options
(
headers:
headers
,
...
...
lib/data/repositories/message/upload_file2.dart
View file @
78b4077
...
...
@@ -46,7 +46,6 @@ class UploadFile2Handler extends MessageHandler {
return
result
;
}
static
const
_bxeBaseUrl
=
'https://iotapp-dev.banxiaoer.com/iotapp'
;
static
const
_signatureNewUrl
=
'/api/v1/obs/multipart/signaturenew'
;
static
const
_signatureNextUrl
=
'/api/v1/obs/multipart/signaturenext'
;
static
const
_completeUrl
=
'/api/v1/obs/multipart/complete'
;
...
...
@@ -65,7 +64,7 @@ class UploadFile2Handler extends MessageHandler {
filePath
=
filePath
.
replaceFirst
(
Constant
.
localServerTemp
,
''
);
}
final
bxeApiService
=
ApiService
(
baseUrl:
_bxe
BaseUrl
);
final
bxeApiService
=
ApiService
(
baseUrl:
Constant
.
iotApp
BaseUrl
);
// 由于服务端签名时未设置Content-Type,这里必须设置为空,否则会报签名错误
// 由于封装有默认值,所以不能不设置
final
obsApiService
=
ApiService
(
defaultHeaders:
{
'Content-Type'
:
''
,
'Accept'
:
''
});
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment