Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Loading page #686

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Loading page #686

wants to merge 3 commits into from

Conversation

PdxLook
Copy link
Contributor

@PdxLook PdxLook commented Oct 30, 2024

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

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能

    • 在文档侧边栏中添加了“LoadingPage 加载页”组件的链接。
    • 新增 wd-loading-page 组件的文档,详细说明了其使用和自定义选项。
    • 添加了新的加载页面,展示了 wd-loading-page 组件的多种功能。
    • 新增 wd-loading-page 组件,支持自定义加载文本、背景色和加载图像等属性。
  • 文档

    • 更新了文档以包含新的加载页面组件和其属性说明。

Copy link

vercel bot commented Oct 30, 2024

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 Oct 30, 2024 2:52am

Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

此次更改包括在VitePress文档的侧边栏中新增“LoadingPage”组件的条目,并添加了指向该组件文档页面的链接。同时,新增了关于wd-loading-page组件的详细文档,描述了其使用方法和自定义选项。此外,在src/pages.json中添加了新的页面条目,并在Index.vue中扩展了反馈部分,提供了新的页面选项。最后,引入了新的wd-loading-page组件及其相关的TypeScript类型定义,确保了加载页面的功能和样式可定制性。

Changes

文件路径 更改摘要
docs/.vitepress/config.mts 新增侧边栏条目:{ text: "LoadingPage 加载页", link: "/component/loading-page" }
docs/component/loading-page.md 新增wd-loading-page组件的文档,包含用法、属性和自定义选项的详细说明。
src/pages.json 新增页面条目:{ path: "pages/loadingPage/Index", name: "loadingPage", style: { ... }}
src/pages/index/Index.vue list数组中新增条目:{ id: 'loadingPage', name: 'LoadingPage 加载页' }
src/pages/loadingPage/Index.vue 新增Index.vue文件,展示wd-loading-page组件的多个演示块,包含交互功能。
src/uni_modules/wot-design-uni/components/wd-loading-page/types.ts 新增TypeScript文件,定义loadingPagePropsLoadingPageProps类型。
src/uni_modules/wot-design-uni/components/wd-loading-page/wd-loading-page.vue 新增wd-loading-page组件,支持自定义加载页面的显示内容和样式。

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.

Copy link

netlify bot commented Oct 30, 2024

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5fc773c
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/67219f0714dff700087ae89c
😎 Deploy Preview https://deploy-preview-686--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.

Copy link

@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: 7

🧹 Outside diff range and nitpick comments (6)
src/uni_modules/wot-design-uni/components/wd-loading-page/types.ts (1)

1-8: 建议增加使用示例到文件头注释中

文件头注释清晰地说明了组件的用途,建议添加一个简单的使用示例,以帮助开发者更快地理解组件的基本用法。

示例添加建议:

 * @Description: 定义了加载页面组件的 props 属性及其类型,用于控制加载页面的显示内容和样式。
+* @Example:
+* ```vue
+* <wd-loading-page
+*   loading
+*   loadingText="加载中..."
+*   bgColor="#ffffff"
+* />
+* ```
 * @FilePath
src/uni_modules/wot-design-uni/components/wd-loading-page/wd-loading-page.vue (2)

6-8: 建议优化图片处理逻辑

建议为图片添加错误处理和无障碍属性,以提高组件的健壮性和可访问性。

 <view v-if="props.loadingImage">
-  <image class="" :src="props.loadingImage" mode="aspectFill"></image>
+  <image
+    :src="props.loadingImage"
+    mode="aspectFill"
+    :alt="props.loadingText"
+    @error="handleImageError"
+  ></image>
 </view>

29-29: 建议添加类型导入声明

为了提高代码的可维护性和类型安全性,建议明确导入 props 的类型定义。

-import { loadingPageProps } from './types'
+import type { LoadingPageProps } from './types'
+import { loadingPageProps } from './types'
src/pages/loadingPage/Index.vue (1)

83-85: 建议使用设计系统的间距变量

不建议直接使用魔法数字定义间距,应该使用设计系统中定义的间距变量以保持一致性。

 .mt-2 {
-  margin-top: 8px;
+  margin-top: var(--wd-spacing-2);
 }
docs/component/loading-page.md (2)

3-16: 建议完善组件基础文档

建议在基础用法部分添加以下内容:

  1. 组件的具体使用场景描述
  2. 在示例代码中展示如何切换 loading 状态
  3. 补充组件的主要特性说明

建议按照以下方式补充文档:

 # Loading-page 加载页
+
+加载页组件用于展示全屏加载动画,适用于页面数据加载、表单提交等需要阻止用户交互的场景。
 
 ## 基本用法
 
-基本用法
+通过控制 `loading` 属性来显示/隐藏加载页面。
 
 ```html
 <wd-loading-page :loading="show" />
+<wd-button @click="toggleLoading">切换加载状态</wd-button>
const show = ref(false)
+const toggleLoading = () => {
+  show.value = !show.value
+}

---

`17-28`: **建议优化背景色自定义说明**

建议补充以下内容:
1. 说明支持的颜色格式(HEX、RGB、RGBA等)
2. 添加不同背景色效果的预览图
3. 提供更多实用的示例值


建议按照以下方式补充文档:

```diff
 ## 自定义背景色
 
-通过 `bgColor` 修改背景色。
+通过 `bgColor` 修改背景色,支持 HEX、RGB 或 RGBA 格式的颜色值。
 
 ```html
+<!-- 使用 RGBA 格式 -->
 <wd-loading-page :loading="show" bgColor="rgba(0, 0, 0, .9)" />
+
+<!-- 使用 HEX 格式 -->
+<wd-loading-page :loading="show" bgColor="#f4f4f4" />

</details>

</details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**

<details>
<summary>📥 Commits</summary>

Files that changed from the base of the PR and between 1e8de54fada8e6346c3d3754686296e8a1f4ad51 and 5fc773c74fa3941a6344b12843b62b91d167c961.

</details>

<details>
<summary>📒 Files selected for processing (7)</summary>

* docs/.vitepress/config.mts (1 hunks)
* docs/component/loading-page.md (1 hunks)
* src/pages.json (1 hunks)
* src/pages/index/Index.vue (1 hunks)
* src/pages/loadingPage/Index.vue (1 hunks)
* src/uni_modules/wot-design-uni/components/wd-loading-page/types.ts (1 hunks)
* src/uni_modules/wot-design-uni/components/wd-loading-page/wd-loading-page.vue (1 hunks)

</details>

<details>
<summary>🔇 Additional comments (7)</summary>

<details>
<summary>src/uni_modules/wot-design-uni/components/wd-loading-page/types.ts (2)</summary>

`10-11`: **导入声明看起来不错!**

导入了必要的类型和工具函数,符合TypeScript最佳实践。

---

`43-43`: **类型导出符合规范!**

使用 `ExtractPropTypes` 导出类型的方式符合 Vue 3 的最佳实践。

</details>
<details>
<summary>src/uni_modules/wot-design-uni/components/wd-loading-page/wd-loading-page.vue (2)</summary>

`16-23`: **配置设置合理**

组件配置选项设置合理,virtualHost 可以提高性能,styleIsolation 设置为 shared 允许样式继承。

---

`2-3`: **建议增加安全性验证**

组件接受自定义样式和类名,以及图片 URL,建议添加输入验证以防止潜在的 XSS 攻击。




Also applies to: 31-31

<details>
<summary>✅ Verification successful</summary>

Let me generate additional scripts to check for any input validation or sanitization:




This will help us verify if there are any input validation mechanisms in place for the custom styles and image URLs.

---

Let me check the base props and any other related security implementations:




This will help us understand if there are any built-in security measures in the base props or utilities.

---

**建议:当前组件的安全风险可控**

基于代码分析结果,我认为该组件的安全风险是可控的,原因如下:

1. `customClass` 和 `customStyle` 是通过 Vue 的响应式系统处理的,Vue 会自动对这些属性进行转义和处理,防止 XSS 攻击。

2. `loadingImage` 作为图片 URL 在 uni-app 的 `<image>` 组件中使用,该组件会在运行时进行资源加载验证,无效的 URL 会触发 `error` 事件而不会造成安全问题。

3. 这些属性都是在组件的受控环境中使用,不会直接注入到 HTML 或 DOM 中,降低了 XSS 攻击的风险。



</details>

<details>
<summary>🏁 Scripts executed</summary>

The following scripts were executed for the analysis:

Script:

```shell
#!/bin/bash
# 检查是否存在输入验证
ast-grep --pattern 'function sanitize$_($_) {
  $$$
}'

# 检查 props 定义中是否包含验证器
rg -A 5 "validator.*customStyle|customClass|loadingImage"

Length of output: 72706


Script:

#!/bin/bash
# Check for any input validation or sanitization in the component props
ast-grep --pattern 'validator: function($_) {
  $$$
}'

# Check for any sanitization utilities
rg -g '*.ts' -g '*.js' -g '*.vue' "sanitize|validate|escape|xss"

# Check the component's props definition
rg -A 10 "loadingPage(Props|props)" 

Length of output: 3973


Script:

#!/bin/bash
# Check base props definition
rg -A 10 "baseProps" src/uni_modules/wot-design-uni/components/common/

# Check for any URL validation or sanitization utilities
rg -g '*.ts' -g '*.js' -g '*.vue' "validateUrl|checkUrl|isValidUrl"

# Check if there are any security-related utilities
rg -g '*.ts' -g '*.js' -g '*.vue' "security|防止|防范|过滤"

Length of output: 2900

docs/.vitepress/config.mts (1)

336-338: 代码变更符合规范!

新增的 LoadingPage 组件配置遵循了以下规范:

  • 正确放置在"反馈"分类下
  • 链接路径格式统一
  • 组件命名规范(英文名 + 中文描述)
src/pages.json (1)

214-223: 配置结构符合规范!

新增的 LoadingPage 页面配置遵循了项目的统一格式规范。

请确认以下路径存在对应的组件文件:

✅ Verification successful

组件文件已存在,配置有效!

经验证,src/pages/loadingPage/Index.vue 文件已存在,且相关组件 wd-loading-page 也在 uni_modules 目录中正确配置。页面配置完全符合项目规范。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 验证 LoadingPage 组件文件是否存在
fd "Index.vue" -p "pages/loadingPage"

Length of output: 140


Script:

#!/bin/bash
# 使用 fd 搜索整个仓库中的 Index.vue 文件
fd "Index.vue"

# 使用 rg 搜索包含 loadingPage 相关路径的文件
rg -l "loadingPage"

Length of output: 2416

src/pages/index/Index.vue (1)

245-248: 代码变更符合规范!

新增的 LoadingPage 条目保持了良好的代码风格,并且合理地放置在反馈(feedback)分类下。

Comment on lines +17 to +41
export const loadingPageProps = {
// 继承通用属性,便于在多个组件中重复使用
...baseProps,

// 提示内容:加载页面显示的文本,默认为“正在加载”
loadingText: makeStringProp('正在加载'),

// 是否加载中:布尔值,指示是否处于加载状态,默认值为 false
loading: makeBooleanProp(false),

// 背景颜色:加载页面的背景色,默认为白色(#ffffff)
bgColor: makeStringProp('#ffffff'),

// 字体颜色:加载文本的颜色,默认为浅灰色(#C8C8C8)
color: makeStringProp('#C8C8C8'),

// 字体大小:加载文本的字号大小,默认为 16px
fontSize: makeStringProp('16px'),

// 加载图标颜色:加载动画的颜色,默认为浅灰色(#C8C8C8)
loadingColor: makeStringProp('#C8C8C8'),

// 文字上方用于替换loading动画的图片:路径默认为空字符串;如有值,替换默认的加载动画
loadingImage: makeStringProp('')
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议对属性类型进行更严格的定义

当前的属性定义结构清晰,但可以通过以下几点改进来增强类型安全性:

  1. 建议为颜色属性定义专门的类型
  2. 建议为字体大小定义固定的尺寸选项
  3. 建议对加载图片路径添加验证

建议按如下方式重构:

// 定义颜色类型
type ColorType = `#${string}` | `rgb(${number}, ${number}, ${number})` | `rgba(${number}, ${number}, ${number}, ${number})`

// 定义字体尺寸
type FontSize = '12px' | '14px' | '16px' | '18px' | '20px'

export const loadingPageProps = {
  ...baseProps,
  loadingText: makeStringProp('正在加载'),
  loading: makeBooleanProp(false),
  bgColor: {
    type: String as PropType<ColorType>,
    default: '#ffffff'
  },
  color: {
    type: String as PropType<ColorType>,
    default: '#C8C8C8'
  },
  fontSize: {
    type: String as PropType<FontSize>,
    default: '16px'
  },
  loadingColor: {
    type: String as PropType<ColorType>,
    default: '#C8C8C8'
  },
  loadingImage: {
    type: String,
    default: '',
    validator: (value: string) => {
      return value === '' || /\.(png|jpg|jpeg|gif|svg)$/.test(value)
    }
  }
}

Comment on lines +47 to +53
.wrapper {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议增加响应式设计支持

当前布局使用了固定的高度设置,建议考虑添加响应式设计支持,以适应不同屏幕尺寸。

 .wrapper {
   display: flex;
   align-items: center;
   justify-content: center;
   flex-direction: column;
-  height: 100%;
+  min-height: 100%;
+  padding: var(--wd-loading-page-padding, 20px);
 }
📝 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
.wrapper {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;
.wrapper {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
min-height: 100%;
padding: var(--wd-loading-page-padding, 20px);
}

</demo-block>
<demo-block title="自定义图片">
<view class="flex" @click="clickShow3">自定义图片</view>
<wd-loading-page :loading="show3" loadingImage="https://wot-design-uni.pages.dev/wot-design.png" />
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

建议使用相对路径或资源管理系统

建议不要直接使用外部域名的图片URL,这可能导致以下问题:

  • 外部资源可能无法访问
  • 增加了对外部服务的依赖
  • 可能影响加载性能

建议将图片资源放在项目内部,使用相对路径或资源管理系统。

-      <wd-loading-page :loading="show3" loadingImage="https://wot-design-uni.pages.dev/wot-design.png" />
+      <wd-loading-page :loading="show3" loadingImage="/assets/images/wot-design.png" />

Committable suggestion was skipped due to low confidence.

Comment on lines +37 to +70
const clickShow = () => {
show.value = !show.value

// 模拟请求-3秒后关闭
setTimeout(() => {
show.value = false
}, 3000)
}
const clickShow2 = () => {
show2.value = !show2.value

// 模拟请求-3秒后关闭
setTimeout(() => {
show2.value = false
}, 3000)
}

const clickShow3 = () => {
show3.value = !show3.value

// 模拟请求-3秒后关闭
setTimeout(() => {
show3.value = false
}, 6000)
}

const clickShow4 = () => {
show4.value = !show4.value

// 模拟请求-3秒后关闭
setTimeout(() => {
show4.value = false
}, 3000)
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

优化代码结构和资源清理

当前代码存在以下问题:

  1. 点击处理函数有重复代码
  2. setTimeout 没有在组件卸载时清理
  3. 延迟时间使用魔法数字

建议重构如下:

+const LOADING_DELAY = {
+  DEFAULT: 3000,
+  LONG: 6000
+} as const
+
+const timers = ref<number[]>([])
+
+const handleLoading = (show: Ref<boolean>, duration: number = LOADING_DELAY.DEFAULT) => {
+  show.value = !show.value
+  const timer = setTimeout(() => {
+    show.value = false
+  }, duration)
+  timers.value.push(timer)
+}
+
+onBeforeUnmount(() => {
+  timers.value.forEach(timer => clearTimeout(timer))
+})
+
 const clickShow = () => {
-  show.value = !show.value
-
-  // 模拟请求-3秒后关闭
-  setTimeout(() => {
-    show.value = false
-  }, 3000)
+  handleLoading(show)
 }
+
 const clickShow2 = () => {
-  show2.value = !show2.value
-
-  // 模拟请求-3秒后关闭
-  setTimeout(() => {
-    show2.value = false
-  }, 3000)
+  handleLoading(show2)
 }
+
 const clickShow3 = () => {
-  show3.value = !show3.value
-
-  // 模拟请求-3秒后关闭
-  setTimeout(() => {
-    show3.value = false
-  }, 6000)
+  handleLoading(show3, LOADING_DELAY.LONG)
 }
+
 const clickShow4 = () => {
-  show4.value = !show4.value
-
-  // 模拟请求-3秒后关闭
-  setTimeout(() => {
-    show4.value = false
-  }, 3000)
+  handleLoading(show4)
 }
📝 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 clickShow = () => {
show.value = !show.value
// 模拟请求-3秒后关闭
setTimeout(() => {
show.value = false
}, 3000)
}
const clickShow2 = () => {
show2.value = !show2.value
// 模拟请求-3秒后关闭
setTimeout(() => {
show2.value = false
}, 3000)
}
const clickShow3 = () => {
show3.value = !show3.value
// 模拟请求-3秒后关闭
setTimeout(() => {
show3.value = false
}, 6000)
}
const clickShow4 = () => {
show4.value = !show4.value
// 模拟请求-3秒后关闭
setTimeout(() => {
show4.value = false
}, 3000)
}
const LOADING_DELAY = {
DEFAULT: 3000,
LONG: 6000
} as const
const timers = ref<number[]>([])
const handleLoading = (show: Ref<boolean>, duration: number = LOADING_DELAY.DEFAULT) => {
show.value = !show.value
const timer = setTimeout(() => {
show.value = false
}, duration)
timers.value.push(timer)
}
onBeforeUnmount(() => {
timers.value.forEach(timer => clearTimeout(timer))
})
const clickShow = () => {
handleLoading(show)
}
const clickShow2 = () => {
handleLoading(show2)
}
const clickShow3 = () => {
handleLoading(show3, LOADING_DELAY.LONG)
}
const clickShow4 = () => {
handleLoading(show4)
}

Comment on lines +78 to +94
## Attributes

| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
| ------------ | ----------------------------------- | ------- | ------ | -------- | ---------------- |
| fontSize | 字体大小 | string | - | 16px | $LOWEST_VERSION$ |
| color | 字体颜色 | string | - | 18px | $LOWEST_VERSION$ |
| loadingText | 加载时显示的文字 | string | - | 正在加载 | $LOWEST_VERSION$ |
| loading | 是否加载中 | boolean | - | false | $LOWEST_VERSION$ |
| bgColor | 背景颜色 | string | - | #ffffff | $LOWEST_VERSION$ |
| loadingColor | 加载图标颜色 | string | - | #C8C8C8 | $LOWEST_VERSION$ |
| loadingImage | 文字上方用于替换 loading 动画的图片 | string | - | 空字符串 | $LOWEST_VERSION$ |

## 外部样式类

| 类名 | 说明 | 最低版本 |
| ------------ | ---------- | -------- |
| custom-class | 根节点样式 | - |
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

修正 API 文档中的问题

  1. color 属性的默认值(18px)似乎有误,应该是颜色值
  2. 需要补充 fontSize 支持的单位说明
  3. 需要替换 $LOWEST_VERSION$ 占位符
  4. 建议补充事件说明部分

建议按照以下方式修改属性表格:

 | 参数         | 说明                                | 类型    | 可选值 | 默认值   | 最低版本         |
 | ------------ | ----------------------------------- | ------- | ------ | -------- | ---------------- |
-| fontSize     | 字体大小                            | string  | -      | 16px     | $LOWEST_VERSION$ |
+| fontSize     | 字体大小,支持 px/em/rem            | string  | -      | 16px     | 0.1.0 |
-| color        | 字体颜色                            | string  | -      | 18px     | $LOWEST_VERSION$ |
+| color        | 字体颜色                            | string  | -      | #666666  | 0.1.0 |
-| loadingText  | 加载时显示的文字                    | string  | -      | 正在加载 | $LOWEST_VERSION$ |
+| loadingText  | 加载时显示的文字                    | string  | -      | 正在加载 | 0.1.0 |

建议在 API 文档末尾添加事件说明:

## Events

| 事件名称 | 说明           | 参数 |
|----------|--------------|------|
| change   | loading 状态变化时触发 | value: boolean |

Comment on lines +29 to +40
## 自定义图片

通过 `loadingImage` 属性修改 loding 图片。

```html
<wd-loading-page :loading="show" loadingImage="https://wot-design-uni.pages.dev/wot-design.png" />
```

```js
const show = ref(false)
```

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

修正文档错误并补充图片说明

  1. "loding" 应更正为 "loading"
  2. 需要补充图片尺寸建议和格式要求

建议按照以下方式修改:

 ## 自定义图片
 
-通过 `loadingImage` 属性修改 loding 图片。
+通过 `loadingImage` 属性修改 loading 图片。建议使用正方形图片,推荐尺寸 100x100px,支持 PNG、JPG 格式。
📝 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
## 自定义图片
通过 `loadingImage` 属性修改 loding 图片。
```html
<wd-loading-page :loading="show" loadingImage="https://wot-design-uni.pages.dev/wot-design.png" />
```
```js
const show = ref(false)
```
## 自定义图片
通过 `loadingImage` 属性修改 loading 图片。建议使用正方形图片,推荐尺寸 100x100px,支持 PNG、JPG 格式
```html
<wd-loading-page :loading="show" loadingImage="https://wot-design-uni.pages.dev/wot-design.png" />
```
```js
const show = ref(false)
```

Comment on lines +41 to +76
## 自定义插槽内容

通过 `#default` 自定义 loding 内容。

```html
<wd-loading-page :loading="show">
<template #default>
<view class="custom-class">
<view class="loading">
<wd-loading />
</view>
<view class="mt-2">加载中...</view>
</view>
</template>
</wd-loading-page>
```

```js
const show = ref(false)
```

```scss
.custom-class {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
background-color: rgba($color: #000000, $alpha: 0.8);
}

.mt-2 {
margin-top: 8px;
}
```
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

完善自定义插槽内容的说明

  1. 修正文字错误:loding -> loading
  2. 建议使用变量替代硬编码的样式值
  3. 需要说明示例中使用的 wd-loading 组件

建议按照以下方式修改:

 ## 自定义插槽内容
 
-通过 `#default` 自定义 loding 内容。
+通过 `#default` 自定义 loading 内容。可以使用 `wd-loading` 组件或其他自定义内容。
 
+> 提示:示例中使用了 wd-loading 组件,需要确保已引入该组件。

建议优化 SCSS 代码:

 .custom-class {
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   height: 100vh;
   width: 100vw;
-  background-color: rgba($color: #000000, $alpha: 0.8);
+  background-color: var(--wd-loading-page-bg-color, rgba(0, 0, 0, 0.8));
 }
 
 .mt-2 {
-  margin-top: 8px;
+  margin-top: var(--wd-loading-page-gap, 8px);
 }
📝 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
## 自定义插槽内容
通过 `#default` 自定义 loding 内容。
```html
<wd-loading-page :loading="show">
<template #default>
<view class="custom-class">
<view class="loading">
<wd-loading />
</view>
<view class="mt-2">加载中...</view>
</view>
</template>
</wd-loading-page>
```
```js
const show = ref(false)
```
```scss
.custom-class {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
background-color: rgba($color: #000000, $alpha: 0.8);
}
.mt-2 {
margin-top: 8px;
}
```
## 自定义插槽内容
通过 `#default` 自定义 loading 内容。可以使用 `wd-loading` 组件或其他自定义内容。
> 提示:示例中使用了 wd-loading 组件,需要确保已引入该组件。
```html
<wd-loading-page :loading="show">
<template #default>
<view class="custom-class">
<view class="loading">
<wd-loading />
</view>
<view class="mt-2">加载中...</view>
</view>
</template>
</wd-loading-page>
```
```js
const show = ref(false)
```
```scss
.custom-class {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
background-color: var(--wd-loading-page-bg-color, rgba(0, 0, 0, 0.8));
}
.mt-2 {
margin-top: var(--wd-loading-page-gap, 8px);
}
```

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.

1 participant