From b1c3abee51cfb8083f45bc92cb6986d59d85662d Mon Sep 17 00:00:00 2001 From: nano71 <80870408+nano71@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=B9=E6=AE=8A=E8=AF=BE?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/local.properties | 4 +- lib/common/get.dart | 100 ++++++++++++++++++++++++--------------- lib/main.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 67 insertions(+), 40 deletions(-) diff --git a/android/local.properties b/android/local.properties index b9e12ea..aca2bbe 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,5 +1,5 @@ sdk.dir=C:\\sdk\\android-sdk flutter.sdk=C:\\sdk\\flutter flutter.buildMode=debug -flutter.versionName=1.6.241118 -flutter.versionCode=71 \ No newline at end of file +flutter.versionName=1.6.241125 +flutter.versionCode=74 \ No newline at end of file diff --git a/lib/common/get.dart b/lib/common/get.dart index 61831f7..e8e02a4 100644 --- a/lib/common/get.dart +++ b/lib/common/get.dart @@ -167,61 +167,87 @@ Future getSchedule() async { } return list; } - + void step3ForSection(String section) { + List range = section.split("-"); + if (range.length == 2) { + for (int i = int.parse(range[0]); i <= int.parse(range[1]); i++) { + weekList.add(i.toString()); + } + } else if (range.length == 1) { + weekList.add(range[0]); + } + } void step3() { List cache = weekInterval.split(","); - for (int i = 0; i < cache.length; i++) { - if (cache[i].split("-").length == 1) { - weekList.add(cache[i]); - continue; + for (String section in cache) { + step3ForSection(section); + } + } + + void handleSingleOrDouble(String section, bool isEven) { + String key = isEven ? "双" : "单"; + section = section.replaceAll(key, ""); // 去掉“单”或“双”关键字 + List range = section.split("-"); + + if (range.length == 2) { + for (int i = int.parse(range[0]); i <= int.parse(range[1]); i++) { + if (isEven ? i.isEven : i.isOdd) { + weekList.add(i.toString()); + } } - for (int j = int.parse(cache[i].split("-")[0]); j <= int.parse(cache[i].split("-")[1]); j++) { - weekList.add(j.toString()); + } else if (range.length == 1) { + if (int.parse(range[0]).isEven == isEven) { + weekList.add(range[0]); } } } - void step4(bool isEven) { - String key = isEven ? "双" : "单"; - if (weekInterval.indexOf(",") != -1) { - List cache = weekInterval.split(","); - if (cache[0].indexOf(key) != -1) { - weekList = cache[0].replaceAll(key, "").split("-"); - weekInterval = cache[1]; + void step4() { + List cache = weekInterval.split(","); // 按逗号分隔区间 + weekList = []; // 初始化周数列表 + + for (String section in cache) { + if (section.contains("单")) { + handleSingleOrDouble(section, false); // 处理“单”周 + } else if (section.contains("双")) { + handleSingleOrDouble(section, true); // 处理“双”周 } else { - weekList = cache[1].replaceAll(key, "").split("-"); - weekInterval = cache[0]; + step3ForSection(section); // 处理普通区间 } - weekList = initList(isEven); - - step3(); - weekList.sort((a, b) => int.parse(a) - int.parse(b)); - } else { - weekInterval = weekInterval.replaceAll(key, ""); - weekList = weekInterval.split("-"); - weekList = initList(isEven); } } + // weekInterval = "11-14,15-17单"; + // weekInterval = "11"; + // weekInterval = "11-14双,15-17单"; + // weekInterval = "11,15-17双"; + // switch (i) { + // case 0: + // weekInterval = "11-14,15-17单"; + // break; + // case 1: + // weekInterval = "11-14双,15-17单"; + // break; + // case 2: + // weekInterval = "11-14,16-17"; + // break; + // case 3: + // weekInterval = "11"; + // break; + // } + //单周 - if (weekInterval.indexOf("单") != -1) { - step4(false); - //双周 - } else if (weekInterval.indexOf("双") != -1) { - step4(true); - } else if (weekInterval.indexOf(",") != -1) { - if (weekInterval.indexOf("-") != -1) { - step3(); - } else { - weekInterval = weekInterval.replaceAll(",", "-"); - weekList = weekInterval.split("-"); - } - print(weekList); + if (weekInterval.contains("单") || weekInterval.contains("双")) { + step4(); // 混合“单/双”处理 + } else if (weekInterval.contains(",")) { + step3(); // 普通区间处理 } else { specialWeek = false; weekList = weekInterval.split("-"); } + + if (lessonList.length > 1 && weekCN != " ") for (int lesson = int.parse(lessonList[0]); lesson <= int.parse(lessonList[1]); lesson++) { // 普通模式 diff --git a/lib/main.dart b/lib/main.dart index f94f6b6..1d68f3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:glutassistantn/common/log.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 0cadbb0..3c38695 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "https://pub.flutter-io.cn" # Remove this line if you wish to publis # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.6.241121+72 +version: 1.6.241125+74 environment: sdk: ">=2.14.0 <4.0.0"