wzq %!s(int64=5) %!d(string=hai) anos
pai
achega
c55257785b
Modificáronse 2 ficheiros con 10 adicións e 1 borrados
  1. 9 0
      app/Helper/helper.php
  2. 1 1
      app/Repositories/MemberGroupRepository.php

+ 9 - 0
app/Helper/helper.php

@@ -121,3 +121,12 @@ function jsonError($msg)
     );
     return $response;
 }
+
+function subtext($text, $length)
+{
+    if(mb_strlen($text, 'utf8') > $length) {
+        return mb_substr($text, 0, $length - 1, 'utf8').'...';
+    } else {
+        return $text;
+    }
+}

+ 1 - 1
app/Repositories/MemberGroupRepository.php

@@ -61,7 +61,7 @@ class MemberGroupRepository {
                        }
                        $data[] = [
                            'uid' => $user['uid'],
-                           'username' => $user['username'],
+                           'username' => subtext($user['username'], 10),
                            'avatar' => $user['avatar'],
                            'follow_status' => $this->getFollowStatus($userInfo['uid'], $user['uid']),
                            'follow_topic' => $names,