@robot-admin/naive-ui-components 0.4.2 → 0.4.4
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/dist/C_ActionBar.cjs +1 -5
- package/dist/C_ActionBar.js +1 -4
- package/dist/C_ActionBar.js.map +1 -0
- package/dist/C_ActionBar2.js +1 -195
- package/dist/C_ActionBar2.js.map +1 -1
- package/dist/C_AntV.cjs +1 -8
- package/dist/C_AntV.js +1 -4
- package/dist/C_AntV.js.map +1 -0
- package/dist/C_AntV2.js +4 -3149
- package/dist/C_AntV2.js.map +1 -1
- package/dist/C_Barcode.cjs +1 -4
- package/dist/C_Barcode.js +1 -3
- package/dist/C_Barcode.js.map +1 -0
- package/dist/C_Barcode2.js +1 -67
- package/dist/C_Barcode2.js.map +1 -1
- package/dist/C_Captcha.cjs +1 -4
- package/dist/C_Captcha.js +1 -3
- package/dist/C_Captcha.js.map +1 -0
- package/dist/C_Captcha2.js +1 -154
- package/dist/C_Captcha2.js.map +1 -1
- package/dist/C_Cascade.cjs +1 -4
- package/dist/C_Cascade.js +1 -3
- package/dist/C_Cascade.js.map +1 -0
- package/dist/C_Cascade2.js +1 -102
- package/dist/C_Cascade2.js.map +1 -1
- package/dist/C_City.cjs +1 -4
- package/dist/C_City.js +1 -3
- package/dist/C_City.js.map +1 -0
- package/dist/C_City2.js +1 -840
- package/dist/C_City2.js.map +1 -1
- package/dist/C_Code.cjs +1 -5
- package/dist/C_Code.js +1 -4
- package/dist/C_Code.js.map +1 -0
- package/dist/C_Code2.js +1 -346
- package/dist/C_Code2.js.map +1 -1
- package/dist/C_CollapsePanel.cjs +1 -6
- package/dist/C_CollapsePanel.js +1 -4
- package/dist/C_CollapsePanel.js.map +1 -0
- package/dist/C_CollapsePanel2.js +1 -318
- package/dist/C_CollapsePanel2.js.map +1 -1
- package/dist/C_Cron.cjs +1 -15
- package/dist/C_Cron.js +1 -4
- package/dist/C_Cron.js.map +1 -0
- package/dist/C_Cron2.js +1 -1209
- package/dist/C_Cron2.js.map +1 -1
- package/dist/C_Date.cjs +1 -4
- package/dist/C_Date.js +1 -3
- package/dist/C_Date.js.map +1 -0
- package/dist/C_Date2.js +1 -218
- package/dist/C_Date2.js.map +1 -1
- package/dist/C_Draggable.cjs +1 -5
- package/dist/C_Draggable.js +1 -3
- package/dist/C_Draggable.js.map +1 -0
- package/dist/C_Draggable2.js +1 -294
- package/dist/C_Draggable2.js.map +1 -1
- package/dist/C_Editor.cjs +1 -4
- package/dist/C_Editor.js +1 -3
- package/dist/C_Editor.js.map +1 -0
- package/dist/C_Editor2.js +1 -159
- package/dist/C_Editor2.js.map +1 -1
- package/dist/C_FilePreview.cjs +1 -7
- package/dist/C_FilePreview.js +1 -4
- package/dist/C_FilePreview.js.map +1 -0
- package/dist/C_FilePreview2.js +1 -1031
- package/dist/C_FilePreview2.js.map +1 -1
- package/dist/C_Form.cjs +1 -16
- package/dist/C_Form.js +1 -5
- package/dist/C_Form.js.map +1 -0
- package/dist/C_Form2.js +1 -2569
- package/dist/C_Form2.js.map +1 -1
- package/dist/C_FormSearch.cjs +1 -6
- package/dist/C_FormSearch.js +1 -3
- package/dist/C_FormSearch.js.map +1 -0
- package/dist/C_FormSearch2.js +1 -355
- package/dist/C_FormSearch2.js.map +1 -1
- package/dist/C_FormulaEditor.cjs +1 -13
- package/dist/C_FormulaEditor.js +1 -4
- package/dist/C_FormulaEditor.js.map +1 -0
- package/dist/C_FormulaEditor2.js +1 -1432
- package/dist/C_FormulaEditor2.js.map +1 -1
- package/dist/C_FullCalendar.cjs +1 -9
- package/dist/C_FullCalendar.js +1 -3
- package/dist/C_FullCalendar.js.map +1 -0
- package/dist/C_FullCalendar2.js +1 -376
- package/dist/C_FullCalendar2.js.map +1 -1
- package/dist/C_GlobalSearch.cjs +1 -5
- package/dist/C_GlobalSearch.js +1 -3
- package/dist/C_GlobalSearch.js.map +1 -0
- package/dist/C_GlobalSearch2.js +1 -335
- package/dist/C_GlobalSearch2.js.map +1 -1
- package/dist/C_Guide.cjs +1 -4
- package/dist/C_Guide.js +1 -3
- package/dist/C_Guide.js.map +1 -0
- package/dist/C_Guide2.js +1 -57
- package/dist/C_Guide2.js.map +1 -1
- package/dist/C_Icon.cjs +1 -4
- package/dist/C_Icon.js +1 -3
- package/dist/C_Icon.js.map +1 -0
- package/dist/C_Icon2.js +1 -285
- package/dist/C_Icon2.js.map +1 -1
- package/dist/C_ImageCropper.cjs +1 -6
- package/dist/C_ImageCropper.js +1 -4
- package/dist/C_ImageCropper.js.map +1 -0
- package/dist/C_ImageCropper2.js +1 -722
- package/dist/C_ImageCropper2.js.map +1 -1
- package/dist/C_Language.cjs +1 -4
- package/dist/C_Language.js +1 -3
- package/dist/C_Language.js.map +1 -0
- package/dist/C_Language2.js +1 -71
- package/dist/C_Language2.js.map +1 -1
- package/dist/C_Map.cjs +1 -7
- package/dist/C_Map.js +1 -3
- package/dist/C_Map.js.map +1 -0
- package/dist/C_Map2.js +1 -198
- package/dist/C_Map2.js.map +1 -1
- package/dist/C_Markdown.cjs +1 -4
- package/dist/C_Markdown.js +1 -3
- package/dist/C_Markdown.js.map +1 -0
- package/dist/C_Markdown2.js +1 -185
- package/dist/C_Markdown2.js.map +1 -1
- package/dist/C_NotificationCenter.cjs +1 -20
- package/dist/C_NotificationCenter.js +1 -4
- package/dist/C_NotificationCenter.js.map +1 -0
- package/dist/C_NotificationCenter2.js +1 -1383
- package/dist/C_NotificationCenter2.js.map +1 -1
- package/dist/C_Progress.cjs +1 -4
- package/dist/C_Progress.js +1 -3
- package/dist/C_Progress.js.map +1 -0
- package/dist/C_Progress2.js +1 -102
- package/dist/C_Progress2.js.map +1 -1
- package/dist/C_QRCode.cjs +1 -5
- package/dist/C_QRCode.js +1 -3
- package/dist/C_QRCode.js.map +1 -0
- package/dist/C_QRCode2.js +1 -217
- package/dist/C_QRCode2.js.map +1 -1
- package/dist/C_Signature.cjs +1 -8
- package/dist/C_Signature.js +1 -4
- package/dist/C_Signature.js.map +1 -0
- package/dist/C_Signature2.js +1 -617
- package/dist/C_Signature2.js.map +1 -1
- package/dist/C_SplitPane.cjs +1 -6
- package/dist/C_SplitPane.js +1 -4
- package/dist/C_SplitPane.js.map +1 -0
- package/dist/C_SplitPane2.js +1 -355
- package/dist/C_SplitPane2.js.map +1 -1
- package/dist/C_Steps.cjs +1 -4
- package/dist/C_Steps.js +1 -3
- package/dist/C_Steps.js.map +1 -0
- package/dist/C_Steps2.js +1 -81
- package/dist/C_Steps2.js.map +1 -1
- package/dist/C_Table.cjs +1 -20
- package/dist/C_Table.js +1 -6
- package/dist/C_Table.js.map +1 -0
- package/dist/C_Table2.js +1 -3023
- package/dist/C_Table2.js.map +1 -1
- package/dist/C_Theme.cjs +1 -4
- package/dist/C_Theme.js +1 -3
- package/dist/C_Theme.js.map +1 -0
- package/dist/C_Theme2.js +1 -59
- package/dist/C_Theme2.js.map +1 -1
- package/dist/C_Time.cjs +1 -5
- package/dist/C_Time.js +1 -3
- package/dist/C_Time.js.map +1 -0
- package/dist/C_Time2.js +1 -198
- package/dist/C_Time2.js.map +1 -1
- package/dist/C_Tree.cjs +1 -7
- package/dist/C_Tree.js +1 -4
- package/dist/C_Tree.js.map +1 -0
- package/dist/C_Tree2.js +1 -440
- package/dist/C_Tree2.js.map +1 -1
- package/dist/C_Upload.cjs +1 -12
- package/dist/C_Upload.js +1 -4
- package/dist/C_Upload.js.map +1 -0
- package/dist/C_Upload2.js +2 -1365
- package/dist/C_Upload2.js.map +1 -1
- package/dist/C_VideoPlayer.cjs +1 -23
- package/dist/C_VideoPlayer.js +1 -3
- package/dist/C_VideoPlayer.js.map +1 -0
- package/dist/C_VideoPlayer2.js +3 -1932
- package/dist/C_VideoPlayer2.js.map +1 -1
- package/dist/C_VtableGantt.cjs +1 -6
- package/dist/C_VtableGantt.js +1 -4
- package/dist/C_VtableGantt.js.map +1 -0
- package/dist/C_VtableGantt2.js +1 -872
- package/dist/C_VtableGantt2.js.map +1 -1
- package/dist/C_WaterFall.cjs +1 -13
- package/dist/C_WaterFall.js +1 -3
- package/dist/C_WaterFall.js.map +1 -0
- package/dist/C_WaterFall2.js +1 -364
- package/dist/C_WaterFall2.js.map +1 -1
- package/dist/C_WorkFlow.cjs +1 -8
- package/dist/C_WorkFlow.js +1 -4
- package/dist/C_WorkFlow.js.map +1 -0
- package/dist/C_WorkFlow2.js +1 -1983
- package/dist/C_WorkFlow2.js.map +1 -1
- package/dist/chunk.js +1 -18
- package/dist/city.js +1 -4816
- package/dist/constants.d.ts +3 -3
- package/dist/constants2.d.ts +5 -5
- package/dist/constants3.d.ts +2 -2
- package/dist/constants4.d.ts +4 -4
- package/dist/constants5.d.ts +2 -2
- package/dist/data.d.ts +1 -1
- package/dist/export-helper.js +1 -9
- package/dist/index.cjs +2 -441
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -19
- package/dist/index.d.ts +2 -19
- package/dist/index.js +1 -258
- package/dist/index.js.map +1 -1
- package/dist/index.vue.d.ts +2 -2
- package/dist/index10.vue.d.ts +6 -6
- package/dist/index11.vue.d.ts +2 -2
- package/dist/index12.vue.d.ts +4 -4
- package/dist/index13.vue.d.ts +3 -3
- package/dist/index14.vue.d.ts +4 -4
- package/dist/index16.vue.d.ts +3 -3
- package/dist/index2.vue.d.ts +5 -5
- package/dist/index3.vue.d.ts +2 -2
- package/dist/index4.vue.d.ts +2 -2
- package/dist/index5.vue.d.ts +3 -3
- package/dist/index6.vue.d.ts +1 -1
- package/dist/index7.vue.d.ts +1 -1
- package/dist/index8.vue.d.ts +2 -2
- package/dist/resolver.cjs +2 -89
- package/dist/resolver.cjs.map +1 -0
- package/dist/resolver.js +1 -86
- package/dist/resolver.js.map +1 -1
- package/dist/storage.js +1 -30
- package/dist/storage.js.map +1 -1
- package/dist/useCollapsePanel.d.ts +2 -2
- package/dist/useCropperCore.d.ts +8 -8
- package/dist/useDraggableLayout.d.ts +3 -3
- package/dist/useDynamicFormState.d.ts +3 -3
- package/dist/useEdgeInteraction.d.ts +2 -2
- package/dist/useInfiniteScroll.d.ts +3 -3
- package/dist/useModalEdit.d.ts +3 -3
- package/dist/useQRCode.d.ts +4 -4
- package/dist/useSignatureHistory.d.ts +2 -2
- package/dist/useSplitResize.d.ts +5 -5
- package/dist/useTimeSelection.d.ts +1 -1
- package/dist/useTreeOperations.d.ts +4 -4
- package/dist/useWorkflowValidation.d.ts +2 -2
- package/package.json +5 -196
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants2.d.ts.map +0 -1
- package/dist/constants3.d.ts.map +0 -1
- package/dist/constants4.d.ts.map +0 -1
- package/dist/constants5.d.ts.map +0 -1
- package/dist/data.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.vue.d.ts.map +0 -1
- package/dist/index10.vue.d.ts.map +0 -1
- package/dist/index11.vue.d.ts.map +0 -1
- package/dist/index12.vue.d.ts.map +0 -1
- package/dist/index13.vue.d.ts.map +0 -1
- package/dist/index14.vue.d.ts.map +0 -1
- package/dist/index15.vue.d.ts.map +0 -1
- package/dist/index16.vue.d.ts.map +0 -1
- package/dist/index2.vue.d.ts.map +0 -1
- package/dist/index3.vue.d.ts.map +0 -1
- package/dist/index4.vue.d.ts.map +0 -1
- package/dist/index5.vue.d.ts.map +0 -1
- package/dist/index6.vue.d.ts.map +0 -1
- package/dist/index7.vue.d.ts.map +0 -1
- package/dist/index8.vue.d.ts.map +0 -1
- package/dist/index9.vue.d.ts.map +0 -1
- package/dist/resolver.d.cts.map +0 -1
- package/dist/resolver.d.ts.map +0 -1
- package/dist/useCalendarEvents.d.ts.map +0 -1
- package/dist/useCollapsePanel.d.ts.map +0 -1
- package/dist/useCropperCore.d.ts.map +0 -1
- package/dist/useDraggableLayout.d.ts.map +0 -1
- package/dist/useDynamicFormState.d.ts.map +0 -1
- package/dist/useEdgeInteraction.d.ts.map +0 -1
- package/dist/useFullscreen.d.ts.map +0 -1
- package/dist/useGlobalSearch.d.ts.map +0 -1
- package/dist/useInfiniteScroll.d.ts.map +0 -1
- package/dist/useModalEdit.d.ts.map +0 -1
- package/dist/useQRCode.d.ts.map +0 -1
- package/dist/useSearchState.d.ts.map +0 -1
- package/dist/useSignatureHistory.d.ts.map +0 -1
- package/dist/useSplitResize.d.ts.map +0 -1
- package/dist/useTimeSelection.d.ts.map +0 -1
- package/dist/useTreeOperations.d.ts.map +0 -1
- package/dist/useWorkflowValidation.d.ts.map +0 -1
package/dist/C_ImageCropper2.js
CHANGED
|
@@ -1,723 +1,2 @@
|
|
|
1
|
-
import { t as C_Icon_default } from "./C_Icon2.js";
|
|
2
|
-
import { t as export_helper_default } from "./export-helper.js";
|
|
3
|
-
import { NButton, NButtonGroup, NDivider, NModal, NSpace, NTooltip } from "naive-ui";
|
|
4
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, toDisplayString, unref, watch, withCtx } from "vue";
|
|
5
|
-
import { VueCropper } from "vue-cropper";
|
|
6
|
-
|
|
7
|
-
//#region src/components/C_ImageCropper/composables/useCropperCore.ts
|
|
8
|
-
function useCropperCore(options = {}) {
|
|
9
|
-
const cropperRef = ref(null);
|
|
10
|
-
function rotateLeft() {
|
|
11
|
-
cropperRef.value?.rotateLeft();
|
|
12
|
-
}
|
|
13
|
-
function rotateRight() {
|
|
14
|
-
cropperRef.value?.rotateRight();
|
|
15
|
-
}
|
|
16
|
-
function rotate(angle) {
|
|
17
|
-
const steps = Math.round(angle / 90);
|
|
18
|
-
const fn = steps > 0 ? rotateRight : rotateLeft;
|
|
19
|
-
for (let i = 0; i < Math.abs(steps); i++) fn();
|
|
20
|
-
}
|
|
21
|
-
function zoom(scale) {
|
|
22
|
-
cropperRef.value?.changeScale(scale > 0 ? 1 : -1);
|
|
23
|
-
}
|
|
24
|
-
function flipX() {
|
|
25
|
-
const el = cropperRef.value?.$refs?.img;
|
|
26
|
-
if (!el) return;
|
|
27
|
-
const current = el.style.transform || "";
|
|
28
|
-
if (current.includes("scaleX(-1)")) el.style.transform = current.replace("scaleX(-1)", "scaleX(1)");
|
|
29
|
-
else el.style.transform = current.replace(/scaleX\([^)]*\)/, "") + " scaleX(-1)";
|
|
30
|
-
}
|
|
31
|
-
function flipY() {
|
|
32
|
-
const el = cropperRef.value?.$refs?.img;
|
|
33
|
-
if (!el) return;
|
|
34
|
-
const current = el.style.transform || "";
|
|
35
|
-
if (current.includes("scaleY(-1)")) el.style.transform = current.replace("scaleY(-1)", "scaleY(1)");
|
|
36
|
-
else el.style.transform = current.replace(/scaleY\([^)]*\)/, "") + " scaleY(-1)";
|
|
37
|
-
}
|
|
38
|
-
function reset() {
|
|
39
|
-
cropperRef.value?.refresh();
|
|
40
|
-
}
|
|
41
|
-
function constrainSize(w, h) {
|
|
42
|
-
let ow = w;
|
|
43
|
-
let oh = h;
|
|
44
|
-
const maxW = options.maxWidth?.value ?? 0;
|
|
45
|
-
const maxH = options.maxHeight?.value ?? 0;
|
|
46
|
-
if (maxW > 0 && ow > maxW) {
|
|
47
|
-
const ratio = maxW / ow;
|
|
48
|
-
ow = maxW;
|
|
49
|
-
oh = Math.round(oh * ratio);
|
|
50
|
-
}
|
|
51
|
-
if (maxH > 0 && oh > maxH) {
|
|
52
|
-
const ratio = maxH / oh;
|
|
53
|
-
oh = maxH;
|
|
54
|
-
ow = Math.round(ow * ratio);
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
width: ow,
|
|
58
|
-
height: oh
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function getCropResult() {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const cropper = cropperRef.value;
|
|
64
|
-
if (!cropper) return reject(/* @__PURE__ */ new Error("Cropper not initialized"));
|
|
65
|
-
const format = options.format?.value ?? "png";
|
|
66
|
-
const quality = options.quality?.value ?? .92;
|
|
67
|
-
const mime = format === "jpeg" ? "image/jpeg" : format === "webp" ? "image/webp" : "image/png";
|
|
68
|
-
cropper.getCropData((base64) => {
|
|
69
|
-
cropper.getCropBlob((blob) => {
|
|
70
|
-
const img = new Image();
|
|
71
|
-
img.onload = () => {
|
|
72
|
-
const { width, height } = constrainSize(img.width, img.height);
|
|
73
|
-
if (width !== img.width || height !== img.height) {
|
|
74
|
-
const canvas = document.createElement("canvas");
|
|
75
|
-
canvas.width = width;
|
|
76
|
-
canvas.height = height;
|
|
77
|
-
canvas.getContext("2d").drawImage(img, 0, 0, width, height);
|
|
78
|
-
const constrainedBase64 = canvas.toDataURL(mime, quality);
|
|
79
|
-
canvas.toBlob((constrainedBlob) => {
|
|
80
|
-
resolve({
|
|
81
|
-
base64: constrainedBase64,
|
|
82
|
-
blob: constrainedBlob,
|
|
83
|
-
width,
|
|
84
|
-
height,
|
|
85
|
-
format
|
|
86
|
-
});
|
|
87
|
-
}, mime, format === "png" ? void 0 : quality);
|
|
88
|
-
} else resolve({
|
|
89
|
-
base64,
|
|
90
|
-
blob,
|
|
91
|
-
width: img.width,
|
|
92
|
-
height: img.height,
|
|
93
|
-
format
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
img.onerror = () => reject(/* @__PURE__ */ new Error("Failed to load crop result"));
|
|
97
|
-
img.src = base64;
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
cropperRef,
|
|
104
|
-
rotate,
|
|
105
|
-
rotateLeft,
|
|
106
|
-
rotateRight,
|
|
107
|
-
zoom,
|
|
108
|
-
flipX,
|
|
109
|
-
flipY,
|
|
110
|
-
reset,
|
|
111
|
-
getCropResult
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/components/C_ImageCropper/components/CropperToolbar.vue?vue&type=script&setup=true&lang.ts
|
|
117
|
-
const _hoisted_1$2 = { class: "cropper-toolbar" };
|
|
118
|
-
var CropperToolbar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
119
|
-
__name: "CropperToolbar",
|
|
120
|
-
props: {
|
|
121
|
-
currentRatio: {},
|
|
122
|
-
ratioPresets: {}
|
|
123
|
-
},
|
|
124
|
-
emits: [
|
|
125
|
-
"ratio",
|
|
126
|
-
"rotate",
|
|
127
|
-
"flipX",
|
|
128
|
-
"flipY",
|
|
129
|
-
"zoom",
|
|
130
|
-
"reset"
|
|
131
|
-
],
|
|
132
|
-
setup(__props) {
|
|
133
|
-
return (_ctx, _cache) => {
|
|
134
|
-
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
135
|
-
createVNode(unref(NButtonGroup), { size: "small" }, {
|
|
136
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.ratioPresets, (item) => {
|
|
137
|
-
return openBlock(), createBlock(unref(NButton), {
|
|
138
|
-
key: item.value,
|
|
139
|
-
type: _ctx.currentRatio === item.value ? "primary" : "default",
|
|
140
|
-
onClick: ($event) => _ctx.$emit("ratio", item.value)
|
|
141
|
-
}, {
|
|
142
|
-
default: withCtx(() => [createTextVNode(toDisplayString(item.label), 1)]),
|
|
143
|
-
_: 2
|
|
144
|
-
}, 1032, ["type", "onClick"]);
|
|
145
|
-
}), 128))]),
|
|
146
|
-
_: 1
|
|
147
|
-
}),
|
|
148
|
-
createVNode(unref(NDivider), { vertical: "" }),
|
|
149
|
-
createVNode(unref(NTooltip), null, {
|
|
150
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
151
|
-
size: "small",
|
|
152
|
-
quaternary: "",
|
|
153
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("rotate", -90))
|
|
154
|
-
}, {
|
|
155
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:rotate-left" })]),
|
|
156
|
-
_: 1
|
|
157
|
-
})]),
|
|
158
|
-
default: withCtx(() => [_cache[7] || (_cache[7] = createTextVNode(" 逆时针旋转 90° ", -1))]),
|
|
159
|
-
_: 1,
|
|
160
|
-
__: [7]
|
|
161
|
-
}),
|
|
162
|
-
createVNode(unref(NTooltip), null, {
|
|
163
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
164
|
-
size: "small",
|
|
165
|
-
quaternary: "",
|
|
166
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("rotate", 90))
|
|
167
|
-
}, {
|
|
168
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:rotate-right" })]),
|
|
169
|
-
_: 1
|
|
170
|
-
})]),
|
|
171
|
-
default: withCtx(() => [_cache[8] || (_cache[8] = createTextVNode(" 顺时针旋转 90° ", -1))]),
|
|
172
|
-
_: 1,
|
|
173
|
-
__: [8]
|
|
174
|
-
}),
|
|
175
|
-
createVNode(unref(NDivider), { vertical: "" }),
|
|
176
|
-
createVNode(unref(NTooltip), null, {
|
|
177
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
178
|
-
size: "small",
|
|
179
|
-
quaternary: "",
|
|
180
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("flipX"))
|
|
181
|
-
}, {
|
|
182
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:flip-horizontal" })]),
|
|
183
|
-
_: 1
|
|
184
|
-
})]),
|
|
185
|
-
default: withCtx(() => [_cache[9] || (_cache[9] = createTextVNode(" 水平翻转 ", -1))]),
|
|
186
|
-
_: 1,
|
|
187
|
-
__: [9]
|
|
188
|
-
}),
|
|
189
|
-
createVNode(unref(NTooltip), null, {
|
|
190
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
191
|
-
size: "small",
|
|
192
|
-
quaternary: "",
|
|
193
|
-
onClick: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("flipY"))
|
|
194
|
-
}, {
|
|
195
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:flip-vertical" })]),
|
|
196
|
-
_: 1
|
|
197
|
-
})]),
|
|
198
|
-
default: withCtx(() => [_cache[10] || (_cache[10] = createTextVNode(" 垂直翻转 ", -1))]),
|
|
199
|
-
_: 1,
|
|
200
|
-
__: [10]
|
|
201
|
-
}),
|
|
202
|
-
createVNode(unref(NDivider), { vertical: "" }),
|
|
203
|
-
createVNode(unref(NTooltip), null, {
|
|
204
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
205
|
-
size: "small",
|
|
206
|
-
quaternary: "",
|
|
207
|
-
onClick: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("zoom", .1))
|
|
208
|
-
}, {
|
|
209
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:magnify-plus-outline" })]),
|
|
210
|
-
_: 1
|
|
211
|
-
})]),
|
|
212
|
-
default: withCtx(() => [_cache[11] || (_cache[11] = createTextVNode(" 放大 ", -1))]),
|
|
213
|
-
_: 1,
|
|
214
|
-
__: [11]
|
|
215
|
-
}),
|
|
216
|
-
createVNode(unref(NTooltip), null, {
|
|
217
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
218
|
-
size: "small",
|
|
219
|
-
quaternary: "",
|
|
220
|
-
onClick: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("zoom", -.1))
|
|
221
|
-
}, {
|
|
222
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:magnify-minus-outline" })]),
|
|
223
|
-
_: 1
|
|
224
|
-
})]),
|
|
225
|
-
default: withCtx(() => [_cache[12] || (_cache[12] = createTextVNode(" 缩小 ", -1))]),
|
|
226
|
-
_: 1,
|
|
227
|
-
__: [12]
|
|
228
|
-
}),
|
|
229
|
-
createVNode(unref(NDivider), { vertical: "" }),
|
|
230
|
-
createVNode(unref(NTooltip), null, {
|
|
231
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
232
|
-
size: "small",
|
|
233
|
-
quaternary: "",
|
|
234
|
-
onClick: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("reset"))
|
|
235
|
-
}, {
|
|
236
|
-
icon: withCtx(() => [createVNode(C_Icon_default, { name: "mdi:refresh" })]),
|
|
237
|
-
_: 1
|
|
238
|
-
})]),
|
|
239
|
-
default: withCtx(() => [_cache[13] || (_cache[13] = createTextVNode(" 重置 ", -1))]),
|
|
240
|
-
_: 1,
|
|
241
|
-
__: [13]
|
|
242
|
-
})
|
|
243
|
-
]);
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/components/C_ImageCropper/components/CropperToolbar.vue
|
|
250
|
-
var CropperToolbar_default = /* @__PURE__ */ export_helper_default(CropperToolbar_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-ac310c55"]]);
|
|
251
|
-
|
|
252
|
-
//#endregion
|
|
253
|
-
//#region src/components/C_ImageCropper/components/CropperPreview.vue?vue&type=script&setup=true&lang.ts
|
|
254
|
-
const _hoisted_1$1 = { class: "cropper-preview" };
|
|
255
|
-
const _hoisted_2$1 = { class: "preview-label" };
|
|
256
|
-
const _hoisted_3$1 = ["src"];
|
|
257
|
-
const _hoisted_4$1 = {
|
|
258
|
-
key: 1,
|
|
259
|
-
class: "preview-empty"
|
|
260
|
-
};
|
|
261
|
-
const _hoisted_5$1 = { class: "preview-thumbs" };
|
|
262
|
-
const _hoisted_6$1 = ["src"];
|
|
263
|
-
const _hoisted_7$1 = { class: "preview-thumb__label" };
|
|
264
|
-
var CropperPreview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
265
|
-
__name: "CropperPreview",
|
|
266
|
-
props: {
|
|
267
|
-
previewData: {},
|
|
268
|
-
circular: { type: Boolean }
|
|
269
|
-
},
|
|
270
|
-
setup(__props) {
|
|
271
|
-
const props = __props;
|
|
272
|
-
const mainBoxRef = ref(null);
|
|
273
|
-
const mainBoxWidth = ref(200);
|
|
274
|
-
const thumbSizes = [
|
|
275
|
-
{
|
|
276
|
-
label: "80px",
|
|
277
|
-
size: 80
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
label: "48px",
|
|
281
|
-
size: 48
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
label: "32px",
|
|
285
|
-
size: 32
|
|
286
|
-
}
|
|
287
|
-
];
|
|
288
|
-
const hasValidPreview = computed(() => {
|
|
289
|
-
const d = props.previewData;
|
|
290
|
-
return d && d.url && d.w > 0 && d.h > 0;
|
|
291
|
-
});
|
|
292
|
-
const mainViewportStyle = computed(() => {
|
|
293
|
-
if (!hasValidPreview.value) return {};
|
|
294
|
-
const { w } = props.previewData;
|
|
295
|
-
return {
|
|
296
|
-
zoom: mainBoxWidth.value / w,
|
|
297
|
-
overflow: "hidden"
|
|
298
|
-
};
|
|
299
|
-
});
|
|
300
|
-
function getThumbViewportStyle(size) {
|
|
301
|
-
if (!hasValidPreview.value) return {};
|
|
302
|
-
const { w } = props.previewData;
|
|
303
|
-
return {
|
|
304
|
-
zoom: size / w,
|
|
305
|
-
overflow: "hidden"
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
let resizeObserver = null;
|
|
309
|
-
onMounted(() => {
|
|
310
|
-
if (mainBoxRef.value) {
|
|
311
|
-
mainBoxWidth.value = mainBoxRef.value.clientWidth;
|
|
312
|
-
resizeObserver = new ResizeObserver((entries) => {
|
|
313
|
-
requestAnimationFrame(() => {
|
|
314
|
-
for (const entry of entries) mainBoxWidth.value = entry.contentRect.width;
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
resizeObserver.observe(mainBoxRef.value);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
onBeforeUnmount(() => {
|
|
321
|
-
resizeObserver?.disconnect();
|
|
322
|
-
});
|
|
323
|
-
return (_ctx, _cache) => {
|
|
324
|
-
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
325
|
-
createElementVNode("div", _hoisted_2$1, [createVNode(C_Icon_default, { name: "mdi:eye-outline" }), _cache[0] || (_cache[0] = createElementVNode("span", null, "裁剪预览", -1))]),
|
|
326
|
-
createElementVNode("div", {
|
|
327
|
-
ref_key: "mainBoxRef",
|
|
328
|
-
ref: mainBoxRef,
|
|
329
|
-
class: normalizeClass(["preview-main", { "preview-main--circular": _ctx.circular }])
|
|
330
|
-
}, [hasValidPreview.value ? (openBlock(), createElementBlock("div", {
|
|
331
|
-
key: 0,
|
|
332
|
-
class: "preview-main__viewport",
|
|
333
|
-
style: normalizeStyle(mainViewportStyle.value)
|
|
334
|
-
}, [createElementVNode("div", { style: normalizeStyle(_ctx.previewData.div) }, [createElementVNode("img", {
|
|
335
|
-
src: _ctx.previewData.url,
|
|
336
|
-
style: normalizeStyle(_ctx.previewData.img),
|
|
337
|
-
alt: "preview"
|
|
338
|
-
}, null, 12, _hoisted_3$1)], 4)], 4)) : (openBlock(), createElementBlock("div", _hoisted_4$1, [createVNode(C_Icon_default, {
|
|
339
|
-
name: "mdi:image-outline",
|
|
340
|
-
style: {
|
|
341
|
-
"font-size": "32px",
|
|
342
|
-
"opacity": "0.2"
|
|
343
|
-
}
|
|
344
|
-
})]))], 2),
|
|
345
|
-
createElementVNode("div", _hoisted_5$1, [(openBlock(), createElementBlock(Fragment, null, renderList(thumbSizes, (item) => {
|
|
346
|
-
return createElementVNode("div", {
|
|
347
|
-
key: item.label,
|
|
348
|
-
class: "preview-thumb"
|
|
349
|
-
}, [createElementVNode("div", {
|
|
350
|
-
class: normalizeClass(["preview-thumb__box", { "preview-thumb__box--circular": _ctx.circular }]),
|
|
351
|
-
style: normalizeStyle({
|
|
352
|
-
width: `${item.size}px`,
|
|
353
|
-
height: `${item.size}px`
|
|
354
|
-
})
|
|
355
|
-
}, [hasValidPreview.value ? (openBlock(), createElementBlock("div", {
|
|
356
|
-
key: 0,
|
|
357
|
-
class: "preview-thumb__viewport",
|
|
358
|
-
style: normalizeStyle(getThumbViewportStyle(item.size))
|
|
359
|
-
}, [createElementVNode("div", { style: normalizeStyle(_ctx.previewData.div) }, [createElementVNode("img", {
|
|
360
|
-
src: _ctx.previewData.url,
|
|
361
|
-
style: normalizeStyle(_ctx.previewData.img),
|
|
362
|
-
alt: "thumb"
|
|
363
|
-
}, null, 12, _hoisted_6$1)], 4)], 4)) : createCommentVNode("v-if", true)], 6), createElementVNode("span", _hoisted_7$1, toDisplayString(item.label), 1)]);
|
|
364
|
-
}), 64))])
|
|
365
|
-
]);
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
//#endregion
|
|
371
|
-
//#region src/components/C_ImageCropper/components/CropperPreview.vue
|
|
372
|
-
var CropperPreview_default = /* @__PURE__ */ export_helper_default(CropperPreview_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-11f355b4"]]);
|
|
373
|
-
|
|
374
|
-
//#endregion
|
|
375
|
-
//#region src/components/C_ImageCropper/index.vue?vue&type=script&setup=true&lang.ts
|
|
376
|
-
const _hoisted_1 = { class: "c-image-cropper__body" };
|
|
377
|
-
const _hoisted_2 = { class: "c-image-cropper__workspace" };
|
|
378
|
-
const _hoisted_3 = {
|
|
379
|
-
key: 1,
|
|
380
|
-
class: "c-image-cropper__placeholder"
|
|
381
|
-
};
|
|
382
|
-
const _hoisted_4 = {
|
|
383
|
-
key: 0,
|
|
384
|
-
class: "c-image-cropper__preview-panel"
|
|
385
|
-
};
|
|
386
|
-
const _hoisted_5 = {
|
|
387
|
-
key: 1,
|
|
388
|
-
class: "c-image-cropper"
|
|
389
|
-
};
|
|
390
|
-
const _hoisted_6 = { class: "c-image-cropper__body" };
|
|
391
|
-
const _hoisted_7 = { class: "c-image-cropper__workspace" };
|
|
392
|
-
const _hoisted_8 = {
|
|
393
|
-
key: 1,
|
|
394
|
-
class: "c-image-cropper__placeholder"
|
|
395
|
-
};
|
|
396
|
-
const _hoisted_9 = {
|
|
397
|
-
key: 0,
|
|
398
|
-
class: "c-image-cropper__preview-panel"
|
|
399
|
-
};
|
|
400
|
-
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
401
|
-
name: "C_ImageCropper",
|
|
402
|
-
__name: "index",
|
|
403
|
-
props: {
|
|
404
|
-
src: { default: "" },
|
|
405
|
-
aspectRatio: { default: 0 },
|
|
406
|
-
outputFormat: { default: "png" },
|
|
407
|
-
outputQuality: { default: .92 },
|
|
408
|
-
maxOutputWidth: { default: 0 },
|
|
409
|
-
maxOutputHeight: { default: 0 },
|
|
410
|
-
showPreview: {
|
|
411
|
-
type: Boolean,
|
|
412
|
-
default: true
|
|
413
|
-
},
|
|
414
|
-
showToolbar: {
|
|
415
|
-
type: Boolean,
|
|
416
|
-
default: true
|
|
417
|
-
},
|
|
418
|
-
circular: {
|
|
419
|
-
type: Boolean,
|
|
420
|
-
default: false
|
|
421
|
-
},
|
|
422
|
-
disabled: {
|
|
423
|
-
type: Boolean,
|
|
424
|
-
default: false
|
|
425
|
-
},
|
|
426
|
-
height: { default: "400px" },
|
|
427
|
-
modal: {
|
|
428
|
-
type: Boolean,
|
|
429
|
-
default: false
|
|
430
|
-
},
|
|
431
|
-
modalTitle: { default: "图片裁剪" }
|
|
432
|
-
},
|
|
433
|
-
emits: [
|
|
434
|
-
"crop",
|
|
435
|
-
"ready",
|
|
436
|
-
"error",
|
|
437
|
-
"confirm",
|
|
438
|
-
"cancel"
|
|
439
|
-
],
|
|
440
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
441
|
-
const props = __props;
|
|
442
|
-
const emit = __emit;
|
|
443
|
-
const imgSrc = ref(props.src);
|
|
444
|
-
const currentRatio = ref(props.aspectRatio);
|
|
445
|
-
const modalVisible = ref(false);
|
|
446
|
-
const exporting = ref(false);
|
|
447
|
-
const previewData = ref(null);
|
|
448
|
-
const inlineCropperRef = ref(null);
|
|
449
|
-
const modalCropperRef = ref(null);
|
|
450
|
-
const activeCropperRef = computed(() => props.modal ? modalCropperRef.value : inlineCropperRef.value);
|
|
451
|
-
const containerHeight = computed(() => typeof props.height === "number" ? `${props.height}px` : props.height);
|
|
452
|
-
const vueCropperOutputType = computed(() => {
|
|
453
|
-
return {
|
|
454
|
-
png: "png",
|
|
455
|
-
jpeg: "jpeg",
|
|
456
|
-
webp: "webp"
|
|
457
|
-
}[props.outputFormat] || "png";
|
|
458
|
-
});
|
|
459
|
-
const isFixed = computed(() => currentRatio.value > 0);
|
|
460
|
-
const fixedNumber = computed(() => {
|
|
461
|
-
if (currentRatio.value <= 0) return [1, 1];
|
|
462
|
-
if (currentRatio.value === 1) return [1, 1];
|
|
463
|
-
if (Math.abs(currentRatio.value - 16 / 9) < .01) return [16, 9];
|
|
464
|
-
if (Math.abs(currentRatio.value - 4 / 3) < .01) return [4, 3];
|
|
465
|
-
if (Math.abs(currentRatio.value - 3 / 2) < .01) return [3, 2];
|
|
466
|
-
return [Math.round(currentRatio.value * 100), 100];
|
|
467
|
-
});
|
|
468
|
-
const autoCropSize = computed(() => ({
|
|
469
|
-
width: 300,
|
|
470
|
-
height: currentRatio.value > 0 ? 300 / currentRatio.value : 200
|
|
471
|
-
}));
|
|
472
|
-
const ratioPresets = [
|
|
473
|
-
{
|
|
474
|
-
label: "自由",
|
|
475
|
-
value: 0
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
label: "1:1",
|
|
479
|
-
value: 1
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
label: "16:9",
|
|
483
|
-
value: 16 / 9
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
label: "4:3",
|
|
487
|
-
value: 4 / 3
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
label: "3:2",
|
|
491
|
-
value: 3 / 2
|
|
492
|
-
}
|
|
493
|
-
];
|
|
494
|
-
const core = useCropperCore({
|
|
495
|
-
format: computed(() => props.outputFormat),
|
|
496
|
-
quality: computed(() => props.outputQuality),
|
|
497
|
-
maxWidth: computed(() => props.maxOutputWidth),
|
|
498
|
-
maxHeight: computed(() => props.maxOutputHeight)
|
|
499
|
-
});
|
|
500
|
-
watch(activeCropperRef, (v) => {
|
|
501
|
-
core.cropperRef.value = v;
|
|
502
|
-
});
|
|
503
|
-
function handleRealTimePreview(data) {
|
|
504
|
-
previewData.value = data;
|
|
505
|
-
}
|
|
506
|
-
function onImgLoad(status) {
|
|
507
|
-
if (status === "success") emit("ready");
|
|
508
|
-
}
|
|
509
|
-
function rotate(angle) {
|
|
510
|
-
core.rotate(angle);
|
|
511
|
-
}
|
|
512
|
-
function handleRatio(v) {
|
|
513
|
-
currentRatio.value = v;
|
|
514
|
-
}
|
|
515
|
-
function handleReset() {
|
|
516
|
-
core.reset();
|
|
517
|
-
}
|
|
518
|
-
async function handleConfirm() {
|
|
519
|
-
exporting.value = true;
|
|
520
|
-
try {
|
|
521
|
-
const result = await core.getCropResult();
|
|
522
|
-
emit("confirm", result);
|
|
523
|
-
emit("crop", result);
|
|
524
|
-
modalVisible.value = false;
|
|
525
|
-
} finally {
|
|
526
|
-
exporting.value = false;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
function handleCancel() {
|
|
530
|
-
modalVisible.value = false;
|
|
531
|
-
emit("cancel");
|
|
532
|
-
}
|
|
533
|
-
function loadFile(file) {
|
|
534
|
-
const reader = new FileReader();
|
|
535
|
-
reader.onload = (e) => {
|
|
536
|
-
imgSrc.value = e.target?.result;
|
|
537
|
-
};
|
|
538
|
-
reader.readAsDataURL(file);
|
|
539
|
-
}
|
|
540
|
-
watch(() => props.src, (v) => {
|
|
541
|
-
imgSrc.value = v;
|
|
542
|
-
});
|
|
543
|
-
watch(() => props.aspectRatio, (v) => {
|
|
544
|
-
currentRatio.value = v;
|
|
545
|
-
});
|
|
546
|
-
__expose({
|
|
547
|
-
getCropResult: core.getCropResult,
|
|
548
|
-
rotate: core.rotate,
|
|
549
|
-
zoom: core.zoom,
|
|
550
|
-
flipX: core.flipX,
|
|
551
|
-
flipY: core.flipY,
|
|
552
|
-
reset: core.reset,
|
|
553
|
-
setAspectRatio: (r) => {
|
|
554
|
-
currentRatio.value = r;
|
|
555
|
-
},
|
|
556
|
-
loadFile,
|
|
557
|
-
open: (src) => {
|
|
558
|
-
if (src) imgSrc.value = src;
|
|
559
|
-
modalVisible.value = true;
|
|
560
|
-
},
|
|
561
|
-
close: () => {
|
|
562
|
-
modalVisible.value = false;
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
return (_ctx, _cache) => {
|
|
566
|
-
return props.modal ? (openBlock(), createBlock(unref(NModal), {
|
|
567
|
-
key: 0,
|
|
568
|
-
show: modalVisible.value,
|
|
569
|
-
"onUpdate:show": _cache[0] || (_cache[0] = ($event) => modalVisible.value = $event),
|
|
570
|
-
preset: "card",
|
|
571
|
-
title: props.modalTitle || "图片裁剪",
|
|
572
|
-
style: { width: "860px" },
|
|
573
|
-
"mask-closable": false,
|
|
574
|
-
closable: true
|
|
575
|
-
}, {
|
|
576
|
-
footer: withCtx(() => [createVNode(unref(NSpace), { justify: "end" }, {
|
|
577
|
-
default: withCtx(() => [createVNode(unref(NButton), { onClick: handleCancel }, {
|
|
578
|
-
default: withCtx(() => _cache[2] || (_cache[2] = [createTextVNode("取消", -1)])),
|
|
579
|
-
_: 1,
|
|
580
|
-
__: [2]
|
|
581
|
-
}), createVNode(unref(NButton), {
|
|
582
|
-
type: "primary",
|
|
583
|
-
loading: exporting.value,
|
|
584
|
-
onClick: handleConfirm
|
|
585
|
-
}, {
|
|
586
|
-
default: withCtx(() => _cache[3] || (_cache[3] = [createTextVNode("确认裁剪", -1)])),
|
|
587
|
-
_: 1,
|
|
588
|
-
__: [3]
|
|
589
|
-
}, 8, ["loading"])]),
|
|
590
|
-
_: 1
|
|
591
|
-
})]),
|
|
592
|
-
default: withCtx(() => [createElementVNode("div", _hoisted_1, [props.showToolbar ? (openBlock(), createBlock(CropperToolbar_default, {
|
|
593
|
-
key: 0,
|
|
594
|
-
"current-ratio": currentRatio.value,
|
|
595
|
-
"ratio-presets": ratioPresets,
|
|
596
|
-
onRatio: handleRatio,
|
|
597
|
-
onRotate: rotate,
|
|
598
|
-
onFlipX: unref(core).flipX,
|
|
599
|
-
onFlipY: unref(core).flipY,
|
|
600
|
-
onZoom: unref(core).zoom,
|
|
601
|
-
onReset: handleReset
|
|
602
|
-
}, null, 8, [
|
|
603
|
-
"current-ratio",
|
|
604
|
-
"onFlipX",
|
|
605
|
-
"onFlipY",
|
|
606
|
-
"onZoom"
|
|
607
|
-
])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_2, [createElementVNode("div", {
|
|
608
|
-
class: "c-image-cropper__canvas",
|
|
609
|
-
style: normalizeStyle({ height: containerHeight.value })
|
|
610
|
-
}, [imgSrc.value ? (openBlock(), createBlock(unref(VueCropper), {
|
|
611
|
-
key: 0,
|
|
612
|
-
ref_key: "modalCropperRef",
|
|
613
|
-
ref: modalCropperRef,
|
|
614
|
-
img: imgSrc.value,
|
|
615
|
-
"output-size": props.outputQuality,
|
|
616
|
-
"output-type": vueCropperOutputType.value,
|
|
617
|
-
"can-scale": false,
|
|
618
|
-
"auto-crop": true,
|
|
619
|
-
"auto-crop-width": autoCropSize.value.width,
|
|
620
|
-
"auto-crop-height": autoCropSize.value.height,
|
|
621
|
-
fixed: isFixed.value,
|
|
622
|
-
"fixed-number": fixedNumber.value,
|
|
623
|
-
"center-box": true,
|
|
624
|
-
info: true,
|
|
625
|
-
"info-true": true,
|
|
626
|
-
"can-move": true,
|
|
627
|
-
"can-move-box": true,
|
|
628
|
-
original: false,
|
|
629
|
-
high: true,
|
|
630
|
-
full: false,
|
|
631
|
-
mode: "contain",
|
|
632
|
-
onRealTime: handleRealTimePreview,
|
|
633
|
-
onImgLoad
|
|
634
|
-
}, null, 8, [
|
|
635
|
-
"img",
|
|
636
|
-
"output-size",
|
|
637
|
-
"output-type",
|
|
638
|
-
"auto-crop-width",
|
|
639
|
-
"auto-crop-height",
|
|
640
|
-
"fixed",
|
|
641
|
-
"fixed-number"
|
|
642
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(C_Icon_default, {
|
|
643
|
-
name: "mdi:image-plus-outline",
|
|
644
|
-
style: {
|
|
645
|
-
"font-size": "48px",
|
|
646
|
-
"opacity": "0.3"
|
|
647
|
-
}
|
|
648
|
-
}), _cache[1] || (_cache[1] = createElementVNode("span", null, "请选择图片", -1))]))], 4), props.showPreview && imgSrc.value ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(CropperPreview_default, {
|
|
649
|
-
"preview-data": previewData.value,
|
|
650
|
-
circular: props.circular
|
|
651
|
-
}, null, 8, ["preview-data", "circular"])])) : createCommentVNode("v-if", true)])])]),
|
|
652
|
-
_: 1
|
|
653
|
-
}, 8, ["show", "title"])) : (openBlock(), createElementBlock("div", _hoisted_5, [createElementVNode("div", _hoisted_6, [props.showToolbar ? (openBlock(), createBlock(CropperToolbar_default, {
|
|
654
|
-
key: 0,
|
|
655
|
-
"current-ratio": currentRatio.value,
|
|
656
|
-
"ratio-presets": ratioPresets,
|
|
657
|
-
onRatio: handleRatio,
|
|
658
|
-
onRotate: rotate,
|
|
659
|
-
onFlipX: unref(core).flipX,
|
|
660
|
-
onFlipY: unref(core).flipY,
|
|
661
|
-
onZoom: unref(core).zoom,
|
|
662
|
-
onReset: handleReset
|
|
663
|
-
}, null, 8, [
|
|
664
|
-
"current-ratio",
|
|
665
|
-
"onFlipX",
|
|
666
|
-
"onFlipY",
|
|
667
|
-
"onZoom"
|
|
668
|
-
])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_7, [createElementVNode("div", {
|
|
669
|
-
class: "c-image-cropper__canvas",
|
|
670
|
-
style: normalizeStyle({ height: containerHeight.value })
|
|
671
|
-
}, [imgSrc.value ? (openBlock(), createBlock(unref(VueCropper), {
|
|
672
|
-
key: 0,
|
|
673
|
-
ref_key: "inlineCropperRef",
|
|
674
|
-
ref: inlineCropperRef,
|
|
675
|
-
img: imgSrc.value,
|
|
676
|
-
"output-size": props.outputQuality,
|
|
677
|
-
"output-type": vueCropperOutputType.value,
|
|
678
|
-
"can-scale": false,
|
|
679
|
-
"auto-crop": true,
|
|
680
|
-
"auto-crop-width": autoCropSize.value.width,
|
|
681
|
-
"auto-crop-height": autoCropSize.value.height,
|
|
682
|
-
fixed: isFixed.value,
|
|
683
|
-
"fixed-number": fixedNumber.value,
|
|
684
|
-
"center-box": true,
|
|
685
|
-
info: true,
|
|
686
|
-
"info-true": true,
|
|
687
|
-
"can-move": true,
|
|
688
|
-
"can-move-box": true,
|
|
689
|
-
original: false,
|
|
690
|
-
high: true,
|
|
691
|
-
full: false,
|
|
692
|
-
mode: "contain",
|
|
693
|
-
onRealTime: handleRealTimePreview,
|
|
694
|
-
onImgLoad
|
|
695
|
-
}, null, 8, [
|
|
696
|
-
"img",
|
|
697
|
-
"output-size",
|
|
698
|
-
"output-type",
|
|
699
|
-
"auto-crop-width",
|
|
700
|
-
"auto-crop-height",
|
|
701
|
-
"fixed",
|
|
702
|
-
"fixed-number"
|
|
703
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_8, [createVNode(C_Icon_default, {
|
|
704
|
-
name: "mdi:image-plus-outline",
|
|
705
|
-
style: {
|
|
706
|
-
"font-size": "48px",
|
|
707
|
-
"opacity": "0.3"
|
|
708
|
-
}
|
|
709
|
-
}), _cache[4] || (_cache[4] = createElementVNode("span", null, "请选择图片", -1))]))], 4), props.showPreview && imgSrc.value ? (openBlock(), createElementBlock("div", _hoisted_9, [createVNode(CropperPreview_default, {
|
|
710
|
-
"preview-data": previewData.value,
|
|
711
|
-
circular: props.circular
|
|
712
|
-
}, null, 8, ["preview-data", "circular"])])) : createCommentVNode("v-if", true)])])]));
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
|
|
717
|
-
//#endregion
|
|
718
|
-
//#region src/components/C_ImageCropper/index.vue
|
|
719
|
-
var C_ImageCropper_default = /* @__PURE__ */ export_helper_default(index_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b25a5839"]]);
|
|
720
|
-
|
|
721
|
-
//#endregion
|
|
722
|
-
export { useCropperCore as n, C_ImageCropper_default as t };
|
|
1
|
+
import{t as e}from"./C_Icon2.js";import{t}from"./export-helper.js";import{NButton as n,NButtonGroup as r,NDivider as i,NModal as a,NSpace as o,NTooltip as s}from"naive-ui";import{Fragment as c,computed as l,createBlock as u,createCommentVNode as d,createElementBlock as f,createElementVNode as p,createTextVNode as m,createVNode as h,defineComponent as g,normalizeClass as _,normalizeStyle as v,onBeforeUnmount as y,onMounted as b,openBlock as x,ref as S,renderList as C,toDisplayString as w,unref as T,watch as E,withCtx as D}from"vue";import{VueCropper as O}from"vue-cropper";function k(e={}){let t=S(null);function n(){t.value?.rotateLeft()}function r(){t.value?.rotateRight()}function i(e){let t=Math.round(e/90),i=t>0?r:n;for(let e=0;e<Math.abs(t);e++)i()}function a(e){t.value?.changeScale(e>0?1:-1)}function o(){let e=t.value?.$refs?.img;if(!e)return;let n=e.style.transform||``;n.includes(`scaleX(-1)`)?e.style.transform=n.replace(`scaleX(-1)`,`scaleX(1)`):e.style.transform=n.replace(/scaleX\([^)]*\)/,``)+` scaleX(-1)`}function s(){let e=t.value?.$refs?.img;if(!e)return;let n=e.style.transform||``;n.includes(`scaleY(-1)`)?e.style.transform=n.replace(`scaleY(-1)`,`scaleY(1)`):e.style.transform=n.replace(/scaleY\([^)]*\)/,``)+` scaleY(-1)`}function c(){t.value?.refresh()}function l(t,n){let r=t,i=n,a=e.maxWidth?.value??0,o=e.maxHeight?.value??0;if(a>0&&r>a){let e=a/r;r=a,i=Math.round(i*e)}if(o>0&&i>o){let e=o/i;i=o,r=Math.round(r*e)}return{width:r,height:i}}function u(){return new Promise((n,r)=>{let i=t.value;if(!i)return r(Error(`Cropper not initialized`));let a=e.format?.value??`png`,o=e.quality?.value??.92,s=a===`jpeg`?`image/jpeg`:a===`webp`?`image/webp`:`image/png`;i.getCropData(e=>{i.getCropBlob(t=>{let i=new Image;i.onload=()=>{let{width:r,height:c}=l(i.width,i.height);if(r!==i.width||c!==i.height){let e=document.createElement(`canvas`);e.width=r,e.height=c,e.getContext(`2d`).drawImage(i,0,0,r,c);let t=e.toDataURL(s,o);e.toBlob(e=>{n({base64:t,blob:e,width:r,height:c,format:a})},s,a===`png`?void 0:o)}else n({base64:e,blob:t,width:i.width,height:i.height,format:a})},i.onerror=()=>r(Error(`Failed to load crop result`)),i.src=e})})})}return{cropperRef:t,rotate:i,rotateLeft:n,rotateRight:r,zoom:a,flipX:o,flipY:s,reset:c,getCropResult:u}}const A={class:`cropper-toolbar`};var j=t(g({__name:`CropperToolbar`,props:{currentRatio:{},ratioPresets:{}},emits:[`ratio`,`rotate`,`flipX`,`flipY`,`zoom`,`reset`],setup(t){return(t,a)=>(x(),f(`div`,A,[h(T(r),{size:`small`},{default:D(()=>[(x(!0),f(c,null,C(t.ratioPresets,e=>(x(),u(T(n),{key:e.value,type:t.currentRatio===e.value?`primary`:`default`,onClick:n=>t.$emit(`ratio`,e.value)},{default:D(()=>[m(w(e.label),1)]),_:2},1032,[`type`,`onClick`]))),128))]),_:1}),h(T(i),{vertical:``}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[0]||=e=>t.$emit(`rotate`,-90)},{icon:D(()=>[h(e,{name:`mdi:rotate-left`})]),_:1})]),default:D(()=>[a[7]||=m(` 逆时针旋转 90° `,-1)]),_:1,__:[7]}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[1]||=e=>t.$emit(`rotate`,90)},{icon:D(()=>[h(e,{name:`mdi:rotate-right`})]),_:1})]),default:D(()=>[a[8]||=m(` 顺时针旋转 90° `,-1)]),_:1,__:[8]}),h(T(i),{vertical:``}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[2]||=e=>t.$emit(`flipX`)},{icon:D(()=>[h(e,{name:`mdi:flip-horizontal`})]),_:1})]),default:D(()=>[a[9]||=m(` 水平翻转 `,-1)]),_:1,__:[9]}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[3]||=e=>t.$emit(`flipY`)},{icon:D(()=>[h(e,{name:`mdi:flip-vertical`})]),_:1})]),default:D(()=>[a[10]||=m(` 垂直翻转 `,-1)]),_:1,__:[10]}),h(T(i),{vertical:``}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[4]||=e=>t.$emit(`zoom`,.1)},{icon:D(()=>[h(e,{name:`mdi:magnify-plus-outline`})]),_:1})]),default:D(()=>[a[11]||=m(` 放大 `,-1)]),_:1,__:[11]}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[5]||=e=>t.$emit(`zoom`,-.1)},{icon:D(()=>[h(e,{name:`mdi:magnify-minus-outline`})]),_:1})]),default:D(()=>[a[12]||=m(` 缩小 `,-1)]),_:1,__:[12]}),h(T(i),{vertical:``}),h(T(s),null,{trigger:D(()=>[h(T(n),{size:`small`,quaternary:``,onClick:a[6]||=e=>t.$emit(`reset`)},{icon:D(()=>[h(e,{name:`mdi:refresh`})]),_:1})]),default:D(()=>[a[13]||=m(` 重置 `,-1)]),_:1,__:[13]})]))}}),[[`__scopeId`,`data-v-ac310c55`]]);const M={class:`cropper-preview`},N={class:`preview-label`},P=[`src`],F={key:1,class:`preview-empty`},I={class:`preview-thumbs`},L=[`src`],R={class:`preview-thumb__label`};var z=t(g({__name:`CropperPreview`,props:{previewData:{},circular:{type:Boolean}},setup(t){let n=t,r=S(null),i=S(200),a=[{label:`80px`,size:80},{label:`48px`,size:48},{label:`32px`,size:32}],o=l(()=>{let e=n.previewData;return e&&e.url&&e.w>0&&e.h>0}),s=l(()=>{if(!o.value)return{};let{w:e}=n.previewData;return{zoom:i.value/e,overflow:`hidden`}});function u(e){if(!o.value)return{};let{w:t}=n.previewData;return{zoom:e/t,overflow:`hidden`}}let m=null;return b(()=>{r.value&&(i.value=r.value.clientWidth,m=new ResizeObserver(e=>{requestAnimationFrame(()=>{for(let t of e)i.value=t.contentRect.width})}),m.observe(r.value))}),y(()=>{m?.disconnect()}),(t,n)=>(x(),f(`div`,M,[p(`div`,N,[h(e,{name:`mdi:eye-outline`}),n[0]||=p(`span`,null,`裁剪预览`,-1)]),p(`div`,{ref_key:`mainBoxRef`,ref:r,class:_([`preview-main`,{"preview-main--circular":t.circular}])},[o.value?(x(),f(`div`,{key:0,class:`preview-main__viewport`,style:v(s.value)},[p(`div`,{style:v(t.previewData.div)},[p(`img`,{src:t.previewData.url,style:v(t.previewData.img),alt:`preview`},null,12,P)],4)],4)):(x(),f(`div`,F,[h(e,{name:`mdi:image-outline`,style:{"font-size":`32px`,opacity:`0.2`}})]))],2),p(`div`,I,[(x(),f(c,null,C(a,e=>p(`div`,{key:e.label,class:`preview-thumb`},[p(`div`,{class:_([`preview-thumb__box`,{"preview-thumb__box--circular":t.circular}]),style:v({width:`${e.size}px`,height:`${e.size}px`})},[o.value?(x(),f(`div`,{key:0,class:`preview-thumb__viewport`,style:v(u(e.size))},[p(`div`,{style:v(t.previewData.div)},[p(`img`,{src:t.previewData.url,style:v(t.previewData.img),alt:`thumb`},null,12,L)],4)],4)):d(`v-if`,!0)],6),p(`span`,R,w(e.label),1)])),64))])]))}}),[[`__scopeId`,`data-v-11f355b4`]]);const B={class:`c-image-cropper__body`},V={class:`c-image-cropper__workspace`},H={key:1,class:`c-image-cropper__placeholder`},U={key:0,class:`c-image-cropper__preview-panel`},W={key:1,class:`c-image-cropper`},G={class:`c-image-cropper__body`},K={class:`c-image-cropper__workspace`},q={key:1,class:`c-image-cropper__placeholder`},ee={key:0,class:`c-image-cropper__preview-panel`};var J=t(g({name:`C_ImageCropper`,__name:`index`,props:{src:{default:``},aspectRatio:{default:0},outputFormat:{default:`png`},outputQuality:{default:.92},maxOutputWidth:{default:0},maxOutputHeight:{default:0},showPreview:{type:Boolean,default:!0},showToolbar:{type:Boolean,default:!0},circular:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},height:{default:`400px`},modal:{type:Boolean,default:!1},modalTitle:{default:`图片裁剪`}},emits:[`crop`,`ready`,`error`,`confirm`,`cancel`],setup(t,{expose:r,emit:i}){let s=t,c=i,g=S(s.src),_=S(s.aspectRatio),y=S(!1),b=S(!1),C=S(null),w=S(null),A=S(null),M=l(()=>s.modal?A.value:w.value),N=l(()=>typeof s.height==`number`?`${s.height}px`:s.height),P=l(()=>({png:`png`,jpeg:`jpeg`,webp:`webp`})[s.outputFormat]||`png`),F=l(()=>_.value>0),I=l(()=>_.value<=0||_.value===1?[1,1]:Math.abs(_.value-16/9)<.01?[16,9]:Math.abs(_.value-4/3)<.01?[4,3]:Math.abs(_.value-3/2)<.01?[3,2]:[Math.round(_.value*100),100]),L=l(()=>({width:300,height:_.value>0?300/_.value:200})),R=[{label:`自由`,value:0},{label:`1:1`,value:1},{label:`16:9`,value:16/9},{label:`4:3`,value:4/3},{label:`3:2`,value:3/2}],J=k({format:l(()=>s.outputFormat),quality:l(()=>s.outputQuality),maxWidth:l(()=>s.maxOutputWidth),maxHeight:l(()=>s.maxOutputHeight)});E(M,e=>{J.cropperRef.value=e});function Y(e){C.value=e}function X(e){e===`success`&&c(`ready`)}function Z(e){J.rotate(e)}function Q(e){_.value=e}function $(){J.reset()}async function te(){b.value=!0;try{let e=await J.getCropResult();c(`confirm`,e),c(`crop`,e),y.value=!1}finally{b.value=!1}}function ne(){y.value=!1,c(`cancel`)}function re(e){let t=new FileReader;t.onload=e=>{g.value=e.target?.result},t.readAsDataURL(e)}return E(()=>s.src,e=>{g.value=e}),E(()=>s.aspectRatio,e=>{_.value=e}),r({getCropResult:J.getCropResult,rotate:J.rotate,zoom:J.zoom,flipX:J.flipX,flipY:J.flipY,reset:J.reset,setAspectRatio:e=>{_.value=e},loadFile:re,open:e=>{e&&(g.value=e),y.value=!0},close:()=>{y.value=!1}}),(t,r)=>s.modal?(x(),u(T(a),{key:0,show:y.value,"onUpdate:show":r[0]||=e=>y.value=e,preset:`card`,title:s.modalTitle||`图片裁剪`,style:{width:`860px`},"mask-closable":!1,closable:!0},{footer:D(()=>[h(T(o),{justify:`end`},{default:D(()=>[h(T(n),{onClick:ne},{default:D(()=>r[2]||=[m(`取消`,-1)]),_:1,__:[2]}),h(T(n),{type:`primary`,loading:b.value,onClick:te},{default:D(()=>r[3]||=[m(`确认裁剪`,-1)]),_:1,__:[3]},8,[`loading`])]),_:1})]),default:D(()=>[p(`div`,B,[s.showToolbar?(x(),u(j,{key:0,"current-ratio":_.value,"ratio-presets":R,onRatio:Q,onRotate:Z,onFlipX:T(J).flipX,onFlipY:T(J).flipY,onZoom:T(J).zoom,onReset:$},null,8,[`current-ratio`,`onFlipX`,`onFlipY`,`onZoom`])):d(`v-if`,!0),p(`div`,V,[p(`div`,{class:`c-image-cropper__canvas`,style:v({height:N.value})},[g.value?(x(),u(T(O),{key:0,ref_key:`modalCropperRef`,ref:A,img:g.value,"output-size":s.outputQuality,"output-type":P.value,"can-scale":!1,"auto-crop":!0,"auto-crop-width":L.value.width,"auto-crop-height":L.value.height,fixed:F.value,"fixed-number":I.value,"center-box":!0,info:!0,"info-true":!0,"can-move":!0,"can-move-box":!0,original:!1,high:!0,full:!1,mode:`contain`,onRealTime:Y,onImgLoad:X},null,8,[`img`,`output-size`,`output-type`,`auto-crop-width`,`auto-crop-height`,`fixed`,`fixed-number`])):(x(),f(`div`,H,[h(e,{name:`mdi:image-plus-outline`,style:{"font-size":`48px`,opacity:`0.3`}}),r[1]||=p(`span`,null,`请选择图片`,-1)]))],4),s.showPreview&&g.value?(x(),f(`div`,U,[h(z,{"preview-data":C.value,circular:s.circular},null,8,[`preview-data`,`circular`])])):d(`v-if`,!0)])])]),_:1},8,[`show`,`title`])):(x(),f(`div`,W,[p(`div`,G,[s.showToolbar?(x(),u(j,{key:0,"current-ratio":_.value,"ratio-presets":R,onRatio:Q,onRotate:Z,onFlipX:T(J).flipX,onFlipY:T(J).flipY,onZoom:T(J).zoom,onReset:$},null,8,[`current-ratio`,`onFlipX`,`onFlipY`,`onZoom`])):d(`v-if`,!0),p(`div`,K,[p(`div`,{class:`c-image-cropper__canvas`,style:v({height:N.value})},[g.value?(x(),u(T(O),{key:0,ref_key:`inlineCropperRef`,ref:w,img:g.value,"output-size":s.outputQuality,"output-type":P.value,"can-scale":!1,"auto-crop":!0,"auto-crop-width":L.value.width,"auto-crop-height":L.value.height,fixed:F.value,"fixed-number":I.value,"center-box":!0,info:!0,"info-true":!0,"can-move":!0,"can-move-box":!0,original:!1,high:!0,full:!1,mode:`contain`,onRealTime:Y,onImgLoad:X},null,8,[`img`,`output-size`,`output-type`,`auto-crop-width`,`auto-crop-height`,`fixed`,`fixed-number`])):(x(),f(`div`,q,[h(e,{name:`mdi:image-plus-outline`,style:{"font-size":`48px`,opacity:`0.3`}}),r[4]||=p(`span`,null,`请选择图片`,-1)]))],4),s.showPreview&&g.value?(x(),f(`div`,ee,[h(z,{"preview-data":C.value,circular:s.circular},null,8,[`preview-data`,`circular`])])):d(`v-if`,!0)])])]))}}),[[`__scopeId`,`data-v-b25a5839`]]);export{k as n,J as t};
|
|
723
2
|
//# sourceMappingURL=C_ImageCropper2.js.map
|