diff --git a/src/config.json b/src/config.json index c609554457..5faf8cc504 100644 --- a/src/config.json +++ b/src/config.json @@ -791,6 +791,7 @@ "cType": "展示组件", "cName": "水印", "desc": "页面上添加特定的文字或图案。适用于防止信息盗用。", + "setup": true, "author": "liukun" }, { diff --git a/src/packages/__VUE/watermark/__tests__/__snapshots__/watermark.spec.tsx.snap b/src/packages/__VUE/watermark/__tests__/__snapshots__/watermark.spec.tsx.snap deleted file mode 100644 index 7ab27ba8e8..0000000000 --- a/src/packages/__VUE/watermark/__tests__/__snapshots__/watermark.spec.tsx.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`should render watermark 1`] = ` -" - -" -`; diff --git a/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx b/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx index 7c1a56bdcb..548ce1b67b 100644 --- a/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx +++ b/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx @@ -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 }) @@ -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 ( - - - - ) + return }) - 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 + }) + expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(1) }) diff --git a/src/packages/__VUE/watermark/doc.en-US.md b/src/packages/__VUE/watermark/doc.en-US.md index 343d292828..bc4f4c9fd0 100644 --- a/src/packages/__VUE/watermark/doc.en-US.md +++ b/src/packages/__VUE/watermark/doc.en-US.md @@ -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 diff --git a/src/packages/__VUE/watermark/doc.md b/src/packages/__VUE/watermark/doc.md index 4f0d56d87e..8d671abe56 100644 --- a/src/packages/__VUE/watermark/doc.md +++ b/src/packages/__VUE/watermark/doc.md @@ -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' +``` ## 主题定制 diff --git a/src/packages/__VUE/watermark/doc.taro.md b/src/packages/__VUE/watermark/doc.taro.md index b66091395d..3bca2ea6ec 100644 --- a/src/packages/__VUE/watermark/doc.taro.md +++ b/src/packages/__VUE/watermark/doc.taro.md @@ -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' +``` ## 主题定制 diff --git a/src/packages/__VUE/watermark/index.taro.ts b/src/packages/__VUE/watermark/index.taro.ts new file mode 100644 index 0000000000..b8f3a51173 --- /dev/null +++ b/src/packages/__VUE/watermark/index.taro.ts @@ -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 + +export { Watermark, Watermark as default } diff --git a/src/packages/__VUE/watermark/index.taro.vue b/src/packages/__VUE/watermark/index.taro.vue deleted file mode 100644 index fb4d1c1e2b..0000000000 --- a/src/packages/__VUE/watermark/index.taro.vue +++ /dev/null @@ -1,254 +0,0 @@ - - diff --git a/src/packages/__VUE/watermark/index.ts b/src/packages/__VUE/watermark/index.ts new file mode 100644 index 0000000000..d335738eaf --- /dev/null +++ b/src/packages/__VUE/watermark/index.ts @@ -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 + +export { Watermark, Watermark as default } diff --git a/src/packages/__VUE/watermark/index.vue b/src/packages/__VUE/watermark/index.vue deleted file mode 100644 index 8e99fc0315..0000000000 --- a/src/packages/__VUE/watermark/index.vue +++ /dev/null @@ -1,200 +0,0 @@ - - diff --git a/src/packages/__VUE/watermark/watermark.taro.vue b/src/packages/__VUE/watermark/watermark.taro.vue new file mode 100644 index 0000000000..fad825b6f1 --- /dev/null +++ b/src/packages/__VUE/watermark/watermark.taro.vue @@ -0,0 +1,175 @@ + + diff --git a/src/packages/__VUE/watermark/watermark.vue b/src/packages/__VUE/watermark/watermark.vue new file mode 100644 index 0000000000..f91fb2378e --- /dev/null +++ b/src/packages/__VUE/watermark/watermark.vue @@ -0,0 +1,122 @@ + +