Skip to content

Commit 7f8caf4

Browse files
author
yubo5
committed
update
1 parent b823f96 commit 7f8caf4

File tree

13 files changed

+261
-191
lines changed

13 files changed

+261
-191
lines changed

.idea/libraries/Dart_Packages.xml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Flutter_Plugins.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 174 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apk/app-release.apk

78.4 KB
Binary file not shown.

ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ EXTERNAL SOURCES:
3535
:path: ".symlinks/plugins/shared_preferences/ios"
3636

3737
SPEC CHECKSUMS:
38-
barcode_scan: 8288e70cb430072003bce2c794a1431e7adbcb4d
39-
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
40-
flutter_webview_plugin: 0b491d31c34ab5c86a71c9f1a57ac000dd1b75e9
41-
image_picker: ee00aab0487cedc80a304085219503cc6d0f2e22
38+
barcode_scan: 33f586d02270046fc6559135038b34b5754eaa4f
39+
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
40+
flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694
41+
image_picker: a211f28b95a560433c00f5cd3773f4710a20404d
4242
MTBBarcodeScanner: bb0bb62e18b57f8a571a482248adc20722b70a91
43-
shared_preferences: 5a1d487c427ee18fcd3ea1f2a131569481834b53
43+
shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523
4444

4545
PODFILE CHECKSUM: 1e5af4103afd21ca5ead147d7b81d06f494f51a2
4646

47-
COCOAPODS: 1.5.3
47+
COCOAPODS: 1.7.0.beta.3

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
1211
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1312
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1413
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -41,7 +40,8 @@
4140
/* Begin PBXFileReference section */
4241
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4342
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
44-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
43+
182DB731E25E2A38A44FAFF7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
44+
1C61375D564E6F057C0AB0C1 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
4545
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4646
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4747
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -84,7 +84,6 @@
8484
9740EEB11CF90186004384FC /* Flutter */ = {
8585
isa = PBXGroup;
8686
children = (
87-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
8887
3B80C3931E831B6300D905FE /* App.framework */,
8988
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9089
9740EEBA1CF902C7004384FC /* Flutter.framework */,
@@ -141,6 +140,8 @@
141140
AF1367F5F6AF0881D93C1A67 /* Pods */ = {
142141
isa = PBXGroup;
143142
children = (
143+
182DB731E25E2A38A44FAFF7 /* Pods-Runner.debug.xcconfig */,
144+
1C61375D564E6F057C0AB0C1 /* Pods-Runner.release.xcconfig */,
144145
);
145146
name = Pods;
146147
sourceTree = "<group>";
@@ -181,6 +182,8 @@
181182
TargetAttributes = {
182183
97C146ED1CF9000F007C117D = {
183184
CreatedOnToolsVersion = 7.3.1;
185+
DevelopmentTeam = 4ZACZ79DU9;
186+
ProvisioningStyle = Automatic;
184187
};
185188
};
186189
};
@@ -189,6 +192,7 @@
189192
developmentRegion = English;
190193
hasScannedForEncodings = 0;
191194
knownRegions = (
195+
English,
192196
en,
193197
Base,
194198
);
@@ -211,7 +215,6 @@
211215
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
212216
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
213217
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
214-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
215218
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
216219
);
217220
runOnlyForDeploymentPostprocessing = 0;
@@ -260,21 +263,17 @@
260263
buildActionMask = 2147483647;
261264
files = (
262265
);
263-
inputFileListPaths = (
264-
);
265266
inputPaths = (
266-
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
267+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
267268
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
268269
);
269270
name = "[CP] Embed Pods Frameworks";
270-
outputFileListPaths = (
271-
);
272271
outputPaths = (
273272
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
274273
);
275274
runOnlyForDeploymentPostprocessing = 0;
276275
shellPath = /bin/sh;
277-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
276+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
278277
showEnvVarsInLog = 0;
279278
};
280279
9740EEB61CF901F6004384FC /* Run Script */ = {
@@ -433,7 +432,10 @@
433432
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
434433
buildSettings = {
435434
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
435+
CODE_SIGN_IDENTITY = "iPhone Developer";
436+
CODE_SIGN_STYLE = Automatic;
436437
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
438+
DEVELOPMENT_TEAM = 4ZACZ79DU9;
437439
ENABLE_BITCODE = NO;
438440
FRAMEWORK_SEARCH_PATHS = (
439441
"$(inherited)",
@@ -447,6 +449,7 @@
447449
);
448450
PRODUCT_BUNDLE_IDENTIFIER = com.yubo.flutterOsc;
449451
PRODUCT_NAME = "$(TARGET_NAME)";
452+
PROVISIONING_PROFILE_SPECIFIER = "";
450453
VERSIONING_SYSTEM = "apple-generic";
451454
};
452455
name = Debug;
@@ -456,7 +459,10 @@
456459
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
457460
buildSettings = {
458461
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
462+
CODE_SIGN_IDENTITY = "iPhone Developer";
463+
CODE_SIGN_STYLE = Automatic;
459464
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
465+
DEVELOPMENT_TEAM = 4ZACZ79DU9;
460466
ENABLE_BITCODE = NO;
461467
FRAMEWORK_SEARCH_PATHS = (
462468
"$(inherited)",
@@ -470,6 +476,7 @@
470476
);
471477
PRODUCT_BUNDLE_IDENTIFIER = com.yubo.flutterOsc;
472478
PRODUCT_NAME = "$(TARGET_NAME)";
479+
PROVISIONING_PROFILE_SPECIFIER = "";
473480
VERSIONING_SYSTEM = "apple-generic";
474481
};
475482
name = Release;

lib/api/Api.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Api {
22
static final String host = "https://www.oschina.net";
33

44
// 资讯列表
5-
static final String newsList = "http://osc.yubo725.top/news/list";
5+
static final String newsList = "http://osc.yubo.me/news/list";
66

77
// 资讯详情
88
static final String newsDetail = host + "/action/openapi/news_detail";
@@ -23,14 +23,14 @@ class Api {
2323
static final String pubTweet = host + "/action/openapi/tweet_pub";
2424

2525
// 添加到小黑屋
26-
static final String addToBlack = "http://osc.yubo725.top/black/add";
26+
static final String addToBlack = "http://osc.yubo.me/black/add";
2727

2828
// 查询小黑屋
29-
static final String queryBlack = "http://osc.yubo725.top/black/query";
29+
static final String queryBlack = "http://osc.yubo.me/black/query";
3030

3131
// 从小黑屋中删除
32-
static final String deleteBlack = "http://osc.yubo725.top/black/delete";
32+
static final String deleteBlack = "http://osc.yubo.me/black/delete";
3333

3434
// 开源活动
35-
static final String eventList = "http://osc.yubo725.top/events/";
35+
static final String eventList = "http://osc.yubo.me/events/";
3636
}

lib/constants/Constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:event_bus/event_bus.dart';
22

33
class Constants {
44

5-
static final String redirectUrl = "http://yubo725.top/osc/osc.php";
5+
static final String redirectUrl = "http://osc.yubo.me/logincallback";
66

77
static final String loginUrl = "https://www.oschina.net/action/oauth2/authorize?client_id=4rWcDXCNTV5gMWxtagxI&response_type=code&redirect_uri=" + redirectUrl;
88

lib/pages/LoginPage.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import 'dart:async';
2+
import 'dart:convert';
3+
4+
import 'package:flutter/cupertino.dart';
25
import 'package:flutter/material.dart';
6+
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
7+
38
import '../constants/Constants.dart';
4-
import 'package:flutter/cupertino.dart';
5-
import 'dart:convert';
69
import '../util/DataUtils.dart';
7-
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
810

911
// 登录页面,使用网页加载的开源中国三方登录页面
1012
class LoginPage extends StatefulWidget {
@@ -17,6 +19,8 @@ class LoginPageState extends State<LoginPage> {
1719
bool loading = true;
1820
// 标记当前页面是否是我们自定义的回调页面
1921
bool isLoadingCallbackPage = false;
22+
// 是否解析了结果,这个字段用于确保parseResult方法只调用一次,真是MMP噢,不用这个字段标记,parseResult就调用了两次,导致黑屏产生,查黑屏问题用了我一天时间!
23+
bool parsedResult = false;
2024
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
2125
// URL变化监听器
2226
StreamSubscription<String> _onUrlChanged;
@@ -58,15 +62,19 @@ class LoginPageState extends State<LoginPage> {
5862
_onUrlChanged = flutterWebViewPlugin.onUrlChanged.listen((url) {
5963
// 登录成功会跳转到自定义的回调页面,该页面地址为http://yubo725.top/osc/osc.php?code=xxx
6064
// 该页面会接收code,然后根据code换取AccessToken,并将获取到的token及其他信息,通过js的get()方法返回
61-
if (url != null && url.length > 0 && url.contains("osc/osc.php?code=")) {
65+
if (url != null && url.length > 0 && url.contains("/logincallback?")) {
6266
isLoadingCallbackPage = true;
6367
}
6468
});
6569
}
6670

6771
// 解析WebView中的数据
6872
void parseResult() {
69-
flutterWebViewPlugin.evalJavascript("get();").then((result) {
73+
if (parsedResult) {
74+
return;
75+
}
76+
parsedResult = true;
77+
flutterWebViewPlugin.evalJavascript("window.atob(get())").then((result) {
7078
// result json字符串,包含token信息
7179
if (result != null && result.length > 0) {
7280
// 拿到了js中的数据
@@ -82,7 +90,7 @@ class LoginPageState extends State<LoginPage> {
8290
Navigator.pop(context, "refresh");
8391
}
8492
} catch (e) {
85-
print("parse login result error: $e");
93+
print(e);
8694
}
8795
}
8896
});

lib/pages/MyInfoPage.dart

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,24 @@ class MyInfoPageState extends State<MyInfoPage> {
109109

110110
// 获取用户信息
111111
getUserInfo() async {
112-
SharedPreferences sp = await SharedPreferences.getInstance();
113-
String accessToken = sp.get(DataUtils.SP_AC_TOKEN);
114-
Map<String, String> params = Map();
115-
params['access_token'] = accessToken;
116-
NetUtils.get(Api.userInfo, params: params).then((data) {
117-
if (data != null) {
118-
var map = json.decode(data);
119-
setState(() {
120-
userAvatar = map['avatar'];
121-
userName = map['name'];
122-
});
123-
DataUtils.saveUserInfo(map);
124-
}
125-
});
112+
try {
113+
SharedPreferences sp = await SharedPreferences.getInstance();
114+
String accessToken = sp.get(DataUtils.SP_AC_TOKEN);
115+
Map<String, String> params = Map();
116+
params['access_token'] = accessToken;
117+
NetUtils.get(Api.userInfo, params: params).then((data) {
118+
if (data != null) {
119+
var map = json.decode(data);
120+
setState(() {
121+
userAvatar = map['avatar'];
122+
userName = map['name'];
123+
});
124+
DataUtils.saveUserInfo(map);
125+
}
126+
});
127+
} catch (e) {
128+
print(e);
129+
}
126130
}
127131

128132
_login() async {

lib/pages/NewLoginPage.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class NewLoginPageState extends State<NewLoginPage> {
3333
bool isOnLogin = false;
3434
// 是否隐藏输入的文本
3535
bool obscureText = true;
36+
// 是否解析了结果
37+
bool parsedResult = false;
3638

3739
final usernameCtrl = TextEditingController(text: '');
3840
final passwordCtrl = TextEditingController(text: '');
@@ -104,9 +106,8 @@ class NewLoginPageState extends State<NewLoginPage> {
104106
_onUrlChanged = flutterWebViewPlugin.onUrlChanged.listen((url) {
105107
// 登录成功会跳转到自定义的回调页面,该页面地址为http://yubo725.top/osc/osc.php?code=xxx
106108
// 该页面会接收code,然后根据code换取AccessToken,并将获取到的token及其他信息,通过js的get()方法返回
107-
if (url != null && url.length > 0 && url.contains("osc/osc.php?code=")) {
109+
if (url != null && url.length > 0 && url.contains("/logincallback?")) {
108110
isLoadingCallbackPage = true;
109-
print("URL变为回调页");
110111
}
111112
});
112113
}
@@ -140,7 +141,11 @@ class NewLoginPageState extends State<NewLoginPage> {
140141

141142
// 解析WebView中的数据
142143
void parseResult() {
143-
flutterWebViewPlugin.evalJavascript("get();").then((result) {
144+
if (parsedResult) {
145+
return;
146+
}
147+
parsedResult = true;
148+
flutterWebViewPlugin.evalJavascript("window.atob(get())").then((result) {
144149
// result json字符串,包含token信息
145150
if (result != null && result.length > 0) {
146151
// 拿到了js中的数据
@@ -215,8 +220,8 @@ class NewLoginPageState extends State<NewLoginPage> {
215220
height: 0.0,
216221
child: WebviewScaffold(
217222
key: _scaffoldKey,
218-
url: Constants.loginUrl, // 登录的URL
219223
hidden: true,
224+
url: Constants.loginUrl, // 登录的URL
220225
withZoom: true, // 允许网页缩放
221226
withLocalStorage: true, // 允许LocalStorage
222227
withJavascript: true, // 允许执行js代码

0 commit comments

Comments
 (0)