Skip to content

docs: ✏️ 调整文档结构增加文档内容可用宽度#765

Merged
Moonofweisheng merged 1 commit into
masterfrom
docs/vitepress-improve
Dec 7, 2024
Merged

docs: ✏️ 调整文档结构增加文档内容可用宽度#765
Moonofweisheng merged 1 commit into
masterfrom
docs/vitepress-improve

Conversation

@Moonofweisheng

@Moonofweisheng Moonofweisheng commented Dec 7, 2024

Copy link
Copy Markdown
Owner

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

自定义Vitepress组件,调整Vitepress的布局,增加组件文档内容的可见范围。

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新特性

    • 新增多个 Vue 组件,包括 VPContentVPDocVPLocalNavVPNavBarVPSidebar,以及其他组件的更新和功能增强。
    • 引入了新的 CSS 变量以支持更好的样式定制。
    • 新增了多个组件的功能,如 CountDownDatetimePickerSelectPickerSwipeActionSwiper 等,增强了用户交互体验。
  • 文档

    • 更新了多个组件的文档,包括 ActionSheetBadgeCalendarCheckboxCellCollapseConfigProviderCountDownDatetimePickerInputPickerTableTabsToast 等,改善了可读性和结构。
    • 删除了部分组件的文档内容,如 BacktopButtonGapInputNumberLayoutSwitch 等,表示这些组件可能已被移除或不再支持。
    • 增强了 TooltipToastTextTextareaTagStatusTip 等组件的文档,提供了更详细的使用示例和属性说明。
  • 修复

    • 修复了文档中关于组件用法和属性的错误或不一致之处,确保信息的准确性。
  • 样式

    • 改进了 CSS 变量的格式和组织,提高了代码的可读性和维护性。

@vercel

vercel Bot commented Dec 7, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 7, 2024 3:46pm

@coderabbitai

coderabbitai Bot commented Dec 7, 2024

Copy link
Copy Markdown

Caution

Review failed

The head commit changed during the review from f8f9f65 to 3890355.

Walkthrough

此次变更涉及多个组件的文档更新和功能增强,包括对 VitePress 配置的修改、Vue 组件的新增和改进,以及现有组件文档的重写和扩展。主要更新包括添加新属性、事件和插槽,改善用户交互和组件可定制性,提升文档的清晰度和可读性。整体结构保持一致,但内容更加详尽,便于开发者理解和使用。

Changes

文件路径 变更摘要
docs/.vitepress/config.mts 添加 fileURLToPathURL 的导入,扩展 Vite 配置,增加 resolve 属性。
docs/.vitepress/plugins/markdown-transform.ts 修改 MarkdownTransform 函数的导入方式,更新 transform 方法的逻辑。
docs/.vitepress/theme/components/CustomFooter.vue 更新 useDatauseSidebar 的导入路径,添加 theme 变量的类型注解。
docs/.vitepress/theme/components/VPContent.vue 新增 Vue 组件,处理页面布局和内容显示。
docs/.vitepress/theme/components/VPDoc.vue 新增 Vue 组件,用于渲染文档页面。
docs/.vitepress/theme/components/VPIframe.vue 修改 <iframe> 逻辑,提升响应式设计。
docs/.vitepress/theme/components/VPLocalNav.vue 新增 Vue 组件,提供本地导航功能。
docs/.vitepress/theme/components/VPNavBar.vue 新增 Vue 组件,构建导航栏。
docs/.vitepress/theme/components/VPSidebar.vue 新增 Vue 组件,构建侧边栏。
docs/.vitepress/theme/index.ts 移除 frame 组件的导入和注册。
docs/.vitepress/theme/styles/vars.css 添加新的 CSS 变量 --vp-sidebar-width--vp-sidebar-bg-color,优化现有变量格式。
docs/component/action-sheet.md 更新 ActionSheet 组件文档,增加使用示例和详细描述。
docs/component/backtop.md 移除 Backtop 组件文档的全部内容。
docs/component/badge.md 更新 Badge 组件文档,增强结构和可读性。
docs/component/button.md 移除 Button 组件文档的全部内容。
docs/component/calendar-view.md 更新 CalendarView 组件文档,增加新特性和属性说明。
docs/component/calendar.md 更新 Calendar 组件文档,增加新特性和属性说明。
docs/component/card.md 完全重写 Card 组件文档,增强可读性和结构。
docs/component/cell.md 更新 Cell 组件文档,增加新部分和详细描述。
docs/component/checkbox.md 更新 Checkbox 组件文档,增加新功能和示例。
docs/component/circle.md 更新 Circle 组件文档,增加新属性和示例。
docs/component/col-picker.md 更新 ColPicker 组件文档,增加新特性和示例。
docs/component/collapse.md 更新 Collapse 组件文档,增加新特性和示例。
docs/component/config-provider.md 更新 ConfigProvider 组件文档,增加主题切换和自定义主题的详细信息。
docs/component/count-down.md 更新 CountDown 组件文档,增加新属性和事件说明。
docs/component/count-to.md 移除 CountTo 组件文档的全部内容。
docs/component/curtain.md 更新 Curtain 组件文档,增加新属性和功能说明。
docs/component/datetime-picker-view.md 更新 DatetimePickerView 组件文档,增加新属性和示例。
docs/component/datetime-picker.md 更新 DatetimePicker 组件文档,增加新特性和属性说明。
docs/component/divider.md 更新 Divider 组件文档,增加新属性和功能说明。
docs/component/drop-menu.md 更新 DropMenu 组件文档,增加新功能和示例。
docs/component/fab.md 更新 FAB 组件文档,增加新功能和示例。
docs/component/form.md 更新 Form 组件文档,增加新功能和验证规则。
docs/component/gap.md 移除 Gap 组件文档的全部内容。
docs/component/grid.md 更新 Grid 组件文档,增加新属性和示例。
docs/component/icon.md 移除 Icon 组件文档的全部内容。
docs/component/img-cropper.md 更新 ImgCropper 组件文档,增加新属性和事件说明。
docs/component/img.md 移除 Img 组件文档的全部内容。
docs/component/index-bar.md 更新 IndexBar 组件文档,增强版本显示方式。
docs/component/input-number.md 移除 InputNumber 组件文档的全部内容。
docs/component/input.md 更新 Input 组件文档,增加新属性和事件说明。
docs/component/keyboard.md 更新 Keyboard 组件文档,增加新功能和示例。
docs/component/layout.md 移除 Layout 组件文档的全部内容。
docs/component/loading.md 更新 Loading 组件文档,增加新属性和使用说明。
docs/component/loadmore.md 更新 LoadMore 组件文档,增加新功能和示例。
docs/component/message-box.md 更新 MessageBox 组件文档,增加新功能和示例。
docs/component/navbar.md 更新 Navbar 组件文档,增强功能和使用示例。
docs/component/notice-bar.md 更新 NoticeBar 组件文档,增加新功能和示例。
docs/component/notify.md 更新 Notify 组件文档,增加新功能和示例。
docs/component/number-keyboard.md 移除 NumberKeyboard 组件文档的全部内容。
docs/component/overlay.md 更新 Overlay 组件文档,增强结构和可读性。
docs/component/pagination.md 更新 Pagination 组件文档,增强结构和可读性。
docs/component/password-input.md 更新 PasswordInput 组件文档,增加新属性和示例。
docs/component/picker-view.md 更新 PickerView 组件文档,增加新属性和示例。
docs/component/picker.md 更新 Picker 组件文档,增加新属性和示例。
docs/component/popover.md 完全重写 Popover 组件文档,增强可读性和使用示例。
docs/component/popup.md 完全重写 Popup 组件文档,增强可读性和使用示例。
docs/component/progress.md 完全重写 Progress 组件文档,增强可读性和使用示例。
docs/component/radio.md 更新 Radio 组件文档,增加新功能和示例。
docs/component/rate.md 更新 Rate 组件文档,增强结构和可读性。
docs/component/resize.md 更新 Resize 组件文档,增强结构和可读性。
docs/component/search.md 更新 Search 组件文档,移除过时属性,增强结构。
docs/component/segmented.md 更新 Segmented 组件文档,增加新功能和示例。
docs/component/select-picker.md 更新 SelectPicker 组件文档,增加新属性和示例。
docs/component/sidebar.md 更新 Sidebar 组件文档,增强功能和使用示例。
docs/component/skeleton.md 完全重写 Skeleton 组件文档,增强可读性和使用示例。
docs/component/slider.md 更新 Slider 组件文档,增加新功能和示例。
docs/component/sort-button.md 更新 SortButton 组件文档,增强结构和可读性。
docs/component/status-tip.md 更新 StatusTip 组件文档,增加新属性和示例。
docs/component/steps.md 更新 Steps 组件文档,移除过时插槽,增强结构。
docs/component/sticky.md 更新 Sticky 组件文档,增强结构和可读性。
docs/component/swipe-action.md 更新 SwipeAction 组件文档,增加新功能和示例。
docs/component/swiper.md 更新 Swiper 组件文档,增加新功能和示例。
docs/component/switch.md 移除 Switch 组件文档的全部内容。
docs/component/tabbar.md 更新 Tabbar 组件文档,增加新属性和示例。
docs/component/table.md 更新 Table 组件文档,增加新功能和示例。
docs/component/tabs.md 更新 Tabs 组件文档,增加新属性和示例。
docs/component/tag.md 更新 Tag 组件文档,增加新属性和事件。
docs/component/text.md 更新 Text 组件文档,增加新属性和示例。
docs/component/textarea.md 更新 Textarea 组件文档,增加新属性和事件。
docs/component/toast.md 更新 Toast 组件文档,增强结构和可读性。
docs/component/tooltip.md 更新 Tooltip 组件文档,增强结构和可读性。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Component

    User->>App: Interact with components
    App->>Component: Render updated component
    Component-->>App: Return rendered output
    App-->>User: Display updated UI
Loading

Possibly related PRs

🐰 在代码的世界里跳跃,
新组件如花般绽放,
文档更新如春风拂面,
开发者笑声声响亮。
让我们一起欢庆这变化,
兔子们在代码中舞动,
未来的功能更辉煌!
🐇✨


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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 7, 2024

Copy link
Copy Markdown

Deploying wot-design-uni with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3890355
Status: ✅  Deploy successful!
Preview URL: https://a26fee78.wot-design-uni.pages.dev
Branch Preview URL: https://docs-vitepress-improve.wot-design-uni.pages.dev

View logs

@netlify

netlify Bot commented Dec 7, 2024

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit 3890355
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/67546d9d0314e300089b3a44
😎 Deploy Preview https://deploy-preview-765--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (12)
docs/.vitepress/theme/index.ts (2)

Line range hint 1-8: 建议完善文件头部注释内容

文件头部的注释缺少对文件功能的具体描述,建议补充说明该文件的主要用途和职责。

建议按照以下方式修改:

 /*
  * @Author: weisheng
  * @Date: 2024-10-12 22:09:33
  * @LastEditTime: 2024-12-07 17:06:42
  * @LastEditors: weisheng
- * @Description: 
+ * @Description: VitePress主题配置文件,用于自定义文档站点的布局和组件
  * @FilePath: /wot-design-uni/docs/.vitepress/theme/index.ts
  * 记得注释
  */

Line range hint 9-22: 建议对导入语句进行分组整理

当前的导入语句混合了Vue核心、VitePress主题、自定义组件和第三方库,建议按类别分组以提高可读性。

建议按照以下结构重新组织:

+ // Vue 核心
 import { h } from 'vue'
+ 
+ // VitePress 主题
 import Theme from 'vitepress/theme'
 import './styles/vars.css'
 import './styles/custom.css'
 import './styles/scrollbar.scss'
 
+ // 自定义组件
 import HomeFriendly from './components/HomeFriendly.vue'
 import NavBarTitleAfter from './components/NavBarTitleAfter.vue'
 import CustomFooter from './components/CustomFooter.vue'
 import SvgImage from './components/SvgImage.vue'
 import HomeStar from './components/HomeStar.vue'
 import ExternalLink from './components/ExternalLink.vue'
+ 
+ // 第三方库
 import ElementPlus from 'element-plus'
 import 'element-plus/dist/index.css'
docs/.vitepress/theme/components/VPIframe.vue (1)

2-3: 建议移除已废弃的属性 frameborderscrolling

iframe 标签中的 frameborderscrolling 属性在 HTML5 中已被废弃,建议使用 CSS 来替代这些样式。

您可以应用以下修改:

- <iframe v-if="href" ref="iframe" id="demo" class="iframe demo-model" scrolling="auto" frameborder="0"
+ <iframe v-if="href" ref="iframe" id="demo" class="iframe demo-model"
    :src="href"></iframe>
docs/.vitepress/theme/components/VPSidebar.vue (2)

18-27: 优化对 props 的监听

建议在 watch 中直接监听 props.open,提高监听的准确性,避免不必要的触发。

您可以修改为:

- watch(
-   [props, navEl],
+ watch(
+   [() => props.open, navEl],

31-37: 注意深度监听 sidebarGroups 的性能影响

sidebarGroups 进行深度监听可能会带来性能开销,尤其是当数据量较大时。建议评估是否需要深度监听,或使用更精确的监听策略。

docs/.vitepress/theme/components/VPNavBar.vue (1)

1-9: 移除文件头部不必要的注释

文件头部的注释包含多余信息,如文件路径和提醒性注释“记得注释”。建议在提交前删除或更新这些注释,以保持代码整洁。

您可以删除这些注释,或根据需要添加有意义的说明性注释。

docs/.vitepress/theme/styles/vars.css (2)

Line range hint 98-109: 优化暗色模式下的链接样式选择器

选择器的格式调整更加规范,但建议为复杂的选择器添加注释说明用途。

+/* 处理暗色模式下各类链接的悬停状态 */
.dark .vp-doc a,
.dark .vp-doc a>code,
.dark .VPNavBarMenuLink.VPNavBarMenuLink:hover,

127-130: 侧边栏变量定义

新增的侧边栏宽度和背景色变量有助于统一管理布局样式,符合文档结构优化的目标。建议考虑添加暗色模式下的背景色变量。

:root {
  --vp-sidebar-width: 338px;
  --vp-sidebar-bg-color: #ffffff;
}
+.dark {
+  --vp-sidebar-bg-color: var(--vp-c-bg);
+}
docs/.vitepress/theme/components/VPContent.vue (2)

3-3: 建议简化导入路径

导入路径可以简化,避免使用过长的相对路径。

-import NotFound from 'vitepress/dist/client/theme-default//NotFound.vue'
+import NotFound from 'vitepress/theme/NotFound.vue'

9-9: 建议使用更精确的类型定义

使用 :any 类型断言可能会掩盖潜在的类型错误。建议使用 VitePress 提供的类型定义。

-const { page, frontmatter }:any = useData()
+const { page, frontmatter } = useData()
docs/.vitepress/config.mts (2)

30-63: 建议优化组件别名配置

当前的别名配置方式较为冗长,可以使用更简洁的方式。

resolve: {
-  alias: [
-    {
-      find: /^.*\/VPSidebar\.vue$/,
-      replacement: fileURLToPath(
-        new URL('./theme/components/VPSidebar.vue', import.meta.url)
-      )
-    },
-    // ... other aliases
-  ]
+  alias: {
+    '@theme': fileURLToPath(new URL('./theme', import.meta.url))
+  }
}

然后在组件中使用 @theme/components/VPSidebar.vue 的方式导入。


29-29: 建议将 SSR 配置移至专门的配置文件

为了更好的配置管理,建议将 SSR 相关的配置移至独立的配置文件。

建议创建 ssr.config.ts 文件来管理所有 SSR 相关的配置。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b06a7a7 and fd540f2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (82)
  • docs/.vitepress/config.mts (2 hunks)
  • docs/.vitepress/plugins/markdown-transform.ts (2 hunks)
  • docs/.vitepress/theme/components/CustomFooter.vue (1 hunks)
  • docs/.vitepress/theme/components/VPContent.vue (1 hunks)
  • docs/.vitepress/theme/components/VPDoc.vue (1 hunks)
  • docs/.vitepress/theme/components/VPIframe.vue (4 hunks)
  • docs/.vitepress/theme/components/VPLocalNav.vue (1 hunks)
  • docs/.vitepress/theme/components/VPNavBar.vue (1 hunks)
  • docs/.vitepress/theme/components/VPSidebar.vue (1 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/.vitepress/theme/styles/vars.css (4 hunks)
  • docs/component/action-sheet.md (0 hunks)
  • docs/component/backtop.md (0 hunks)
  • docs/component/badge.md (0 hunks)
  • docs/component/button.md (0 hunks)
  • docs/component/calendar-view.md (0 hunks)
  • docs/component/calendar.md (0 hunks)
  • docs/component/card.md (0 hunks)
  • docs/component/cell.md (0 hunks)
  • docs/component/checkbox.md (0 hunks)
  • docs/component/circle.md (0 hunks)
  • docs/component/col-picker.md (0 hunks)
  • docs/component/collapse.md (0 hunks)
  • docs/component/config-provider.md (0 hunks)
  • docs/component/count-down.md (0 hunks)
  • docs/component/count-to.md (0 hunks)
  • docs/component/curtain.md (0 hunks)
  • docs/component/datetime-picker-view.md (0 hunks)
  • docs/component/datetime-picker.md (0 hunks)
  • docs/component/divider.md (0 hunks)
  • docs/component/drop-menu.md (0 hunks)
  • docs/component/fab.md (0 hunks)
  • docs/component/form.md (0 hunks)
  • docs/component/gap.md (0 hunks)
  • docs/component/grid.md (0 hunks)
  • docs/component/icon.md (0 hunks)
  • docs/component/img-cropper.md (0 hunks)
  • docs/component/img.md (0 hunks)
  • docs/component/index-bar.md (1 hunks)
  • docs/component/input-number.md (0 hunks)
  • docs/component/input.md (0 hunks)
  • docs/component/keyboard.md (0 hunks)
  • docs/component/layout.md (0 hunks)
  • docs/component/loading.md (0 hunks)
  • docs/component/loadmore.md (0 hunks)
  • docs/component/message-box.md (0 hunks)
  • docs/component/navbar.md (0 hunks)
  • docs/component/notice-bar.md (0 hunks)
  • docs/component/notify.md (0 hunks)
  • docs/component/number-keyboard.md (0 hunks)
  • docs/component/overlay.md (0 hunks)
  • docs/component/pagination.md (0 hunks)
  • docs/component/password-input.md (0 hunks)
  • docs/component/picker-view.md (0 hunks)
  • docs/component/picker.md (0 hunks)
  • docs/component/popover.md (0 hunks)
  • docs/component/popup.md (0 hunks)
  • docs/component/progress.md (0 hunks)
  • docs/component/radio.md (0 hunks)
  • docs/component/rate.md (0 hunks)
  • docs/component/resize.md (0 hunks)
  • docs/component/search.md (0 hunks)
  • docs/component/segmented.md (0 hunks)
  • docs/component/select-picker.md (0 hunks)
  • docs/component/sidebar.md (0 hunks)
  • docs/component/skeleton.md (0 hunks)
  • docs/component/slider.md (0 hunks)
  • docs/component/sort-button.md (0 hunks)
  • docs/component/status-tip.md (0 hunks)
  • docs/component/steps.md (0 hunks)
  • docs/component/sticky.md (0 hunks)
  • docs/component/swipe-action.md (0 hunks)
  • docs/component/swiper.md (0 hunks)
  • docs/component/switch.md (0 hunks)
  • docs/component/tabbar.md (0 hunks)
  • docs/component/table.md (0 hunks)
  • docs/component/tabs.md (0 hunks)
  • docs/component/tag.md (0 hunks)
  • docs/component/text.md (0 hunks)
  • docs/component/textarea.md (0 hunks)
  • docs/component/toast.md (0 hunks)
  • docs/component/tooltip.md (0 hunks)
⛔ Files not processed due to max files limit (6)
  • docs/component/transition.md
  • docs/component/upload.md
  • docs/component/watermark.md
  • package.json
  • src/pages/radio/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-radio/types.ts
💤 Files with no reviewable changes (70)
  • docs/component/backtop.md
  • docs/component/switch.md
  • docs/component/count-to.md
  • docs/component/resize.md
  • docs/component/gap.md
  • docs/component/button.md
  • docs/component/img.md
  • docs/component/input-number.md
  • docs/component/divider.md
  • docs/component/layout.md
  • docs/component/card.md
  • docs/component/drop-menu.md
  • docs/component/progress.md
  • docs/component/count-down.md
  • docs/component/config-provider.md
  • docs/component/icon.md
  • docs/component/navbar.md
  • docs/component/slider.md
  • docs/component/circle.md
  • docs/component/search.md
  • docs/component/skeleton.md
  • docs/component/fab.md
  • docs/component/popup.md
  • docs/component/loading.md
  • docs/component/segmented.md
  • docs/component/sticky.md
  • docs/component/tabs.md
  • docs/component/datetime-picker.md
  • docs/component/calendar-view.md
  • docs/component/swipe-action.md
  • docs/component/toast.md
  • docs/component/number-keyboard.md
  • docs/component/textarea.md
  • docs/component/rate.md
  • docs/component/checkbox.md
  • docs/component/tabbar.md
  • docs/component/curtain.md
  • docs/component/notify.md
  • docs/component/keyboard.md
  • docs/component/password-input.md
  • docs/component/datetime-picker-view.md
  • docs/component/swiper.md
  • docs/component/col-picker.md
  • docs/component/message-box.md
  • docs/component/cell.md
  • docs/component/sort-button.md
  • docs/component/loadmore.md
  • docs/component/input.md
  • docs/component/calendar.md
  • docs/component/tooltip.md
  • docs/component/select-picker.md
  • docs/component/collapse.md
  • docs/component/picker-view.md
  • docs/component/pagination.md
  • docs/component/radio.md
  • docs/component/grid.md
  • docs/component/table.md
  • docs/component/text.md
  • docs/component/popover.md
  • docs/component/tag.md
  • docs/component/steps.md
  • docs/component/action-sheet.md
  • docs/component/sidebar.md
  • docs/component/status-tip.md
  • docs/component/form.md
  • docs/component/img-cropper.md
  • docs/component/badge.md
  • docs/component/picker.md
  • docs/component/overlay.md
  • docs/component/notice-bar.md
✅ Files skipped from review due to trivial changes (1)
  • docs/component/index-bar.md
🔇 Additional comments (15)
docs/.vitepress/theme/index.ts (2)

Line range hint 25-34: 布局配置结构清晰,符合最佳实践

主题布局配置采用了VitePress推荐的插槽注入方式,结构清晰。


Line range hint 35-40: 建议增加类型安全性

enhanceApp函数中,建议添加TypeScript类型定义以增强代码的可维护性。

建议按照以下方式改进:

- enhanceApp({ app }) {
+ enhanceApp({ app }: { app: any }) {
    app.component('SvgImage', SvgImage)
    app.component('ExternalLink',ExternalLink)
    app.use(ElementPlus)
  },

另外,建议验证ElementPlus的集成是否真的必要,因为这会增加文档站点的体积。

✅ Verification successful

Let me check the actual usage of Element Plus components in these files.


Element Plus 组件确实在文档中被使用,建议保留但优化类型定义

根据验证,Element Plus 组件在文档中有实际使用场景:

  • 在 changelog.md 中使用 ElTag 显示组件版本信息
  • 在 join-group.md 中使用 ElMessage 和 ElMessageBox 实现交互功能

建议采用以下改进:

- enhanceApp({ app }) {
+ enhanceApp({ app }: { app: import('vue').App }) {
    app.component('SvgImage', SvgImage)
    app.component('ExternalLink',ExternalLink)
    app.use(ElementPlus)
  },
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查ElementPlus组件的使用情况
rg -l "ElButton|ElInput|El[A-Z]" docs/

Length of output: 133


Script:

#!/bin/bash
# Check the actual usage of Element Plus components in the identified files
echo "=== changelog.md ==="
rg "ElButton|ElInput|El[A-Z]" docs/guide/changelog.md -A 2
echo -e "\n=== join-group.md ==="
rg "ElButton|ElInput|El[A-Z]" docs/guide/join-group.md -A 2

Length of output: 892

docs/.vitepress/theme/components/VPIframe.vue (7)

9-9: baseUrl 变量转换为响应式引用

baseUrl 从普通变量转换为 ref,以适应在生命周期钩子中动态更新的需求,这是符合 Vue 3 最佳实践的做法。


17-19: 更新 href 计算属性以适应响应式的 baseUrl

在计算属性中使用 baseUrl.value,确保正确获取最新的 baseUrl 值。


29-29: onMounted 中设置 baseUrl.value

根据运行环境动态设置 baseUrl.value,确保在生产和开发环境中 iframe 能够正确加载。


67-68: 调整 .demo-model 的定位属性

更新了 .demo-modelrighttop 属性,优化了组件在页面中的位置布局。


85-89: 为大屏幕调整 .demo-model 的位置

在屏幕宽度不小于 1280px 时,调整了 .demo-modelright 属性,改善了大屏幕下的显示效果。


96-98: 为更大屏幕调整 .demo-model 的尺寸和位置

在屏幕宽度不小于 1440px 时,更新了 .demo-modelwidthheightright 属性,提供了更好的用户体验。


104-106: 在小屏幕上隐藏 .demo-model

在屏幕宽度小于 1280px 时,将 .demo-model 设置为 display: none,以提高移动设备上的内容可读性。

docs/.vitepress/theme/components/VPLocalNav.vue (1)

1-166: 组件实现良好,符合最佳实践

代码结构清晰,逻辑合理,样式定义规范,符合 Vue 3 和 VitePress 的最佳实践。

docs/.vitepress/plugins/markdown-transform.ts (2)

2-2: 导入语句的改进

从类型导入改为常规导入更符合最佳实践,因为 Plugin 不仅仅是类型定义。


11-11: 验证组件文档的转换逻辑

将检查条件从 <frame/> 更改为 /component 使转换更加明确,但需要确保所有组件文档都位于正确的路径下。

✅ Verification successful

组件文档路径验证已完成

根据检查结果,所有组件的文档都已正确放置在 /component 目录下,包括 action-sheet、backtop、badge 等所有组件。修改检查条件从 <frame/>/component 是安全的,不会遗漏任何组件文档。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证组件文档的位置是否符合新的路径要求

# 检查是否有组件文档不在 /component 目录下
fd -e md | rg -v '/component' | rg -l 'wd-'

Length of output: 41


Script:

#!/bin/bash
# 检查组件文档的位置分布
fd -e md -d 3 .

# 检查包含 wd- 前缀的文件
rg -l "wd-" .

Length of output: 21510

docs/.vitepress/theme/components/CustomFooter.vue (1)

12-13: 优化 VitePress 导入路径

从具体路径改为使用官方推荐的导入路径,这样可以更好地适应 VitePress 的版本更新。

docs/.vitepress/theme/styles/vars.css (1)

42-48: 改进渐变色定义的格式

渐变色定义的格式调整提高了代码的可读性,便于维护。

docs/.vitepress/theme/components/VPContent.vue (1)

41-44: 建议增加动态组件的错误处理

使用动态组件时,应该添加错误处理以防止未知布局导致的运行时错误。

<template>
<div
class="VPDoc"
:class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside ,' is-component': isComponent }"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

修正类名绑定中的多余空格

在绑定类名时,' is-component' 前多了一个空格,可能导致类名错误或样式无法正确应用。

建议修改为:

-     :class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside ,' is-component': isComponent }"
+     :class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside, 'is-component': isComponent }"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
:class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside ,' is-component': isComponent }"
:class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside, 'is-component': isComponent }"

import { useRoute } from 'vitepress'
import { computed } from 'vue'
import VPDocAside from 'vitepress/dist/client/theme-default/components/VPDocAside.vue'
import VPDocFooter from 'vitepress/dist/client/theme-default/components//VPDocFooter.vue'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

修正多余斜杠导致的导入路径错误

在导入 VPDocFooter 时,路径中多了一个斜杠,可能导致模块无法正确加载。

建议修改为:

- import VPDocFooter from 'vitepress/dist/client/theme-default/components//VPDocFooter.vue'
+ import VPDocFooter from 'vitepress/dist/client/theme-default/components/VPDocFooter.vue'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import VPDocFooter from 'vitepress/dist/client/theme-default/components//VPDocFooter.vue'
import VPDocFooter from 'vitepress/dist/client/theme-default/components/VPDocFooter.vue'



const { theme } = useData()
const { theme }:any = useData()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议改进类型定义

使用 any 类型断言可能会降低类型安全性。建议使用 VitePress 提供的类型定义。

-const { theme }:any = useData()
+import type { DefaultTheme } from 'vitepress/theme'
+const { theme } = useData<DefaultTheme>()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { theme }:any = useData()
import type { DefaultTheme } from 'vitepress/theme'
const { theme } = useData<DefaultTheme>()

Comment on lines +81 to +93
.VPNavBar.container{
max-width: auto;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

修复 CSS 属性值错误

max-width: auto 是无效的 CSS 属性值。

-.VPNavBar.container{
-  max-width: auto;
-}
+.VPNavBar.container{
+  max-width: none;
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.VPNavBar.container{
max-width: auto;
}
.VPNavBar.container{
max-width: none;
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (1)
docs/.vitepress/theme/components/VPLocalNav.vue (1)

26-31: 建议在 parseInt 中指定 radix 参数

在第27行的 parseInt() 函数中,建议指定 radix 参数为 10,以确保在所有环境下正确解析数值。

可以应用以下修改:

       navHeight.value = parseInt(
         getComputedStyle(document.documentElement).getPropertyValue(
           '--vp-nav-height'
-        )
+        ), 10
       )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fd540f2 and 9cf6f44.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (82)
  • docs/.vitepress/config.mts (2 hunks)
  • docs/.vitepress/plugins/markdown-transform.ts (2 hunks)
  • docs/.vitepress/theme/components/CustomFooter.vue (1 hunks)
  • docs/.vitepress/theme/components/VPContent.vue (1 hunks)
  • docs/.vitepress/theme/components/VPDoc.vue (1 hunks)
  • docs/.vitepress/theme/components/VPIframe.vue (1 hunks)
  • docs/.vitepress/theme/components/VPLocalNav.vue (1 hunks)
  • docs/.vitepress/theme/components/VPNavBar.vue (1 hunks)
  • docs/.vitepress/theme/components/VPSidebar.vue (1 hunks)
  • docs/.vitepress/theme/components/frame.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/.vitepress/theme/styles/vars.css (4 hunks)
  • docs/component/action-sheet.md (0 hunks)
  • docs/component/backtop.md (0 hunks)
  • docs/component/badge.md (0 hunks)
  • docs/component/button.md (0 hunks)
  • docs/component/calendar-view.md (0 hunks)
  • docs/component/calendar.md (0 hunks)
  • docs/component/card.md (0 hunks)
  • docs/component/cell.md (0 hunks)
  • docs/component/checkbox.md (0 hunks)
  • docs/component/circle.md (0 hunks)
  • docs/component/col-picker.md (0 hunks)
  • docs/component/collapse.md (0 hunks)
  • docs/component/config-provider.md (0 hunks)
  • docs/component/count-down.md (0 hunks)
  • docs/component/count-to.md (0 hunks)
  • docs/component/curtain.md (0 hunks)
  • docs/component/datetime-picker-view.md (0 hunks)
  • docs/component/datetime-picker.md (0 hunks)
  • docs/component/divider.md (0 hunks)
  • docs/component/drop-menu.md (0 hunks)
  • docs/component/fab.md (0 hunks)
  • docs/component/form.md (0 hunks)
  • docs/component/gap.md (0 hunks)
  • docs/component/grid.md (0 hunks)
  • docs/component/icon.md (0 hunks)
  • docs/component/img-cropper.md (0 hunks)
  • docs/component/img.md (0 hunks)
  • docs/component/index-bar.md (1 hunks)
  • docs/component/input-number.md (0 hunks)
  • docs/component/input.md (0 hunks)
  • docs/component/keyboard.md (0 hunks)
  • docs/component/layout.md (0 hunks)
  • docs/component/loading.md (0 hunks)
  • docs/component/loadmore.md (0 hunks)
  • docs/component/message-box.md (0 hunks)
  • docs/component/navbar.md (0 hunks)
  • docs/component/notice-bar.md (0 hunks)
  • docs/component/notify.md (0 hunks)
  • docs/component/number-keyboard.md (0 hunks)
  • docs/component/overlay.md (0 hunks)
  • docs/component/pagination.md (0 hunks)
  • docs/component/password-input.md (0 hunks)
  • docs/component/picker-view.md (0 hunks)
  • docs/component/picker.md (0 hunks)
  • docs/component/popover.md (0 hunks)
  • docs/component/popup.md (0 hunks)
  • docs/component/progress.md (0 hunks)
  • docs/component/radio.md (0 hunks)
  • docs/component/rate.md (0 hunks)
  • docs/component/resize.md (0 hunks)
  • docs/component/search.md (0 hunks)
  • docs/component/segmented.md (0 hunks)
  • docs/component/select-picker.md (0 hunks)
  • docs/component/sidebar.md (0 hunks)
  • docs/component/skeleton.md (0 hunks)
  • docs/component/slider.md (0 hunks)
  • docs/component/sort-button.md (0 hunks)
  • docs/component/status-tip.md (0 hunks)
  • docs/component/steps.md (0 hunks)
  • docs/component/sticky.md (0 hunks)
  • docs/component/swipe-action.md (0 hunks)
  • docs/component/swiper.md (0 hunks)
  • docs/component/switch.md (0 hunks)
  • docs/component/tabbar.md (0 hunks)
  • docs/component/table.md (0 hunks)
  • docs/component/tabs.md (0 hunks)
  • docs/component/tag.md (0 hunks)
  • docs/component/text.md (0 hunks)
  • docs/component/textarea.md (0 hunks)
  • docs/component/toast.md (0 hunks)
⛔ Files not processed due to max files limit (7)
  • docs/component/tooltip.md
  • docs/component/transition.md
  • docs/component/upload.md
  • docs/component/watermark.md
  • package.json
  • src/pages/radio/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-radio/types.ts
💤 Files with no reviewable changes (70)
  • docs/component/count-to.md
  • docs/component/backtop.md
  • docs/component/layout.md
  • docs/component/gap.md
  • docs/component/button.md
  • docs/component/img.md
  • docs/component/icon.md
  • docs/component/switch.md
  • docs/component/search.md
  • docs/.vitepress/theme/components/frame.vue
  • docs/component/count-down.md
  • docs/component/overlay.md
  • docs/component/pagination.md
  • docs/component/curtain.md
  • docs/component/sticky.md
  • docs/component/resize.md
  • docs/component/divider.md
  • docs/component/skeleton.md
  • docs/component/datetime-picker-view.md
  • docs/component/sort-button.md
  • docs/component/segmented.md
  • docs/component/config-provider.md
  • docs/component/password-input.md
  • docs/component/swipe-action.md
  • docs/component/form.md
  • docs/component/fab.md
  • docs/component/tabbar.md
  • docs/component/slider.md
  • docs/component/circle.md
  • docs/component/card.md
  • docs/component/popup.md
  • docs/component/toast.md
  • docs/component/input-number.md
  • docs/component/input.md
  • docs/component/rate.md
  • docs/component/action-sheet.md
  • docs/component/drop-menu.md
  • docs/component/textarea.md
  • docs/component/navbar.md
  • docs/component/datetime-picker.md
  • docs/component/swiper.md
  • docs/component/keyboard.md
  • docs/component/tabs.md
  • docs/component/collapse.md
  • docs/component/table.md
  • docs/component/sidebar.md
  • docs/component/badge.md
  • docs/component/grid.md
  • docs/component/calendar-view.md
  • docs/component/select-picker.md
  • docs/component/col-picker.md
  • docs/component/message-box.md
  • docs/component/number-keyboard.md
  • docs/component/progress.md
  • docs/component/notify.md
  • docs/component/status-tip.md
  • docs/component/text.md
  • docs/component/picker.md
  • docs/component/radio.md
  • docs/component/popover.md
  • docs/component/calendar.md
  • docs/component/loading.md
  • docs/component/steps.md
  • docs/component/loadmore.md
  • docs/component/tag.md
  • docs/component/img-cropper.md
  • docs/component/picker-view.md
  • docs/component/cell.md
  • docs/component/checkbox.md
  • docs/component/notice-bar.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/.vitepress/theme/index.ts
  • docs/component/index-bar.md
  • docs/.vitepress/theme/components/VPContent.vue
  • docs/.vitepress/plugins/markdown-transform.ts
  • docs/.vitepress/theme/styles/vars.css
  • docs/.vitepress/theme/components/CustomFooter.vue
🔇 Additional comments (6)
docs/.vitepress/theme/components/VPIframe.vue (1)

95-100: ⚠️ Potential issue

确保在 onTransitionEnd 中使用正确的状态检查

onTransitionEnd 函数中,直接使用 props.expanded 可能不会反映最新的状态。由于 props.expanded 的更新可能是异步的,建议使用 transitionEnd 或在触发条件中使用与状态变化同步的变量。

应用以下差异以修复此问题:

function onTransitionEnd() {
- if (!props.expanded) {
+ if (!transitionEnd.value) {
    transitionEnd.value = true
  }
}

Likely invalid or redundant comment.

docs/.vitepress/theme/components/VPNavBar.vue (1)

1-266: 代码良好,组件实现正确

整个导航栏组件实现了预期的功能,代码清晰,结构合理,没有发现明显问题。

docs/.vitepress/theme/components/VPSidebar.vue (1)

1-130: 代码良好,组件实现正确

侧边栏组件的实现符合预期,代码结构清晰,逻辑正确,没有发现明显问题。

docs/.vitepress/theme/components/VPDoc.vue (2)

5-5: ⚠️ Potential issue

修正导入路径中的多余斜杠

在第5行,导入 VPDocFooter 时,路径中有多余的斜杠,可能导致模块无法正确加载。

建议修改为:

- import VPDocFooter from 'vitepress/dist/client/theme-default/components//VPDocFooter.vue'
+ import VPDocFooter from 'vitepress/dist/client/theme-default/components/VPDocFooter.vue'

25-25: ⚠️ Potential issue

修正类名绑定中的多余空格

在第25行,绑定类名时,' is-component' 前多了一个空格,可能导致类名错误或样式无法正确应用。

建议修改为:

-     :class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside ,' is-component': isComponent, 'is-expanded': expanded }"
+     :class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside, 'is-component': isComponent, 'is-expanded': expanded }"
docs/.vitepress/config.mts (1)

Line range hint 12-63: Alias 配置正确,便于组件引用

在 Vite 配置中添加了组件的别名设置,路径解析正确,有助于在项目中方便地引用新组件。

Comment on lines +84 to +81
function toggleExpand() {
// 触发事件通知父组件
emit('update:expanded', !props.expanded)
emit('state-change', !props.expanded)

if (props.expanded) {
transitionEnd.value = false
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

修复 toggleExpand 函数中的状态更新逻辑

toggleExpand 函数中,您在更新 expanded 状态后立即使用 props.expanded,这可能导致逻辑错误。由于 props.expanded 的更新是异步的,立即读取它可能不会得到最新的值。建议使用一个局部变量存储更新后的状态。

应用以下差异以修复此问题:

function toggleExpand() {
+ const newExpanded = !props.expanded
  // 触发事件通知父组件
- emit('update:expanded', !props.expanded)
- emit('state-change', !props.expanded)
+ emit('update:expanded', newExpanded)
+ emit('state-change', newExpanded)
  
- if (props.expanded) {
+ if (newExpanded) {
    transitionEnd.value = false
  }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function toggleExpand() {
// 触发事件通知父组件
emit('update:expanded', !props.expanded)
emit('state-change', !props.expanded)
if (props.expanded) {
transitionEnd.value = false
}
}
function toggleExpand() {
const newExpanded = !props.expanded
// 触发事件通知父组件
emit('update:expanded', newExpanded)
emit('state-change', newExpanded)
if (newExpanded) {
transitionEnd.value = false
}
}

Comment on lines +108 to +104
onMounted(() => {
baseUrl.value = process.env.NODE_ENV === 'production'
? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
: 'http://localhost:5173/demo/#/'

// 监听 iframe 加载完成事件
iframe.value?.addEventListener('load', sendMessage)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

防止在组件未渲染完成前访问 iframe

onMounted 生命周期钩子中,您试图为 iframe 添加事件监听器,但此时 iframe 可能尚未渲染,导致 iframe.valuenull。建议使用 nextTick 确保 DOM 已更新,或者使用 watch 监听 iframe 的变化。

应用以下差异以修复此问题:

onMounted(() => {
  baseUrl.value = process.env.NODE_ENV === 'production' 
    ? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/` 
    : 'http://localhost:5173/demo/#/'

- iframe.value?.addEventListener('load', sendMessage)
+ nextTick(() => {
+   iframe.value?.addEventListener('load', sendMessage)
+ })
})

或者使用 watch

+ watch(iframe, (newIframe) => {
+   newIframe?.addEventListener('load', sendMessage)
+ })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onMounted(() => {
baseUrl.value = process.env.NODE_ENV === 'production'
? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
: 'http://localhost:5173/demo/#/'
// 监听 iframe 加载完成事件
iframe.value?.addEventListener('load', sendMessage)
})
onMounted(() => {
baseUrl.value = process.env.NODE_ENV === 'production'
? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
: 'http://localhost:5173/demo/#/'
nextTick(() => {
iframe.value?.addEventListener('load', sendMessage)
})
})
Suggested change
onMounted(() => {
baseUrl.value = process.env.NODE_ENV === 'production'
? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
: 'http://localhost:5173/demo/#/'
// 监听 iframe 加载完成事件
iframe.value?.addEventListener('load', sendMessage)
})
onMounted(() => {
baseUrl.value = process.env.NODE_ENV === 'production'
? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
: 'http://localhost:5173/demo/#/'
})
watch(iframe, (newIframe) => {
newIframe?.addEventListener('load', sendMessage)
})

Comment on lines +114 to +104
iframe.value?.addEventListener('load', sendMessage)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

在组件卸载时移除事件监听器以防止内存泄漏

当组件卸载时,应移除在 iframe 上添加的事件监听器,防止内存泄漏。

添加以下代码:

import { onMounted, onUnmounted, ref, watch, nextTick } from 'vue'

...

onMounted(() => {
  // 现有代码
})

+ onUnmounted(() => {
+   iframe.value?.removeEventListener('load', sendMessage)
+ })

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +105 to +95
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

确保 postMessage 的安全性

在使用 postMessage 时,应指定目标源 targetOrigin,以确保消息只发送到可信任的域,防止潜在的安全风险。

应用以下差异以修复此问题:

function sendMessage() {
  if (iframe.value?.contentWindow) {
-   iframe.value.contentWindow.postMessage(vitepressData.isDark.value, href.value)
+   iframe.value.contentWindow.postMessage(vitepressData.isDark.value, baseUrl.value)
  }
}

请确保 baseUrl.value 是可信任的源。

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +206 to +208
.VPDoc.is-component:not(.is-expanded) .container {
padding-right: 48px;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

消除重复的 CSS 规则

在第206-208行和第216-218行,发现重复的 CSS 规则,可能导致样式冲突或混淆。

建议合并重复的样式定义,以提高代码的可维护性和清晰度。

Also applies to: 216-218

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
docs/.vitepress/theme/components/VPIframe.vue (2)

26-29: 建议完善 Props 接口定义

当前的 Props 接口定义较为简单,建议添加更多的类型约束和验证规则。

建议修改为:

 interface Props {
-  /** 是否展开状态 */
-  expanded?: boolean
+  /**
+   * 是否展开状态
+   * @default true
+   * @description 控制演示面板的展开/折叠状态
+   */
+  expanded?: boolean
+  /**
+   * 自动折叠阈值
+   * @default 1279
+   * @description 当视窗宽度小于该值时自动折叠
+   */
+  autoCollapseWidth?: number
 }

118-130: 建议使用 CSS 自定义属性优化样式维护性

当前的样式定义中有许多魔术数字,建议使用 CSS 自定义属性来提高可维护性。

建议修改为:

+<style>
+:root {
+  --demo-model-width-default: 330px;
+  --demo-model-spacing: 32px;
+  --demo-model-header-height: 48px;
+  --demo-model-border-radius: 12px;
+  --demo-model-transition-duration: 0.3s;
+}
+</style>
+
 <style scoped>
 .demo-model {
   position: fixed;
   z-index: 10;
-  right: 32px;
-  top: calc(var(--vp-nav-height) + 32px);
-  width: 330px;
+  right: var(--demo-model-spacing);
+  top: calc(var(--vp-nav-height) + var(--demo-model-spacing));
+  width: var(--demo-model-width-default);
   font-size: 16px;
   background: var(--vp-c-bg-alt);
-  border-radius: 12px;
+  border-radius: var(--demo-model-border-radius);
   box-shadow: var(--vp-shadow-4);
   overflow: hidden;
-  transition: all 0.3s ease-in-out;
+  transition: all var(--demo-model-transition-duration) ease-in-out;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf6f44 and 2983114.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (82)
  • docs/.vitepress/config.mts (2 hunks)
  • docs/.vitepress/plugins/markdown-transform.ts (2 hunks)
  • docs/.vitepress/theme/components/CustomFooter.vue (1 hunks)
  • docs/.vitepress/theme/components/VPContent.vue (1 hunks)
  • docs/.vitepress/theme/components/VPDoc.vue (1 hunks)
  • docs/.vitepress/theme/components/VPIframe.vue (1 hunks)
  • docs/.vitepress/theme/components/VPLocalNav.vue (1 hunks)
  • docs/.vitepress/theme/components/VPNavBar.vue (1 hunks)
  • docs/.vitepress/theme/components/VPSidebar.vue (1 hunks)
  • docs/.vitepress/theme/components/frame.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/.vitepress/theme/styles/vars.css (4 hunks)
  • docs/component/action-sheet.md (0 hunks)
  • docs/component/backtop.md (0 hunks)
  • docs/component/badge.md (0 hunks)
  • docs/component/button.md (0 hunks)
  • docs/component/calendar-view.md (0 hunks)
  • docs/component/calendar.md (0 hunks)
  • docs/component/card.md (0 hunks)
  • docs/component/cell.md (0 hunks)
  • docs/component/checkbox.md (0 hunks)
  • docs/component/circle.md (0 hunks)
  • docs/component/col-picker.md (0 hunks)
  • docs/component/collapse.md (0 hunks)
  • docs/component/config-provider.md (0 hunks)
  • docs/component/count-down.md (0 hunks)
  • docs/component/count-to.md (0 hunks)
  • docs/component/curtain.md (0 hunks)
  • docs/component/datetime-picker-view.md (0 hunks)
  • docs/component/datetime-picker.md (0 hunks)
  • docs/component/divider.md (0 hunks)
  • docs/component/drop-menu.md (0 hunks)
  • docs/component/fab.md (0 hunks)
  • docs/component/form.md (0 hunks)
  • docs/component/gap.md (0 hunks)
  • docs/component/grid.md (0 hunks)
  • docs/component/icon.md (0 hunks)
  • docs/component/img-cropper.md (0 hunks)
  • docs/component/img.md (0 hunks)
  • docs/component/index-bar.md (1 hunks)
  • docs/component/input-number.md (0 hunks)
  • docs/component/input.md (0 hunks)
  • docs/component/keyboard.md (0 hunks)
  • docs/component/layout.md (0 hunks)
  • docs/component/loading.md (0 hunks)
  • docs/component/loadmore.md (0 hunks)
  • docs/component/message-box.md (0 hunks)
  • docs/component/navbar.md (0 hunks)
  • docs/component/notice-bar.md (0 hunks)
  • docs/component/notify.md (0 hunks)
  • docs/component/number-keyboard.md (0 hunks)
  • docs/component/overlay.md (0 hunks)
  • docs/component/pagination.md (0 hunks)
  • docs/component/password-input.md (0 hunks)
  • docs/component/picker-view.md (0 hunks)
  • docs/component/picker.md (0 hunks)
  • docs/component/popover.md (0 hunks)
  • docs/component/popup.md (0 hunks)
  • docs/component/progress.md (0 hunks)
  • docs/component/radio.md (0 hunks)
  • docs/component/rate.md (0 hunks)
  • docs/component/resize.md (0 hunks)
  • docs/component/search.md (0 hunks)
  • docs/component/segmented.md (0 hunks)
  • docs/component/select-picker.md (0 hunks)
  • docs/component/sidebar.md (0 hunks)
  • docs/component/skeleton.md (0 hunks)
  • docs/component/slider.md (0 hunks)
  • docs/component/sort-button.md (0 hunks)
  • docs/component/status-tip.md (0 hunks)
  • docs/component/steps.md (0 hunks)
  • docs/component/sticky.md (0 hunks)
  • docs/component/swipe-action.md (0 hunks)
  • docs/component/swiper.md (0 hunks)
  • docs/component/switch.md (0 hunks)
  • docs/component/tabbar.md (0 hunks)
  • docs/component/table.md (0 hunks)
  • docs/component/tabs.md (0 hunks)
  • docs/component/tag.md (0 hunks)
  • docs/component/text.md (0 hunks)
  • docs/component/textarea.md (0 hunks)
  • docs/component/toast.md (0 hunks)
⛔ Files not processed due to max files limit (7)
  • docs/component/tooltip.md
  • docs/component/transition.md
  • docs/component/upload.md
  • docs/component/watermark.md
  • package.json
  • src/pages/radio/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-radio/types.ts
💤 Files with no reviewable changes (70)
  • docs/component/count-to.md
  • docs/component/gap.md
  • docs/component/switch.md
  • docs/component/overlay.md
  • docs/component/backtop.md
  • docs/component/input-number.md
  • docs/component/img.md
  • docs/component/layout.md
  • docs/component/popup.md
  • docs/component/icon.md
  • docs/component/button.md
  • docs/component/resize.md
  • docs/component/sticky.md
  • docs/.vitepress/theme/components/frame.vue
  • docs/component/count-down.md
  • docs/component/loading.md
  • docs/component/pagination.md
  • docs/component/search.md
  • docs/component/skeleton.md
  • docs/component/progress.md
  • docs/component/divider.md
  • docs/component/sort-button.md
  • docs/component/slider.md
  • docs/component/form.md
  • docs/component/notify.md
  • docs/component/drop-menu.md
  • docs/component/steps.md
  • docs/component/swipe-action.md
  • docs/component/card.md
  • docs/component/toast.md
  • docs/component/password-input.md
  • docs/component/number-keyboard.md
  • docs/component/segmented.md
  • docs/component/curtain.md
  • docs/component/badge.md
  • docs/component/swiper.md
  • docs/component/datetime-picker-view.md
  • docs/component/tag.md
  • docs/component/tabs.md
  • docs/component/input.md
  • docs/component/datetime-picker.md
  • docs/component/select-picker.md
  • docs/component/config-provider.md
  • docs/component/circle.md
  • docs/component/calendar-view.md
  • docs/component/popover.md
  • docs/component/radio.md
  • docs/component/action-sheet.md
  • docs/component/picker-view.md
  • docs/component/checkbox.md
  • docs/component/status-tip.md
  • docs/component/text.md
  • docs/component/tabbar.md
  • docs/component/navbar.md
  • docs/component/img-cropper.md
  • docs/component/calendar.md
  • docs/component/notice-bar.md
  • docs/component/sidebar.md
  • docs/component/cell.md
  • docs/component/fab.md
  • docs/component/col-picker.md
  • docs/component/table.md
  • docs/component/keyboard.md
  • docs/component/collapse.md
  • docs/component/rate.md
  • docs/component/textarea.md
  • docs/component/loadmore.md
  • docs/component/picker.md
  • docs/component/message-box.md
  • docs/component/grid.md
🚧 Files skipped from review as they are similar to previous changes (11)
  • docs/.vitepress/theme/index.ts
  • docs/.vitepress/plugins/markdown-transform.ts
  • docs/.vitepress/config.mts
  • docs/component/index-bar.md
  • docs/.vitepress/theme/components/VPSidebar.vue
  • docs/.vitepress/theme/styles/vars.css
  • docs/.vitepress/theme/components/VPLocalNav.vue
  • docs/.vitepress/theme/components/CustomFooter.vue
  • docs/.vitepress/theme/components/VPContent.vue
  • docs/.vitepress/theme/components/VPDoc.vue
  • docs/.vitepress/theme/components/VPNavBar.vue
🔇 Additional comments (2)
docs/.vitepress/theme/components/VPIframe.vue (2)

73-81: 🛠️ Refactor suggestion

优化状态切换逻辑

toggleExpand 函数中的状态更新可能存在竞态条件。

建议修改为:

 function toggleExpand() {
+  const newExpanded = !props.expanded
   // 触发事件通知父组件
-  emit('update:expanded', !props.expanded)
-  emit('state-change', !props.expanded)
+  emit('update:expanded', newExpanded)
+  emit('state-change', newExpanded)
 
-  if (props.expanded) {
+  if (newExpanded) {
     transitionEnd.value = false
   }
 }

Likely invalid or redundant comment.


97-104: ⚠️ Potential issue

需要处理组件卸载时的清理工作

组件在卸载时需要移除事件监听器,以防止内存泄漏。

建议添加:

+import { onMounted, onUnmounted } from 'vue'
+
 onMounted(() => {
   baseUrl.value = process.env.NODE_ENV === 'production'
     ? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
     : 'http://localhost:5173/demo/#/'
 
   iframe.value?.addEventListener('load', sendMessage)
 })
+
+onUnmounted(() => {
+  iframe.value?.removeEventListener('load', sendMessage)
+})

Likely invalid or redundant comment.

Comment on lines +11 to +13
<el-icon class="expand-icon" style="cursor: pointer;" @click="toggleExpand">
<component :is="expanded ? Fold : Expand" />
</el-icon>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

需要增加无障碍访问支持

展开/折叠按钮缺少必要的无障碍访问属性,这可能会影响使用屏幕阅读器的用户。

建议添加以下属性:

- <el-icon class="expand-icon" style="cursor: pointer;" @click="toggleExpand">
+ <el-icon
+   class="expand-icon"
+   style="cursor: pointer;"
+   @click="toggleExpand"
+   role="button"
+   :aria-label="expanded ? '折叠演示' : '展开演示'"
+   :aria-expanded="expanded">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<el-icon class="expand-icon" style="cursor: pointer;" @click="toggleExpand">
<component :is="expanded ? Fold : Expand" />
</el-icon>
<el-icon
class="expand-icon"
style="cursor: pointer;"
@click="toggleExpand"
role="button"
:aria-label="expanded ? '折叠演示' : '展开演示'"
:aria-expanded="expanded">
<component :is="expanded ? Fold : Expand" />
</el-icon>

Comment on lines +48 to +55
const href = computed(() => {
const path = route.path
const paths = path ? path.split('.')[0].split('/') : []

if (!paths.length) return baseUrl.value

return baseUrl.value + `pages/${kebabToCamel(paths[paths.length - 1])}/Index`
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

需要加强 URL 构建的安全性

当前的 URL 构建逻辑缺少必要的输入验证和清理,可能存在安全风险。

建议添加以下安全措施:

 const href = computed(() => {
   const path = route.path
   const paths = path ? path.split('.')[0].split('/') : []
 
   if (!paths.length) return baseUrl.value
 
+  // 验证路径合法性
+  const lastPath = paths[paths.length - 1]
+  if (!lastPath || /[^a-zA-Z0-9-]/.test(lastPath)) {
+    console.warn('Invalid path detected:', lastPath)
+    return baseUrl.value
+  }
 
   return baseUrl.value + `pages/${kebabToCamel(paths[paths.length - 1])}/Index`
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const href = computed(() => {
const path = route.path
const paths = path ? path.split('.')[0].split('/') : []
if (!paths.length) return baseUrl.value
return baseUrl.value + `pages/${kebabToCamel(paths[paths.length - 1])}/Index`
})
const href = computed(() => {
const path = route.path
const paths = path ? path.split('.')[0].split('/') : []
if (!paths.length) return baseUrl.value
// 验证路径合法性
const lastPath = paths[paths.length - 1]
if (!lastPath || /[^a-zA-Z0-9-]/.test(lastPath)) {
console.warn('Invalid path detected:', lastPath)
return baseUrl.value
}
return baseUrl.value + `pages/${kebabToCamel(paths[paths.length - 1])}/Index`
})

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
docs/.vitepress/theme/components/VPIframe.vue (1)

129-129: 优化过渡动画性能

多个元素使用 all 属性进行过渡可能影响性能。

建议只对必要的属性应用过渡:

- transition: all 0.3s ease-in-out;
+ transition: width 0.3s ease-in-out,
+            height 0.3s ease-in-out,
+            opacity 0.3s ease-in-out;

Also applies to: 135-135, 175-175

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2983114 and 95c9fe1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (82)
  • docs/.vitepress/config.mts (2 hunks)
  • docs/.vitepress/plugins/markdown-transform.ts (2 hunks)
  • docs/.vitepress/theme/components/CustomFooter.vue (1 hunks)
  • docs/.vitepress/theme/components/VPContent.vue (1 hunks)
  • docs/.vitepress/theme/components/VPDoc.vue (1 hunks)
  • docs/.vitepress/theme/components/VPIframe.vue (1 hunks)
  • docs/.vitepress/theme/components/VPLocalNav.vue (1 hunks)
  • docs/.vitepress/theme/components/VPNavBar.vue (1 hunks)
  • docs/.vitepress/theme/components/VPSidebar.vue (1 hunks)
  • docs/.vitepress/theme/components/frame.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/.vitepress/theme/styles/vars.css (4 hunks)
  • docs/component/action-sheet.md (0 hunks)
  • docs/component/backtop.md (0 hunks)
  • docs/component/badge.md (0 hunks)
  • docs/component/button.md (0 hunks)
  • docs/component/calendar-view.md (0 hunks)
  • docs/component/calendar.md (0 hunks)
  • docs/component/card.md (0 hunks)
  • docs/component/cell.md (0 hunks)
  • docs/component/checkbox.md (0 hunks)
  • docs/component/circle.md (0 hunks)
  • docs/component/col-picker.md (0 hunks)
  • docs/component/collapse.md (0 hunks)
  • docs/component/config-provider.md (0 hunks)
  • docs/component/count-down.md (0 hunks)
  • docs/component/count-to.md (0 hunks)
  • docs/component/curtain.md (0 hunks)
  • docs/component/datetime-picker-view.md (0 hunks)
  • docs/component/datetime-picker.md (0 hunks)
  • docs/component/divider.md (0 hunks)
  • docs/component/drop-menu.md (0 hunks)
  • docs/component/fab.md (0 hunks)
  • docs/component/form.md (0 hunks)
  • docs/component/gap.md (0 hunks)
  • docs/component/grid.md (0 hunks)
  • docs/component/icon.md (0 hunks)
  • docs/component/img-cropper.md (0 hunks)
  • docs/component/img.md (0 hunks)
  • docs/component/index-bar.md (1 hunks)
  • docs/component/input-number.md (0 hunks)
  • docs/component/input.md (0 hunks)
  • docs/component/keyboard.md (0 hunks)
  • docs/component/layout.md (0 hunks)
  • docs/component/loading.md (0 hunks)
  • docs/component/loadmore.md (0 hunks)
  • docs/component/message-box.md (0 hunks)
  • docs/component/navbar.md (0 hunks)
  • docs/component/notice-bar.md (0 hunks)
  • docs/component/notify.md (0 hunks)
  • docs/component/number-keyboard.md (0 hunks)
  • docs/component/overlay.md (0 hunks)
  • docs/component/pagination.md (0 hunks)
  • docs/component/password-input.md (0 hunks)
  • docs/component/picker-view.md (0 hunks)
  • docs/component/picker.md (0 hunks)
  • docs/component/popover.md (0 hunks)
  • docs/component/popup.md (0 hunks)
  • docs/component/progress.md (0 hunks)
  • docs/component/radio.md (0 hunks)
  • docs/component/rate.md (0 hunks)
  • docs/component/resize.md (0 hunks)
  • docs/component/search.md (0 hunks)
  • docs/component/segmented.md (0 hunks)
  • docs/component/select-picker.md (0 hunks)
  • docs/component/sidebar.md (0 hunks)
  • docs/component/skeleton.md (0 hunks)
  • docs/component/slider.md (0 hunks)
  • docs/component/sort-button.md (0 hunks)
  • docs/component/status-tip.md (0 hunks)
  • docs/component/steps.md (0 hunks)
  • docs/component/sticky.md (0 hunks)
  • docs/component/swipe-action.md (0 hunks)
  • docs/component/swiper.md (0 hunks)
  • docs/component/switch.md (0 hunks)
  • docs/component/tabbar.md (0 hunks)
  • docs/component/table.md (0 hunks)
  • docs/component/tabs.md (0 hunks)
  • docs/component/tag.md (0 hunks)
  • docs/component/text.md (0 hunks)
  • docs/component/textarea.md (0 hunks)
  • docs/component/toast.md (0 hunks)
⛔ Files not processed due to max files limit (7)
  • docs/component/tooltip.md
  • docs/component/transition.md
  • docs/component/upload.md
  • docs/component/watermark.md
  • package.json
  • src/pages/radio/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-radio/types.ts
💤 Files with no reviewable changes (70)
  • docs/component/gap.md
  • docs/component/layout.md
  • docs/component/button.md
  • docs/component/count-to.md
  • docs/component/input-number.md
  • docs/component/resize.md
  • docs/component/icon.md
  • docs/component/img.md
  • docs/component/backtop.md
  • docs/component/switch.md
  • docs/.vitepress/theme/components/frame.vue
  • docs/component/overlay.md
  • docs/component/count-down.md
  • docs/component/pagination.md
  • docs/component/divider.md
  • docs/component/datetime-picker-view.md
  • docs/component/config-provider.md
  • docs/component/skeleton.md
  • docs/component/popup.md
  • docs/component/search.md
  • docs/component/drop-menu.md
  • docs/component/loading.md
  • docs/component/curtain.md
  • docs/component/card.md
  • docs/component/input.md
  • docs/component/form.md
  • docs/component/progress.md
  • docs/component/sticky.md
  • docs/component/sort-button.md
  • docs/component/slider.md
  • docs/component/action-sheet.md
  • docs/component/password-input.md
  • docs/component/circle.md
  • docs/component/fab.md
  • docs/component/notify.md
  • docs/component/loadmore.md
  • docs/component/toast.md
  • docs/component/keyboard.md
  • docs/component/navbar.md
  • docs/component/text.md
  • docs/component/message-box.md
  • docs/component/collapse.md
  • docs/component/select-picker.md
  • docs/component/table.md
  • docs/component/col-picker.md
  • docs/component/swipe-action.md
  • docs/component/status-tip.md
  • docs/component/popover.md
  • docs/component/tabbar.md
  • docs/component/swiper.md
  • docs/component/datetime-picker.md
  • docs/component/img-cropper.md
  • docs/component/tabs.md
  • docs/component/number-keyboard.md
  • docs/component/steps.md
  • docs/component/calendar-view.md
  • docs/component/tag.md
  • docs/component/checkbox.md
  • docs/component/radio.md
  • docs/component/rate.md
  • docs/component/segmented.md
  • docs/component/badge.md
  • docs/component/sidebar.md
  • docs/component/picker-view.md
  • docs/component/grid.md
  • docs/component/textarea.md
  • docs/component/calendar.md
  • docs/component/notice-bar.md
  • docs/component/cell.md
  • docs/component/picker.md
🚧 Files skipped from review as they are similar to previous changes (11)
  • docs/.vitepress/theme/index.ts
  • docs/component/index-bar.md
  • docs/.vitepress/plugins/markdown-transform.ts
  • docs/.vitepress/theme/components/VPLocalNav.vue
  • docs/.vitepress/theme/components/VPSidebar.vue
  • docs/.vitepress/theme/components/VPContent.vue
  • docs/.vitepress/theme/styles/vars.css
  • docs/.vitepress/theme/components/VPDoc.vue
  • docs/.vitepress/config.mts
  • docs/.vitepress/theme/components/CustomFooter.vue
  • docs/.vitepress/theme/components/VPNavBar.vue
🔇 Additional comments (4)
docs/.vitepress/theme/components/VPIframe.vue (4)

73-81: 🛠️ Refactor suggestion

优化状态更新逻辑

toggleExpand 函数中,直接使用 props.expanded 可能导致状态不同步的问题。

建议使用局部变量来管理状态更新:

function toggleExpand() {
+ const newExpanded = !props.expanded
  // 触发事件通知父组件
- emit('update:expanded', !props.expanded)
- emit('state-change', !props.expanded)
+ emit('update:expanded', newExpanded)
+ emit('state-change', newExpanded)

- if (props.expanded) {
+ if (newExpanded) {
    transitionEnd.value = false
  }
}

Likely invalid or redundant comment.


97-104: ⚠️ Potential issue

添加事件监听器清理和安全性增强

组件缺少必要的清理操作,且 iframe 事件监听可能在 DOM 更新前执行。

建议进行以下改进:

+ import { onMounted, onUnmounted, nextTick } from 'vue'

onMounted(() => {
  baseUrl.value = process.env.NODE_ENV === 'production'
    ? `${location.origin}/demo/?timestamp=${new Date().getTime()}#/`
    : 'http://localhost:5173/demo/#/'

- iframe.value?.addEventListener('load', sendMessage)
+ nextTick(() => {
+   iframe.value?.addEventListener('load', sendMessage)
+ })
})

+ onUnmounted(() => {
+   iframe.value?.removeEventListener('load', sendMessage)
+ })

Likely invalid or redundant comment.


91-95: ⚠️ Potential issue

增强 postMessage 安全性

使用 postMessage 时需要指定目标源,以防止潜在的安全风险。

建议修改如下:

function sendMessage() {
  if (iframe.value?.contentWindow) {
-   iframe.value.contentWindow.postMessage(vitepressData.isDark.value, href.value)
+   const targetOrigin = process.env.NODE_ENV === 'production'
+     ? location.origin
+     : 'http://localhost:5173'
+   iframe.value.contentWindow.postMessage(
+     vitepressData.isDark.value,
+     targetOrigin
+   )
  }
}

Likely invalid or redundant comment.


11-13: 🛠️ Refactor suggestion

需要增加无障碍访问支持

展开/折叠按钮缺少必要的无障碍访问属性,这会影响使用屏幕阅读器的用户体验。

建议添加以下属性:

- <el-icon class="expand-icon" style="cursor: pointer;" @click="toggleExpand">
+ <el-icon
+   class="expand-icon"
+   style="cursor: pointer;"
+   @click="toggleExpand"
+   role="button"
+   :aria-label="expanded ? '折叠演示' : '展开演示'"
+   :aria-expanded="expanded"
+   tabindex="0"
+   @keydown.enter="toggleExpand"
+   @keydown.space.prevent="toggleExpand">

Likely invalid or redundant comment.

@Moonofweisheng Moonofweisheng merged commit 402f73f into master Dec 7, 2024
@Moonofweisheng Moonofweisheng deleted the docs/vitepress-improve branch December 7, 2024 15:52
@malqqin

malqqin commented Dec 21, 2024

Copy link
Copy Markdown

本地文档无法预览,404

Repository owner locked as resolved and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants