添加注释

gxh_branch
gexinghai 2 years ago
parent adb12c0302
commit cb4ce20a7c

@ -1,8 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/jcenter'}
maven {url 'https://maven.aliyun.com/repository/central'}
maven {url 'https://maven.aliyun.com/repository/public'}
maven {url 'https://maven.aliyun.com/repository/spring'}
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
}
dependencies {
@ -13,11 +17,16 @@ buildscript {
allprojects {
repositories {
google()
mavenCentral()
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/jcenter'}
maven {url 'https://maven.aliyun.com/repository/central'}
maven {url 'https://maven.aliyun.com/repository/public'}
maven {url 'https://maven.aliyun.com/repository/spring'}
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"

@ -25,15 +25,18 @@ class _ReportsScreenState extends State<ReportsScreen> {
classifyTimers().then((value) => persentMap = value);
}
/**
*
* @return
*/
Future<Map<String, num>> classifyTimers() async {
var timers = await TimerEntryDatabase.instance.readAll();
Map<String, num> persentMap = {};
var timers = await TimerEntryDatabase.instance.readAll(); //
Map<String, num> presentMap = {}; //
for (var timer in timers) {
var response = await postData(timer.name);
// 0.5API
await Future.delayed(Duration(milliseconds: 500));
var response = await postData(timer.name); // API
await Future.delayed(Duration(milliseconds: 500)); // 0.5API
var classification =
jsonDecode(response.body)['item']['lv1_tag_list'][0]['tag'];
jsonDecode(response.body)['item']['lv1_tag_list'][0]['tag']; // API
// APIISO-8859-1
classification = utf8.decode(classification.runes.toList());
persentMap[classification] = timer.stopwatch!.elapsed.inSeconds;
@ -42,14 +45,17 @@ class _ReportsScreenState extends State<ReportsScreen> {
return persentMap;
}
// API
/**
* API
* @param name
* @return API
*/
Future<http.Response> postData(String name) async {
// ignore: non_constant_identifier_names
var API_KEY = "YGxSMNdWKO5Gpt12dNVY2nGq";
// ignore: non_constant_identifier_names
var SECRET_KEY = "G5NBDTiRPhsBqMi1Od0XZw4RSMlFgeek";
var accessToken = await getAccessToken(API_KEY, SECRET_KEY);
var response = await http.post(
String API_KEY = "YGxSMNdWKO5Gpt12dNVY2nGq"; // APIAPI Key
String SECRET_KEY = "G5NBDTiRPhsBqMi1Od0XZw4RSMlFgeek"; // APISecret Key
String accessToken =
await getAccessToken(API_KEY, SECRET_KEY); // APIaccess token
http.Response response = await http.post(
Uri.parse(
'https://aip.baidubce.com/rpc/2.0/nlp/v1/topic?charset=UTF-8&access_token=$accessToken'),
headers: {
@ -60,11 +66,10 @@ class _ReportsScreenState extends State<ReportsScreen> {
"title": name,
"content": name,
}),
);
return response;
); // API
return response; // API
}
// ignore: non_constant_identifier_names
Future<String> getAccessToken(String API_KEY, String SECRET_KEY) async {
var response = await http.post(
Uri.parse('https://aip.baidubce.com/oauth/2.0/token'),

Loading…
Cancel
Save