From abb9dd098153df7ed1cc666cc0efae99bedccdfa Mon Sep 17 00:00:00 2001 From: xiaosansiji Date: Wed, 2 Aug 2023 16:51:07 +0800 Subject: [PATCH 1/4] feat: add download API to Link --- src/link/_example/download.vue | 6 ++++++ src/link/link.en-US.md | 7 ++++--- src/link/link.md | 1 + src/link/link.tsx | 1 + src/link/props.ts | 4 ++++ src/link/type.ts | 4 ++++ 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/link/_example/download.vue diff --git a/src/link/_example/download.vue b/src/link/_example/download.vue new file mode 100644 index 000000000..c568acbd2 --- /dev/null +++ b/src/link/_example/download.vue @@ -0,0 +1,6 @@ + diff --git a/src/link/link.en-US.md b/src/link/link.en-US.md index 28fd15f48..8f03c5ed3 100644 --- a/src/link/link.en-US.md +++ b/src/link/link.en-US.md @@ -8,13 +8,14 @@ name | type | default | description | required content | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N default | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N disabled | Boolean | - | make link to be disabled | N -hover | String | underline | hover link style。options:color/underline | N +download | String / Boolean | - | Causes the browser to treat the linked URL as a download | N +hover | String | underline | hover link style。options: color/underline | N href | String | - | \- | N prefixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N -size | String | medium | options:small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +size | String | medium | options: small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N suffixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N target | String | - | target is an attribute of `` | N -theme | String | default | options:default/primary/danger/warning/success | N +theme | String | default | options: default/primary/danger/warning/success | N underline | Boolean | - | \- | N onClick | Function | | Typescript:`(e: MouseEvent) => void`
click event, it won't trigger when it's disabled | N diff --git a/src/link/link.md b/src/link/link.md index a8f2ccee5..5a86b6a59 100644 --- a/src/link/link.md +++ b/src/link/link.md @@ -8,6 +8,7 @@ content | String / Slot / Function | - | 链接内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N default | String / Slot / Function | - | 链接内容,同 content。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N disabled | Boolean | - | 禁用链接 | N +download | String / Boolean | - | 使得浏览器将链接的 URL 视为可下载资源 | N hover | String | underline | 链接悬浮态样式,有 文本颜色变化、添加下划线等 2 种方法。可选项:color/underline | N href | String | - | 跳转链接 | N prefixIcon | Slot / Function | - | 前置图标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N diff --git a/src/link/link.tsx b/src/link/link.tsx index baf27da6f..05a10063d 100644 --- a/src/link/link.tsx +++ b/src/link/link.tsx @@ -36,6 +36,7 @@ export default mixins(classPrefixMixins).extend({ class={linkClass} href={this.disabled || !this.href ? undefined : this.href} target={this.target} + download={this.download} onClick={this.handleClick} > {prefixContent && {prefixContent}} diff --git a/src/link/props.ts b/src/link/props.ts index 43a182d94..853987c15 100644 --- a/src/link/props.ts +++ b/src/link/props.ts @@ -18,6 +18,10 @@ export default { }, /** 禁用链接 */ disabled: Boolean, + /** 使得浏览器将链接的 URL 视为可下载资源 */ + download: { + type: [String, Boolean] as PropType, + }, /** 链接悬浮态样式,有 文本颜色变化、添加下划线等 2 种方法 */ hover: { type: String as PropType, diff --git a/src/link/type.ts b/src/link/type.ts index 7748826f1..64bfe6161 100644 --- a/src/link/type.ts +++ b/src/link/type.ts @@ -19,6 +19,10 @@ export interface TdLinkProps { * 禁用链接 */ disabled?: boolean; + /** + * 使得浏览器将链接的 URL 视为可下载资源 + */ + download?: string | boolean; /** * 链接悬浮态样式,有 文本颜色变化、添加下划线等 2 种方法 * @default underline From 9a616bd9141c0d8f4ff891da6831559085522d2e Mon Sep 17 00:00:00 2001 From: xiaosansiji Date: Tue, 8 Aug 2023 11:06:58 +0800 Subject: [PATCH 2/4] feat: update common --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index 772d0a363..9460f2d7c 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 772d0a36386f57d2e98e373f142f5e4e75e44ac1 +Subproject commit 9460f2d7c439755e08445609f91109e2d7e0b444 From 394173b08d247adf59df763912249471125254ea Mon Sep 17 00:00:00 2001 From: xiaosansiji Date: Tue, 8 Aug 2023 11:07:15 +0800 Subject: [PATCH 3/4] test: update snapshot --- test/snap/__snapshots__/csr.test.js.snap | 32 ++++++++++++++++++++++++ test/snap/__snapshots__/ssr.test.js.snap | 2 ++ 2 files changed, 34 insertions(+) diff --git a/test/snap/__snapshots__/csr.test.js.snap b/test/snap/__snapshots__/csr.test.js.snap index ddb86c021..7fee595b5 100644 --- a/test/snap/__snapshots__/csr.test.js.snap +++ b/test/snap/__snapshots__/csr.test.js.snap @@ -65311,6 +65311,38 @@ exports[`csr snapshot test > csr test ./src/link/_example/disabled.vue 1`] = ` `; +exports[`csr snapshot test > csr test ./src/link/_example/download.vue 1`] = ` +
+ + +
+`; + exports[`csr snapshot test > csr test ./src/link/_example/hover.vue 1`] = `
renders ./src/link/_example/base.vue correctly 1`] exports[`ssr snapshot test > renders ./src/link/_example/disabled.vue correctly 1`] = `""`; +exports[`ssr snapshot test > renders ./src/link/_example/download.vue correctly 1`] = `""`; + exports[`ssr snapshot test > renders ./src/link/_example/hover.vue correctly 1`] = `""`; exports[`ssr snapshot test > renders ./src/link/_example/icon.vue correctly 1`] = `""`; From 1e3437b70199dcf4e36665bd8c27fc6ab935b5c5 Mon Sep 17 00:00:00 2001 From: xiaosansiji Date: Wed, 9 Aug 2023 16:33:12 +0800 Subject: [PATCH 4/4] feat: update common --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index 9460f2d7c..05f588ae6 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 9460f2d7c439755e08445609f91109e2d7e0b444 +Subproject commit 05f588ae6c1d71255320a7d7f6ff61b7cd14318c