From f35500f47fa4ab772b4c7836052d6946b8dc3e1a Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 20 Feb 2021 10:18:07 +0800 Subject: [PATCH 1/2] upgrade power_logger to 0.1.0 (online version) --- pubspec.lock | 8 +++----- pubspec.yaml | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 8b03cf0..e32c070 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -495,11 +495,9 @@ packages: power_logger: dependency: "direct main" description: - path: "." - ref: HEAD - resolved-ref: "5a6be230ed03e9da941b2c67018e4a6bc3e81759" - url: "http://192.168.2.201:8099/aku_fe/power_logger.git" - source: git + name: power_logger + url: "https://pub.flutter-io.cn" + source: hosted version: "0.1.0" pretty_json: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 7ba30c5..2113512 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,9 +49,7 @@ dependencies: dio: - power_logger: - git: - url: http://192.168.2.201:8099/aku_fe/power_logger.git + power_logger: ^0.1.0 logger: ^0.9.4 aku_ui: git: From 051c8f6f97d967138f34559c121d5e38a9e22471 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 20 Feb 2021 10:19:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E9=99=90?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 3 +++ lib/provider/user_provider.dart | 18 +++++++++--------- lib/utils/network/net_util.dart | 9 +++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index 97d970f..d8ee73a 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -21,6 +21,9 @@ class _Auth { ///登录/退出:管家app用户短信登录 String get login => '/login/loginSMSUser'; + + ///登录/退出:管家用户退出账户 + String get logout => '/user/signOut'; } class _User { diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index acefa69..122220c 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -2,6 +2,7 @@ import 'dart:io'; // Flutter imports: +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Project imports: @@ -24,13 +25,9 @@ class UserProvider extends ChangeNotifier { ///登陆 Future setLogin(int token) async { _isLogin = true; - NetUtil() - .dio - .options - .headers - .putIfAbsent('butlerApp-admin-token', () => token); - HiveStore.appBox.put('token', token); - HiveStore.appBox.put('login', true); + NetUtil().auth(token); + await HiveStore.appBox.put('token', token); + await HiveStore.appBox.put('login', true); _profileModel = await updateProfile(); _infoModel = await updateUserInfo(); // await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true) @@ -62,9 +59,12 @@ class UserProvider extends ChangeNotifier { } ///注销登录 - logout() { + logout() async { + await NetUtil().get(API.auth.logout, showMessage: true); + NetUtil().logout(); _isLogin = false; - HiveStore.appBox.delete('token'); + await HiveStore.appBox.delete('token'); + await HiveStore.appBox.put('login', false); notifyListeners(); } diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index a139cfa..b4b96d6 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -37,6 +37,7 @@ class NetUtil { onRequest: (RequestOptions options) async => options, onResponse: (Response response) async { LoggerData.addData(response); + print(response.headers); return response; }, onError: (DioError error) async { @@ -47,8 +48,12 @@ class NetUtil { } ///call auth after login - auth(String token) { - _dio.options.headers.putIfAbsent('Butler-Admin-Token', () => token); + auth(int token) { + _dio.options.headers.putIfAbsent('butlerApp-admin-token', () => token); + } + + logout() { + _dio.options.headers.remove('butlerApp-admin-token'); } /// ## alias of Dio().get