ele-admin-plus 1.4.1-beta.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/es/core-components.d.ts +2 -0
  2. package/es/core-components.js +104 -100
  3. package/es/ele-app/plus.d.ts +9 -1
  4. package/es/ele-app/plusx.d.ts +26 -13
  5. package/es/ele-backtop/index.js +7 -1
  6. package/es/ele-basic-select/components/select-view.d.ts +53 -22
  7. package/es/ele-basic-select/components/select-view.js +57 -20
  8. package/es/ele-basic-select/index.d.ts +39 -19
  9. package/es/ele-basic-select/index.js +62 -13
  10. package/es/ele-basic-select/props.d.ts +33 -21
  11. package/es/ele-basic-select/props.js +33 -21
  12. package/es/ele-basic-select/style/index.js +2 -0
  13. package/es/ele-basic-select/types.d.ts +1 -1
  14. package/es/ele-config-provider/components/receiver-view.d.ts +2 -0
  15. package/es/ele-config-provider/components/receiver-view.js +74 -72
  16. package/es/ele-config-provider/receiver.d.ts +2 -2
  17. package/es/ele-config-provider/receiver.js +5 -1
  18. package/es/ele-config-provider/types.d.ts +10 -1
  19. package/es/ele-copyable/index.d.ts +2 -4
  20. package/es/ele-cron-builder/index.d.ts +24 -0
  21. package/es/ele-cron-builder/index.js +81 -0
  22. package/es/ele-cron-builder/props.d.ts +31 -0
  23. package/es/ele-cron-builder/props.js +24 -0
  24. package/es/ele-cron-builder/style/index.d.ts +1 -0
  25. package/es/ele-cron-builder/style/index.js +4 -0
  26. package/es/ele-cron-builder/style/index.scss +6 -0
  27. package/es/ele-cron-builder/types.d.ts +8 -0
  28. package/es/ele-cron-panel/components/cron-day.d.ts +25 -0
  29. package/es/ele-cron-panel/components/cron-day.js +232 -0
  30. package/es/ele-cron-panel/components/cron-hour.d.ts +25 -0
  31. package/es/ele-cron-panel/components/cron-hour.js +174 -0
  32. package/es/ele-cron-panel/components/cron-minute.d.ts +25 -0
  33. package/es/ele-cron-panel/components/cron-minute.js +174 -0
  34. package/es/ele-cron-panel/components/cron-month.d.ts +25 -0
  35. package/es/ele-cron-panel/components/cron-month.js +174 -0
  36. package/es/ele-cron-panel/components/cron-second.d.ts +25 -0
  37. package/es/ele-cron-panel/components/cron-second.js +174 -0
  38. package/es/ele-cron-panel/components/cron-week.d.ts +25 -0
  39. package/es/ele-cron-panel/components/cron-week.js +229 -0
  40. package/es/ele-cron-panel/components/cron-year.d.ts +25 -0
  41. package/es/ele-cron-panel/components/cron-year.js +186 -0
  42. package/es/ele-cron-panel/index.d.ts +14 -0
  43. package/es/ele-cron-panel/index.js +348 -0
  44. package/es/ele-cron-panel/props.d.ts +20 -0
  45. package/es/ele-cron-panel/props.js +14 -0
  46. package/es/ele-cron-panel/style/index.d.ts +1 -0
  47. package/es/ele-cron-panel/style/index.js +7 -0
  48. package/es/ele-cron-panel/style/index.scss +282 -0
  49. package/es/ele-cron-panel/types.d.ts +118 -0
  50. package/es/ele-cron-panel/util.d.ts +23 -0
  51. package/es/ele-cron-panel/util.js +542 -0
  52. package/es/ele-cropper/components/cropper-tools.d.ts +2 -2
  53. package/es/ele-cropper-modal/index.d.ts +2 -4
  54. package/es/ele-crud/index.d.ts +3 -3
  55. package/es/ele-drawer/index.d.ts +9 -0
  56. package/es/ele-drawer/index.js +5 -1
  57. package/es/ele-drawer/props.d.ts +5 -0
  58. package/es/ele-drawer/props.js +6 -1
  59. package/es/ele-drawer/style/index.scss +11 -0
  60. package/es/ele-file-list/index.d.ts +3 -3
  61. package/es/ele-icon-select/components/icon-grid.d.ts +8 -3
  62. package/es/ele-icon-select/components/icon-grid.js +20 -12
  63. package/es/ele-icon-select/index.d.ts +58 -59
  64. package/es/ele-icon-select/index.js +92 -86
  65. package/es/ele-icon-select/props.d.ts +35 -35
  66. package/es/ele-icon-select/props.js +34 -34
  67. package/es/ele-icon-select/style/css-var.scss +1 -1
  68. package/es/ele-icon-select/style/index.scss +50 -18
  69. package/es/ele-icon-select/types.d.ts +13 -0
  70. package/es/ele-map-picker/index.d.ts +3 -3
  71. package/es/ele-modal/index.d.ts +4 -2
  72. package/es/ele-modal/index.js +9 -3
  73. package/es/ele-modal/props.d.ts +2 -0
  74. package/es/ele-modal/props.js +2 -0
  75. package/es/ele-modal/style/index.scss +16 -0
  76. package/es/ele-pro-form/components/item-type-data.js +39 -64
  77. package/es/ele-pro-form/index.d.ts +3 -3
  78. package/es/ele-pro-table/components/table-tools.d.ts +12 -97
  79. package/es/ele-pro-table/components/table-tools.js +118 -248
  80. package/es/ele-pro-table/components/tool-export.d.ts +5 -1
  81. package/es/ele-pro-table/components/tool-export.js +32 -20
  82. package/es/ele-pro-table/components/tool-print.d.ts +5 -1
  83. package/es/ele-pro-table/components/tool-print.js +37 -25
  84. package/es/ele-pro-table/exceljs-plugin.d.ts +12 -0
  85. package/es/ele-pro-table/exceljs-plugin.js +81 -0
  86. package/es/ele-pro-table/index.d.ts +6 -7
  87. package/es/ele-pro-table/index.js +117 -46
  88. package/es/ele-pro-table/types.d.ts +11 -0
  89. package/es/ele-split-panel/style/index.scss +1 -1
  90. package/es/ele-table-select/index.d.ts +2 -0
  91. package/es/ele-table-select/props.d.ts +2 -0
  92. package/es/ele-table-select/props.js +3 -1
  93. package/es/ele-tour/index.d.ts +3 -3
  94. package/es/ele-tree-select/index.d.ts +2 -0
  95. package/es/ele-upload-list/index.d.ts +3 -3
  96. package/es/ele-upload-list/index.js +25 -8
  97. package/es/ele-virtual-table/components/body-cell.d.ts +1 -1
  98. package/es/ele-watermark/index.d.ts +20 -7
  99. package/es/ele-watermark/index.js +253 -94
  100. package/es/ele-watermark/props.d.ts +10 -3
  101. package/es/ele-watermark/props.js +10 -3
  102. package/es/ele-watermark/types.d.ts +12 -0
  103. package/es/ele-watermark/util.d.ts +2 -9
  104. package/es/ele-watermark/util.js +10 -19
  105. package/es/lang/en_US.js +116 -0
  106. package/es/lang/zh_CN.js +116 -0
  107. package/es/lang/zh_TW.js +116 -0
  108. package/es/style/plus.scss +3 -1
  109. package/es/style/themes/default.scss +12 -3
  110. package/es/style/themes/rounded.scss +2 -1
  111. package/es/utils/theme-util.d.ts +1 -1
  112. package/lib/core-components.cjs +104 -100
  113. package/lib/core-components.d.ts +2 -0
  114. package/lib/ele-app/plus.d.ts +9 -1
  115. package/lib/ele-app/plusx.d.ts +26 -13
  116. package/lib/ele-backtop/index.cjs +6 -0
  117. package/lib/ele-basic-select/components/select-view.cjs +56 -19
  118. package/lib/ele-basic-select/components/select-view.d.ts +53 -22
  119. package/lib/ele-basic-select/index.cjs +61 -12
  120. package/lib/ele-basic-select/index.d.ts +39 -19
  121. package/lib/ele-basic-select/props.cjs +33 -21
  122. package/lib/ele-basic-select/props.d.ts +33 -21
  123. package/lib/ele-basic-select/style/index.cjs +2 -0
  124. package/lib/ele-basic-select/types.d.ts +1 -1
  125. package/lib/ele-config-provider/components/receiver-view.cjs +2 -2
  126. package/lib/ele-config-provider/components/receiver-view.d.ts +2 -0
  127. package/lib/ele-config-provider/receiver.cjs +5 -1
  128. package/lib/ele-config-provider/receiver.d.ts +2 -2
  129. package/lib/ele-config-provider/types.d.ts +10 -1
  130. package/lib/ele-copyable/index.d.ts +2 -4
  131. package/lib/ele-cron-builder/index.cjs +80 -0
  132. package/lib/ele-cron-builder/index.d.ts +24 -0
  133. package/lib/ele-cron-builder/props.cjs +24 -0
  134. package/lib/ele-cron-builder/props.d.ts +31 -0
  135. package/lib/ele-cron-builder/style/index.cjs +5 -0
  136. package/lib/ele-cron-builder/style/index.d.ts +1 -0
  137. package/lib/ele-cron-builder/style/index.scss +6 -0
  138. package/lib/ele-cron-builder/types.d.ts +8 -0
  139. package/lib/ele-cron-panel/components/cron-day.cjs +231 -0
  140. package/lib/ele-cron-panel/components/cron-day.d.ts +25 -0
  141. package/lib/ele-cron-panel/components/cron-hour.cjs +173 -0
  142. package/lib/ele-cron-panel/components/cron-hour.d.ts +25 -0
  143. package/lib/ele-cron-panel/components/cron-minute.cjs +173 -0
  144. package/lib/ele-cron-panel/components/cron-minute.d.ts +25 -0
  145. package/lib/ele-cron-panel/components/cron-month.cjs +173 -0
  146. package/lib/ele-cron-panel/components/cron-month.d.ts +25 -0
  147. package/lib/ele-cron-panel/components/cron-second.cjs +173 -0
  148. package/lib/ele-cron-panel/components/cron-second.d.ts +25 -0
  149. package/lib/ele-cron-panel/components/cron-week.cjs +228 -0
  150. package/lib/ele-cron-panel/components/cron-week.d.ts +25 -0
  151. package/lib/ele-cron-panel/components/cron-year.cjs +185 -0
  152. package/lib/ele-cron-panel/components/cron-year.d.ts +25 -0
  153. package/lib/ele-cron-panel/index.cjs +347 -0
  154. package/lib/ele-cron-panel/index.d.ts +14 -0
  155. package/lib/ele-cron-panel/props.cjs +14 -0
  156. package/lib/ele-cron-panel/props.d.ts +20 -0
  157. package/lib/ele-cron-panel/style/index.cjs +8 -0
  158. package/lib/ele-cron-panel/style/index.d.ts +1 -0
  159. package/lib/ele-cron-panel/style/index.scss +282 -0
  160. package/lib/ele-cron-panel/types.d.ts +118 -0
  161. package/lib/ele-cron-panel/util.cjs +542 -0
  162. package/lib/ele-cron-panel/util.d.ts +23 -0
  163. package/lib/ele-cropper/components/cropper-tools.d.ts +2 -2
  164. package/lib/ele-cropper-modal/index.d.ts +2 -4
  165. package/lib/ele-crud/index.d.ts +3 -3
  166. package/lib/ele-drawer/index.cjs +4 -0
  167. package/lib/ele-drawer/index.d.ts +9 -0
  168. package/lib/ele-drawer/props.cjs +6 -1
  169. package/lib/ele-drawer/props.d.ts +5 -0
  170. package/lib/ele-drawer/style/index.scss +11 -0
  171. package/lib/ele-file-list/index.d.ts +3 -3
  172. package/lib/ele-icon-select/components/icon-grid.cjs +19 -11
  173. package/lib/ele-icon-select/components/icon-grid.d.ts +8 -3
  174. package/lib/ele-icon-select/index.cjs +91 -85
  175. package/lib/ele-icon-select/index.d.ts +58 -59
  176. package/lib/ele-icon-select/props.cjs +34 -34
  177. package/lib/ele-icon-select/props.d.ts +35 -35
  178. package/lib/ele-icon-select/style/css-var.scss +1 -1
  179. package/lib/ele-icon-select/style/index.scss +50 -18
  180. package/lib/ele-icon-select/types.d.ts +13 -0
  181. package/lib/ele-map-picker/index.d.ts +3 -3
  182. package/lib/ele-modal/index.cjs +9 -3
  183. package/lib/ele-modal/index.d.ts +4 -2
  184. package/lib/ele-modal/props.cjs +2 -0
  185. package/lib/ele-modal/props.d.ts +2 -0
  186. package/lib/ele-modal/style/index.scss +16 -0
  187. package/lib/ele-pro-form/components/item-type-data.cjs +39 -64
  188. package/lib/ele-pro-form/index.d.ts +3 -3
  189. package/lib/ele-pro-table/components/table-tools.cjs +117 -247
  190. package/lib/ele-pro-table/components/table-tools.d.ts +12 -97
  191. package/lib/ele-pro-table/components/tool-export.cjs +32 -20
  192. package/lib/ele-pro-table/components/tool-export.d.ts +5 -1
  193. package/lib/ele-pro-table/components/tool-print.cjs +37 -25
  194. package/lib/ele-pro-table/components/tool-print.d.ts +5 -1
  195. package/lib/ele-pro-table/exceljs-plugin.cjs +81 -0
  196. package/lib/ele-pro-table/exceljs-plugin.d.ts +12 -0
  197. package/lib/ele-pro-table/index.cjs +143 -72
  198. package/lib/ele-pro-table/index.d.ts +6 -7
  199. package/lib/ele-pro-table/types.d.ts +11 -0
  200. package/lib/ele-split-panel/style/index.scss +1 -1
  201. package/lib/ele-table-select/index.d.ts +2 -0
  202. package/lib/ele-table-select/props.cjs +3 -1
  203. package/lib/ele-table-select/props.d.ts +2 -0
  204. package/lib/ele-tour/index.d.ts +3 -3
  205. package/lib/ele-tree-select/index.d.ts +2 -0
  206. package/lib/ele-upload-list/index.cjs +25 -8
  207. package/lib/ele-upload-list/index.d.ts +3 -3
  208. package/lib/ele-virtual-table/components/body-cell.d.ts +1 -1
  209. package/lib/ele-watermark/index.cjs +251 -92
  210. package/lib/ele-watermark/index.d.ts +20 -7
  211. package/lib/ele-watermark/props.cjs +10 -3
  212. package/lib/ele-watermark/props.d.ts +10 -3
  213. package/lib/ele-watermark/types.d.ts +12 -0
  214. package/lib/ele-watermark/util.cjs +10 -19
  215. package/lib/ele-watermark/util.d.ts +2 -9
  216. package/lib/lang/en_US.cjs +116 -0
  217. package/lib/lang/zh_CN.cjs +116 -0
  218. package/lib/lang/zh_TW.cjs +116 -0
  219. package/lib/style/plus.scss +3 -1
  220. package/lib/style/themes/default.scss +12 -3
  221. package/lib/style/themes/rounded.scss +2 -1
  222. package/lib/utils/theme-util.d.ts +1 -1
  223. package/package.json +1 -1
  224. package/typings/global.d.ts +2 -0
@@ -1,4 +1,5 @@
1
1
  import { StyleValue } from '../ele-app/types';
2
+ import { WatermarkFont } from './types';
2
3
 
3
4
  declare function __VLS_template(): {
4
5
  default?(_: {}): any;
@@ -6,11 +7,14 @@ declare function __VLS_template(): {
6
7
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
7
8
  width: NumberConstructor;
8
9
  height: NumberConstructor;
9
- rotate: NumberConstructor;
10
+ rotate: {
11
+ type: NumberConstructor;
12
+ default: number;
13
+ };
10
14
  zIndex: NumberConstructor;
11
15
  image: StringConstructor;
12
16
  content: import('vue').PropType<string | string[]>;
13
- font: import('vue').PropType<import('./types').WatermarkFont>;
17
+ font: import('vue').PropType<WatermarkFont>;
14
18
  gap: import('vue').PropType<import('./types').WatermarkGap>;
15
19
  offset: import('vue').PropType<import('./types').WatermarkOffset>;
16
20
  lineGap: {
@@ -18,20 +22,25 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
18
22
  default: number;
19
23
  };
20
24
  customStyle: import('vue').PropType<Exclude<StyleValue, string>>;
25
+ svgRender: BooleanConstructor;
26
+ disabled: BooleanConstructor;
21
27
  fixed: BooleanConstructor;
22
28
  wrapPosition: {
23
29
  type: BooleanConstructor;
24
30
  default: boolean;
25
31
  };
26
- disabled: BooleanConstructor;
32
+ wrapHeight: StringConstructor;
27
33
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
28
34
  width: NumberConstructor;
29
35
  height: NumberConstructor;
30
- rotate: NumberConstructor;
36
+ rotate: {
37
+ type: NumberConstructor;
38
+ default: number;
39
+ };
31
40
  zIndex: NumberConstructor;
32
41
  image: StringConstructor;
33
42
  content: import('vue').PropType<string | string[]>;
34
- font: import('vue').PropType<import('./types').WatermarkFont>;
43
+ font: import('vue').PropType<WatermarkFont>;
35
44
  gap: import('vue').PropType<import('./types').WatermarkGap>;
36
45
  offset: import('vue').PropType<import('./types').WatermarkOffset>;
37
46
  lineGap: {
@@ -39,17 +48,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
39
48
  default: number;
40
49
  };
41
50
  customStyle: import('vue').PropType<Exclude<StyleValue, string>>;
51
+ svgRender: BooleanConstructor;
52
+ disabled: BooleanConstructor;
42
53
  fixed: BooleanConstructor;
43
54
  wrapPosition: {
44
55
  type: BooleanConstructor;
45
56
  default: boolean;
46
57
  };
47
- disabled: BooleanConstructor;
58
+ wrapHeight: StringConstructor;
48
59
  }>> & Readonly<{}>, {
49
60
  fixed: boolean;
61
+ rotate: number;
50
62
  lineGap: number;
51
- wrapPosition: boolean;
63
+ svgRender: boolean;
52
64
  disabled: boolean;
65
+ wrapPosition: boolean;
53
66
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
54
67
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
55
68
  export default _default;
@@ -1,6 +1,17 @@
1
- import { defineComponent, ref, nextTick, inject, computed, onMounted, watch, createElementBlock, openBlock, normalizeStyle, renderSlot, createCommentVNode } from "vue";
2
- import { useMutation, INFO_LOG_KEY, getFont, getPixelRatio, getGap, rotateWatermark, joinStyle } from "./util";
1
+ import { defineComponent, ref, nextTick, useId, computed, inject, watch, onMounted, createElementBlock, openBlock, normalizeStyle, renderSlot, createCommentVNode, Fragment, createElementVNode, unref, renderList, toDisplayString } from "vue";
2
+ import { useMutation, joinStyle, INFO_LOG_KEY, getPixelRatio, rotateWatermark } from "./util";
3
3
  import { watermarkProps } from "./props";
4
+ const _hoisted_1 = ["id", "width", "height"];
5
+ const _hoisted_2 = ["transform"];
6
+ const _hoisted_3 = ["href", "width", "height", "x", "y"];
7
+ const _hoisted_4 = ["transform"];
8
+ const _hoisted_5 = ["href", "width", "height", "x", "y"];
9
+ const _hoisted_6 = ["id", "width", "height"];
10
+ const _hoisted_7 = ["transform"];
11
+ const _hoisted_8 = ["x", "y", "fill", "font-size", "font-weight", "font-family", "font-style"];
12
+ const _hoisted_9 = ["transform"];
13
+ const _hoisted_10 = ["x", "y", "fill", "font-size", "font-weight", "font-family", "font-style"];
14
+ const _hoisted_11 = ["fill", "transform"];
4
15
  const SIZE = 2;
5
16
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
17
  ...{ name: "EleWatermark" },
@@ -8,7 +19,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
8
19
  props: watermarkProps,
9
20
  setup(__props) {
10
21
  const props = __props;
11
- const { observe, disconnect } = useMutation({
22
+ const { observe, observeTextNode, disconnect } = useMutation({
12
23
  getRoot: () => rootRef.value,
13
24
  getEl: () => imgRef.value,
14
25
  onDeleted: () => {
@@ -22,95 +33,121 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
33
  render();
23
34
  }
24
35
  });
36
+ const svgId = useId();
25
37
  const rootKey = ref(1);
26
38
  const rootRef = ref(null);
27
39
  const imgRef = ref(null);
28
- const imgStyle = ref({ display: "none" });
29
- const updateStyle = (base64, size) => {
40
+ const imgStyle = ref(joinStyle({ display: "none" }));
41
+ const markWidth = computed(() => {
42
+ return props.width ?? 120;
43
+ });
44
+ const markHeight = computed(() => {
45
+ return props.height ?? 64;
46
+ });
47
+ const markGapX = computed(() => {
48
+ var _a;
49
+ return ((_a = props.gap) == null ? void 0 : _a[0]) ?? 100;
50
+ });
51
+ const markGapY = computed(() => {
52
+ var _a;
53
+ return ((_a = props.gap) == null ? void 0 : _a[1]) ?? 100;
54
+ });
55
+ const markOffsetX = computed(() => {
56
+ var _a;
57
+ return ((_a = props.offset) == null ? void 0 : _a[0]) ?? markGapX.value / 2;
58
+ });
59
+ const markOffsetY = computed(() => {
60
+ var _a;
61
+ return ((_a = props.offset) == null ? void 0 : _a[1]) ?? markGapY.value / 2;
62
+ });
63
+ const markFont = computed(() => {
64
+ return {
65
+ color: "rgba(122, 122, 122, 0.35)",
66
+ fontSize: 16,
67
+ fontWeight: "normal",
68
+ fontFamily: "sans-serif",
69
+ fontStyle: "normal",
70
+ ...props.font || {}
71
+ };
72
+ });
73
+ const markContents = computed(() => {
74
+ if (typeof props.content === "string") {
75
+ return [props.content];
76
+ }
77
+ return props.content || [];
78
+ });
79
+ const markCommonStyle = computed(() => {
30
80
  const position = props.fixed ? "fixed" : "absolute";
31
81
  const width = props.fixed ? "100vw" : "100%";
32
82
  const height = props.fixed ? "100vh" : "100%";
33
- const style = {
83
+ return {
34
84
  position: `${position} !important`,
35
85
  top: "0 !important",
36
86
  left: "0 !important",
37
- right: "auto !important",
38
- bottom: "auto !important",
87
+ right: "0 !important",
88
+ bottom: "0 !important",
39
89
  width: `${width} !important`,
40
90
  height: `${height} !important`,
91
+ zIndex: `${props.zIndex ?? 2147483647} !important`,
41
92
  pointerEvents: "none !important",
42
- backgroundRepeat: "repeat !important",
43
- opacity: "1 !important",
44
- transform: "none !important",
45
- filter: "none !important",
46
- visibility: "visible !important",
47
- transition: "none !important",
48
- maxWidth: "none !important",
49
- maxHeight: "none !important",
50
- zoom: "1 !important",
51
- mask: "none !important",
52
- clipPath: "none !important",
53
- display: "block !important",
54
93
  ...props.customStyle || {}
55
94
  };
95
+ });
96
+ const infoLog = inject(INFO_LOG_KEY, void 0);
97
+ const svgStyle = computed(() => joinStyle(markCommonStyle.value));
98
+ const updateStyle = (base64, imgWidth, imgHeight) => {
99
+ disconnect();
100
+ const style = { ...markCommonStyle.value };
56
101
  if (!base64) {
57
102
  style.display = "none !important";
58
103
  } else {
59
104
  style.backgroundImage = `url('${base64}') !important`;
60
- if (size) {
61
- style.backgroundSize = `${size} !important`;
105
+ style.backgroundSize = `${imgWidth}px ${imgHeight}px !important`;
106
+ let positionLeft = markOffsetX.value - markGapX.value / 2;
107
+ let positionTop = markOffsetY.value - markGapY.value / 2;
108
+ if (positionLeft > 0) {
109
+ style.left = `${positionLeft}px !important`;
110
+ style.width = `calc(100% - ${positionLeft}px) !important`;
111
+ positionLeft = 0;
112
+ }
113
+ if (positionTop > 0) {
114
+ style.top = `${positionTop}px !important`;
115
+ style.height = `calc(100% - ${positionTop}px) !important`;
116
+ positionTop = 0;
62
117
  }
63
- style.zIndex = `${props.zIndex ?? 2147483647} !important`;
118
+ style.backgroundPosition = `${positionLeft}px ${positionTop}px !important`;
64
119
  }
65
- disconnect();
66
- if (imgRef.value && imgRef.value.style && imgRef.value.style.cssText) {
67
- imgRef.value.style.cssText = joinStyle(style);
120
+ imgStyle.value = joinStyle(style);
121
+ nextTick(() => {
68
122
  observe();
69
- } else {
70
- imgStyle.value = style;
71
- nextTick(() => {
72
- observe();
73
- });
74
- }
75
- };
76
- const infoLog = inject(INFO_LOG_KEY, void 0);
77
- const getDefaultWidth = (ctx) => {
78
- if (props.image || !ctx.measureText) {
79
- return 120;
80
- }
81
- const content = props.content;
82
- const contents = Array.isArray(content) ? content : [content];
83
- const widths = contents.map((item) => ctx.measureText(item).width);
84
- return Math.ceil(Math.max(...widths));
85
- };
86
- const getDefaultHeight = (ctx) => {
87
- if (props.image || !ctx.measureText) {
88
- return 64;
89
- }
90
- const lines = Array.isArray(props.content) ? props.content.length : 1;
91
- const { fontSize } = getFont(props.font);
92
- return fontSize * lines + (lines - 1) * props.lineGap;
123
+ });
93
124
  };
94
125
  const getMarkSize = (ctx) => {
95
- const width = props.width;
96
- const height = props.height;
97
- return [width ?? getDefaultWidth(ctx), height ?? getDefaultHeight(ctx)];
126
+ if (props.image || props.width != null && props.height != null || !ctx.measureText) {
127
+ return [markWidth.value, markHeight.value];
128
+ }
129
+ const widths = markContents.value.map(
130
+ (text) => ctx.measureText(text).width
131
+ );
132
+ const textWidth = Math.ceil(Math.max(...widths));
133
+ const lines = markContents.value.length;
134
+ const { fontSize } = markFont.value;
135
+ const textHeight = fontSize * lines + (lines - 1) * props.lineGap;
136
+ return [props.width ?? textWidth, props.height ?? textHeight];
98
137
  };
99
138
  const froined = computed(() => !!(infoLog && !infoLog.froined));
139
+ const isDisabled = computed(() => !(!props.disabled || froined.value));
100
140
  const fillTexts = (ctx, drawX, drawY, drawWidth, drawHeight) => {
101
141
  const ratio = getPixelRatio();
102
- const { color, fontSize, fontStyle, fontWeight, fontFamily } = getFont(
103
- props.font
104
- );
142
+ const { color, fontSize, fontStyle, fontWeight, fontFamily } = markFont.value;
105
143
  const mergedFontSize = fontSize * ratio;
106
- ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${drawHeight}px ${fontFamily}`;
107
144
  ctx.fillStyle = color;
145
+ ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${drawHeight}px ${fontFamily}`;
146
+ const froin = "el-n-d-s-p";
108
147
  ctx.textAlign = "center";
109
148
  ctx.textBaseline = "top";
110
149
  ctx.translate(drawWidth / 2, 0);
111
- const content = props.content;
112
- const froin = ["el", "nimda", "sulp"].reverse().join(" ").split("");
113
- const contents = froined.value ? [`e${froin.reduce((n, m) => m + n, "")}`.toUpperCase()] : Array.isArray(content) ? content : content == null ? [] : [content];
150
+ const contents = froined.value ? [`e${observeTextNode(froin)}`.toUpperCase()] : markContents.value;
114
151
  contents.forEach((item, index) => {
115
152
  ctx.fillText(
116
153
  item ?? "",
@@ -120,9 +157,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
120
157
  });
121
158
  };
122
159
  const render = () => {
123
- if (props.disabled && !froined.value) {
160
+ if (props.svgRender || isDisabled.value) {
124
161
  disconnect();
125
- imgStyle.value = { display: "none" };
162
+ imgStyle.value = joinStyle({ display: "none" });
126
163
  return;
127
164
  }
128
165
  const canvas = document.createElement("canvas");
@@ -130,20 +167,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
130
167
  if (!ctx) {
131
168
  return;
132
169
  }
133
- const rotate = props.rotate ?? -22;
170
+ const rotate = props.rotate;
171
+ const gapX = markGapX.value;
172
+ const gapY = markGapY.value;
134
173
  if (!props.image && ctx.measureText != null) {
135
- const { fontSize, fontFamily } = getFont(props.font);
174
+ const { fontSize, fontFamily } = markFont.value;
136
175
  ctx.font = `${fontSize}px ${fontFamily}`;
137
176
  }
138
- const [markWidth, markHeight] = getMarkSize(ctx);
177
+ const [markWidth2, markHeight2] = getMarkSize(ctx);
139
178
  const ratio = getPixelRatio();
140
- const [gapX, gapY] = getGap(props.gap);
141
- const canvasWidth = (gapX + markWidth) * ratio;
142
- const canvasHeight = (gapY + markHeight) * ratio;
179
+ const canvasWidth = (gapX + markWidth2) * ratio;
180
+ const canvasHeight = (gapY + markHeight2) * ratio;
143
181
  canvas.setAttribute("width", `${canvasWidth * SIZE}px`);
144
182
  canvas.setAttribute("height", `${canvasHeight * SIZE}px`);
145
- const drawWidth = markWidth * ratio;
146
- const drawHeight = markHeight * ratio;
183
+ const drawWidth = markWidth2 * ratio;
184
+ const drawHeight = markHeight2 * ratio;
147
185
  const rotateX = (drawWidth + gapX * ratio) / 2;
148
186
  const rotateY = (drawHeight + gapY * ratio) / 2;
149
187
  ctx.save();
@@ -158,52 +196,173 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
158
196
  const img = new Image();
159
197
  img.onload = () => {
160
198
  ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
161
- ctx.restore();
162
- rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
163
- ctx.drawImage(
164
- img,
165
- alternateDrawX,
166
- alternateDrawY,
167
- drawWidth,
168
- drawHeight
199
+ {
200
+ ctx.restore();
201
+ rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
202
+ ctx.drawImage(
203
+ img,
204
+ alternateDrawX,
205
+ alternateDrawY,
206
+ drawWidth,
207
+ drawHeight
208
+ );
209
+ }
210
+ updateStyle(
211
+ canvas.toDataURL(),
212
+ (gapX + markWidth2) * SIZE,
213
+ (gapY + markHeight2) * SIZE
169
214
  );
170
- updateStyle(canvas.toDataURL(), `${(gapX + markWidth) * SIZE}px`);
171
215
  };
172
216
  img.crossOrigin = "anonymous";
173
217
  img.referrerPolicy = "no-referrer";
174
218
  img.src = props.image;
175
219
  } else {
176
220
  fillTexts(ctx, drawX, drawY, drawWidth, drawHeight);
177
- ctx.restore();
178
- rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
179
- fillTexts(ctx, alternateDrawX, alternateDrawY, drawWidth, drawHeight);
180
- updateStyle(canvas.toDataURL(), `${(gapX + markWidth) * SIZE}px`);
221
+ {
222
+ ctx.restore();
223
+ rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
224
+ fillTexts(ctx, alternateDrawX, alternateDrawY, drawWidth, drawHeight);
225
+ }
226
+ updateStyle(
227
+ canvas.toDataURL(),
228
+ (gapX + markWidth2) * SIZE,
229
+ (gapY + markHeight2) * SIZE
230
+ );
181
231
  }
182
232
  };
183
- onMounted(() => {
184
- render();
185
- });
186
233
  watch(
187
- [() => props, froined],
234
+ [
235
+ () => props.rotate,
236
+ () => props.image,
237
+ () => props.lineGap,
238
+ () => props.svgRender,
239
+ markWidth,
240
+ markHeight,
241
+ markGapX,
242
+ markGapY,
243
+ markOffsetX,
244
+ markOffsetY,
245
+ markFont,
246
+ markContents,
247
+ markCommonStyle,
248
+ isDisabled
249
+ ],
188
250
  () => {
189
251
  render();
190
252
  },
191
253
  { deep: true }
192
254
  );
255
+ onMounted(() => {
256
+ render();
257
+ });
193
258
  return (_ctx, _cache) => {
194
259
  return openBlock(), createElementBlock("div", {
195
260
  ref_key: "rootRef",
196
261
  ref: rootRef,
197
262
  key: rootKey.value,
198
- style: normalizeStyle(!_ctx.wrapPosition || _ctx.fixed ? void 0 : { position: "relative" })
263
+ style: normalizeStyle([
264
+ props.wrapHeight == null ? {} : { height: props.wrapHeight },
265
+ !_ctx.wrapPosition || _ctx.fixed ? {} : { position: "relative" }
266
+ ])
199
267
  }, [
200
268
  renderSlot(_ctx.$slots, "default"),
201
- !_ctx.disabled || froined.value ? (openBlock(), createElementBlock("div", {
202
- key: 0,
203
- ref_key: "imgRef",
204
- ref: imgRef,
205
- style: normalizeStyle(imgStyle.value)
206
- }, null, 4)) : createCommentVNode("", true)
269
+ !isDisabled.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
270
+ _ctx.svgRender ? (openBlock(), createElementBlock("svg", {
271
+ key: 0,
272
+ style: normalizeStyle(svgStyle.value)
273
+ }, [
274
+ createElementVNode("defs", null, [
275
+ _ctx.image ? (openBlock(), createElementBlock("pattern", {
276
+ key: 0,
277
+ id: `imgPattern-${unref(svgId)}`,
278
+ patternUnits: "userSpaceOnUse",
279
+ width: (markWidth.value + markGapX.value) * SIZE,
280
+ height: (markHeight.value + markGapY.value) * SIZE
281
+ }, [
282
+ createElementVNode("g", {
283
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2}, ${(markHeight.value + markGapY.value) / 2})`
284
+ }, [
285
+ createElementVNode("image", {
286
+ href: _ctx.image,
287
+ width: markWidth.value,
288
+ height: markHeight.value,
289
+ x: markGapX.value / 2,
290
+ y: markGapY.value / 2
291
+ }, null, 8, _hoisted_3)
292
+ ], 8, _hoisted_2),
293
+ (openBlock(), createElementBlock("g", {
294
+ key: 0,
295
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value}, ${(markHeight.value + markGapY.value) / 2 + markHeight.value + markGapY.value})`
296
+ }, [
297
+ createElementVNode("image", {
298
+ href: _ctx.image,
299
+ width: markWidth.value,
300
+ height: markHeight.value,
301
+ x: markGapX.value / 2 + markWidth.value + markGapX.value,
302
+ y: markGapY.value / 2 + markHeight.value + markGapY.value
303
+ }, null, 8, _hoisted_5)
304
+ ], 8, _hoisted_4))
305
+ ], 8, _hoisted_1)) : (openBlock(), createElementBlock("pattern", {
306
+ key: 1,
307
+ id: `textPattern-${unref(svgId)}`,
308
+ patternUnits: "userSpaceOnUse",
309
+ width: (markWidth.value + markGapX.value) * SIZE,
310
+ height: (markHeight.value + markGapY.value) * SIZE
311
+ }, [
312
+ createElementVNode("g", {
313
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2}, ${(markHeight.value + markGapY.value) / 2})`
314
+ }, [
315
+ (openBlock(true), createElementBlock(Fragment, null, renderList(markContents.value, (text, index) => {
316
+ return openBlock(), createElementBlock("text", {
317
+ key: index,
318
+ x: (markWidth.value + markGapX.value) / 2,
319
+ y: markGapY.value / 2 + index * (markFont.value.fontSize + _ctx.lineGap),
320
+ fill: markFont.value.color,
321
+ "font-size": markFont.value.fontSize,
322
+ "font-weight": markFont.value.fontWeight,
323
+ "font-family": markFont.value.fontFamily,
324
+ "font-style": markFont.value.fontStyle,
325
+ "text-anchor": "middle",
326
+ "alignment-baseline": "hanging",
327
+ "vector-effect": "non-scaling-stroke"
328
+ }, toDisplayString(text), 9, _hoisted_8);
329
+ }), 128))
330
+ ], 8, _hoisted_7),
331
+ (openBlock(), createElementBlock("g", {
332
+ key: 0,
333
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value}, ${(markHeight.value + markGapY.value) / 2 + markHeight.value + markGapY.value})`
334
+ }, [
335
+ (openBlock(true), createElementBlock(Fragment, null, renderList(markContents.value, (text, index) => {
336
+ return openBlock(), createElementBlock("text", {
337
+ key: index,
338
+ x: (markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value,
339
+ y: markGapY.value / 2 + index * (markFont.value.fontSize + _ctx.lineGap) + markHeight.value + markGapY.value,
340
+ fill: markFont.value.color,
341
+ "font-size": markFont.value.fontSize,
342
+ "font-weight": markFont.value.fontWeight,
343
+ "font-family": markFont.value.fontFamily,
344
+ "font-style": markFont.value.fontStyle,
345
+ "text-anchor": "middle",
346
+ "alignment-baseline": "hanging",
347
+ "vector-effect": "non-scaling-stroke"
348
+ }, toDisplayString(text), 9, _hoisted_10);
349
+ }), 128))
350
+ ], 8, _hoisted_9))
351
+ ], 8, _hoisted_6))
352
+ ]),
353
+ createElementVNode("rect", {
354
+ width: "100%",
355
+ height: "100%",
356
+ fill: `url(#${_ctx.image ? "img" : "text"}Pattern-${unref(svgId)})`,
357
+ transform: `translate(${markOffsetX.value - markGapX.value / 2}, ${markOffsetY.value - markGapY.value / 2})`
358
+ }, null, 8, _hoisted_11)
359
+ ], 4)) : (openBlock(), createElementBlock("div", {
360
+ key: 1,
361
+ ref_key: "imgRef",
362
+ ref: imgRef,
363
+ style: normalizeStyle(imgStyle.value)
364
+ }, null, 4))
365
+ ], 64)) : createCommentVNode("", true)
207
366
  ], 4);
208
367
  };
209
368
  }
@@ -8,7 +8,10 @@ export declare const watermarkProps: {
8
8
  /** 高度 */
9
9
  height: NumberConstructor;
10
10
  /** 旋转角度 */
11
- rotate: NumberConstructor;
11
+ rotate: {
12
+ type: NumberConstructor;
13
+ default: number;
14
+ };
12
15
  /** 层级 */
13
16
  zIndex: NumberConstructor;
14
17
  /** 图片源 */
@@ -28,6 +31,10 @@ export declare const watermarkProps: {
28
31
  };
29
32
  /** 自定义样式 */
30
33
  customStyle: PropType<Exclude<StyleValue, string>>;
34
+ /** 是否使用 svg 渲染 */
35
+ svgRender: BooleanConstructor;
36
+ /** 是否禁用 */
37
+ disabled: BooleanConstructor;
31
38
  /** 是否使用固定定位 */
32
39
  fixed: BooleanConstructor;
33
40
  /** 是否为外层添加定位样式 */
@@ -35,7 +42,7 @@ export declare const watermarkProps: {
35
42
  type: BooleanConstructor;
36
43
  default: boolean;
37
44
  };
38
- /** 是否禁用 */
39
- disabled: BooleanConstructor;
45
+ /** 外层高度 */
46
+ wrapHeight: StringConstructor;
40
47
  };
41
48
  export type WatermarkProps = ExtractPropTypes<typeof watermarkProps>;
@@ -4,7 +4,10 @@ const watermarkProps = {
4
4
  /** 高度 */
5
5
  height: Number,
6
6
  /** 旋转角度 */
7
- rotate: Number,
7
+ rotate: {
8
+ type: Number,
9
+ default: -22
10
+ },
8
11
  /** 层级 */
9
12
  zIndex: Number,
10
13
  /** 图片源 */
@@ -24,6 +27,10 @@ const watermarkProps = {
24
27
  },
25
28
  /** 自定义样式 */
26
29
  customStyle: Object,
30
+ /** 是否使用 svg 渲染 */
31
+ svgRender: Boolean,
32
+ /** 是否禁用 */
33
+ disabled: Boolean,
27
34
  /** 是否使用固定定位 */
28
35
  fixed: Boolean,
29
36
  /** 是否为外层添加定位样式 */
@@ -31,8 +38,8 @@ const watermarkProps = {
31
38
  type: Boolean,
32
39
  default: true
33
40
  },
34
- /** 是否禁用 */
35
- disabled: Boolean
41
+ /** 外层高度 */
42
+ wrapHeight: String
36
43
  };
37
44
  export {
38
45
  watermarkProps
@@ -37,3 +37,15 @@ export interface MutationOption {
37
37
  /** 水印样式被篡改回调 */
38
38
  onDalsified: () => void;
39
39
  }
40
+
41
+ /**
42
+ * 水印图片的数据
43
+ */
44
+ export interface WatermarkImgData {
45
+ /** 图片的宽度 */
46
+ width: number;
47
+ /** 图片的高度 */
48
+ height: number;
49
+ /** 图片的base64数据 */
50
+ base64: string;
51
+ }
@@ -1,16 +1,8 @@
1
1
  import { StyleValue } from '../ele-app/types';
2
2
  import { ERROR_MESSAGE_KEY as INFO_LOG_KEY } from '../utils/common';
3
- import { WatermarkGap, WatermarkFont, MutationOption } from './types';
3
+ import { MutationOption } from './types';
4
4
 
5
5
  export { INFO_LOG_KEY };
6
- /**
7
- * 获取文字样式
8
- */
9
- export declare function getFont(font?: WatermarkFont): Required<WatermarkFont>;
10
- /**
11
- * 获取间距
12
- */
13
- export declare function getGap(gap?: WatermarkGap): number[];
14
6
  /**
15
7
  * 返回设备像素密度
16
8
  */
@@ -29,5 +21,6 @@ export declare function joinStyle(style: StyleValue): string;
29
21
  */
30
22
  export declare function useMutation(option: MutationOption): {
31
23
  observe: () => void;
24
+ observeTextNode: (text: string) => string;
32
25
  disconnect: () => void;
33
26
  };