mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-04 07:18:11 +08:00
temp
This commit is contained in:
@ -17,6 +17,7 @@ dependencies:
|
||||
args: '^1.5.1'
|
||||
dart_inquirer: '^1.0.0'
|
||||
watcher: ^0.9.7+10
|
||||
mustache: ^1.1.1
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
|
@ -1,11 +1,23 @@
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:mustache/mustache.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import '../../utils/util.dart';
|
||||
import '../config.dart';
|
||||
import '../exception/demo.dart';
|
||||
|
||||
|
||||
String prettyJson(Map json) {
|
||||
String res = "{";
|
||||
json.forEach((k, v) {
|
||||
res += (
|
||||
"\t'$k': '$v'");
|
||||
});
|
||||
res +='}';
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Future<List> buildPageListJson() async {
|
||||
List<FileSystemEntity> childList = await readeDirChildren(TARGET_PAGE_DIC, false);
|
||||
List<String> pagePathList = [];
|
||||
@ -55,36 +67,49 @@ Future<List> buildPageListJson() async {
|
||||
}
|
||||
|
||||
String renderPagesDart(List<Map<String, dynamic>> data) {
|
||||
// 自定义前缀 避免出现数字非法字符等
|
||||
String pre = "StandardPage";
|
||||
String head = '';
|
||||
String foot = """
|
||||
print('data>>> $data');
|
||||
var source = '''
|
||||
|
||||
{{# pages }}
|
||||
import '{{ name }}_{{ author }}_{{ id }}/index.dart' as StandardPage_{{ name }}_{{ id }};
|
||||
{{/ pages }}
|
||||
class StandardPages {
|
||||
Map<String, String> standardPages;
|
||||
Map<String, String> getPages() {
|
||||
return {
|
||||
""";
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
Map<String, dynamic> item = data[i];
|
||||
String demoImportName = '${item['name']}_${item['id']}';
|
||||
head += "import '${item['name']}_${item['author']}_${item['id']}/index.dart' as ${pre}_$demoImportName;\r\n";
|
||||
|
||||
foot += "\t\t\t'${item['id']}': ${pre}_${demoImportName}.getMd()";
|
||||
|
||||
if (i != data.length - 1) {
|
||||
foot += ',\r\n';
|
||||
}
|
||||
|
||||
}
|
||||
foot += """\r
|
||||
"0": "0" {{# pages }},
|
||||
"{{ id }}" : StandardPage_{{ name }}_{{ id }}.getMd()
|
||||
{{/ pages }}
|
||||
};
|
||||
}
|
||||
List<Map<String, String>> getLocalList() {
|
||||
return [
|
||||
{}{{# pages }},
|
||||
{ "id": "{{ id }}", "name": "{{ name }}", "email": "{{ email }}", "author": "{{ author }}"}
|
||||
{{/ pages }}
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
""";
|
||||
''';
|
||||
var template = new Template(source, name: 'template-filename.html');
|
||||
|
||||
|
||||
// print(prettyJson(data[0]));
|
||||
// 自定义前缀 避免出现数字非法字符等
|
||||
String pre = "StandardPage";
|
||||
Map<String, List> formatData = {
|
||||
"pages": data
|
||||
};
|
||||
|
||||
var output = template.renderString(formatData);
|
||||
print(output);
|
||||
|
||||
|
||||
// }
|
||||
return output;
|
||||
|
||||
return head + foot;
|
||||
}
|
||||
Future<bool> checkPage(String path) async {
|
||||
List files = [
|
||||
|
@ -6,6 +6,7 @@ import './version.dart';
|
||||
import './command/create_demo.dart';
|
||||
import './command/create_page.dart';
|
||||
import './command/watch_md.dart';
|
||||
import './command/build.dart';
|
||||
|
||||
|
||||
|
||||
@ -17,7 +18,7 @@ class _CommandRunner extends CommandRunner<int> {
|
||||
negatable: false, help: 'Prints the version of goCi.');
|
||||
addCommand(CreateDemoCommand());
|
||||
addCommand(CreatePageCommand());
|
||||
addCommand(WatchCommand());
|
||||
addCommand(Build());
|
||||
|
||||
}
|
||||
|
||||
|
32
go-cli/src/command/build.dart
Normal file
32
go-cli/src/command/build.dart
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created with Android Studio.
|
||||
// User: 三帆
|
||||
// Date: 30/07/2019
|
||||
// Time: 16:51
|
||||
// email: sanfan.hx@alibaba-inc.com
|
||||
// target: build
|
||||
//
|
||||
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import '../build/build_demo_list.dart';
|
||||
import '../build/build_page_list.dart';
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
|
||||
class Build extends Command<int> {
|
||||
@override
|
||||
final name = 'build';
|
||||
@override
|
||||
final description = '生成索引等';
|
||||
|
||||
|
||||
@override
|
||||
Future<int> run() async {
|
||||
buildPageListJson();
|
||||
buildDemoListJson();
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -191,7 +191,10 @@ void main() async {
|
||||
new SearchHistoryList(sp);
|
||||
await DataUtils.getWidgetTreeList().then((List json) {
|
||||
Application.widgetTree = WidgetTree.buildWidgetTree(json);
|
||||
if (Application.env == ENV.DEV) {
|
||||
|
||||
}
|
||||
print("Application.widgetTree>>>> ${Application.widgetTree}");
|
||||
});
|
||||
db = Provider.db;
|
||||
runApp(new MyApp());
|
||||
|
@ -297,7 +297,6 @@ class WidgetTree {
|
||||
current = CategoryComponent(id: 0, name: 'root', parentId: null, children: []);
|
||||
}
|
||||
json.forEach((item) {
|
||||
|
||||
// 归属分类级别
|
||||
if (['root', 'category'].indexOf(item['type']) != -1) {
|
||||
CategoryComponent cate = CategoryComponent.fromJson(item);
|
||||
|
@ -1,11 +1 @@
|
||||
[
|
||||
{
|
||||
"name": "standard",
|
||||
"screenShot": "",
|
||||
"author": "sanfan",
|
||||
"title": "介绍页",
|
||||
"email": "hanxu317@qq.com",
|
||||
"desc": "desc",
|
||||
"id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"
|
||||
}
|
||||
]
|
||||
[{"name":"standard","screenShot":"","author":"sanfan","title":"介绍页","email":"hanxu317@qq.com","desc":"desc","id":"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"}]
|
@ -1,11 +1,20 @@
|
||||
|
||||
import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096;
|
||||
class StandardPages {
|
||||
Map<String, String> standardPages;
|
||||
Map<String, String> getPages() {
|
||||
return {
|
||||
'ee4feb8e_32ae_4241_9c8a_5c9e1f92b096': StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
"0": "0" ,
|
||||
"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
};
|
||||
}
|
||||
List<Map<String, String>> getLocalList() {
|
||||
return [
|
||||
{},
|
||||
{ "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", "name": "standard", "email": "hanxu317@qq.com", "author": "sanfan"}
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user