Commit 9fa0ddbd authored by 林生雨's avatar 林生雨

commit

parent 885b3a97
......@@ -234,11 +234,11 @@ mkdir /Users/apple/lsy/aar_update/androd${message}/
mkdir /Users/apple/lsy/aar_update/ios${message}/
clean
#android_apk
android_apk
#android
#android_publish
#upload_android_aar
ios
#ios
#ios_publish
#notifyDingDing
......
......@@ -2,6 +2,7 @@
* @author lsy
* @date 2019-09-24
**/
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
......@@ -37,23 +38,24 @@ Observable getNetType() {
return Observable.fromFuture(platform.invokeMethod(NET_TYPE, null));
}
void initParams() {
void initParams(VoidCallback callback) {
platform.invokeMethod(INIT_PARAMS, null).then((value) {
print("lsy INITPARAMS !! $value");
Api.getInstance().initBuildConfig(value);
initBuried();
initBuried(callback);
}).catchError((error) {
print(error);
});
}
void initBuried() {
void initBuried(VoidCallback call) {
getBuriedInfo().then((value) {
Map temp = new Map<String, dynamic>.from(value);
print("lsy INITBURIED !! $temp");
temp.forEach((k, v) {
CacheManager.getInstance().get(MEMORY_CACHE).save(k, v);
});
call();
}).catchError((error) {
print(error);
});
......
......@@ -49,14 +49,22 @@ class Api {
DioUtil().setProxy(httpProxy);
}
}
var cookie = params["cookie"] == null ? params["Cookie"] : params["cookie"];
Map cookieMap = {};
cookieMap.putIfAbsent("Cookie", () => cookie);
DioUtil().setConfig(HttpConfig(
options: BaseOptions(
baseUrl: baseUrl,
),
nativeCookie: cookieMap));
)));
return true;
}
bool setDioCookie(Map params) {
if (params == null) {
return false;
}
var cookie = params["cookie"] == null ? params["Cookie"] : params["cookie"];
if (cookie == null) {
return false;
}
DioUtil().setCookie(cookie);
return true;
}
......
......@@ -435,6 +435,12 @@ class DioUtil {
void _mergeNativeCookie(HttpConfig config) {
//合并native cookie
if (config.nativeCookie == null) {
return;
}
if (_options.headers == null) {
_options.headers = Map();
}
Map<String, dynamic> headers = _options.headers;
headers['Cookie'] = config.nativeCookie['Cookie'];
_options.headers = headers;
......@@ -443,6 +449,18 @@ class DioUtil {
print(_options.headers);
}
void setCookie(String cookie) {
if (_options.headers == null) {
_options.headers = Map();
}
Map<String, dynamic> headers = _options.headers;
headers['Cookie'] = cookie;
_options.headers = headers;
print('cookie---------');
print(_options.headers);
}
/// print Http Log.
void _printHttpLog(Response response) {
if (!_isDebug) {
......
......@@ -12,9 +12,8 @@ import 'package:gmalpha_flutter/messageModel/home/message_home.dart';
import 'comment_suggest.dart';
void main() async {
runApp(MyApp());
initParams();
void main(){
initParams(()=>runApp(MyApp()));
}
class MyApp extends StatefulWidget {
......@@ -48,7 +47,8 @@ class _MyAppState extends State<MyApp> {
print("PARAMS!! ${params}");
String fromPage = params["fromPage"];
if (params == null ||
fromPage == null) {
fromPage == null ||
!Api.getInstance().setDioCookie(params)) {
return ErrorPage("出错:需要传递的参数为空");
}
int userId = int.parse(params["userId"]);
......@@ -57,9 +57,11 @@ class _MyAppState extends State<MyApp> {
?.getReputationsPage(userId, params["userName"], fromPage);
},
"activity_report": (pageName, params, _) {
print("PARAMS!! ${params}");
String fromPage = params["fromPage"];
if (params == null ||
fromPage == null) {
fromPage == null ||
!Api.getInstance().setDioCookie(params)) {
return ErrorPage("出错:需要传递的参数为空");
}
return RouterCenterImpl()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment