Skip to content

Commit 9d491b9

Browse files
author
yangshangzhi
committed
删除codeurl
1 parent 81ca6c9 commit 9d491b9

File tree

13 files changed

+29
-58
lines changed

13 files changed

+29
-58
lines changed

lib/components/widgetComp.dart

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import 'package:efox_flutter/router/index.dart' show FluroRouter;
1212
class Index extends StatefulWidget {
1313
final List<Widget> demoChild;
1414
final String originCodeUrl;
15-
final String codeUrl;
1615
final String mdUrl;
1716
final String title;
1817
Index({
1918
Key key,
2019
this.title,
2120
this.demoChild,
2221
this.originCodeUrl,
23-
this.codeUrl,
2422
this.mdUrl,
2523
}) : super(key: key);
2624

@@ -29,7 +27,6 @@ class Index extends StatefulWidget {
2927
title: title,
3028
demoChild: demoChild,
3129
originCodeUrl: originCodeUrl,
32-
codeUrl: codeUrl,
3330
mdUrl: mdUrl);
3431
}
3532

@@ -39,7 +36,6 @@ class IndexState extends State<Index> {
3936
final List mdList;
4037
final List<Widget> demoChild;
4138
final String originCodeUrl;
42-
final String codeUrl;
4339
final String mdUrl;
4440
final String title;
4541
bool loading = true;
@@ -52,7 +48,6 @@ class IndexState extends State<Index> {
5248
this.mdList,
5349
this.demoChild,
5450
this.originCodeUrl,
55-
this.codeUrl,
5651
this.mdUrl,
5752
});
5853

@@ -98,7 +93,7 @@ class IndexState extends State<Index> {
9893
// 加载页面
9994
if (model.config.state.isPro) {
10095
FluroRouter.router.navigateTo(context,
101-
'/webview?url=${Uri.encodeComponent(model.config.state.env.GithubAssetOrigin + url)}');
96+
'/webview?url=${Uri.encodeComponent(model.config.state.env.GithubAssetOrigin + url.replaceAll(RegExp('/index.md'), ''))}');
10297
} else {
10398
// 加载本地
10499
String mdStr = await FileUtils.readLocaleFile(url);
@@ -116,27 +111,18 @@ class IndexState extends State<Index> {
116111
}
117112

118113
Future getMdFile(url) async {
119-
String mdStr = await LoadAssetUtils.loadMarkdownAssets(url);
114+
String mdStr = (await LoadAssetUtils.loadMarkdownAssets(url)).toString();
120115
return mdStr;
121116
}
122117

123118
getActions(context, model) {
124119
return [
125-
IconButton(
126-
icon: Icon(
127-
Icons.favorite_border,
128-
),
129-
onPressed: () async {
130-
// TODO favirote
131-
this.openPage(context, model, this.mdUrl);
132-
},
133-
),
134120
IconButton(
135121
icon: Icon(
136122
Icons.code,
137123
),
138124
onPressed: () async {
139-
this.openPage(context, model, this.codeUrl);
125+
this.openPage(context, model, this.mdUrl);
140126
},
141127
),
142128
PopupMenuButton(
@@ -150,9 +136,6 @@ class IndexState extends State<Index> {
150136
);
151137
break;
152138
case 1:
153-
this.openPage(context, model, this.mdUrl);
154-
break;
155-
case 2:
156139
FluroRouter.router.navigateTo(
157140
context,
158141
'/webview?url=${Uri.encodeComponent(this.originCodeUrl)}',
@@ -169,21 +152,10 @@ class IndexState extends State<Index> {
169152
color: Color(model.theme.greyColor),
170153
),
171154
Text(" "),
172-
Text('官网'),
155+
Text('Flutter-UI'),
173156
]),
174157
value: 0,
175158
),
176-
PopupMenuItem(
177-
child: Row(children: [
178-
Icon(
179-
Icons.all_inclusive,
180-
color: Color(model.theme.greyColor),
181-
),
182-
Text(" "),
183-
Text("Markdown"),
184-
]),
185-
value: 1,
186-
),
187159
PopupMenuItem(
188160
child: Row(children: [
189161
Icon(
@@ -193,7 +165,7 @@ class IndexState extends State<Index> {
193165
Text(" "),
194166
Text(this.title),
195167
]),
196-
value: 2,
168+
value: 1,
197169
),
198170
];
199171
},
@@ -226,7 +198,6 @@ class IndexState extends State<Index> {
226198
mainAxisSize: MainAxisSize.min,
227199
children: <Widget>[
228200
CircularProgressIndicator(
229-
// backgroundColor: Color(this.model.theme.mainColor),
230201
strokeWidth: 4,
231202
),
232203
Container(

lib/config/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'development.dart' as Development;
22
import 'production.dart' as Production;
33

4-
const bool isPro = false;
4+
const bool isPro = true;
55

66
Object env = isPro ? Production.Config() : Development.Config();

lib/store/http.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import 'package:dio/dio.dart';
22

3-
request() async {
3+
Future<dynamic> get(url, [data = const {}]) async {
44
Dio dio = new Dio(); // with default Options
5+
// dio.interceptors
6+
// .add(InterceptorsWrapper(onRequest: (RequestOptions requestOptions) {
7+
// return dio.resolve('sfs');
8+
// }));
9+
dio.interceptors.add(LogInterceptor(responseBody: true));
10+
try {
11+
return await dio.get(url).then((res) => res.data);
12+
} on DioError catch(e) {
13+
return e.response;
14+
}
15+
}
516

17+
Future post(url, [data = const {}, params = const {}]) async {
18+
Dio dio = new Dio(); // with default Options
19+
// dio.interceptors
20+
// .add(InterceptorsWrapper(onRequest: (RequestOptions requestOptions) {
21+
// return dio.resolve('sfs');
22+
// }));
23+
return dio.post(url, data: data, queryParameters: params);
624
}

lib/utils/loadAsset.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import 'package:dio/dio.dart';
21
import 'package:efox_flutter/store/store.dart' as Store;
2+
import 'package:efox_flutter/store/http.dart' as Http;
33
import 'file.dart' as FileUtil;
44

5-
Future<String> loadMarkdownAssets(path) async {
5+
Future<dynamic> loadMarkdownAssets(path) async {
66
if (!Store.model.config.state.isPro) {
77
return FileUtil.readLocaleFile(path);
88
}
99
String url = Store.model.config.state.env.GithubMarkdownOrigin + path;
10-
return Dio().get(url).then((res) {
11-
return res.data;
10+
return Http.get(url).then((res) {
11+
return res;
1212
});
1313
}

lib/widget/regular/align/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'demo.dart' as Demo;
55
class Index extends StatefulWidget {
66
static String title = 'Align';
77
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Align-class.html';
8-
static String codeUrl = 'docs/widget/regular/align/code.md';
98
static String mdUrl = 'docs/widget/regular/align/index.md';
109

1110
@override
@@ -17,7 +16,6 @@ class _IndexState extends State<Index> {
1716
Widget build(BuildContext context) {
1817
return WidgetComp.Index(
1918
title: Index.title,
20-
codeUrl: Index.codeUrl,
2119
originCodeUrl: Index.originCodeUrl,
2220
mdUrl: Index.mdUrl,
2321
demoChild: <Widget>[

lib/widget/regular/center/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'demo.dart' as Demo;
55
class Index extends StatefulWidget {
66
static String title = 'Center';
77
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Center-class.html';
8-
static String codeUrl = 'docs/widget/regular/center/code.md';
98
static String mdUrl = 'docs/widget/regular/center/index.md';
109
@override
1110
_IndexState createState() => _IndexState();
@@ -16,7 +15,6 @@ class _IndexState extends State<Index> {
1615
Widget build(BuildContext context) {
1716
return WidgetComp.Index(
1817
title: Index.title,
19-
codeUrl: Index.codeUrl,
2018
originCodeUrl: Index.originCodeUrl,
2119
mdUrl: Index.mdUrl,
2220
demoChild: <Widget>[

lib/widget/regular/column/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'demo_expanded.dart' as DemoExpanded;
66
class Index extends StatefulWidget {
77
static String title = 'Column';
88
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Column-class.html';
9-
static String codeUrl = 'docs/widget/regular/column/code.md';
109
static String mdUrl = 'docs/widget/regular/column/index.md';
1110

1211
@override
@@ -18,7 +17,6 @@ class _IndexState extends State<Index> {
1817
Widget build(BuildContext context) {
1918
return WidgetComp.Index(
2019
title: Index.title,
21-
codeUrl: Index.codeUrl,
2220
originCodeUrl: Index.originCodeUrl,
2321
mdUrl: Index.mdUrl,
2422
demoChild: <Widget>[

lib/widget/regular/container/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'demo.dart' as Demo;
66
class Index extends StatefulWidget {
77
static String title = 'Container';
88
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Container-class.html';
9-
static String codeUrl = 'docs/widget/regular/container/code.md';
109
static String mdUrl = 'docs/widget/regular/container/index.md';
1110

1211
@override
@@ -18,7 +17,6 @@ class _IndexState extends State<Index> {
1817
Widget build(BuildContext context) {
1918
return WidgetComp.Index(
2019
title: Index.title,
21-
codeUrl: Index.codeUrl,
2220
originCodeUrl: Index.originCodeUrl,
2321
mdUrl: Index.mdUrl,
2422
demoChild: <Widget>[

lib/widget/regular/fittedbox/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'demo.dart' as Demo;
55
class Index extends StatefulWidget {
66
static String title = 'FittedBox';
77
static String originCodeUrl = '';
8-
static String codeUrl = 'docs/widget/regular/fittedbox/code.md';
98
static String mdUrl = 'docs/widget/regular/fittedbox/index.md';
109
@override
1110
_IndexState createState() => _IndexState();
@@ -16,7 +15,6 @@ class _IndexState extends State<Index> {
1615
Widget build(BuildContext context) {
1716
return WidgetComp.Index(
1817
title: Index.title,
19-
codeUrl: Index.codeUrl,
2018
originCodeUrl: Index.originCodeUrl,
2119
mdUrl: Index.mdUrl,
2220
demoChild: <Widget>[

lib/widget/regular/padding/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'demo.dart' as Demo;
66
class Index extends StatefulWidget {
77
static String title = 'Padding';
88
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Padding-class.html';
9-
static String codeUrl = 'docs/widget/regular/padding/code.md';
109
static String mdUrl = 'docs/widget/regular/padding/index.md';
1110
@override
1211
_IndexState createState() => _IndexState();
@@ -17,7 +16,6 @@ class _IndexState extends State<Index> {
1716
Widget build(BuildContext context) {
1817
return WidgetComp.Index(
1918
title: Index.title,
20-
codeUrl: Index.codeUrl,
2119
originCodeUrl: Index.originCodeUrl,
2220
mdUrl: Index.mdUrl,
2321
demoChild: <Widget>[

0 commit comments

Comments
 (0)