diff --git a/ci/Cargo.toml b/ci/Cargo.toml index 44b2372..5784f5c 100644 --- a/ci/Cargo.toml +++ b/ci/Cargo.toml @@ -20,11 +20,11 @@ name = "community-notify" path = "src/community_notify/main.rs" [dependencies] -anyhow = "1.0.56" +anyhow = "1.0.75" reqwest = { version = "0.11.10", features = ["json"] } -serde = "1.0.136" -serde_derive = "1.0.136" -serde_json = "1.0.79" -tokio = { version = "1.17.0", features = ["full"] } +serde = { version = "1.0.190", features = ["derive"] } +serde_derive = "1.0.190" +serde_json = "1.0.108" +tokio = { version = "1.33.0", features = ["full"] } teloxide = { version = "0.9", features = ["macros", "auto-send"] } serenity = { version = "0.11", features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"], default-features = false } diff --git a/ci/version.code.txt b/ci/version.code.txt index b78946b..57645dd 100644 --- a/ci/version.code.txt +++ b/ci/version.code.txt @@ -1 +1 @@ -v0.2.3 \ No newline at end of file +v0.2.5 \ No newline at end of file diff --git a/ci/version.info.txt b/ci/version.info.txt index a52e55b..88c45ec 100644 --- a/ci/version.info.txt +++ b/ci/version.info.txt @@ -1,3 +1,3 @@ -v0.2.3 +v0.2.5 - [x] ♻️ Network diff --git a/lib/configs/login.dart b/lib/configs/login.dart index 2b008ea..6194908 100644 --- a/lib/configs/login.dart +++ b/lib/configs/login.dart @@ -170,23 +170,8 @@ class _LoginDialogState extends State<_LoginDialog> { margin: const EdgeInsets.all(10), child: MaterialButton( color: Colors.orange.shade700, - onPressed: () async { - String? fen = await chooseMapDialog( - context, - values: { - "国际分流1": "aHR0cHM6Ly8xOGNvbWljLnZpcC9zaWdudXA=", - "国际分流2": "aHR0cHM6Ly8xOGNvbWljLm9yZy9zaWdudXA=", - "东南亚分流3": "aHR0cHM6Ly9qbWNvbWljLm1lL3NpZ251cA==", - "东南亚分流4": "aHR0cHM6Ly9qbWNvbWljMS5tZS9zaWdudXA=", - "内地分流5": "aHR0cHM6Ly9qbS1jb21pYzIuY2Mvc2lnbnVw", - "分流7": "aHR0cHM6Ly9qbS1jb21pYy5vcmcvc2lnbnVw", - "分流8": "aHR0cHM6Ly9qbWNvbWljMi5ncm91cC9zaWdudXA=", - }, - title: "选择注册分流", - ); - if (fen != null) { - openUrl(String.fromCharCodes(base64Decode(fen))); - } + onPressed: () { + regxxx(context); }, child: Container( padding: const EdgeInsets.all(10), @@ -223,3 +208,22 @@ class _LoginDialogState extends State<_LoginDialog> { ); } } + +Future regxxx(BuildContext context) async { + String? fen = await chooseMapDialog( + context, + values: { + "國際通用網域1": "aHR0cHM6Ly8xOGNvbWljLnZpcC9zaWdudXA=", + "國際通用網域2": "aHR0cHM6Ly8xOGNvbWljLm9yZy9zaWdudXA=", + "东南亚分流1": "aHR0cHM6Ly9qbWNvbWljLm1lL3NpZ251cA==", + "东南亚分流2": "aHR0cHM6Ly9qbWNvbWljMS5tZS9zaWdudXA=", + "内地分流0": "aHR0cHM6Ly8xOGNvbWljLWdvZC5jYy9zaWdudXA=", + "内地分流1": "aHR0cHM6Ly8xOGNvbWljLWdvZC5jbHViL3NpZ251cA==", + "内地分流2": "aHR0cHM6Ly8xOGNvbWljLWdvZC54eXovc2lnbnVw", + }, + title: "选择注册分流", + ); + if (fen != null) { + openUrl(String.fromCharCodes(base64Decode(fen))); + } +} diff --git a/lib/configs/network_cdn_host.dart b/lib/configs/network_cdn_host.dart index b5a6c54..f3a42b5 100644 --- a/lib/configs/network_cdn_host.dart +++ b/lib/configs/network_cdn_host.dart @@ -22,9 +22,6 @@ Future chooseCdnHost(BuildContext context) async { "随机": "0", "分流1": "1", "分流2": "2", - "分流3": "3", - "分流4": "4", - "分流5": "5", }, ); if (choose != null) { diff --git a/lib/screens/app_screen.dart b/lib/screens/app_screen.dart index cfe1cef..661531d 100644 --- a/lib/screens/app_screen.dart +++ b/lib/screens/app_screen.dart @@ -20,7 +20,7 @@ class _AppScreenState extends State { late final List _screens = [ AppScreenData( - BrowserScreen(searchBarController: _searchBarController), + BrowserScreenWrapper(searchBarController: _searchBarController), '浏览', const Icon(Icons.menu_book_outlined), const Icon(Icons.menu_book), diff --git a/lib/screens/browser_screen.dart b/lib/screens/browser_screen.dart index 91793a1..25f40c6 100644 --- a/lib/screens/browser_screen.dart +++ b/lib/screens/browser_screen.dart @@ -4,12 +4,67 @@ import 'package:flutter/material.dart'; import 'package:jenny/basic/methods.dart'; import 'package:jenny/screens/components/comic_pager.dart'; import 'package:jenny/screens/components/content_builder.dart'; +import 'package:jenny/screens/components/content_error.dart'; +import 'package:jenny/screens/components/content_loading.dart'; import 'package:jenny/screens/components/floating_search_bar.dart'; +import '../configs/login.dart'; import 'components/browser_bottom_sheet.dart'; import 'components/actions.dart'; import 'components/comic_floating_search_bar.dart'; +class BrowserScreenWrapper extends StatefulWidget { + final FloatingSearchBarController searchBarController; + + const BrowserScreenWrapper({Key? key, required this.searchBarController}) + : super(key: key); + + @override + State createState() => _BrowserScreenWrapperState(); +} + +class _BrowserScreenWrapperState extends State { + @override + void initState() { + loginEvent.subscribe(_setState); + super.initState(); + } + + @override + void dispose() { + loginEvent.unsubscribe(_setState); + super.dispose(); + } + + void _setState(_) { + setState(() {}); + } + + @override + Widget build(BuildContext context) { + switch (loginStatus) { + case LoginStatus.loginSuccess: + return BrowserScreen(searchBarController: widget.searchBarController); + case LoginStatus.loginField: + return ContentError( + error: "请先登录", + stackTrace: StackTrace.current, + onRefresh: () async {}, + ); + case LoginStatus.logging: + return const ContentLoading( + label: "登录中", + ); + case LoginStatus.notSet: + return ContentError( + error: "请先登录", + stackTrace: StackTrace.current, + onRefresh: () async {}, + ); + } + } +} + class BrowserScreen extends StatefulWidget { final FloatingSearchBarController searchBarController; diff --git a/lib/screens/first_login_screen.dart b/lib/screens/first_login_screen.dart index 3f57bfd..348aa2a 100644 --- a/lib/screens/first_login_screen.dart +++ b/lib/screens/first_login_screen.dart @@ -97,31 +97,39 @@ class _FirstLoginScreenState extends State { actions: _logging ? [] : [ - IconButton( - onPressed: () { - setState(() { - _onClickVersion++; - }); - if (_onClickVersion >= 7) { - openUrl(String.fromCharCodes(base64Decode("aHR0cHM6Ly9qbWNvbWljMS5yb2Nrcy9zaWdudXA="))); - } - }, - icon: Text(currentVersion()), - ), - _saveButton, - ], + IconButton( + onPressed: () { + setState(() { + _onClickVersion++; + }); + if (_onClickVersion >= 7) { + openUrl(String.fromCharCodes(base64Decode( + "aHR0cHM6Ly9qbWNvbWljMS5yb2Nrcy9zaWdudXA="))); + } + }, + icon: Text(currentVersion()), + ), + _saveButton, + ], ), body: ListView( children: _logging ? [ - const Center(child: ContentLoading()), - ] + const Center(child: ContentLoading()), + ] : [ - _usernameField(), - _passwordField(), - apiHostSetting(), - cdnHostSetting(), - ], + _usernameField(), + _passwordField(), + apiHostSetting(), + cdnHostSetting(), + const Divider(), + ListTile( + title: const Text("注册"), + onTap: () { + regxxx(context); + }, + ), + ], ), ); } diff --git a/lib/screens/init_screen.dart b/lib/screens/init_screen.dart index 30473ce..bb5e44b 100644 --- a/lib/screens/init_screen.dart +++ b/lib/screens/init_screen.dart @@ -6,8 +6,6 @@ import 'package:jenny/basic/commons.dart'; import 'package:jenny/basic/methods.dart'; import 'package:jenny/configs/configs.dart'; import 'package:jenny/configs/login.dart'; -import 'package:jenny/configs/passed.dart'; -import 'package:jenny/screens/calculator_screen.dart'; import '../basic/web_dav_sync.dart'; import 'app_screen.dart'; @@ -61,12 +59,13 @@ class _InitScreenState extends State { try { await methods.init(); await initConfigs(); - if (!currentPassed()) { + print("STATE : ${loginStatus}"); + if (loginStatus == LoginStatus.notSet) { Future.delayed(Duration.zero, () async { await webDavSyncAuto(context); Navigator.of(context).pushReplacement( MaterialPageRoute(builder: (BuildContext context) { - return const CalculatorScreen(); + return firstLoginScreen; }), ); }); diff --git a/pubspec.yaml b/pubspec.yaml index e3cf212..bea9582 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: jenny comic browser publish_to: 'none' -version: 0.2.3+23 +version: 0.2.2+22 environment: sdk: ">=2.15.1 <3.0.0"