Skip to content

fix: search localized role names and adjust application type column - #8198

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_role_filter
Nov 27, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_role_filter

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: search localized role names and adjust application type column

>
<el-button text type="primary" @click="handleOpenApplication(row)">
<MkIcon name="icon_admin_outlined" />
</el-button>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a review of the code changes with potential issues and optimization suggestions:

1. Performance Optimization (Critical)

Issue: The v-if condition calls four separate functions (perm.application.system...) on every render cycle for every row in the table. If the permission check involves complex logic or API calls, this will significantly degrade performance for large tables.

Recommendation:
Pre-compute the result of this permission check outside the template loop. Create a computed property or a method that returns a boolean, ensuring it only runs once per data update rather than millions of times during rendering.

// In <script setup>
const canManage = computed(() => {
  return perm.application.system.overviewRead() ||
         perm.application.system.accessRead() ||
         perm.application.system.chatLogRead() ||
         perm.application.system.chatUserRead();
});

Then use it in the template:

<MkTooltip v-if="canManage" :content="t('common.actions.manage')">

2. Readability & Maintenance

Positive Change: Breaking the long v-if line into multiple lines improves readability significantly. This adheres well to Vue/HTML best practices.

3. Minor UI Adjustment

Change: Width increased from 100 to 110 for the "type" column.

  • Check: Ensure that the new width doesn't cause horizontal overflow on smaller screens. Consider using CSS media queries or dynamic width adjustments if responsive design is a concern.

Summary

  • Fix: Move the complex permission check out of the template's v-if to avoid repeated function calls.
  • Keep: The multi-line formatting for readability.

role_list: group.role_list.filter(({ id, role_name }) => getRoleName(id, role_name).toLowerCase().includes(keyword)),
}))
.filter((group) => group.role_list.length > 0)
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change introduces potential issues and performance concerns:

  1. Performance: getRoleName is called inside a .filter() on every item in the loop. If this function performs heavy computation or async operations, it will significantly slow down rendering. It should ideally be pre-computed or cached.
  2. Null Safety: If role_name can be null or undefined, .toLowerCase() will throw an error unless getRoleName guarantees a string return.
  3. Side Effects: Ensure getRoleName is pure and does not mutate state or have side effects.

Suggestion: Cache the result of getRoleName(id, role_name) if possible, or ensure it's lightweight. Add optional chaining: getRoleName(id, role_name)?.toLowerCase() || ''.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 4ae6b12 into v3 Nov 27, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_role_filter branch November 27, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants