设备名称 人员名称 显示长度限制

This commit is contained in:
czz
2025-08-05 17:55:12 +08:00
parent 00215e99d2
commit 16a304cae8
5 changed files with 312 additions and 219 deletions

View File

@@ -117,7 +117,7 @@ class _MinePageState extends State<NewMinePage> {
child: Row(
children: [
Obx(() {
userInfoController.model.login!;
userInfoController.model.login!;
return Container(
width: 120.rpx,
height: 120.rpx,
@@ -151,12 +151,29 @@ class _MinePageState extends State<NewMinePage> {
children: [
Row(
children: [
// Text(
// login == 1
// ? (userInfoController
// .model.user!.nick_name ??
// '未命名'.tr)
// : "未命名".tr,
// style: TextStyle(
// fontFamily: 'Inter',
// color: themeController.currentColor.sc3,
// fontSize:
// AppConstants().title_text_fontSize,
// letterSpacing: 0.0,
// ),
// ),
Text(
login == 1
? (userInfoController
.model.user!.nick_name ??
'未命名'.tr)
: "未命名".tr,
limitText(
login == 1
? userInfoController
.model.user?.nick_name
: '未命名'.tr,
AppConstants()
.text_length, // 这里设置最大长度,按你需求改,比如 6~10 字符
),
style: TextStyle(
fontFamily: 'Inter',
color: themeController.currentColor.sc3,
@@ -491,3 +508,10 @@ class _MinePageState extends State<NewMinePage> {
);
}
}
String limitText(String? text, int maxLength) {
if (text == null || text.isEmpty) return '';
if (text.characters.length <= maxLength) return text;
return text.characters.take(maxLength).toString() + '...';
}