Skip to content

Commit

Permalink
feat: add download API to Link
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaosansiji committed Aug 2, 2023
1 parent 1d79795 commit abb9dd0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/link/_example/download.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<t-space>
<t-link theme="primary" download href="/starter/assets/vue.ee956b80.svg">跳转链接</t-link>
<t-link theme="primary" download="test/download-file.png" href="/starter/assets/vue.ee956b80.svg">跳转链接</t-link>
</t-space>
</template>
7 changes: 4 additions & 3 deletions src/link/link.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | optionssmall/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 `<a>` | N
theme | String | default | optionsdefault/primary/danger/warning/success | N
theme | String | default | options: default/primary/danger/warning/success | N
underline | Boolean | - | \- | N
onClick | Function | | Typescript:`(e: MouseEvent) => void`<br/>click event, it won't trigger when it's disabled | N

Expand Down
1 change: 1 addition & 0 deletions src/link/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 && <span class={`${this.componentName}__prefix-icon`}>{prefixContent}</span>}
Expand Down
4 changes: 4 additions & 0 deletions src/link/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default {
},
/** 禁用链接 */
disabled: Boolean,
/** 使得浏览器将链接的 URL 视为可下载资源 */
download: {
type: [String, Boolean] as PropType<TdLinkProps['download']>,
},
/** 链接悬浮态样式,有 文本颜色变化、添加下划线等 2 种方法 */
hover: {
type: String as PropType<TdLinkProps['hover']>,
Expand Down
4 changes: 4 additions & 0 deletions src/link/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export interface TdLinkProps {
* 禁用链接
*/
disabled?: boolean;
/**
* 使得浏览器将链接的 URL 视为可下载资源
*/
download?: string | boolean;
/**
* 链接悬浮态样式,有 文本颜色变化、添加下划线等 2 种方法
* @default underline
Expand Down

0 comments on commit abb9dd0

Please sign in to comment.