feat: release undergraduate integration 0.7.0
This commit is contained in:
@@ -102,8 +102,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
return NavigationDecision.prevent;
|
||||
}
|
||||
if (request.isMainFrame &&
|
||||
UndergraduateNavigationPolicy.isLogout(uri))
|
||||
UndergraduateNavigationPolicy.isLogout(uri)) {
|
||||
invalidateAuthentication();
|
||||
}
|
||||
return NavigationDecision.navigate;
|
||||
},
|
||||
onPageStarted: (_) {
|
||||
@@ -123,8 +124,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
final g = _generation,
|
||||
d = _document,
|
||||
current = await web.currentUrl();
|
||||
if (_valid(g) && d == _document && error.url == current)
|
||||
if (_valid(g) && d == _document && error.url == current) {
|
||||
_failure('学校页面加载未完成,请检查网络后重试。');
|
||||
}
|
||||
},
|
||||
onHttpError: (error) async {
|
||||
final g = _generation,
|
||||
@@ -132,8 +134,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
current = await web.currentUrl();
|
||||
if (_valid(g) &&
|
||||
d == _document &&
|
||||
error.request?.uri.toString() == current)
|
||||
error.request?.uri.toString() == current) {
|
||||
_failure('学校请求未完成,请稍后重试。');
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -184,7 +187,7 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
_active = true;
|
||||
if (hasOpened && !_complete && !_failed) {
|
||||
if (hasOpened && !_loading && !_complete && !_failed) {
|
||||
unawaited(
|
||||
web.currentUrl().then((url) {
|
||||
if (url != null && _active) _loaded(url);
|
||||
@@ -216,8 +219,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
void _schedulePoll(int g, int document, String url) {
|
||||
_poll?.cancel();
|
||||
_poll = Timer(const Duration(milliseconds: 450), () {
|
||||
if (_valid(g) && _document == document && !_failed && !_complete)
|
||||
if (_valid(g) && _document == document && !_failed && !_complete) {
|
||||
unawaited(_loaded(url));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -237,8 +241,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
if (!_valid(g) || d != _document || current != url) return;
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null ||
|
||||
!UndergraduateNavigationPolicy.canNavigate(uri, isMainFrame: true))
|
||||
!UndergraduateNavigationPolicy.canNavigate(uri, isMainFrame: true)) {
|
||||
return;
|
||||
}
|
||||
final status = await _evidence(uri, false);
|
||||
if (!_valid(g) || d != _document) return;
|
||||
_loading = false;
|
||||
@@ -319,8 +324,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
final evidence = await _evidence(current, true);
|
||||
if (!_valid(g) || d != _document) return;
|
||||
final pages = evidence.pages.where((p) => p.kind == 'timetable').toList();
|
||||
if (pages.length != 1)
|
||||
if (pages.length != 1) {
|
||||
throw const FormatException('请先在学校网页打开完整课表,再点击导入。');
|
||||
}
|
||||
final draft = UndergraduateTimetableAdapter.extract(
|
||||
pages.single.html,
|
||||
pages.single.url,
|
||||
@@ -345,8 +351,9 @@ class UndergraduateSession extends ChangeNotifier {
|
||||
}
|
||||
|
||||
bool saved({required int generation}) {
|
||||
if (!_valid(generation) || pendingDraft == null && pendingExams == null)
|
||||
if (!_valid(generation) || pendingDraft == null && pendingExams == null) {
|
||||
return false;
|
||||
}
|
||||
pendingDraft = null;
|
||||
pendingExams = null;
|
||||
message = '已导入';
|
||||
|
||||
Reference in New Issue
Block a user