fix cm client authorized

This commit is contained in:
csf 2022-08-23 15:25:18 +08:00
parent 5326e32128
commit befb6ffe8f
3 changed files with 13 additions and 4 deletions

View File

@ -18,11 +18,11 @@ import 'models/platform_model.dart';
final globalKey = GlobalKey<NavigatorState>();
final navigationBarKey = GlobalKey();
var isAndroid = Platform.isAndroid;
var isIOS = Platform.isIOS;
final isAndroid = Platform.isAndroid;
final isIOS = Platform.isIOS;
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
var isWeb = false;
var isWebDesktop = false;
var isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
var version = "";
int androidVersion = 0;

View File

@ -161,6 +161,7 @@ class DesktopTabBar extends StatelessWidget {
}
static onAdd(RxList<TabInfo> tabs, TabInfo tab) {
if (!isDesktop) return;
int index = tabs.indexWhere((e) => e.key == tab.key);
if (index >= 0) {
selected.value = index;
@ -178,6 +179,7 @@ class DesktopTabBar extends StatelessWidget {
}
static remove(RxList<TabInfo> tabs, int index) {
if (!isDesktop) return;
if (index < 0) return;
if (index == tabs.length - 1) {
selected.value = max(0, selected.value - 1);
@ -189,12 +191,14 @@ class DesktopTabBar extends StatelessWidget {
}
static void jumpTo(RxList<TabInfo> tabs, int index) {
if (!isDesktop) return;
if (index < 0 || index >= tabs.length) return;
selected.value = index;
controller.value.jumpToPage(selected.value);
}
static void close(String? key) {
if (!isDesktop) return;
final tabBar = _tabBarListViewKey.currentWidget as _ListView?;
if (tabBar == null) return;
final tabs = tabBar.tabs;

View File

@ -465,7 +465,12 @@ class ServerModel with ChangeNotifier {
try {
final client = Client.fromJson(jsonDecode(evt['client']));
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(client.id));
_clients.add(client);
final index = _clients.indexWhere((c) => c.id == client.id);
if (index < 0) {
_clients.add(client);
} else {
_clients[index].authorized = true;
}
DesktopTabBar.onAdd(
tabs,
TabInfo(