Skip to content

Commit

Permalink
refactor(watermark): move to script setup (jd-opensource#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored May 10, 2024
1 parent d83f94c commit 2f1b7ba
Show file tree
Hide file tree
Showing 12 changed files with 373 additions and 473 deletions.
1 change: 1 addition & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@
"cType": "展示组件",
"cName": "水印",
"desc": "页面上添加特定的文字或图案。适用于防止信息盗用。",
"setup": true,
"author": "liukun"
},
{
Expand Down

This file was deleted.

22 changes: 13 additions & 9 deletions src/packages/__VUE/watermark/__tests__/watermark.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mount } from '@vue/test-utils'
import { Watermark, Cell } from '@nutui/nutui'
import { Watermark } from '@nutui/nutui'
import { nextTick } from 'vue'
import 'vitest-canvas-mock'

test('render fullPage props ', async () => {
test('WaterMark: fullPage = true', async () => {
const wrapper = mount(() => {
return <Watermark font-color="#fa2c19" content="nut-ui"></Watermark>
})
Expand All @@ -13,13 +13,17 @@ test('render fullPage props ', async () => {
expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(1)
})

test('should render watermark', () => {
test('WaterMark: fullPage = false, content string[]', () => {
const wrapper = mount(() => {
return (
<Cell>
<Watermark fullPage={false} fontColor="#fa2c19" content="nut-ui"></Watermark>
</Cell>
)
return <Watermark fullPage={false} fontColor="#fa2c19" content={['nut1', 'nut2']}></Watermark>
})
expect(wrapper.html()).toMatchSnapshot()
expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(0)
})

test('WaterMark: image', () => {
const url = 'img10.360buyimg.com/ling/jfs/t1/181258/24/10385/53029/60d04978Ef21f2d42/92baeb21f907cd24.jpg'
const wrapper = mount(() => {
return <Watermark image={url}></Watermark>
})
expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(1)
})
13 changes: 12 additions & 1 deletion src/packages/__VUE/watermark/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ The content attribute is passed into a string array, showing a multi-line waterm
| gap-x | Horizontal spacing between watermarks | number | `24` |
| gap-y | Vertical spacing between watermarks | number | `48` |
| full-page | Overwrite entire page | boolean | `true` |
| font-family | Watermark text font family | boolean | `true` |
| font-family | Watermark text font family | string | `PingFang SC` |

### Types version

The component exports the following type definitions:

```js
import type {
WatermarkProps,
WatermarkInstance
} from '@nutui/nutui'
```

## Theming

Expand Down
13 changes: 12 additions & 1 deletion src/packages/__VUE/watermark/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ app.use(Watermark)
| gap-x | 水印之间的水平间距 | number | `24` |
| gap-y | 水印之间的垂直间距 | number | `48` |
| full-page | 是否覆盖整个页面 | boolean | `true` |
| font-family | 水印文字字体 | boolean | `true` |
| font-family | 水印文字字体 | string | `PingFang SC` |

### 类型定义 version

组件导出以下类型定义:

```js
import type {
WatermarkProps,
WatermarkInstance
} from '@nutui/nutui'
```

## 主题定制

Expand Down
13 changes: 12 additions & 1 deletion src/packages/__VUE/watermark/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ app.use(Watermark)
| gap-x | 水印之间的水平间距 | number | `24` |
| gap-y | 水印之间的垂直间距 | number | `48` |
| full-page | 是否覆盖整个页面 | boolean | `true` |
| font-family | 水印文字字体 | boolean | `true` |
| font-family | 水印文字字体 | string | `PingFang SC` |

### 类型定义 version

组件导出以下类型定义:

```js
import type {
WatermarkProps,
WatermarkInstance
} from '@nutui/nutui-taro'
```

## 主题定制

Expand Down
13 changes: 13 additions & 0 deletions src/packages/__VUE/watermark/index.taro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Watermark from './watermark.taro.vue'
import type { ComponentPublicInstance } from 'vue'
import { withInstall } from '@/packages/utils'

withInstall(Watermark)

export type { WatermarkProps } from './watermark.taro.vue'

export type { } from './types'

export type WatermarkInstance = ComponentPublicInstance & InstanceType<typeof Watermark>

export { Watermark, Watermark as default }
254 changes: 0 additions & 254 deletions src/packages/__VUE/watermark/index.taro.vue

This file was deleted.

13 changes: 13 additions & 0 deletions src/packages/__VUE/watermark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Watermark from './watermark.vue'
import type { ComponentPublicInstance } from 'vue'
import { withInstall } from '@/packages/utils'

withInstall(Watermark)

export type { WatermarkProps } from './watermark.vue'

export type { } from './types'

export type WatermarkInstance = ComponentPublicInstance & InstanceType<typeof Watermark>

export { Watermark, Watermark as default }
Loading

0 comments on commit 2f1b7ba

Please sign in to comment.