diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d57a98..c4b5d8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 1.0.2 +* 支持修改用户名密码(仅限使用用户名密码登录用户) * 支持脚本的编辑删除 * 支持client_id登录之后只启用部分模块 diff --git a/lib/base/http/http.dart b/lib/base/http/http.dart index c1ed0c5..f89e33c 100644 --- a/lib/base/http/http.dart +++ b/lib/base/http/http.dart @@ -22,9 +22,9 @@ class Http { _dio = Dio( BaseOptions( baseUrl: host, - connectTimeout: 5000, - receiveTimeout: 5000, - sendTimeout: 5000, + connectTimeout: 50000, + receiveTimeout: 50000, + sendTimeout: 50000, contentType: "application/json", ), ); @@ -38,6 +38,10 @@ class Http { } } + static void clear() { + _dio = null; + } + static Future> get( String uri, Map? json, { @@ -124,8 +128,9 @@ class Http { static HttpResponse exceptionHandler(DioError e) { if (e.response?.statusCode == 401 && !getIt().useSecretLogined) { exitLogin(); - } return HttpResponse(success: false, message: "没有该模块的访问权限", code: 0); + } + return HttpResponse(success: false, message: e.message, code: 0); } static HttpResponse decodeResponse( diff --git a/lib/module/login/login_page.dart b/lib/module/login/login_page.dart index 80954e7..f811ed6 100644 --- a/lib/module/login/login_page.dart +++ b/lib/module/login/login_page.dart @@ -22,8 +22,7 @@ class LoginPage extends ConsumerStatefulWidget { } class _LoginPageState extends ConsumerState { - final TextEditingController _hostController = - TextEditingController(text: getIt().host); + final TextEditingController _hostController = TextEditingController(text: getIt().host); final TextEditingController _userNameController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); final TextEditingController _cIdController = TextEditingController(); @@ -39,8 +38,7 @@ class _LoginPageState extends ConsumerState { super.initState(); useSecretLogin = getIt().useSecretLogined; - if (getIt().userName != null && - getIt().userName!.isNotEmpty) { + if (getIt().userName != null && getIt().userName!.isNotEmpty) { if (getIt().useSecretLogined) { _cIdController.text = getIt().userName!; } else { @@ -50,8 +48,7 @@ class _LoginPageState extends ConsumerState { } else { rememberPassword = false; } - if (getIt().passWord != null && - getIt().passWord!.isNotEmpty) { + if (getIt().passWord != null && getIt().passWord!.isNotEmpty) { if (getIt().useSecretLogined) { _cSecretController.text = getIt().passWord!; } else { @@ -181,8 +178,7 @@ class _LoginPageState extends ConsumerState { }, controller: _userNameController, decoration: const InputDecoration( - contentPadding: - EdgeInsets.fromLTRB(0, 5, 0, 5), + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), hintText: "请输入用户名", ), autofocus: false, @@ -204,8 +200,7 @@ class _LoginPageState extends ConsumerState { controller: _passwordController, obscureText: true, decoration: const InputDecoration( - contentPadding: - EdgeInsets.fromLTRB(0, 5, 0, 5), + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), hintText: "请输入密码", ), autofocus: false, @@ -239,8 +234,7 @@ class _LoginPageState extends ConsumerState { }, controller: _cIdController, decoration: const InputDecoration( - contentPadding: - EdgeInsets.fromLTRB(0, 5, 0, 5), + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), hintText: "请输入client_id", ), autofocus: false, @@ -262,8 +256,7 @@ class _LoginPageState extends ConsumerState { controller: _cSecretController, obscureText: true, decoration: const InputDecoration( - contentPadding: - EdgeInsets.fromLTRB(0, 5, 0, 5), + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), hintText: "请输入client_secret", ), autofocus: false, @@ -294,8 +287,7 @@ class _LoginPageState extends ConsumerState { GestureDetector( onTap: () { cardKey.currentState?.toggleCard(); - WidgetsBinding.instance - ?.addPostFrameCallback((timeStamp) { + WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { setState(() {}); }); }, @@ -319,14 +311,7 @@ class _LoginPageState extends ConsumerState { padding: const EdgeInsets.symmetric( vertical: 5, ), - color: canClickLoginBtn() - ? ref - .watch(themeProvider) - .themeColor - .buttonBgColor() - : Theme.of(context) - .primaryColor - .withOpacity(0.4), + color: canClickLoginBtn() ? ref.watch(themeProvider).themeColor.buttonBgColor() : Theme.of(context).primaryColor.withOpacity(0.4), child: isLoading ? const CupertinoActivityIndicator() : const Text( @@ -338,14 +323,12 @@ class _LoginPageState extends ConsumerState { onPressed: () { Http.pushedLoginPage = false; Utils.hideKeyBoard(context); - getIt() - .updateHost(_hostController.text); + getIt().updateHost(_hostController.text); + Http.clear(); if (loginByUserName()) { - login(_userNameController.text, - _passwordController.text); + login(_userNameController.text, _passwordController.text); } else { - login(_cIdController.text, - _cSecretController.text); + login(_cIdController.text, _cSecretController.text); } }, ), @@ -390,9 +373,7 @@ class _LoginPageState extends ConsumerState { } else { HttpResponse userResponse = await Api.user(); if (userResponse.success) { - if (userResponse.bean != null && - userResponse.bean!.twoFactorActivated != null && - userResponse.bean!.twoFactorActivated!) { + if (userResponse.bean != null && userResponse.bean!.twoFactorActivated != null && userResponse.bean!.twoFactorActivated!) { ("你已开启两步验证,App暂不支持").toast(); isLoading = false; setState(() {}); @@ -417,11 +398,9 @@ class _LoginPageState extends ConsumerState { if (_hostController.text.isEmpty) return false; if (!loginByUserName()) { - return _cIdController.text.isNotEmpty && - _cSecretController.text.isNotEmpty; + return _cIdController.text.isNotEmpty && _cSecretController.text.isNotEmpty; } else { - return _userNameController.text.isNotEmpty && - _passwordController.text.isNotEmpty; + return _userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty; } } } diff --git a/pubspec.yaml b/pubspec.yaml index f257197..62e605a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: qinglong_app description: A new Flutter project. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.0.1+2 +version: 1.0.2+3 environment: sdk: ">=2.15.1 <3.0.0"