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