diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index a4d0e28c..56997947 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -16,7 +16,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
- java-version: '11.0'
+ java-version: '17.0'
- name: Decrypt Android keys
run: sh ./.github/scripts/decrypt_android_keys.sh
env:
@@ -50,8 +50,14 @@ jobs:
deploy_ios:
name: iOS Deploy TestFlight
- runs-on: macOS-latest
+ runs-on: macos-13
steps:
+ # Ensure the xcode version is available
+ - name: List Xcode installations
+ run: sudo ls -1 /Applications | grep "Xcode"
+ # Select your required version
+ - name: Select Xcode 15.0
+ run: sudo xcode-select -s /Applications/Xcode_15.0.app/Contents/Developer
- name: Checkout code
uses: actions/checkout@v2
with:
diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml
index fcaa93db..8e2ff1e9 100644
--- a/.github/workflows/workflow.yml
+++ b/.github/workflows/workflow.yml
@@ -38,7 +38,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
- java-version: '11.0'
+ java-version: '17.0'
- name: Decrypt Android keys
run: sh ./.github/scripts/decrypt_android_keys.sh
env:
@@ -53,8 +53,14 @@ jobs:
build_ios:
name: Build iOS App
- runs-on: macOS-latest
+ runs-on: macos-13
steps:
+ # Ensure the xcode version is available
+ - name: List Xcode installations
+ run: sudo ls -1 /Applications | grep "Xcode"
+ # Select your required version
+ - name: Select Xcode 15.0
+ run: sudo xcode-select -s /Applications/Xcode_15.0.app/Contents/Developer
- name: Checkout code
uses: actions/checkout@v2
- name: Decrypt iOS keys
diff --git a/assets_test/login/password_error_five.html b/assets_test/login/password_error_five.html
new file mode 100644
index 00000000..410eafd4
--- /dev/null
+++ b/assets_test/login/password_error_five.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ios/CourseAppWidget/CourseAppWidget.swift b/ios/CourseAppWidget/CourseAppWidget.swift
index f0fe2565..34ab4ae6 100644
--- a/ios/CourseAppWidget/CourseAppWidget.swift
+++ b/ios/CourseAppWidget/CourseAppWidget.swift
@@ -119,7 +119,7 @@ struct CourseAppWidgetEntryView: View {
.padding([.trailing, .leading], 8)
.multilineTextAlignment(.center)
}
- .background(getContentBackgroudColor())
+ .widgetBackground(getContentBackgroudColor())
}
}
}
@@ -134,6 +134,7 @@ struct CourseAppWidget: Widget {
}
.configurationDisplayName("上課提醒")
.description("提醒本日下一堂課")
+ .disableContentMarginsIfNeeded()
}
}
@@ -143,3 +144,25 @@ struct CourseAppWidget_Previews: PreviewProvider {
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
+
+extension View {
+ func widgetBackground(_ backgroundView: some View) -> some View {
+ if #available(iOSApplicationExtension 17.0, *) {
+ return containerBackground(for: .widget) {
+ backgroundView
+ }
+ } else {
+ return background(backgroundView)
+ }
+ }
+}
+
+extension WidgetConfiguration {
+ func disableContentMarginsIfNeeded() -> some WidgetConfiguration {
+ if #available(iOSApplicationExtension 17.0, *) {
+ return self.contentMarginsDisabled()
+ } else {
+ return self
+ }
+ }
+}
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index b62f0bab..bb5b2134 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -17,9 +17,26 @@
A4465982221FF258008B8826 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A4465984221FF258008B8826 /* InfoPlist.strings */; };
A45559A0217B2AE100687009 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = A455599F217B2AE100687009 /* GoogleService-Info.plist */; };
A461B7E4222AE0E20080F604 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A461B7E3222AE0E20080F604 /* AdSupport.framework */; };
+ A4E3F874252644D700343570 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4E3F873252644D700343570 /* WidgetKit.framework */; };
+ A4E3F876252644D700343570 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4E3F875252644D700343570 /* SwiftUI.framework */; };
+ A4E3F879252644D700343570 /* CourseAppWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E3F878252644D700343570 /* CourseAppWidget.swift */; };
+ A4E3F87C252644D800343570 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A4E3F87B252644D800343570 /* Assets.xcassets */; };
+ A4E3F87E252644D800343570 /* CourseAppWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = A4E3F87A252644D700343570 /* CourseAppWidget.intentdefinition */; };
A4E3F87F252644D800343570 /* CourseAppWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = A4E3F87A252644D700343570 /* CourseAppWidget.intentdefinition */; };
+ A4E3F883252644D800343570 /* CourseAppWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A4E3F872252644D700343570 /* CourseAppWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
+ A4E3F91C2526499D00343570 /* CourseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E3F91B2526499D00343570 /* CourseData.swift */; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ A4E3F880252644D800343570 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 97C146E61CF9000F007C117D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = A4E3F871252644D700343570;
+ remoteInfo = CourseAppWidgetExtension;
+ };
+/* End PBXContainerItemProxy section */
+
/* Begin PBXCopyFilesBuildPhase section */
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
@@ -37,6 +54,7 @@
dstPath = "";
dstSubfolderSpec = 13;
files = (
+ A4E3F883252644D800343570 /* CourseAppWidgetExtension.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
@@ -67,6 +85,7 @@
A455599F217B2AE100687009 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; };
A45559A5217C871600687009 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; };
A461B7E3222AE0E20080F604 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
+ A4E3F872252644D700343570 /* CourseAppWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = CourseAppWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
A4E3F873252644D700343570 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
A4E3F875252644D700343570 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
A4E3F878252644D700343570 /* CourseAppWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseAppWidget.swift; sourceTree = ""; };
@@ -87,6 +106,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ A4E3F86F252644D700343570 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A4E3F876252644D700343570 /* SwiftUI.framework in Frameworks */,
+ A4E3F874252644D700343570 /* WidgetKit.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -138,6 +166,7 @@
isa = PBXGroup;
children = (
97C146EE1CF9000F007C117D /* Runner.app */,
+ A4E3F872252644D700343570 /* CourseAppWidgetExtension.appex */,
);
name = Products;
sourceTree = "";
@@ -188,6 +217,8 @@
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
3BB8511C87A2DDE3F5418E48 /* [CP] Check Pods Manifest.lock */,
+ A4E3F882252644D800343570 /* Embed App Extensions */,
+ A4B0643825C7EC38006D4AAB /* ShellScript */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
@@ -196,18 +227,34 @@
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
206ACDB7DFB38C569AEBD820 /* [CP] Embed Pods Frameworks */,
A45559A6217D5F9D00687009 /* ShellScript */,
- A4E3F882252644D800343570 /* Embed App Extensions */,
- A4B0643825C7EC38006D4AAB /* ShellScript */,
);
buildRules = (
);
dependencies = (
+ A4E3F881252644D800343570 /* PBXTargetDependency */,
);
name = Runner;
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
};
+ A4E3F871252644D700343570 /* CourseAppWidgetExtension */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = A4E3F886252644D800343570 /* Build configuration list for PBXNativeTarget "CourseAppWidgetExtension" */;
+ buildPhases = (
+ A4E3F86E252644D700343570 /* Sources */,
+ A4E3F86F252644D700343570 /* Frameworks */,
+ A4E3F870252644D700343570 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CourseAppWidgetExtension;
+ productName = CourseAppWidgetExtension;
+ productReference = A4E3F872252644D700343570 /* CourseAppWidgetExtension.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -229,6 +276,11 @@
};
};
};
+ A4E3F871252644D700343570 = {
+ CreatedOnToolsVersion = 12.0;
+ DevelopmentTeam = 5SP52F6F2C;
+ ProvisioningStyle = Automatic;
+ };
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
@@ -247,6 +299,7 @@
projectRoot = "";
targets = (
97C146ED1CF9000F007C117D /* Runner */,
+ A4E3F871252644D700343570 /* CourseAppWidgetExtension */,
);
};
/* End PBXProject section */
@@ -265,6 +318,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ A4E3F870252644D700343570 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A4E3F87C252644D800343570 /* Assets.xcassets in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -455,8 +516,26 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ A4E3F86E252644D700343570 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A4E3F87E252644D800343570 /* CourseAppWidget.intentdefinition in Sources */,
+ A4E3F879252644D700343570 /* CourseAppWidget.swift in Sources */,
+ A4E3F91C2526499D00343570 /* CourseData.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ A4E3F881252644D800343570 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = A4E3F871252644D700343570 /* CourseAppWidgetExtension */;
+ targetProxy = A4E3F880252644D800343570 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin PBXVariantGroup section */
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
isa = PBXVariantGroup;
@@ -684,6 +763,79 @@
};
name = Release;
};
+ A4E3F884252644D800343570 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = CourseAppWidgetExtension.entitlements;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 30602;
+ DEVELOPMENT_TEAM = 5SP52F6F2C;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = CourseAppWidget/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ MARKETING_VERSION = 3.6.2;
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = com.nkust.ap.flutter.CourseAppWidget;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SKIP_INSTALL = YES;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ A4E3F885252644D800343570 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = CourseAppWidgetExtension.entitlements;
+ CODE_SIGN_IDENTITY = "iPhone Distribution";
+ CODE_SIGN_STYLE = Manual;
+ CURRENT_PROJECT_VERSION = 30602;
+ DEVELOPMENT_TEAM = 5SP52F6F2C;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = CourseAppWidget/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ MARKETING_VERSION = 3.6.2;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = com.nkust.ap.flutter.CourseAppWidget;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.nkust.ap.flutter.CourseAppWidget";
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -705,6 +857,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ A4E3F886252644D800343570 /* Build configuration list for PBXNativeTarget "CourseAppWidgetExtension" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A4E3F884252644D800343570 /* Debug */,
+ A4E3F885252644D800343570 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
diff --git a/lib/api/ap_helper.dart b/lib/api/ap_helper.dart
index 918f5187..b8bd1e49 100644
--- a/lib/api/ap_helper.dart
+++ b/lib/api/ap_helper.dart
@@ -138,14 +138,14 @@ class WebApHelper {
data: {
'uid': username,
'pwd': password,
- 'etxt_code': captchaCode
+ 'etxt_code': captchaCode,
},
options: Options(contentType: 'application/x-www-form-urlencoded'),
);
Helper.username = username;
Helper.password = password;
final int code = WebApParser.instance.apLoginParser(res.data);
- switch (WebApParser.instance.apLoginParser(res.data)) {
+ switch (code) {
case -1:
//Captcha error, go retry.
break;
@@ -163,6 +163,11 @@ class WebApHelper {
statusCode: ApStatusCode.userDataError,
message: 'username or password error',
);
+ case 5:
+ throw GeneralResponse(
+ statusCode: ApStatusCode.passwordFiveTimesError,
+ message: 'username or password error',
+ );
case 500:
throw GeneralResponse(
statusCode: ApStatusCode.schoolServerError,
@@ -268,7 +273,7 @@ class WebApHelper {
'https://leave.nkust.edu.tw/SkyDir.aspx',
queryParameters: {
'u': skyDirectData['uid'],
- 'r': skyDirectData['ls_randnum']
+ 'r': skyDirectData['ls_randnum'],
},
options: Options(
followRedirects: false,
@@ -541,7 +546,7 @@ class WebApHelper {
'ag302_01',
{
'yms_yms': '$years#$semesterValue',
- 'cmp_area_id': cmpAreaId
+ 'cmp_area_id': cmpAreaId,
},
);
diff --git a/lib/api/ap_status_code.dart b/lib/api/ap_status_code.dart
index b8e31d06..9b39d7fb 100644
--- a/lib/api/ap_status_code.dart
+++ b/lib/api/ap_status_code.dart
@@ -6,6 +6,7 @@ class ApStatusCode {
static const int cancel = 100;
static const int userDataError = 1401;
static const int unknownError = 1402;
+ static const int passwordFiveTimesError = 1405;
//Common
static const int apiExpire = 401;
diff --git a/lib/api/bus_helper.dart b/lib/api/bus_helper.dart
index 70c2eeee..e65b84aa 100644
--- a/lib/api/bus_helper.dart
+++ b/lib/api/bus_helper.dart
@@ -96,7 +96,7 @@ class BusEncrypt {
'c': i,
'd': j,
'e': k,
- 'f': passwordMD5
+ 'f': passwordMD5,
},
);
}
@@ -222,7 +222,7 @@ class BusHelper {
'n': busEncryptObject.loginEncrypt(
Helper.username!,
Helper.password!,
- )
+ ),
},
options: Options(contentType: Headers.formUrlEncodedContentType),
);
@@ -262,7 +262,7 @@ class BusHelper {
'operation': '全部',
'page': 1,
'start': 0,
- 'limit': 90
+ 'limit': 90,
};
options = Options(contentType: Headers.formUrlEncodedContentType);
} else {
@@ -277,7 +277,7 @@ class BusHelper {
'operation': '全部',
'page': 1,
'start': 0,
- 'limit': 90
+ 'limit': 90,
},
);
options = buildCacheOptions(
diff --git a/lib/api/leave_helper.dart b/lib/api/leave_helper.dart
index e995ae72..af4b716b 100644
--- a/lib/api/leave_helper.dart
+++ b/lib/api/leave_helper.dart
@@ -73,7 +73,7 @@ class LeaveHelper {
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Referer': 'https://leave.nkust.edu.tw/LogOn.aspx',
'Accept-Encoding': 'gzip, deflate',
- 'Accept-Language': 'zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6'
+ 'Accept-Language': 'zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6',
});
dio.options.headers['Connection'] = 'close';
diff --git a/lib/api/mobile_nkust_helper.dart b/lib/api/mobile_nkust_helper.dart
index f2400711..01d2183c 100644
--- a/lib/api/mobile_nkust_helper.dart
+++ b/lib/api/mobile_nkust_helper.dart
@@ -91,7 +91,7 @@ class MobileNkustHelper {
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1623.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/44.0.2403.155 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36',
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36'
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36',
];
String? get userAgent => dio.options.headers['user-agent'] as String?;
@@ -167,7 +167,9 @@ class MobileNkustHelper {
if (data != null) {
if (otherRequestUrl != null) {
final Map requestData = {
- '__RequestVerificationToken': MobileNkustParser.getCSRF(response.data)
+ '__RequestVerificationToken': MobileNkustParser.getCSRF(
+ response.data,
+ ),
};
requestData.addAll(data);
@@ -369,7 +371,7 @@ class MobileNkustHelper {
'driveDate': '$year/$month/$day',
'beginStation': requestData[0],
'endStation': requestData[1],
- '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data)
+ '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data),
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
@@ -469,7 +471,7 @@ class MobileNkustHelper {
'endStation': requestData[1],
'pageNum': 1,
'pageSize': 99,
- '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data)
+ '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data),
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
@@ -514,7 +516,7 @@ class MobileNkustHelper {
'Referer': homeUrl,
},
otherRequestHeader: {
- 'Referer': busViolationRecordsPageUrl
+ 'Referer': busViolationRecordsPageUrl,
},
);
// not pay request
diff --git a/lib/api/nkust_helper.dart b/lib/api/nkust_helper.dart
index ed68312a..532420e6 100644
--- a/lib/api/nkust_helper.dart
+++ b/lib/api/nkust_helper.dart
@@ -106,7 +106,7 @@ class NKUSTHelper {
'data': {
'page': page + 1,
'notification': acadData,
- }
+ },
});
}
}
diff --git a/lib/api/parser/ap_parser.dart b/lib/api/parser/ap_parser.dart
index 3c397ec8..d6187149 100644
--- a/lib/api/parser/ap_parser.dart
+++ b/lib/api/parser/ap_parser.dart
@@ -9,6 +9,9 @@ import 'package:html/dom.dart';
import 'package:html/parser.dart' show parse;
import 'package:nkust_ap/api/helper.dart';
+//TODO confirm this rule
+//ignore_for_file: unreachable_from_main
+
final String specialSpace = String.fromCharCode(160);
class WebApParser {
@@ -83,11 +86,14 @@ class WebApParser {
if (rawHtml.contains(";top.location.href='index.html'")) {
final RegExp regex = RegExp(r"alert\('(.*)'\);");
// log(rawHtml);
- final String? match = regex.firstMatch(rawHtml)?.group(1);
+ final String? match = regex.allMatches(rawHtml).elementAt(1).group(1);
+ log('match $match');
if (match == null) {
return 999;
} else if (match.contains('無此帳號或密碼不正確')) {
return 1;
+ } else if (match.contains('您先前已登入')) {
+ return 5;
} else if (match.contains('繁忙')) {
return 500;
}
@@ -108,7 +114,7 @@ class WebApParser {
'className': null,
'id': null,
'name': null,
- 'pictureUrl': null
+ 'pictureUrl': null,
};
final Document document = parse(html);
final List tdElements = document.getElementsByTagName('td');
@@ -162,8 +168,8 @@ class WebApParser {
'default': {
'year': '108',
'value': '2',
- 'text': '108學年第二學期(Parse失敗)'
- }
+ 'text': '108學年第二學期(Parse失敗)',
+ },
};
final Document document = parse(html);
@@ -178,7 +184,7 @@ class WebApParser {
{
'year': ymsElements[i].attributes['value']!.split('#')[0],
'value': ymsElements[i].attributes['value']!.split('#')[1],
- 'text': ymsElements[i].text
+ 'text': ymsElements[i].text,
},
);
if (ymsElements[i].attributes['selected'] != null) {
@@ -186,7 +192,7 @@ class WebApParser {
data['default'] = {
'year': ymsElements[i].attributes['value']!.split('#')[0],
'value': ymsElements[i].attributes['value']!.split('#')[1],
- 'text': ymsElements[i].text
+ 'text': ymsElements[i].text,
};
}
}
@@ -202,8 +208,8 @@ class WebApParser {
'conduct': null,
'classRank': null,
'departmentRank': null,
- 'average': null
- }
+ 'average': null,
+ },
};
//detail part
try {
@@ -220,7 +226,7 @@ class WebApParser {
'departmentRank': matches.elementAt(3).group(1),
'average': (matches.elementAt(1).group(1) != '')
? double.parse(matches.elementAt(1).group(1)!)
- : 0.0
+ : 0.0,
};
} catch (_) {}
//scores part
@@ -287,7 +293,7 @@ class WebApParser {
'location': {
'building': '',
'room': td[10].text,
- }
+ },
},
);
}
@@ -366,7 +372,7 @@ class WebApParser {
'Thursday',
'Friday',
'Saturday',
- 'Sunday'
+ 'Sunday',
];
try {
for (int weekdayIndex = 0;
@@ -425,7 +431,7 @@ class WebApParser {
Map midtermAlertsParser(String? html) {
final Map data = {
- 'courses':