Procházet zdrojové kódy

fix: 家庭成员管理页 isAdmin 类型比较修复,管理员删除/编辑按钮恢复显示

- isAdmin = String(creatorId) === String(userId),避免 JSON 数字与 storage 字符串严格相等恒 false
- 列表过滤自身成员同样按 String 归一(m.userId === userId 类型敏感)
liaoxg před 1 měsícem
rodič
revize
9ba080117e

+ 3 - 2
cfc-frontend/pages/profile-extra/family-members.vue

@@ -170,7 +170,7 @@ export default {
       var self = this
       return (this.members || []).filter(function(m) {
         var isSelf = m.isSelf === true
-        if (!isSelf && m.userId && m.userId === self.userId) {
+        if (!isSelf && m.userId && String(m.userId) === String(self.userId)) {
           isSelf = true
         }
         return !isSelf
@@ -281,7 +281,8 @@ export default {
           this.familyId = data.familyId
           this.familyName = data.familyName
           this.creatorId = data.creatorId
-          this.isAdmin = this.creatorId === this.userId
+          // creatorId 来自后端 JSON(数字),userId 来自 storage(可能为字符串),用 String 归一避免 === 恒 false 导致管理员按钮不显示
+          this.isAdmin = String(this.creatorId) === String(this.userId)
           var arr = data.members
           if (!(arr instanceof Array)) {
             // 后端旧版本未返回 members 字段时的兼容:补一次无参请求