desktop tab lable format: id/alias@hostname

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-09-26 15:11:31 +08:00
parent 4e97d2503b
commit e000fdfb50
8 changed files with 50 additions and 24 deletions

View File

@@ -2303,7 +2303,7 @@ String getWindowName({WindowType? overrideType}) {
}
String getWindowNameWithId(String id, {WindowType? overrideType}) {
return "${DesktopTab.labelGetterAlias(id).value} - ${getWindowName(overrideType: overrideType)}";
return "${DesktopTab.tablabelGetter(id).value} - ${getWindowName(overrideType: overrideType)}";
}
Future<void> updateSystemWindowTheme() async {
@@ -2536,3 +2536,21 @@ Widget buildErrorBanner(BuildContext context,
)).marginOnly(bottom: 14),
));
}
String getDesktopTabLabel(String peerId, String alias) {
String label = alias.isEmpty ? peerId : alias;
try {
String peer = bind.mainGetPeerSync(id: peerId);
Map<String, dynamic> config = jsonDecode(peer);
if (config['info']['hostname'] is String) {
String hostname = config['info']['hostname'];
if (hostname.isNotEmpty &&
!label.toLowerCase().contains(hostname.toLowerCase())) {
label += "@$hostname";
}
}
} catch (e) {
debugPrint("Failed to get hostname:$e");
}
return label;
}