Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Duplicate data appears when adding "button permissions" to the menu #548

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

westng
Copy link
Contributor

@westng westng commented Feb 20, 2025

2025-02-20.21.20.28.mov

Summary by CodeRabbit

  • 新功能

    • 按钮权限组件现支持直接删除操作,自动更新权限配置,提升用户权限管理体验。
  • 重构

    • 优化了表单中按钮权限的数据传递逻辑,仅绑定必要的权限数据,确保组件交互更精准高效。

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 20, 2025
Copy link

coderabbitai bot commented Feb 20, 2025

📝 Walkthrough

Walkthrough

此次更改涉及两个组件的代码调整。首先在 button-permission.vue 中新增了 modelValue prop(类型为 Array<MenuVo[]>),增加了 update:modelValue 事件,并添加了 deleteItem 方法用于从 modelValue 数组中删除项,同时更新了 setBtnData 方法。其次在 menu-form.vue 中,对 ButtonPermission 组件传入的数据做了调整,由原来的整个表单数据改为仅传递 btnPermission 部分。

Changes

文件 更改摘要
web/src/.../permission/menu/button-permission.vue 新增 modelValue prop(Array<MenuVo[]>)、新增 update:modelValue 事件、添加 deleteItem 方法以删除数组项并触发事件、更新 setBtnData 方法处理数据过滤
web/src/.../permission/menu/menu-form.vue 修改 ButtonPermission 组件渲染逻辑,从传递整个表单数据改为传递 form.value.btnPermission 数据

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant BP as ButtonPermission 组件
    participant P as 父组件
    U->>BP: 点击删除按钮
    BP->>BP: 调用 deleteItem(index)
    BP->>BP: 从 modelValue 数组中删除指定项
    BP->>P: 发送 update:modelValue 事件(传递更新后的数组)
Loading

Suggested labels

bug, size:XS

Poem

我是一只快乐的小兔子,
在代码森林里跳跃不息。
更新的按钮闪闪发亮,
每次点击都像收获一根胡萝卜。
数据在流动间散发着奇迹,
代码变更,欢欣鼓舞迎接新日!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea3455e and 86aa4d6.

📒 Files selected for processing (2)
  • web/src/modules/base/views/permission/menu/button-permission.vue (4 hunks)
  • web/src/modules/base/views/permission/menu/menu-form.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Test on PHP8.1 Swoole-master
  • GitHub Check: Test on PHP8.1 Swoole-v5.1.5
  • GitHub Check: Test on PHP8.1 Swoole-v5.0.3
  • GitHub Check: Test on PHP8.2 Swoole-master
  • GitHub Check: Test on PHP8.2 Swoole-v5.1.5
  • GitHub Check: Test on PHP8.2 Swoole-v5.0.3
  • GitHub Check: Test on PHP8.1 Swow-develop
  • GitHub Check: Test on PHP8.3 Swoole-master
  • GitHub Check: Test on PHP8.2 Swow-develop
  • GitHub Check: Test on PHP8.3 Swoole-v5.1.5
  • GitHub Check: Test on PHP8.3 Swow-develop
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build Code coverage report (ubuntu-latest, 8.1, v5.1.3)
🔇 Additional comments (5)
web/src/modules/base/views/permission/menu/button-permission.vue (4)

15-25: 代码变更符合 Vue 最佳实践!

使用 modelValue prop 和 update:modelValue emit 事件实现了标准的 v-model 双向绑定,这是一个很好的改进。


34-38: 删除操作的实现非常规范!

deleteItem 函数通过创建数组副本来保持数据不可变性,并正确地通知父组件数据更新,这是很好的实践。


61-61: 事件处理程序更新恰当!

将删除操作委托给专门的 deleteItem 函数处理,使代码结构更清晰。


88-90: 函数实现更加简洁高效!

setBtnData 函数通过直接过滤设置数据,避免了不必要的数组操作,提高了性能。

web/src/modules/base/views/permission/menu/menu-form.vue (1)

279-279: 数据绑定优化得当!

model 属性绑定更改为 form.value.btnPermission,使数据流更加精确,避免了不必要的组件更新。


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or PR title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot bot added the bug label Feb 20, 2025
@kanyxmo kanyxmo merged commit 88a7200 into mineadmin:master Feb 21, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants