完全跑通1.0版本
This commit is contained in:
8
frontend/node_modules/element-plus/es/components/watermark/index.d.ts
generated
vendored
Normal file
8
frontend/node_modules/element-plus/es/components/watermark/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { SFCWithInstall } from "../../utils/vue/typescript.js";
|
||||
import { WatermarkFontType, WatermarkInstance, WatermarkProps, WatermarkPropsPublic, watermarkProps } from "./src/watermark.js";
|
||||
import _default from "./src/watermark.vue.js";
|
||||
|
||||
//#region ../../packages/components/watermark/index.d.ts
|
||||
declare const ElWatermark: SFCWithInstall<typeof _default>;
|
||||
//#endregion
|
||||
export { ElWatermark, ElWatermark as default, WatermarkFontType, WatermarkInstance, WatermarkProps, WatermarkPropsPublic, watermarkProps };
|
||||
9
frontend/node_modules/element-plus/es/components/watermark/index.mjs
generated
vendored
Normal file
9
frontend/node_modules/element-plus/es/components/watermark/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { withInstall } from "../../utils/vue/install.mjs";
|
||||
import { watermarkProps } from "./src/watermark.mjs";
|
||||
import watermark_default from "./src/watermark2.mjs";
|
||||
//#region ../../packages/components/watermark/index.ts
|
||||
const ElWatermark = withInstall(watermark_default);
|
||||
//#endregion
|
||||
export { ElWatermark, ElWatermark as default, watermarkProps };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":["Watermark"],"sources":["../../../../../packages/components/watermark/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Watermark from './src/watermark.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElWatermark: SFCWithInstall<typeof Watermark> =\n withInstall(Watermark)\nexport default ElWatermark\n\nexport * from './src/watermark'\n"],"mappings":";;;;AAKA,MAAa,cACX,YAAYA,kBAAU"}
|
||||
10
frontend/node_modules/element-plus/es/components/watermark/src/useClips.d.ts
generated
vendored
Normal file
10
frontend/node_modules/element-plus/es/components/watermark/src/useClips.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { WatermarkProps } from "./watermark.js";
|
||||
|
||||
//#region ../../packages/components/watermark/src/useClips.d.ts
|
||||
/**
|
||||
* Get the clips of text content.
|
||||
* This is a lazy hook function since SSR no need this
|
||||
*/
|
||||
declare function useClips(): (content: NonNullable<WatermarkProps["content"]> | HTMLImageElement, rotate: number, ratio: number, width: number, height: number, font: Required<NonNullable<WatermarkProps["font"]>>, gapX: number, gapY: number, space: number) => [dataURL: string, finalWidth: number, finalHeight: number];
|
||||
//#endregion
|
||||
export { useClips as default };
|
||||
106
frontend/node_modules/element-plus/es/components/watermark/src/useClips.mjs
generated
vendored
Normal file
106
frontend/node_modules/element-plus/es/components/watermark/src/useClips.mjs
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
import { isArray } from "../../../utils/types.mjs";
|
||||
//#region ../../packages/components/watermark/src/useClips.ts
|
||||
const TEXT_ALIGN_RATIO_MAP = {
|
||||
left: [0, .5],
|
||||
start: [0, .5],
|
||||
center: [.5, 0],
|
||||
right: [1, -.5],
|
||||
end: [1, -.5]
|
||||
};
|
||||
function prepareCanvas(width, height, ratio = 1) {
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
const realWidth = width * ratio;
|
||||
const realHeight = height * ratio;
|
||||
canvas.setAttribute("width", `${realWidth}px`);
|
||||
canvas.setAttribute("height", `${realHeight}px`);
|
||||
ctx.save();
|
||||
return [
|
||||
ctx,
|
||||
canvas,
|
||||
realWidth,
|
||||
realHeight
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Get the clips of text content.
|
||||
* This is a lazy hook function since SSR no need this
|
||||
*/
|
||||
function useClips() {
|
||||
function getClips(content, rotate, ratio, width, height, font, gapX, gapY, space) {
|
||||
const [ctx, canvas, contentWidth, contentHeight] = prepareCanvas(width, height, ratio);
|
||||
let baselineOffset = 0;
|
||||
if (content instanceof HTMLImageElement) ctx.drawImage(content, 0, 0, contentWidth, contentHeight);
|
||||
else {
|
||||
const { color, fontSize, fontStyle, fontWeight, fontFamily, textAlign, textBaseline } = font;
|
||||
const mergedFontSize = Number(fontSize) * ratio;
|
||||
ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${height}px ${fontFamily}`;
|
||||
ctx.fillStyle = color;
|
||||
ctx.textAlign = textAlign;
|
||||
ctx.textBaseline = textBaseline;
|
||||
const contents = isArray(content) ? content : [content];
|
||||
if (textBaseline !== "top" && contents[0]) {
|
||||
const argumentMetrics = ctx.measureText(contents[0]);
|
||||
ctx.textBaseline = "top";
|
||||
const topMetrics = ctx.measureText(contents[0]);
|
||||
baselineOffset = argumentMetrics.actualBoundingBoxAscent - topMetrics.actualBoundingBoxAscent;
|
||||
}
|
||||
contents?.forEach((item, index) => {
|
||||
const [alignRatio, spaceRatio] = TEXT_ALIGN_RATIO_MAP[textAlign];
|
||||
ctx.fillText(item ?? "", contentWidth * alignRatio + space * spaceRatio, index * (mergedFontSize + font.fontGap * ratio));
|
||||
});
|
||||
}
|
||||
const angle = Math.PI / 180 * Number(rotate);
|
||||
const maxSize = Math.max(width, height);
|
||||
const [rCtx, rCanvas, realMaxSize] = prepareCanvas(maxSize, maxSize, ratio);
|
||||
rCtx.translate(realMaxSize / 2, realMaxSize / 2);
|
||||
rCtx.rotate(angle);
|
||||
if (contentWidth > 0 && contentHeight > 0) rCtx.drawImage(canvas, -contentWidth / 2, -contentHeight / 2);
|
||||
function getRotatePos(x, y) {
|
||||
return [x * Math.cos(angle) - y * Math.sin(angle), x * Math.sin(angle) + y * Math.cos(angle)];
|
||||
}
|
||||
let left = 0;
|
||||
let right = 0;
|
||||
let top = 0;
|
||||
let bottom = 0;
|
||||
const halfWidth = contentWidth / 2;
|
||||
const halfHeight = contentHeight / 2;
|
||||
[
|
||||
[0 - halfWidth, 0 - halfHeight],
|
||||
[0 + halfWidth, 0 - halfHeight],
|
||||
[0 + halfWidth, 0 + halfHeight],
|
||||
[0 - halfWidth, 0 + halfHeight]
|
||||
].forEach(([x, y]) => {
|
||||
const [targetX, targetY] = getRotatePos(x, y);
|
||||
left = Math.min(left, targetX);
|
||||
right = Math.max(right, targetX);
|
||||
top = Math.min(top, targetY);
|
||||
bottom = Math.max(bottom, targetY);
|
||||
});
|
||||
const cutLeft = left + realMaxSize / 2;
|
||||
const cutTop = top + realMaxSize / 2;
|
||||
const cutWidth = right - left;
|
||||
const cutHeight = bottom - top;
|
||||
const realGapX = gapX * ratio;
|
||||
const realGapY = gapY * ratio;
|
||||
const filledWidth = (cutWidth + realGapX) * 2;
|
||||
const filledHeight = cutHeight + realGapY;
|
||||
const [fCtx, fCanvas] = prepareCanvas(filledWidth, filledHeight);
|
||||
function drawImg(targetX = 0, targetY = 0) {
|
||||
fCtx.drawImage(rCanvas, cutLeft, cutTop, cutWidth, cutHeight, targetX, targetY + baselineOffset, cutWidth, cutHeight);
|
||||
}
|
||||
drawImg();
|
||||
drawImg(cutWidth + realGapX, -cutHeight / 2 - realGapY / 2);
|
||||
drawImg(cutWidth + realGapX, +cutHeight / 2 + realGapY / 2);
|
||||
return [
|
||||
fCanvas.toDataURL(),
|
||||
filledWidth / ratio,
|
||||
filledHeight / ratio
|
||||
];
|
||||
}
|
||||
return getClips;
|
||||
}
|
||||
//#endregion
|
||||
export { useClips as default };
|
||||
|
||||
//# sourceMappingURL=useClips.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/src/useClips.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/src/useClips.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
frontend/node_modules/element-plus/es/components/watermark/src/utils.d.ts
generated
vendored
Normal file
12
frontend/node_modules/element-plus/es/components/watermark/src/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { CSSProperties } from "vue";
|
||||
|
||||
//#region ../../packages/components/watermark/src/utils.d.ts
|
||||
/** converting camel-cased strings to be lowercase and link it with Separator */
|
||||
declare function toLowercaseSeparator(key: string): string;
|
||||
declare function getStyleStr(style: CSSProperties): string;
|
||||
/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */
|
||||
declare function getPixelRatio(): number;
|
||||
/** Whether to re-render the watermark */
|
||||
declare const reRendering: (mutation: MutationRecord, watermarkElement?: HTMLElement) => boolean;
|
||||
//#endregion
|
||||
export { getPixelRatio, getStyleStr, reRendering, toLowercaseSeparator };
|
||||
23
frontend/node_modules/element-plus/es/components/watermark/src/utils.mjs
generated
vendored
Normal file
23
frontend/node_modules/element-plus/es/components/watermark/src/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
//#region ../../packages/components/watermark/src/utils.ts
|
||||
/** converting camel-cased strings to be lowercase and link it with Separator */
|
||||
function toLowercaseSeparator(key) {
|
||||
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
}
|
||||
function getStyleStr(style) {
|
||||
return Object.keys(style).map((key) => `${toLowercaseSeparator(key)}: ${style[key]};`).join(" ");
|
||||
}
|
||||
/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */
|
||||
function getPixelRatio() {
|
||||
return window.devicePixelRatio || 1;
|
||||
}
|
||||
/** Whether to re-render the watermark */
|
||||
const reRendering = (mutation, watermarkElement) => {
|
||||
let flag = false;
|
||||
if (mutation.removedNodes.length && watermarkElement) flag = Array.from(mutation.removedNodes).includes(watermarkElement);
|
||||
if (mutation.type === "attributes" && mutation.target === watermarkElement) flag = true;
|
||||
return flag;
|
||||
};
|
||||
//#endregion
|
||||
export { getPixelRatio, getStyleStr, reRendering, toLowercaseSeparator };
|
||||
|
||||
//# sourceMappingURL=utils.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/src/utils.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/src/utils.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../../../../packages/components/watermark/src/utils.ts"],"sourcesContent":["import type { CSSProperties } from 'vue'\n\n/** converting camel-cased strings to be lowercase and link it with Separator */\nexport function toLowercaseSeparator(key: string) {\n return key.replace(/([A-Z])/g, '-$1').toLowerCase()\n}\n\nexport function getStyleStr(style: CSSProperties): string {\n return Object.keys(style)\n .map(\n (key) =>\n `${toLowercaseSeparator(key)}: ${style[key as keyof CSSProperties]};`\n )\n .join(' ')\n}\n\n/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */\nexport function getPixelRatio() {\n return window.devicePixelRatio || 1\n}\n\n/** Whether to re-render the watermark */\nexport const reRendering = (\n mutation: MutationRecord,\n watermarkElement?: HTMLElement\n) => {\n let flag = false\n // Whether to delete the watermark node\n if (mutation.removedNodes.length && watermarkElement) {\n flag = Array.from(mutation.removedNodes).includes(watermarkElement)\n }\n // Whether the watermark dom property value has been modified\n if (mutation.type === 'attributes' && mutation.target === watermarkElement) {\n flag = true\n }\n return flag\n}\n"],"mappings":";;AAGA,SAAgB,qBAAqB,KAAa;CAChD,OAAO,IAAI,QAAQ,YAAY,MAAM,CAAC,aAAa;;AAGrD,SAAgB,YAAY,OAA8B;CACxD,OAAO,OAAO,KAAK,MAAM,CACtB,KACE,QACC,GAAG,qBAAqB,IAAI,CAAC,IAAI,MAAM,KAA4B,GACtE,CACA,KAAK,IAAI;;;AAId,SAAgB,gBAAgB;CAC9B,OAAO,OAAO,oBAAoB;;;AAIpC,MAAa,eACX,UACA,qBACG;CACH,IAAI,OAAO;CAEX,IAAI,SAAS,aAAa,UAAU,kBAClC,OAAO,MAAM,KAAK,SAAS,aAAa,CAAC,SAAS,iBAAiB;CAGrE,IAAI,SAAS,SAAS,gBAAgB,SAAS,WAAW,kBACxD,OAAO;CAET,OAAO"}
|
||||
85
frontend/node_modules/element-plus/es/components/watermark/src/watermark.d.ts
generated
vendored
Normal file
85
frontend/node_modules/element-plus/es/components/watermark/src/watermark.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { EpPropFinalized } from "../../../utils/vue/props/types.js";
|
||||
import _default from "./watermark.vue.js";
|
||||
import * as _$vue from "vue";
|
||||
import { ExtractPublicPropTypes } from "vue";
|
||||
|
||||
//#region ../../packages/components/watermark/src/watermark.d.ts
|
||||
interface WatermarkFontType {
|
||||
color?: string;
|
||||
fontSize?: number | string;
|
||||
fontWeight?: 'normal' | 'bold' | 'lighter' | 'bolder' | number;
|
||||
fontStyle?: 'none' | 'normal' | 'italic' | 'oblique';
|
||||
fontFamily?: string;
|
||||
fontGap?: number;
|
||||
textAlign?: 'start' | 'end' | 'left' | 'right' | 'center';
|
||||
textBaseline?: 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
|
||||
}
|
||||
interface WatermarkProps {
|
||||
/**
|
||||
* @description The z-index of the appended watermark element
|
||||
*/
|
||||
zIndex?: number;
|
||||
/**
|
||||
* @description The rotation angle of the watermark
|
||||
*/
|
||||
rotate?: number;
|
||||
/**
|
||||
* @description The width of the watermark
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* @description The height of the watermark
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* @description Image source, it is recommended to export 2x or 3x image, high priority (support base64 format)
|
||||
*/
|
||||
image?: string;
|
||||
/**
|
||||
* @description Watermark text content
|
||||
*/
|
||||
content?: string | string[];
|
||||
/**
|
||||
* @description Text style
|
||||
*/
|
||||
font?: WatermarkFontType;
|
||||
/**
|
||||
* @description The spacing between watermarks
|
||||
*/
|
||||
gap?: [number, number];
|
||||
/**
|
||||
* @description The offset of the watermark from the upper left corner of the container. The default is gap/2
|
||||
*/
|
||||
offset?: [number, number];
|
||||
}
|
||||
/**
|
||||
* @deprecated Removed after 3.0.0, Use `WatermarkProps` instead.
|
||||
*/
|
||||
declare const watermarkProps: {
|
||||
readonly zIndex: EpPropFinalized<NumberConstructor, unknown, unknown, 9, boolean>;
|
||||
readonly rotate: EpPropFinalized<NumberConstructor, unknown, unknown, -22, boolean>;
|
||||
readonly width: NumberConstructor;
|
||||
readonly height: NumberConstructor;
|
||||
readonly image: StringConstructor;
|
||||
readonly content: EpPropFinalized<(new (...args: any[]) => string | string[]) | (() => string | string[]) | (((new (...args: any[]) => string | string[]) | (() => string | string[])) | null)[], unknown, unknown, "Element Plus", boolean>;
|
||||
readonly font: {
|
||||
readonly type: _$vue.PropType<WatermarkFontType>;
|
||||
readonly required: false;
|
||||
readonly validator: ((val: unknown) => boolean) | undefined;
|
||||
__epPropKey: true;
|
||||
};
|
||||
readonly gap: EpPropFinalized<(new (...args: any[]) => [number, number]) | (() => [number, number]) | (((new (...args: any[]) => [number, number]) | (() => [number, number])) | null)[], unknown, unknown, () => number[], boolean>;
|
||||
readonly offset: {
|
||||
readonly type: _$vue.PropType<[number, number]>;
|
||||
readonly required: false;
|
||||
readonly validator: ((val: unknown) => boolean) | undefined;
|
||||
__epPropKey: true;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @deprecated Removed after 3.0.0, Use `WatermarkProps` instead.
|
||||
*/
|
||||
type WatermarkPropsPublic = ExtractPublicPropTypes<typeof watermarkProps>;
|
||||
type WatermarkInstance = InstanceType<typeof _default> & unknown;
|
||||
//#endregion
|
||||
export { WatermarkFontType, WatermarkInstance, WatermarkProps, WatermarkPropsPublic, watermarkProps };
|
||||
59
frontend/node_modules/element-plus/es/components/watermark/src/watermark.mjs
generated
vendored
Normal file
59
frontend/node_modules/element-plus/es/components/watermark/src/watermark.mjs
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
|
||||
//#region ../../packages/components/watermark/src/watermark.ts
|
||||
/**
|
||||
* @deprecated Removed after 3.0.0, Use `WatermarkProps` instead.
|
||||
*/
|
||||
const watermarkProps = buildProps({
|
||||
/**
|
||||
* @description The z-index of the appended watermark element
|
||||
*/
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 9
|
||||
},
|
||||
/**
|
||||
* @description The rotation angle of the watermark
|
||||
*/
|
||||
rotate: {
|
||||
type: Number,
|
||||
default: -22
|
||||
},
|
||||
/**
|
||||
* @description The width of the watermark
|
||||
*/
|
||||
width: Number,
|
||||
/**
|
||||
* @description The height of the watermark
|
||||
*/
|
||||
height: Number,
|
||||
/**
|
||||
* @description Image source, it is recommended to export 2x or 3x image, high priority (support base64 format)
|
||||
*/
|
||||
image: String,
|
||||
/**
|
||||
* @description Watermark text content
|
||||
*/
|
||||
content: {
|
||||
type: definePropType([String, Array]),
|
||||
default: "Element Plus"
|
||||
},
|
||||
/**
|
||||
* @description Text style
|
||||
*/
|
||||
font: { type: definePropType(Object) },
|
||||
/**
|
||||
* @description The spacing between watermarks
|
||||
*/
|
||||
gap: {
|
||||
type: definePropType(Array),
|
||||
default: () => [100, 100]
|
||||
},
|
||||
/**
|
||||
* @description The offset of the watermark from the upper left corner of the container. The default is gap/2
|
||||
*/
|
||||
offset: { type: definePropType(Array) }
|
||||
});
|
||||
//#endregion
|
||||
export { watermarkProps };
|
||||
|
||||
//# sourceMappingURL=watermark.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"watermark.mjs","names":[],"sources":["../../../../../../packages/components/watermark/src/watermark.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type Watermark from './watermark.vue'\n\nexport interface WatermarkFontType {\n color?: string\n fontSize?: number | string\n fontWeight?: 'normal' | 'bold' | 'lighter' | 'bolder' | number\n fontStyle?: 'none' | 'normal' | 'italic' | 'oblique'\n fontFamily?: string\n fontGap?: number\n textAlign?: 'start' | 'end' | 'left' | 'right' | 'center'\n textBaseline?:\n | 'top'\n | 'hanging'\n | 'middle'\n | 'alphabetic'\n | 'ideographic'\n | 'bottom'\n}\n\nexport interface WatermarkProps {\n /**\n * @description The z-index of the appended watermark element\n */\n zIndex?: number\n /**\n * @description The rotation angle of the watermark\n */\n rotate?: number\n /**\n * @description The width of the watermark\n */\n width?: number\n /**\n * @description The height of the watermark\n */\n height?: number\n /**\n * @description Image source, it is recommended to export 2x or 3x image, high priority (support base64 format)\n */\n image?: string\n /**\n * @description Watermark text content\n */\n content?: string | string[]\n /**\n * @description Text style\n */\n font?: WatermarkFontType\n /**\n * @description The spacing between watermarks\n */\n gap?: [number, number]\n /**\n * @description The offset of the watermark from the upper left corner of the container. The default is gap/2\n */\n offset?: [number, number]\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `WatermarkProps` instead.\n */\nexport const watermarkProps = buildProps({\n /**\n * @description The z-index of the appended watermark element\n */\n zIndex: {\n type: Number,\n default: 9,\n },\n /**\n * @description The rotation angle of the watermark\n */\n rotate: {\n type: Number,\n default: -22,\n },\n /**\n * @description The width of the watermark\n */\n width: Number,\n /**\n * @description The height of the watermark\n */\n height: Number,\n /**\n * @description Image source, it is recommended to export 2x or 3x image, high priority (support base64 format)\n */\n image: String,\n /**\n * @description Watermark text content\n */\n content: {\n type: definePropType<string | string[]>([String, Array]),\n default: 'Element Plus',\n },\n /**\n * @description Text style\n */\n font: {\n type: definePropType<WatermarkFontType>(Object),\n },\n /**\n * @description The spacing between watermarks\n */\n gap: {\n type: definePropType<[number, number]>(Array),\n default: () => [100, 100],\n },\n /**\n * @description The offset of the watermark from the upper left corner of the container. The default is gap/2\n */\n offset: {\n type: definePropType<[number, number]>(Array),\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `WatermarkProps` instead.\n */\nexport type WatermarkPropsPublic = ExtractPublicPropTypes<typeof watermarkProps>\nexport type WatermarkInstance = InstanceType<typeof Watermark> & unknown\n"],"mappings":";;;;;AAgEA,MAAa,iBAAiB,WAAW;;;;CAIvC,QAAQ;EACN,MAAM;EACN,SAAS;EACV;;;;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;;;;CAID,OAAO;;;;CAIP,QAAQ;;;;CAIR,OAAO;;;;CAIP,SAAS;EACP,MAAM,eAAkC,CAAC,QAAQ,MAAM,CAAC;EACxD,SAAS;EACV;;;;CAID,MAAM,EACJ,MAAM,eAAkC,OAAO,EAChD;;;;CAID,KAAK;EACH,MAAM,eAAiC,MAAM;EAC7C,eAAe,CAAC,KAAK,IAAI;EAC1B;;;;CAID,QAAQ,EACN,MAAM,eAAiC,MAAM,EAC9C;CACF,CAAU"}
|
||||
23
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue.d.ts
generated
vendored
Normal file
23
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { WatermarkProps } from "./watermark.js";
|
||||
import * as _$vue from "vue";
|
||||
|
||||
//#region ../../packages/components/watermark/src/watermark.vue.d.ts
|
||||
declare var __VLS_1: {};
|
||||
type __VLS_Slots = {} & {
|
||||
default?: (props: typeof __VLS_1) => any;
|
||||
};
|
||||
declare const __VLS_base: _$vue.DefineComponent<WatermarkProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<WatermarkProps> & Readonly<{}>, {
|
||||
zIndex: number;
|
||||
content: string | string[];
|
||||
gap: [number, number];
|
||||
rotate: number;
|
||||
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
||||
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
||||
declare const _default: typeof __VLS_export;
|
||||
type __VLS_WithSlots<T, S> = T & {
|
||||
new (): {
|
||||
$slots: S;
|
||||
};
|
||||
};
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
186
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue_vue_type_script_setup_true_lang.mjs
generated
vendored
Normal file
186
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue_vue_type_script_setup_true_lang.mjs
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
import { isArray, isUndefined } from "../../../utils/types.mjs";
|
||||
import { watermarkProps } from "./watermark.mjs";
|
||||
import { getPixelRatio, getStyleStr, reRendering } from "./utils.mjs";
|
||||
import useClips from "./useClips.mjs";
|
||||
import { useMutationObserver } from "@vueuse/core";
|
||||
import { computed, createElementBlock, defineComponent, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, shallowRef, watch } from "vue";
|
||||
//#region ../../packages/components/watermark/src/watermark.vue?vue&type=script&setup=true&lang.ts
|
||||
var watermark_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
||||
name: "ElWatermark",
|
||||
__name: "watermark",
|
||||
props: watermarkProps,
|
||||
setup(__props) {
|
||||
const style = { position: "relative" };
|
||||
const props = __props;
|
||||
const fontGap = computed(() => props.font?.fontGap ?? 3);
|
||||
const color = computed(() => props.font?.color ?? "rgba(0,0,0,.15)");
|
||||
const fontSize = computed(() => props.font?.fontSize ?? 16);
|
||||
const fontWeight = computed(() => props.font?.fontWeight ?? "normal");
|
||||
const fontStyle = computed(() => props.font?.fontStyle ?? "normal");
|
||||
const fontFamily = computed(() => props.font?.fontFamily ?? "sans-serif");
|
||||
const textAlign = computed(() => props.font?.textAlign ?? "center");
|
||||
const textBaseline = computed(() => props.font?.textBaseline ?? "hanging");
|
||||
const gapX = computed(() => props.gap[0]);
|
||||
const gapY = computed(() => props.gap[1]);
|
||||
const gapXCenter = computed(() => gapX.value / 2);
|
||||
const gapYCenter = computed(() => gapY.value / 2);
|
||||
const offsetLeft = computed(() => props.offset?.[0] ?? gapXCenter.value);
|
||||
const offsetTop = computed(() => props.offset?.[1] ?? gapYCenter.value);
|
||||
const getMarkStyle = () => {
|
||||
const markStyle = {
|
||||
zIndex: props.zIndex,
|
||||
position: "absolute",
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
pointerEvents: "none",
|
||||
backgroundRepeat: "repeat"
|
||||
};
|
||||
/** Calculate the style of the offset */
|
||||
let positionLeft = offsetLeft.value - gapXCenter.value;
|
||||
let positionTop = offsetTop.value - gapYCenter.value;
|
||||
if (positionLeft > 0) {
|
||||
markStyle.left = `${positionLeft}px`;
|
||||
markStyle.width = `calc(100% - ${positionLeft}px)`;
|
||||
positionLeft = 0;
|
||||
}
|
||||
if (positionTop > 0) {
|
||||
markStyle.top = `${positionTop}px`;
|
||||
markStyle.height = `calc(100% - ${positionTop}px)`;
|
||||
positionTop = 0;
|
||||
}
|
||||
markStyle.backgroundPosition = `${positionLeft}px ${positionTop}px`;
|
||||
return markStyle;
|
||||
};
|
||||
const containerRef = shallowRef(null);
|
||||
const watermarkRef = shallowRef();
|
||||
const stopObservation = ref(false);
|
||||
const destroyWatermark = () => {
|
||||
if (watermarkRef.value) {
|
||||
watermarkRef.value.remove();
|
||||
watermarkRef.value = void 0;
|
||||
}
|
||||
};
|
||||
const appendWatermark = (base64Url, markWidth) => {
|
||||
if (containerRef.value && watermarkRef.value) {
|
||||
stopObservation.value = true;
|
||||
watermarkRef.value.setAttribute("style", getStyleStr({
|
||||
...getMarkStyle(),
|
||||
backgroundImage: `url('${base64Url}')`,
|
||||
backgroundSize: `${Math.floor(markWidth)}px`
|
||||
}));
|
||||
containerRef.value?.append(watermarkRef.value);
|
||||
setTimeout(() => {
|
||||
stopObservation.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Get the width and height of the watermark. The default values are as follows
|
||||
* Image: [120, 64]; Content: It's calculated by content;
|
||||
*/
|
||||
const getMarkSize = (ctx) => {
|
||||
let defaultWidth = 120;
|
||||
let defaultHeight = 64;
|
||||
let space = 0;
|
||||
const { image, content, width, height, rotate } = props;
|
||||
if (!image && ctx.measureText) {
|
||||
ctx.font = `${Number(fontSize.value)}px ${fontFamily.value}`;
|
||||
const contents = isArray(content) ? content : [content];
|
||||
let maxWidth = 0;
|
||||
let maxHeight = 0;
|
||||
contents.forEach((item) => {
|
||||
const { width, fontBoundingBoxAscent, fontBoundingBoxDescent, actualBoundingBoxAscent, actualBoundingBoxDescent } = ctx.measureText(item);
|
||||
const height = isUndefined(fontBoundingBoxAscent) ? actualBoundingBoxAscent + actualBoundingBoxDescent : fontBoundingBoxAscent + fontBoundingBoxDescent;
|
||||
if (width > maxWidth) maxWidth = Math.ceil(width);
|
||||
if (height > maxHeight) maxHeight = Math.ceil(height);
|
||||
});
|
||||
defaultWidth = maxWidth;
|
||||
defaultHeight = maxHeight * contents.length + (contents.length - 1) * fontGap.value;
|
||||
const angle = Math.PI / 180 * Number(rotate);
|
||||
space = Math.ceil(Math.abs(Math.sin(angle) * defaultHeight) / 2);
|
||||
defaultWidth += space;
|
||||
}
|
||||
return [
|
||||
width ?? defaultWidth,
|
||||
height ?? defaultHeight,
|
||||
space
|
||||
];
|
||||
};
|
||||
const getClips = useClips();
|
||||
const renderWatermark = () => {
|
||||
const ctx = document.createElement("canvas").getContext("2d");
|
||||
const image = props.image;
|
||||
const content = props.content;
|
||||
const rotate = props.rotate;
|
||||
if (ctx) {
|
||||
if (!watermarkRef.value) watermarkRef.value = document.createElement("div");
|
||||
const ratio = getPixelRatio();
|
||||
const [markWidth, markHeight, space] = getMarkSize(ctx);
|
||||
const drawCanvas = (drawContent) => {
|
||||
const [textClips, clipWidth] = getClips(drawContent || "", rotate, ratio, markWidth, markHeight, {
|
||||
color: color.value,
|
||||
fontSize: fontSize.value,
|
||||
fontStyle: fontStyle.value,
|
||||
fontWeight: fontWeight.value,
|
||||
fontFamily: fontFamily.value,
|
||||
fontGap: fontGap.value,
|
||||
textAlign: textAlign.value,
|
||||
textBaseline: textBaseline.value
|
||||
}, gapX.value, gapY.value, space);
|
||||
appendWatermark(textClips, clipWidth);
|
||||
};
|
||||
if (image) {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
drawCanvas(img);
|
||||
};
|
||||
img.onerror = () => {
|
||||
drawCanvas(content);
|
||||
};
|
||||
img.crossOrigin = "anonymous";
|
||||
img.referrerPolicy = "no-referrer";
|
||||
img.src = image;
|
||||
} else drawCanvas(content);
|
||||
}
|
||||
};
|
||||
onMounted(() => {
|
||||
renderWatermark();
|
||||
});
|
||||
watch(() => props, () => {
|
||||
renderWatermark();
|
||||
}, {
|
||||
deep: true,
|
||||
flush: "post"
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
destroyWatermark();
|
||||
});
|
||||
const onMutate = (mutations) => {
|
||||
if (stopObservation.value) return;
|
||||
mutations.forEach((mutation) => {
|
||||
if (reRendering(mutation, watermarkRef.value)) {
|
||||
destroyWatermark();
|
||||
renderWatermark();
|
||||
}
|
||||
});
|
||||
};
|
||||
useMutationObserver(containerRef, onMutate, {
|
||||
attributes: true,
|
||||
subtree: true,
|
||||
childList: true
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return openBlock(), createElementBlock("div", {
|
||||
ref_key: "containerRef",
|
||||
ref: containerRef,
|
||||
style: normalizeStyle([style])
|
||||
}, [renderSlot(_ctx.$slots, "default")], 4);
|
||||
};
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
export { watermark_vue_vue_type_script_setup_true_lang_default as default };
|
||||
|
||||
//# sourceMappingURL=watermark.vue_vue_type_script_setup_true_lang.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue_vue_type_script_setup_true_lang.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark.vue_vue_type_script_setup_true_lang.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
frontend/node_modules/element-plus/es/components/watermark/src/watermark2.mjs
generated
vendored
Normal file
7
frontend/node_modules/element-plus/es/components/watermark/src/watermark2.mjs
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import watermark_vue_vue_type_script_setup_true_lang_default from "./watermark.vue_vue_type_script_setup_true_lang.mjs";
|
||||
//#region ../../packages/components/watermark/src/watermark.vue
|
||||
var watermark_default = watermark_vue_vue_type_script_setup_true_lang_default;
|
||||
//#endregion
|
||||
export { watermark_default as default };
|
||||
|
||||
//# sourceMappingURL=watermark2.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark2.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/watermark/src/watermark2.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
0
frontend/node_modules/element-plus/es/components/watermark/style/css.mjs
generated
vendored
Normal file
0
frontend/node_modules/element-plus/es/components/watermark/style/css.mjs
generated
vendored
Normal file
0
frontend/node_modules/element-plus/es/components/watermark/style/index.mjs
generated
vendored
Normal file
0
frontend/node_modules/element-plus/es/components/watermark/style/index.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user