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

commit

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