Skip to content

Conversation

zouawen
Copy link
Contributor

@zouawen zouawen commented Oct 6, 2025

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

    • Support for custom watermark text with fallback to user info when the custom text is empty.
    • Preferences now include a watermark content input shown when watermark is enabled; disabling watermark clears the content.
  • UI/Style

    • Added clear button for preference input fields.
    • Added a subtle hover shrink animation to several toolbar and control buttons.
  • Localization

    • Added English and Chinese prompts for watermark content.

@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: 38a62c2

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

Walkthrough

Adds optional custom watermark content to preferences and propagates it to layout watchers across apps and playground to use provided content (with fallback to user info). Extends preferences schema, updates preferences UI to edit/clear content, adds input clear button, i18n keys, a new shrink keyframe, and hover shrink classes on several icon buttons.

Changes

Cohort / File(s) Summary
Layout watermark watcher updates
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
Watcher now observes { enable, content } (from preferences.app.watermark and preferences.app.watermarkContent); handler destructures { enable, content }. When enabled calls `updateWatermark(content
Preferences schema extension
packages/@core/preferences/src/config.ts, packages/@core/preferences/src/types.ts
Adds app.watermarkContent default ('') and watermarkContent: string to AppPreferences interface.
Preferences UI wiring
packages/effects/layouts/src/widgets/preferences/preferences-drawer.vue, packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue
Adds appWatermarkContent model; binds it in the drawer; General block shows an input for watermark content when watermark enabled and clears content when switched off.
Input component enhancement
packages/effects/layouts/src/widgets/preferences/blocks/input-item.vue
Adds clear (CircleX) button that appears when input non-empty and clears value on click; explicitly binds placeholder.
Localization
packages/locales/src/langs/en-US/preferences.json, packages/locales/src/langs/zh-CN/preferences.json
Adds watermarkContent strings: "Please input Watermark content" (en-US) and "请输入水印文案" (zh-CN).
CSS animation & hover effects
packages/@core/base/design/src/css/ui.css, 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
Adds @keyframes shrink animation and applies hover:animate-[shrink_0.3s_ease-in-out] classes to various icon/button elements for a hover shrink effect; no behavioral changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant UI as Preferences UI
    participant Store as Preferences Store
    participant Layout as Layout Watcher
    participant WM as Watermark Manager

    rect rgb(245,248,252)
    note over Layout: immediate: true on mount
    Layout->>Store: Read { watermark, watermarkContent }
    alt watermark enabled
        Layout->>WM: updateWatermark(content || "username - realName")
    else disabled
        Layout->>WM: destroyWatermark()
    end
    end

    User->>UI: Toggle watermark / Edit content
    UI->>Store: Update { watermark, watermarkContent }
    Store-->>Layout: Change notification
    alt watermark enabled
        Layout->>WM: updateWatermark(content || fallback)
    else disabled
        Layout->>WM: destroyWatermark()
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • mynetfan
  • anncwb
  • jinmao88
  • vince292007

Poem

A bunny prints whispers on screens so bright,
Custom drops of ink in watermark light.
Flip the switch, clear with a tap—so neat! ✨
Names or lines, your message stays true,
Hop-hop, prefs updated—happy view! 🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description retains only the template headings and placeholder comments without actual content explaining the changes, and the Type of change section still lists all options instead of deleting non-relevant entries, leaving reviewers without context on the implemented features or any required migrations and providing no detail on the claimed documentation or test updates. Please replace the placeholder comments in the Description section with a concise narrative of the watermark customization and input-item clear functionality, remove non-applicable options in the Type of change section leaving only the relevant checkboxes, and ensure each Checklist item is supported by specific references to the updated documentation and tests so that reviewers can verify the claimed changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title enumerates the three main features introduced by the pull request—custom watermark text, a clear button in the input-item component, and hover animations on various UI controls—and directly corresponds to the actual changes in the codebase without referencing file paths or unrelated details. It provides clear and specific information about what this PR delivers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

♻️ Duplicate comments (1)
apps/web-antd/src/layouts/basic.vue (1)

108-127: Same pattern and considerations as web-ele layout.

This watch implementation is identical to the one in apps/web-ele/src/layouts/basic.vue (lines 108-127). The same null-safety consideration for the fallback watermark text applies here. See the review comment on that file for suggested improvements regarding both the null check and potential code duplication across layouts.

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

27-43: Consider preserving watermark content when toggling off.

The current implementation clears appWatermarkContent when the watermark is disabled. This means users lose their custom text if they temporarily toggle the watermark off. Consider preserving the value to improve UX, allowing users to re-enable the watermark without re-entering their custom text.

If you choose to preserve the content, you can simplify to:

-  <SwitchItem
-    v-model="appWatermark"
-    @update:model-value="
-      (val) => {
-        if (!val) appWatermarkContent = '';
-      }
-    "
-  >
+  <SwitchItem v-model="appWatermark">
     {{ $t('preferences.watermark') }}
   </SwitchItem>
apps/web-ele/src/layouts/basic.vue (1)

108-127: Consider null-safe fallback for userInfo.

The fallback watermark text uses optional chaining (userInfo?.username, userInfo?.realName), but if userInfo is nullish, this produces "undefined - undefined". Consider adding an explicit check or providing a more graceful default.

Apply this diff for a safer fallback:

 watch(
   () => ({
     enable: preferences.app.watermark,
     content: preferences.app.watermarkContent,
   }),
   async ({ enable, content }) => {
     if (enable) {
+      const fallback = userStore.userInfo
+        ? `${userStore.userInfo.username} - ${userStore.userInfo.realName}`
+        : '';
       await updateWatermark({
-        content:
-          content ||
-          `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
+        content: content || fallback,
       });
     } else {
       destroyWatermark();
     }
   },
   {
     immediate: true,
   },
 );

Note on duplication: This watch logic appears identical in apps/web-antd/src/layouts/basic.vue (and per the AI summary, likely in other layouts). If this pattern is repeated across multiple layouts, consider extracting it into a shared composable (e.g., useWatermarkSync) to reduce duplication and simplify future maintenance.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33306a5 and b08e67b.

📒 Files selected for processing (11)
  • 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/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/preferences-drawer.vue (2 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)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Check (windows-latest)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
🔇 Additional comments (12)
packages/@core/preferences/src/types.ts (1)

78-81: LGTM!

The watermarkContent property is correctly typed and appropriately positioned adjacent to the related watermark boolean field.

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

40-40: LGTM!

The English localization for watermark content is clear and appropriately placed.

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

40-40: LGTM!

The Chinese localization is clear and maintains consistency with the English locale structure.

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

32-32: LGTM!

An empty string is an appropriate default value for optional watermark content.

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

6-6: LGTM!

The CircleX import supports the new clear button functionality.


50-61: LGTM!

The clear button implementation follows best practices:

  • Conditional rendering prevents unnecessary DOM nodes when input is empty
  • Absolute positioning keeps the button within the input bounds
  • Hover states and cursor styling provide clear affordances
  • Click handler correctly resets the input value
packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue (2)

5-5: LGTM!

The InputItem import enables the new watermark content input field.


16-16: LGTM!

The appWatermarkContent model is correctly defined to manage custom watermark text.

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

109-128: LGTM!

The watermark watcher correctly:

  • Observes both enable and content as a composite object
  • Uses custom content when provided, falling back to generated content from user info
  • Handles the disabled state by destroying the watermark
  • Runs immediately on component mount
playground/src/layouts/basic.vue (1)

124-143: LGTM!

The watermark watcher implementation mirrors the pattern in other layout files, correctly handling custom content with appropriate fallback behavior.

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

70-70: LGTM!

The appWatermarkContent model definition follows the same pattern as other preference models and is properly typed as a string.


271-271: LGTM!

The binding to the General component is correctly placed alongside the existing app-watermark binding, maintaining consistency with the component's API.

@zouawen zouawen changed the title feature: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能。 feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能。 Oct 6, 2025
@zouawen zouawen changed the title feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能。 feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能;3、偏好设置、主题切换、语言选择、是否全屏按钮新增动画效果 Oct 6, 2025
@zouawen zouawen changed the title feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能;3、偏好设置、主题切换、语言选择、是否全屏按钮新增动画效果 feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能(可用于快捷清除水印文案);3、偏好设置、主题切换、语言选择、是否全屏按钮新增动画效果 Oct 6, 2025
@jinmao88 jinmao88 merged commit 2ce161e into vbenjs:main Oct 6, 2025
12 of 16 checks passed
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