Skip to content

fix: 1、fix mock-data.ts; 2、Add custom watermark content; 3、Add hover animation to the header toolbar; 4、Fix the uncheck bug of the tree component; 5、The segmented component of the preference-drawer has added a fixed tabs header style; 6、input-item component has added the clear function and placeholder. #6155

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

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented May 10, 2025

1、fix mock-data.ts;
2、Add custom watermark content;
3、Add hover animation to the header toolbar;
4、Fix the uncheck bug of the tree component;
5、The segmented component of the preference-drawer has added a fixed tabs header style; 6、input-item component has added the clear function and placeholder.

Description

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Added support for customizing watermark content in user preferences, with dynamic input and localization.
    • Permissions tree now automatically expands to its maximum depth based on data.
    • Tabs header in segmented controls can now be fixed (sticky) for improved navigation.
  • Enhancements

    • Watermark logic updated to support both enable/disable and custom content, with fallback to user info if no content is provided.
    • Improved tree selection logic to deselect parent nodes when all children are deselected.
  • UI Improvements

    • Added hover animations to language, theme, fullscreen, and preferences buttons for a more interactive experience.
    • Input fields in preferences now include a clear button for easier editing.
  • Bug Fixes

    • Corrected parent IDs for certain menu items in mock data.
  • Localization

    • Added new translations for watermark content in English and Chinese.

1、fix mock-data.ts;
2、Add custom watermark content;
3、Add hover animation to the header toolbar;
4、Fix the uncheck bug of the tree component;
5、The segmented component of the preference-drawer has added a fixed tabs header style;
6、input-item component has added the clear function and placeholder.
@ghost ghost requested review from anncwb, vince292007, mynetfan, jinmao88 and a team as code owners May 10, 2025 02:26
Copy link

changeset-bot bot commented May 10, 2025

⚠️ No Changeset found

Latest commit: 14707fa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 10, 2025

Walkthrough

This update introduces support for customizable watermark content in user preferences across multiple frontends, adds related localization strings, and updates the UI to allow users to input watermark text. Several UI components receive animation enhancements for better interactivity. The permissions tree logic is improved to dynamically expand based on its depth, and some mock data is corrected.

Changes

Files/Groups Change Summary
apps/backend-mock/utils/mock-data.ts Corrected parent IDs (pid) for three menu button items under "SystemDept" from 201 to 202.
apps/web-antd/src/layouts/basic.vue, apps/web-ele/src/layouts/basic.vue, apps/web-naive/src/layouts/basic.vue, playground/src/layouts/basic.vue Updated watermark watcher to observe both enable flag and content, using dynamic content for watermark or fallback default.
packages/@core/preferences/src/config.ts, packages/@core/preferences/src/types.ts Added watermarkContent property to preferences config and types.
packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue, packages/effects/layouts/src/widgets/preferences/preferences-drawer.vue Added reactive model and UI for watermark content input, clearing content when watermark is disabled, and binding input to preferences.
packages/effects/layouts/src/widgets/preferences/blocks/input-item.vue Enhanced input field with clear button (icon) functionality.
packages/locales/src/langs/en-US/preferences.json, packages/locales/src/langs/zh-CN/preferences.json Added localization key for watermark content in English and Chinese.
packages/@core/ui-kit/shadcn-ui/src/components/full-screen/full-screen.vue, packages/effects/layouts/src/widgets/language-toggle.vue, packages/effects/layouts/src/widgets/preferences/preferences-button.vue, packages/effects/layouts/src/widgets/theme-toggle/theme-button.vue Added hover animations to various icon buttons for improved UI feedback.
packages/@core/ui-kit/shadcn-ui/src/components/segmented/segmented.vue Added fixedTabsHeader prop for sticky tab headers and improved tab active/hover styling.
packages/@core/ui-kit/shadcn-ui/src/ui/tree/tree.vue Extended tree flattening logic to track id and parentId, and improved deselection logic for parent nodes.
packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue Changed z-index class of a theme icon from z-10 to z-1.
playground/src/views/system/role/modules/form.vue Added dynamic calculation of tree max depth for permissions and updated tree expansion logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PreferencesDrawer
    participant GeneralTab
    participant PreferencesStore
    participant Layout

    User->>PreferencesDrawer: Open preferences
    PreferencesDrawer->>GeneralTab: Render general settings
    User->>GeneralTab: Enable watermark
    User->>GeneralTab: Enter watermark content
    GeneralTab->>PreferencesStore: Update watermark enable & content
    PreferencesStore->>Layout: Emit updated preferences
    Layout->>Layout: Watch for changes (enable, content)
    alt Watermark enabled
        Layout->>Layout: Update watermark (use custom content or fallback)
    else Watermark disabled
        Layout->>Layout: Destroy watermark
    end
Loading

Suggested reviewers

  • anncwb
  • jinmao88

Poem

A bunny hopped and tapped its paw,
To add a watermark with awe.
Now users choose the words they see,
In settings, input—fancy free!
Buttons twirl and icons spin,
With every change, new joys begin.
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 🔥 Error while generating docstrings. (🔄 Check again to generate docstrings again)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/effects/layouts/src/widgets/preferences/preferences-button.vue (1)

22-40: Rotate settings icon on hover.

The :deep(.setting-button) selector correctly penetrates the scoped style boundary, and the setting-rotate keyframes animate the nested SVG as intended. Consider adding animation-fill-mode: forwards; if you want the icon to maintain its rotated state after the animation completes.

packages/effects/layouts/src/widgets/language-toggle.vue (1)

41-59: Add scale animation for language toggle on hover.

The language-expand keyframes deliver a smooth scaling effect. For consistency with other components (e.g., the settings button), you might choose to standardize on using the :deep combinator or adjust selector specificity across all icon-button animations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9062578 and 14707fa.

📒 Files selected for processing (20)
  • apps/backend-mock/utils/mock-data.ts (3 hunks)
  • apps/web-antd/src/layouts/basic.vue (1 hunks)
  • apps/web-ele/src/layouts/basic.vue (1 hunks)
  • apps/web-naive/src/layouts/basic.vue (1 hunks)
  • packages/@core/preferences/src/config.ts (1 hunks)
  • packages/@core/preferences/src/types.ts (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/components/full-screen/full-screen.vue (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/components/segmented/segmented.vue (2 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/tree/tree.vue (4 hunks)
  • packages/effects/layouts/src/widgets/language-toggle.vue (1 hunks)
  • packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue (3 hunks)
  • packages/effects/layouts/src/widgets/preferences/blocks/input-item.vue (2 hunks)
  • packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue (1 hunks)
  • packages/effects/layouts/src/widgets/preferences/preferences-button.vue (1 hunks)
  • packages/effects/layouts/src/widgets/preferences/preferences-drawer.vue (2 hunks)
  • packages/effects/layouts/src/widgets/theme-toggle/theme-button.vue (3 hunks)
  • packages/locales/src/langs/en-US/preferences.json (1 hunks)
  • packages/locales/src/langs/zh-CN/preferences.json (1 hunks)
  • playground/src/layouts/basic.vue (1 hunks)
  • playground/src/views/system/role/modules/form.vue (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
🔇 Additional comments (47)
apps/backend-mock/utils/mock-data.ts (1)

279-279: Correct parent-child relationship fix

The changes correctly align the parent IDs (pid) of the SystemDept button actions with their actual parent menu ID (202 for SystemDept), fixing what was likely an incorrect assignment to SystemMenu (201). This ensures proper menu hierarchy and permission inheritance.

Also applies to: 288-288, 297-297

playground/src/views/system/role/modules/form.vue (4)

31-31: Good addition of a reactive reference for tree depth

Adding the maxLevel reference to track permission tree depth will help dynamically adjust tree expansion.


75-75: Approve setting the max level calculation

Good implementation of calculating the maximum depth level after loading permissions data, which will make the tree expansion adapt to the actual data structure.


81-93: Well-implemented recursive depth calculation function

The getMaxLevel function correctly implements a recursive tree traversal algorithm to determine the maximum depth of the permission tree structure. The implementation handles all edge cases properly.


122-122: Dynamic tree expansion based on actual data structure

Replacing the likely hardcoded expansion level with the dynamically calculated maxLevel ensures the tree expands to show all relevant permissions without requiring users to manually expand deeper levels.

packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue (1)

142-142: Z-index reduced from z-10 to z-1

This change reduces the stacking order of the pen icon in the custom theme color selector. Ensure this doesn't cause any unintended overlap issues with other elements, though the change appears intentional to fix a potential stacking issue.

packages/@core/preferences/src/types.ts (1)

66-69: Good addition of watermarkContent property

This properly implements support for custom watermark content as mentioned in the PR objectives. The property is well-documented with appropriate JSDocs comments, consistent with the existing codebase style.

packages/@core/ui-kit/shadcn-ui/src/components/full-screen/full-screen.vue (2)

24-33: Nice enhancement with conditional class binding

Adding conditional classes based on the fullscreen state improves code organization and makes styling more maintainable.


36-72: Good addition of hover animations

The hover animations provide helpful visual feedback to users. The implementation is clean with well-defined keyframes that match the actions they represent (shrink for minimize, expand for maximize).

packages/effects/layouts/src/widgets/theme-toggle/theme-button.vue (3)

164-169: Good enhancement with light theme hover animation

The sun rotation animation adds a nice interactive touch to the light theme toggle button.


183-187: Good enhancement with dark theme hover animation

The moon expansion animation provides consistent interactive feedback for the dark theme toggle.


198-220: Well-implemented animation keyframes

The keyframe definitions are clean and appropriate for their respective animations. Good choice of animation timing (0.6s) that's noticeable but not distracting.

packages/@core/ui-kit/shadcn-ui/src/components/segmented/segmented.vue (6)

13-13: Good addition of fixedTabsHeader prop

This new prop enables the sticky header functionality mentioned in the PR objectives.


19-19: Appropriate default value for fixedTabsHeader

Setting the default to false maintains backward compatibility with existing usage.


41-43: Well-implemented activeClass helper function

This helper function improves code readability by encapsulating the active tab styling logic.


45-51: Good use of computed property for conditional classes

The fixedTabsHeaderClass computed property cleanly implements the conditional sticky positioning.


56-60: Good implementation of fixed tabs header

The conditional class binding for sticky positioning is properly applied to the TabsList element.


63-67: Enhanced tab trigger styling

Adding hover effects and dynamic active classes improves the user experience with better visual feedback.

packages/locales/src/langs/en-US/preferences.json (1)

39-41: Add watermarkContent localization key.

The new key "watermarkContent" is correctly inserted after "watermark", and the JSON syntax (commas, braces) remains valid.

packages/@core/preferences/src/config.ts (1)

25-27: Introduce watermarkContent default preference.

The new property watermarkContent: '' aligns with the updated AppPreferences interface. This default value ensures that downstream logic handling watermark content won't encounter undefined.

packages/effects/layouts/src/widgets/preferences/preferences-button.vue (1)

16-18: Enable hover animation on settings button.

Adding class="setting-button" to the <VbenIconButton> provides the hook for the scoped CSS animation defined below.

packages/locales/src/langs/zh-CN/preferences.json (1)

39-41: Add Chinese translation for watermark content.

The "watermarkContent": "水印文案" entry is properly added and the JSON remains syntactically correct.

packages/effects/layouts/src/widgets/language-toggle.vue (1)

34-37: Hook up language-button class for animation.

The class="language-button" on <VbenIconButton> aligns with the CSS hover animation defined in the scoped style block below.

packages/effects/layouts/src/widgets/preferences/preferences-drawer.vue (3)

70-70: Good addition of the watermark content model

The introduction of appWatermarkContent model properly extends the preferences system to support custom watermark text, aligning with the PR objectives.


262-263: Excellent enhancement to the segmented component UI

The addition of the fixed-tabs-header prop to the VbenSegmented component improves the user experience by creating a sticky tabs header. This is a good implementation of the segmented component enhancement mentioned in the PR objectives.


271-271: Properly wired watermark content binding

The v-model:app-watermark-content binding correctly connects the new watermark content model with the General component, ensuring the user preference is properly synchronized.

packages/effects/layouts/src/widgets/preferences/blocks/input-item.vue (2)

6-6: Good icon import for clear functionality

The addition of the CircleX icon is necessary for the new clear functionality and is properly imported alongside the existing CircleHelp icon.


50-61: Well-implemented input enhancement with clear functionality

The input component has been effectively enhanced with:

  1. A placeholder binding that improves user guidance
  2. A clear button that appears conditionally when text is present
  3. Proper positioning and styling of the clear button

This implementation aligns perfectly with the PR objective to add clear functionality and placeholder support to the input-item component.

apps/web-naive/src/layouts/basic.vue (2)

110-114: Good watermark reactivity implementation

The watcher has been appropriately enhanced to track both the watermark enable state and its content. This approach efficiently responds to changes in either property without requiring multiple watchers.


114-120: Well-designed watermark content logic

The implementation correctly:

  1. Uses custom content when provided by the user
  2. Falls back to a sensible default (username and real name) when no custom content is specified
  3. Maintains the existing watermark behavior

This change fully supports the custom watermark content feature mentioned in the PR objectives.

playground/src/layouts/basic.vue (2)

125-129: Consistent watermark reactivity implementation

The watcher implementation matches the approach used in other layout files, ensuring consistent behavior across different UIs. This is a good practice for maintainability.


129-135: Well-designed watermark content handling

The implementation maintains consistency with other layouts by:

  1. Using custom content when provided
  2. Falling back to username and real name when no custom content exists
  3. Preserving the existing watermark toggle behavior

This consistency across layouts demonstrates a well-coordinated approach to the feature implementation.

packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue (4)

5-5: Good addition of InputItem component import

This import appropriately supports the new watermark content input functionality.


16-16: Well-defined model for watermark content

The appWatermarkContent model is correctly typed as a string and uses Vue's defineModel API for two-way binding.


27-36: Good UI behavior implementation for watermark toggle

The event handler that clears watermark content when the toggle is turned off provides a good user experience by ensuring users don't have stale content when re-enabling the feature.


37-43: Well-implemented conditional watermark content input

The conditional rendering with v-if="appWatermark" correctly shows the input field only when needed. The component properly uses localization for both label and placeholder.

apps/web-antd/src/layouts/basic.vue (2)

109-113: Efficient watch implementation for watermark properties

Watching an object with both properties is more efficient than watching two separate values. The destructuring in the callback function makes the code clean and readable.


116-119: Good fallback mechanism for watermark content

The implementation correctly prioritizes user-configured content while maintaining backward compatibility with a sensible default. This ensures the watermark always displays meaningful content.

apps/web-ele/src/layouts/basic.vue (2)

109-113: Consistent implementation across UI frameworks

This watch implementation matches the one in the Ant Design version, ensuring consistent behavior across different UI frameworks.


116-119: Proper watermark content handling with fallback

The implementation follows the same pattern as in the Ant Design version, correctly prioritizing user content with a fallback to username and real name when needed.

packages/@core/ui-kit/shadcn-ui/src/ui/tree/tree.vue (7)

43-45: Interface enhancement improves type safety

The addition of id and parentId properties to the InnerFlattenItem interface provides better type safety and enables more robust parent-child relationship tracking in the tree structure.


54-54: Function signature updated for parent-child tracking

The flatten function now accepts a parentId parameter which properly supports the parent-child relationship tracking.


60-68: Enhanced tree node flattening implementation

The flatten function now properly captures the relationship between tree nodes by storing both the node's ID and its parent's ID, which enables more sophisticated tree operations.


72-72: Improved recursion with parent-child relationship preservation

The recursive call now correctly passes the current node's ID as the parent ID for child nodes, maintaining the hierarchical relationship throughout the tree structure.


243-243: Improved container styling

The container styling is now more consistent with the design system, using the appropriate text color and removing padding to allow for more flexible layout control.


249-249: Enhanced header with proper visual separation

Adding a border and padding to the header container creates proper visual separation when the header slot is used, improving the UI/UX of the component.


177-213:

❓ Verification inconclusive

Implemented upward propagation for unchecking nodes

This new logic correctly handles the scenario where a node is unchecked by checking if it affects parent nodes. When a child is unchecked, it verifies if any siblings remain selected before deselecting the parent, which implements the expected cascading behavior for tree selections.

One potential concern is the use of item._id at line 195, which might be a property from the FlattenedItem type from radix-vue, but it would be good to ensure this property exists.


🏁 Script executed:

#!/bin/bash
# Verify if the _id property exists in FlattenedItem type from radix-vue

# Look for the definition of FlattenedItem in the codebase or node_modules
rg -t ts "interface FlattenedItem" --include "*.d.ts" -A 10 -g "!node_modules"

# If not found in project files, look in node_modules
rg -t ts "interface FlattenedItem" --include "*.d.ts" -A 10 node_modules/radix-vue

Length of output: 1049


🏁 Script executed:

#!/bin/bash
# Search for FlattenedItem definition in TypeScript definition files across the repo
rg -e 'interface FlattenedItem' -e 'type FlattenedItem' -g '*.d.ts' -A 10 .

Length of output: 77


Verify item._id exists on flattened nodes

The upward‐propagation logic looks correct: when unchecking a child, it ascends the parent chain and only deselects a parent if no other selected siblings remain.

One remaining concern is the use of item._id at line 195. Please confirm that each entry in flattenData.value actually has an _id property and that it corresponds to the node’s identifier. If your data uses id (or another field) instead, update this reference accordingly.

@aonoa
Copy link
Contributor

aonoa commented May 10, 2025

建议把不同的功能分开成几个pr提交

Copy link
Contributor

coderabbitai bot commented May 11, 2025

Caution

No docstrings were generated.

@jinmao88
Copy link
Collaborator

@846027729 分开提PR吧

Repository owner closed this by deleting the head repository May 12, 2025
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.

4 participants