@robot-admin/naive-ui-components 0.3.0
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/README.md +257 -0
- package/dist/C_ActionBar-DWN-woTc.css.map +1 -0
- package/dist/C_ActionBar.cjs +5 -0
- package/dist/C_ActionBar.d.cts +2 -0
- package/dist/C_ActionBar.d.ts +2 -0
- package/dist/C_ActionBar.js +4 -0
- package/dist/C_ActionBar2.js +196 -0
- package/dist/C_ActionBar2.js.map +1 -0
- package/dist/C_AntV-AFKyK6hH.css.map +1 -0
- package/dist/C_AntV.cjs +8 -0
- package/dist/C_AntV.d.cts +2 -0
- package/dist/C_AntV.d.ts +2 -0
- package/dist/C_AntV.js +4 -0
- package/dist/C_AntV2.js +3150 -0
- package/dist/C_AntV2.js.map +1 -0
- package/dist/C_Barcode-P_EFj8dC.css.map +1 -0
- package/dist/C_Barcode.cjs +4 -0
- package/dist/C_Barcode.d.cts +2 -0
- package/dist/C_Barcode.d.ts +2 -0
- package/dist/C_Barcode.js +3 -0
- package/dist/C_Barcode2.js +68 -0
- package/dist/C_Barcode2.js.map +1 -0
- package/dist/C_Captcha-C-ef41xw.css.map +1 -0
- package/dist/C_Captcha.cjs +4 -0
- package/dist/C_Captcha.d.cts +2 -0
- package/dist/C_Captcha.d.ts +2 -0
- package/dist/C_Captcha.js +3 -0
- package/dist/C_Captcha2.js +155 -0
- package/dist/C_Captcha2.js.map +1 -0
- package/dist/C_Cascade-D9kNsjsV.css.map +1 -0
- package/dist/C_Cascade.cjs +4 -0
- package/dist/C_Cascade.d.cts +2 -0
- package/dist/C_Cascade.d.ts +2 -0
- package/dist/C_Cascade.js +3 -0
- package/dist/C_Cascade2.js +103 -0
- package/dist/C_Cascade2.js.map +1 -0
- package/dist/C_City-BCQ4ipiK.css.map +1 -0
- package/dist/C_City.cjs +4 -0
- package/dist/C_City.d.cts +2 -0
- package/dist/C_City.d.ts +2 -0
- package/dist/C_City.js +3 -0
- package/dist/C_City2.js +841 -0
- package/dist/C_City2.js.map +1 -0
- package/dist/C_Code-C9kvvEmO.css.map +1 -0
- package/dist/C_Code.cjs +5 -0
- package/dist/C_Code.d.cts +2 -0
- package/dist/C_Code.d.ts +2 -0
- package/dist/C_Code.js +4 -0
- package/dist/C_Code2.js +346 -0
- package/dist/C_Code2.js.map +1 -0
- package/dist/C_CollapsePanel-BUJHuYcU.css.map +1 -0
- package/dist/C_CollapsePanel.cjs +6 -0
- package/dist/C_CollapsePanel.d.cts +2 -0
- package/dist/C_CollapsePanel.d.ts +2 -0
- package/dist/C_CollapsePanel.js +4 -0
- package/dist/C_CollapsePanel2.js +319 -0
- package/dist/C_CollapsePanel2.js.map +1 -0
- package/dist/C_Cron-yx2Ob4Jl.css.map +1 -0
- package/dist/C_Cron.cjs +15 -0
- package/dist/C_Cron.d.cts +2 -0
- package/dist/C_Cron.d.ts +2 -0
- package/dist/C_Cron.js +4 -0
- package/dist/C_Cron2.js +1209 -0
- package/dist/C_Cron2.js.map +1 -0
- package/dist/C_Date.cjs +4 -0
- package/dist/C_Date.d.cts +2 -0
- package/dist/C_Date.d.ts +2 -0
- package/dist/C_Date.js +3 -0
- package/dist/C_Date2.js +219 -0
- package/dist/C_Date2.js.map +1 -0
- package/dist/C_Draggable-C483syRC.css.map +1 -0
- package/dist/C_Draggable.cjs +5 -0
- package/dist/C_Draggable.d.cts +2 -0
- package/dist/C_Draggable.d.ts +2 -0
- package/dist/C_Draggable.js +3 -0
- package/dist/C_Draggable2.js +295 -0
- package/dist/C_Draggable2.js.map +1 -0
- package/dist/C_Editor-Bp0SyIEw.css.map +1 -0
- package/dist/C_Editor.cjs +4 -0
- package/dist/C_Editor.d.cts +2 -0
- package/dist/C_Editor.d.ts +2 -0
- package/dist/C_Editor.js +3 -0
- package/dist/C_Editor2.js +160 -0
- package/dist/C_Editor2.js.map +1 -0
- package/dist/C_FilePreview-CPqvhoCy.css.map +1 -0
- package/dist/C_FilePreview.cjs +6 -0
- package/dist/C_FilePreview.d.cts +2 -0
- package/dist/C_FilePreview.d.ts +2 -0
- package/dist/C_FilePreview.js +3 -0
- package/dist/C_FilePreview2.js +1031 -0
- package/dist/C_FilePreview2.js.map +1 -0
- package/dist/C_Form-Jx7PY3sT.css.map +1 -0
- package/dist/C_Form.cjs +15 -0
- package/dist/C_Form.d.cts +2 -0
- package/dist/C_Form.d.ts +2 -0
- package/dist/C_Form.js +4 -0
- package/dist/C_Form2.js +2510 -0
- package/dist/C_Form2.js.map +1 -0
- package/dist/C_FormSearch-DvRgxlRn.css.map +1 -0
- package/dist/C_FormSearch.cjs +6 -0
- package/dist/C_FormSearch.d.cts +2 -0
- package/dist/C_FormSearch.d.ts +2 -0
- package/dist/C_FormSearch.js +3 -0
- package/dist/C_FormSearch2.js +356 -0
- package/dist/C_FormSearch2.js.map +1 -0
- package/dist/C_FormulaEditor-DtGkt4T_.css.map +1 -0
- package/dist/C_FormulaEditor.cjs +13 -0
- package/dist/C_FormulaEditor.d.cts +2 -0
- package/dist/C_FormulaEditor.d.ts +2 -0
- package/dist/C_FormulaEditor.js +4 -0
- package/dist/C_FormulaEditor2.js +1433 -0
- package/dist/C_FormulaEditor2.js.map +1 -0
- package/dist/C_FullCalendar-BF7H0YIx.css.map +1 -0
- package/dist/C_FullCalendar.cjs +9 -0
- package/dist/C_FullCalendar.d.cts +2 -0
- package/dist/C_FullCalendar.d.ts +2 -0
- package/dist/C_FullCalendar.js +3 -0
- package/dist/C_FullCalendar2.js +377 -0
- package/dist/C_FullCalendar2.js.map +1 -0
- package/dist/C_Guide.cjs +4 -0
- package/dist/C_Guide.d.cts +2 -0
- package/dist/C_Guide.d.ts +2 -0
- package/dist/C_Guide.js +3 -0
- package/dist/C_Guide2.js +58 -0
- package/dist/C_Guide2.js.map +1 -0
- package/dist/C_Icon.cjs +4 -0
- package/dist/C_Icon.d.cts +2 -0
- package/dist/C_Icon.d.ts +2 -0
- package/dist/C_Icon.js +3 -0
- package/dist/C_Icon2.js +286 -0
- package/dist/C_Icon2.js.map +1 -0
- package/dist/C_ImageCropper-BVJfUufl.css.map +1 -0
- package/dist/C_ImageCropper.cjs +6 -0
- package/dist/C_ImageCropper.d.cts +2 -0
- package/dist/C_ImageCropper.d.ts +2 -0
- package/dist/C_ImageCropper.js +4 -0
- package/dist/C_ImageCropper2.js +723 -0
- package/dist/C_ImageCropper2.js.map +1 -0
- package/dist/C_Language.cjs +4 -0
- package/dist/C_Language.d.cts +2 -0
- package/dist/C_Language.d.ts +2 -0
- package/dist/C_Language.js +3 -0
- package/dist/C_Language2.js +72 -0
- package/dist/C_Language2.js.map +1 -0
- package/dist/C_Map-DpzeuWdX.css.map +1 -0
- package/dist/C_Map.cjs +7 -0
- package/dist/C_Map.d.cts +2 -0
- package/dist/C_Map.d.ts +2 -0
- package/dist/C_Map.js +3 -0
- package/dist/C_Map2.js +199 -0
- package/dist/C_Map2.js.map +1 -0
- package/dist/C_Markdown-BEjxknqd.css.map +1 -0
- package/dist/C_Markdown.cjs +4 -0
- package/dist/C_Markdown.d.cts +2 -0
- package/dist/C_Markdown.d.ts +2 -0
- package/dist/C_Markdown.js +3 -0
- package/dist/C_Markdown2.js +186 -0
- package/dist/C_Markdown2.js.map +1 -0
- package/dist/C_NotificationCenter-0l3TY2Gn.css.map +1 -0
- package/dist/C_NotificationCenter.cjs +20 -0
- package/dist/C_NotificationCenter.d.cts +2 -0
- package/dist/C_NotificationCenter.d.ts +2 -0
- package/dist/C_NotificationCenter.js +4 -0
- package/dist/C_NotificationCenter2.js +1383 -0
- package/dist/C_NotificationCenter2.js.map +1 -0
- package/dist/C_Progress.cjs +4 -0
- package/dist/C_Progress.d.cts +2 -0
- package/dist/C_Progress.d.ts +2 -0
- package/dist/C_Progress.js +3 -0
- package/dist/C_Progress2.js +103 -0
- package/dist/C_Progress2.js.map +1 -0
- package/dist/C_QRCode-DbdiAIPg.css.map +1 -0
- package/dist/C_QRCode.cjs +5 -0
- package/dist/C_QRCode.d.cts +2 -0
- package/dist/C_QRCode.d.ts +2 -0
- package/dist/C_QRCode.js +3 -0
- package/dist/C_QRCode2.js +218 -0
- package/dist/C_QRCode2.js.map +1 -0
- package/dist/C_Signature-zhHCbra9.css.map +1 -0
- package/dist/C_Signature.cjs +8 -0
- package/dist/C_Signature.d.cts +2 -0
- package/dist/C_Signature.d.ts +2 -0
- package/dist/C_Signature.js +4 -0
- package/dist/C_Signature2.js +618 -0
- package/dist/C_Signature2.js.map +1 -0
- package/dist/C_SplitPane-C6sBsfKY.css.map +1 -0
- package/dist/C_SplitPane.cjs +6 -0
- package/dist/C_SplitPane.d.cts +2 -0
- package/dist/C_SplitPane.d.ts +2 -0
- package/dist/C_SplitPane.js +4 -0
- package/dist/C_SplitPane2.js +356 -0
- package/dist/C_SplitPane2.js.map +1 -0
- package/dist/C_Steps-CODHN5Hs.css.map +1 -0
- package/dist/C_Steps.cjs +4 -0
- package/dist/C_Steps.d.cts +2 -0
- package/dist/C_Steps.d.ts +2 -0
- package/dist/C_Steps.js +3 -0
- package/dist/C_Steps2.js +82 -0
- package/dist/C_Steps2.js.map +1 -0
- package/dist/C_Table-DSNsntmT.css.map +1 -0
- package/dist/C_Table.cjs +19 -0
- package/dist/C_Table.d.cts +2 -0
- package/dist/C_Table.d.ts +2 -0
- package/dist/C_Table.js +5 -0
- package/dist/C_Table2.js +3009 -0
- package/dist/C_Table2.js.map +1 -0
- package/dist/C_Theme.cjs +4 -0
- package/dist/C_Theme.d.cts +2 -0
- package/dist/C_Theme.d.ts +2 -0
- package/dist/C_Theme.js +3 -0
- package/dist/C_Theme2.js +60 -0
- package/dist/C_Theme2.js.map +1 -0
- package/dist/C_Time-BvZLYraL.css.map +1 -0
- package/dist/C_Time.cjs +5 -0
- package/dist/C_Time.d.cts +2 -0
- package/dist/C_Time.d.ts +2 -0
- package/dist/C_Time.js +3 -0
- package/dist/C_Time2.js +199 -0
- package/dist/C_Time2.js.map +1 -0
- package/dist/C_Tree-0GDv--jX.css.map +1 -0
- package/dist/C_Tree.cjs +7 -0
- package/dist/C_Tree.d.cts +2 -0
- package/dist/C_Tree.d.ts +2 -0
- package/dist/C_Tree.js +4 -0
- package/dist/C_Tree2.js +441 -0
- package/dist/C_Tree2.js.map +1 -0
- package/dist/C_Upload-BXd3YYLx.css.map +1 -0
- package/dist/C_Upload.cjs +12 -0
- package/dist/C_Upload.d.cts +2 -0
- package/dist/C_Upload.d.ts +2 -0
- package/dist/C_Upload.js +4 -0
- package/dist/C_Upload2.js +1388 -0
- package/dist/C_Upload2.js.map +1 -0
- package/dist/C_VideoPlayer-DYG3RL0Q.css.map +1 -0
- package/dist/C_VideoPlayer.cjs +23 -0
- package/dist/C_VideoPlayer.d.cts +2 -0
- package/dist/C_VideoPlayer.d.ts +2 -0
- package/dist/C_VideoPlayer.js +3 -0
- package/dist/C_VideoPlayer2.js +1932 -0
- package/dist/C_VideoPlayer2.js.map +1 -0
- package/dist/C_VtableGantt-fhItIiHE.css.map +1 -0
- package/dist/C_VtableGantt.cjs +6 -0
- package/dist/C_VtableGantt.d.cts +2 -0
- package/dist/C_VtableGantt.d.ts +2 -0
- package/dist/C_VtableGantt.js +4 -0
- package/dist/C_VtableGantt2.js +873 -0
- package/dist/C_VtableGantt2.js.map +1 -0
- package/dist/C_WaterFall-8sQDFXKg.css.map +1 -0
- package/dist/C_WaterFall.cjs +13 -0
- package/dist/C_WaterFall.d.cts +2 -0
- package/dist/C_WaterFall.d.ts +2 -0
- package/dist/C_WaterFall.js +3 -0
- package/dist/C_WaterFall2.js +365 -0
- package/dist/C_WaterFall2.js.map +1 -0
- package/dist/C_WorkFlow-J-dyIuh9.css.map +1 -0
- package/dist/C_WorkFlow.cjs +8 -0
- package/dist/C_WorkFlow.d.cts +2 -0
- package/dist/C_WorkFlow.d.ts +2 -0
- package/dist/C_WorkFlow.js +4 -0
- package/dist/C_WorkFlow2.js +1984 -0
- package/dist/C_WorkFlow2.js.map +1 -0
- package/dist/chunk.js +22 -0
- package/dist/city.js +4817 -0
- package/dist/city.js.map +1 -0
- package/dist/constants.d.ts +273 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants2.d.ts +178 -0
- package/dist/constants2.d.ts.map +1 -0
- package/dist/constants3.d.ts +475 -0
- package/dist/constants3.d.ts.map +1 -0
- package/dist/constants4.d.ts +430 -0
- package/dist/constants4.d.ts.map +1 -0
- package/dist/constants5.d.ts +4283 -0
- package/dist/constants5.d.ts.map +1 -0
- package/dist/data.d.ts +67 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/export-helper.js +9 -0
- package/dist/index.cjs +409 -0
- package/dist/index.d.cts +96 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +230 -0
- package/dist/index.js.map +1 -0
- package/dist/index.vue.d.ts +80 -0
- package/dist/index.vue.d.ts.map +1 -0
- package/dist/index10.vue.d.ts +72 -0
- package/dist/index10.vue.d.ts.map +1 -0
- package/dist/index11.vue.d.ts +26 -0
- package/dist/index11.vue.d.ts.map +1 -0
- package/dist/index12.vue.d.ts +81 -0
- package/dist/index12.vue.d.ts.map +1 -0
- package/dist/index13.vue.d.ts +55 -0
- package/dist/index13.vue.d.ts.map +1 -0
- package/dist/index14.vue.d.ts +33 -0
- package/dist/index14.vue.d.ts.map +1 -0
- package/dist/index15.vue.d.ts +18 -0
- package/dist/index15.vue.d.ts.map +1 -0
- package/dist/index16.vue.d.ts +662 -0
- package/dist/index16.vue.d.ts.map +1 -0
- package/dist/index2.vue.d.ts +38 -0
- package/dist/index2.vue.d.ts.map +1 -0
- package/dist/index3.vue.d.ts +45 -0
- package/dist/index3.vue.d.ts.map +1 -0
- package/dist/index4.vue.d.ts +31 -0
- package/dist/index4.vue.d.ts.map +1 -0
- package/dist/index5.vue.d.ts +35 -0
- package/dist/index5.vue.d.ts.map +1 -0
- package/dist/index6.vue.d.ts +48 -0
- package/dist/index6.vue.d.ts.map +1 -0
- package/dist/index7.vue.d.ts +56 -0
- package/dist/index7.vue.d.ts.map +1 -0
- package/dist/index8.vue.d.ts +41 -0
- package/dist/index8.vue.d.ts.map +1 -0
- package/dist/index9.vue.d.ts +30 -0
- package/dist/index9.vue.d.ts.map +1 -0
- package/dist/storage.js +31 -0
- package/dist/storage.js.map +1 -0
- package/dist/style.css +7725 -0
- package/dist/useCalendarEvents.d.ts +148 -0
- package/dist/useCalendarEvents.d.ts.map +1 -0
- package/dist/useCollapsePanel.d.ts +132 -0
- package/dist/useCollapsePanel.d.ts.map +1 -0
- package/dist/useCropperCore.d.ts +102 -0
- package/dist/useCropperCore.d.ts.map +1 -0
- package/dist/useDraggableLayout.d.ts +194 -0
- package/dist/useDraggableLayout.d.ts.map +1 -0
- package/dist/useDynamicFormState.d.ts +4248 -0
- package/dist/useDynamicFormState.d.ts.map +1 -0
- package/dist/useEdgeInteraction.d.ts +7614 -0
- package/dist/useEdgeInteraction.d.ts.map +1 -0
- package/dist/useFullscreen.d.ts +166 -0
- package/dist/useFullscreen.d.ts.map +1 -0
- package/dist/useInfiniteScroll.d.ts +169 -0
- package/dist/useInfiniteScroll.d.ts.map +1 -0
- package/dist/useModalEdit.d.ts +960 -0
- package/dist/useModalEdit.d.ts.map +1 -0
- package/dist/useQRCode.d.ts +87 -0
- package/dist/useQRCode.d.ts.map +1 -0
- package/dist/useSearchState.d.ts +180 -0
- package/dist/useSearchState.d.ts.map +1 -0
- package/dist/useSignatureHistory.d.ts +189 -0
- package/dist/useSignatureHistory.d.ts.map +1 -0
- package/dist/useSplitResize.d.ts +158 -0
- package/dist/useSplitResize.d.ts.map +1 -0
- package/dist/useTimeSelection.d.ts +105 -0
- package/dist/useTimeSelection.d.ts.map +1 -0
- package/dist/useTreeOperations.d.ts +183 -0
- package/dist/useTreeOperations.d.ts.map +1 -0
- package/dist/useWorkflowValidation.d.ts +1052 -0
- package/dist/useWorkflowValidation.d.ts.map +1 -0
- package/package.json +342 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { t as C_Icon_default } from "./C_Icon2.js";
|
|
2
|
+
import { t as export_helper_default } from "./export-helper.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, toDisplayString, unref, watch, withCtx } from "vue";
|
|
4
|
+
import { NButton, NButtonGroup, NDivider, NModal, NSpace, NTooltip } from "naive-ui";
|
|
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-499ffd01"]]);
|
|
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-cefefdc0"]]);
|
|
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-692ad231"]]);
|
|
720
|
+
|
|
721
|
+
//#endregion
|
|
722
|
+
export { useCropperCore as n, C_ImageCropper_default as t };
|
|
723
|
+
//# sourceMappingURL=C_ImageCropper2.js.map
|