From 973b58b956a5d613bd03293a9e6dc77660d1a8f8 Mon Sep 17 00:00:00 2001 From: sakurayinfei <970412446@qq.com> Date: Wed, 16 Jul 2025 14:25:53 +0800 Subject: [PATCH 01/17] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96propsToAttrStr?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E6=A3=80=E6=9F=A5tag=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=90=8D=E6=98=AF=E5=90=A6=E5=90=88=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/opendesign/src/_demo/utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/opendesign/src/_demo/utils.ts b/packages/opendesign/src/_demo/utils.ts index 9be19c80..a705eb0b 100644 --- a/packages/opendesign/src/_demo/utils.ts +++ b/packages/opendesign/src/_demo/utils.ts @@ -1,3 +1,5 @@ +const canLog = process.env.NODE_ENV === 'development'; +const validTagAttrName = (name: string) => /^[a-zA-Z0-9_\-]+$/.test(name); /** * 将组件的props转为属性字符串以便拼接到html标签中 * 仅在__docs__/__case__/ 中使用 @@ -11,6 +13,12 @@ export function propsToAttrStr(props: Record, exclude = [] as strin if (exclude.includes(key)) { return acc; } + if (!validTagAttrName(key)) { + if (canLog) { + console.warn(`Invalid tag attr name: ${name}`); + } + return acc; + } switch (typeof value) { case 'boolean': if (value) { -- Gitee From 79bed54e0b5cc7fca45fe3255a9a863e7bc6aaca Mon Sep 17 00:00:00 2001 From: sakurayinfei <970412446@qq.com> Date: Wed, 16 Jul 2025 14:36:30 +0800 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Eanchor=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=96=87=E6=A1=A3=EF=BC=8C=E4=BC=98=E5=8C=96button?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../anchor/__docs__/__case__/AnchorSlot.vue | 33 +++++ .../anchor/__docs__/__case__/AnchorUsage.vue | 113 ++++++++++++++++++ .../src/anchor/__docs__/index.en-US.md | 10 ++ .../src/anchor/__docs__/index.zh-CN.md | 10 ++ packages/opendesign/src/anchor/types.ts | 38 +++++- .../button/__docs__/__case__/BtnIconSize.vue | 28 ++--- .../button/__docs__/__case__/BtnLoading.vue | 11 +- .../src/button/__docs__/__case__/BtnRound.vue | 10 -- .../src/button/__docs__/__case__/btnUsage.ts | 8 +- .../src/button/__docs__/index.en-US.md | 2 +- packages/opendesign/src/button/types.ts | 32 +++-- 11 files changed, 239 insertions(+), 56 deletions(-) create mode 100644 packages/opendesign/src/anchor/__docs__/__case__/AnchorSlot.vue create mode 100644 packages/opendesign/src/anchor/__docs__/__case__/AnchorUsage.vue create mode 100644 packages/opendesign/src/anchor/__docs__/index.en-US.md create mode 100644 packages/opendesign/src/anchor/__docs__/index.zh-CN.md diff --git a/packages/opendesign/src/anchor/__docs__/__case__/AnchorSlot.vue b/packages/opendesign/src/anchor/__docs__/__case__/AnchorSlot.vue new file mode 100644 index 00000000..9fe8e27f --- /dev/null +++ b/packages/opendesign/src/anchor/__docs__/__case__/AnchorSlot.vue @@ -0,0 +1,33 @@ + + + +### 自定义标题 + +使用 `title` 插槽自定义标题内容 + + + +### Custom Title + +Use the `title` slot to customize the title content + + + + \ No newline at end of file diff --git a/packages/opendesign/src/anchor/__docs__/__case__/AnchorUsage.vue b/packages/opendesign/src/anchor/__docs__/__case__/AnchorUsage.vue new file mode 100644 index 00000000..b6ee355c --- /dev/null +++ b/packages/opendesign/src/anchor/__docs__/__case__/AnchorUsage.vue @@ -0,0 +1,113 @@ + + + +### 使用 + +1. `container` 属性 + + - 说明:指定锚点监听的滚动容器(默认值:window) + - 用法:组件会在该容器上监听 `scroll` 事件,以判断当前激活的锚点 + - 示例:`container="#wrap"` 表示监听 id 为 wrap 的容器滚动事件 + +2. `targetOffset` 属性 + + - 说明:目标元素跳转或激活时距离容器顶部的偏移量(默认值:0) + - 示例:`:target-offset="10"` 表示点击锚点时目标元素会滚动到距离容器顶部 10px 的位置;滚动距离小于 10px 时锚点处于激活状态 + +3. `bounds` 属性 + + - 说明:设置锚点激活的判定边界(默认值:5) + - 用法:当需要跳转位置和激活判定边界不一致时可设置 + - 示例:`:bounds="100" :target-offset="10"` 表示目标元素滚动到距离容器顶部 110px 时锚点激活。可实现点击锚点时目标元素滚动到顶部,滚动浏览时需到容器中上部才激活锚点的交互效果 + +4. `changeHash` 属性 + - 说明:是否在点击锚点时改变浏览器地址栏的 hash 值(默认值:true) + - 用法:如果需要手动控制 URL 跳转,可以设置为 false,并在 `click` 事件中处理跳转逻辑 + - 示例:`:change-hash="false"` 表示点击锚点时不会改变浏览器地址栏的 hash 值 + +5. 锚点嵌套:`OAnchorItem` 可以嵌套使用,形成多级锚点结构 + + + +### Usage + +1. `container` property + + - Description: Specifies the scroll container to be monitored by the anchor (default: window) + - Usage: The component listens for the `scroll` event on this container to determine the currently active anchor + - Example: `container="#wrap"` means listening to the scroll event of the container with id "wrap" + +2. `targetOffset` property + + - Description: The offset from the top of the container when the target element is scrolled or activated (default: 0) + - Example: `:target-offset="10"` means when clicking the anchor, the target element will scroll to 10px from the top of the container; when the scroll distance is less than 10px, the anchor is considered active + +3. `bounds` property + + - Description: Sets the boundary for anchor activation (default: 5) + - Usage: Use when the scroll position and activation boundary need to be different + - Example: `:bounds="100" :target-offset="10"` means the anchor is activated when the target element is 110px from the top of the container. This allows the target element to scroll to the top when clicking the anchor, but requires scrolling further down to activate + +4. `changeHash` property + - Description: Whether to change the browser's address bar hash value when clicking the anchor (default: true) + - Usage: If you need to manually control URL navigation, set this to false and handle the navigation logic in the `click` event + - Example: `:change-hash="false"` means clicking the anchor will not change the hash value in the browser's address bar + +5. Nested anchors: `OAnchorItem` can be nested to create multi-level anchor structures + + + + + + + diff --git a/packages/opendesign/src/anchor/__docs__/index.en-US.md b/packages/opendesign/src/anchor/__docs__/index.en-US.md new file mode 100644 index 00000000..bc63152a --- /dev/null +++ b/packages/opendesign/src/anchor/__docs__/index.en-US.md @@ -0,0 +1,10 @@ +--- +sidebar: OAnchor +--- + +# Anchor + +## Demo + + + diff --git a/packages/opendesign/src/anchor/__docs__/index.zh-CN.md b/packages/opendesign/src/anchor/__docs__/index.zh-CN.md new file mode 100644 index 00000000..2527fe44 --- /dev/null +++ b/packages/opendesign/src/anchor/__docs__/index.zh-CN.md @@ -0,0 +1,10 @@ +--- +sidebar: OAnchor 锚点 +--- + +# 锚点 + +## 示例 + + + diff --git a/packages/opendesign/src/anchor/types.ts b/packages/opendesign/src/anchor/types.ts index bc9d688c..6e5a847a 100644 --- a/packages/opendesign/src/anchor/types.ts +++ b/packages/opendesign/src/anchor/types.ts @@ -1,38 +1,70 @@ import type { ExtractPropTypes, PropType } from 'vue'; export const anchorProps = { + /** + * @zh-CN 监测容器 + * @en-US Scroll container to monitor + * @default window + */ container: { type: [String, Object] as PropType, }, + /** + * @zh-CN 锚点激活的边界范围 + * @en-US Boundary for anchor activation + * @default 5 + */ bounds: { type: Number, default: 5, }, + /** + * @zh-CN 锚点激活的判定边界 + * @en-US Boundary for anchor activation + * @default 0 + */ targetOffset: { type: Number, default: 0, }, + /** + * @zh-CN 点击锚点时是否改变浏览器地址栏的 hash 值 + * @en-US Whether to change the browser's address bar hash value when clicking the anchor + * @default true + */ changeHash: { type: Boolean, default: true, }, -}; +} as const; export const anchorItemProps = { + /** + * @zh-CN 锚点标题 + * @en-US Anchor title + */ title: { type: String, default: '', }, + /** + * @zh-CN 锚点跳转的目标元素(带#前缀) + * @en-US Target element for anchor navigation (with # prefix) + */ href: { type: String, - default: '', required: true, }, + /** + * @zh-CN 锚点跳转方式 + * @en-US Anchor navigation method + * @default '_self' + */ target: { type: String as PropType<'_blank' | '_parent' | '_self' | '_top'>, default: '_self', }, -}; +} as const; export type AnchorContainerT = HTMLElement | Window; diff --git a/packages/opendesign/src/button/__docs__/__case__/BtnIconSize.vue b/packages/opendesign/src/button/__docs__/__case__/BtnIconSize.vue index af8ad13c..5d163df1 100644 --- a/packages/opendesign/src/button/__docs__/__case__/BtnIconSize.vue +++ b/packages/opendesign/src/button/__docs__/__case__/BtnIconSize.vue @@ -1,41 +1,27 @@ -### icon插槽及按钮大小 +### 插槽及大小 -可以通过`icon`插槽设置按钮图标,通过`size`属性设置按钮大小。 +可以通过`icon`插槽设置按钮左侧内容,通过`suffix`插槽设置按钮右侧内容,通过`size`属性设置按钮大小。 -### Icon Slot and Button Size +### Slots -The button icon can be set using the `icon` slot, and the button size can be adjusted via the `size` prop. +The button icon can be set using the `icon` slot, and the button suffix can be set using the `suffix` slot, and the button size can be set using the `size` property.