@cmstops/pro-compo 0.1.14 → 0.1.15
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/gif.worker.js +3 -0
- package/dist/index.css +469 -1
- package/dist/index.min.css +1 -1
- package/es/contentDetailList/component.js +1 -2
- package/es/contentDetailList/components/Content/CompoItem/index.js +1 -2
- package/es/contentDetailList/components/Content/ContentListItem/index.js +1 -2
- package/es/contentDetailList/components/Content/DocItem/ApprovalStateMap/index.js +1 -2
- package/es/contentDetailList/components/Content/DocItem/index.js +1 -2
- package/es/contentDetailList/components/Content/KongoNavItem/index.js +1 -2
- package/es/contentDetailList/components/Content/LiveItem/index.js +1 -2
- package/es/contentDetailList/components/Content/MaccountItem/index.js +1 -2
- package/es/contentDetailList/components/Content/index.js +1 -2
- package/es/contentDetailList/components/Doc/index.js +1 -2
- package/es/contentModal/component.js +1 -2
- package/es/contentModal/components/CompoList/CompoFilter/index.js +2 -3
- package/es/contentModal/components/CompoList/index.js +2 -3
- package/es/contentModal/components/ViewAllColumn/MediaFilter/index.js +1 -2
- package/es/contentModal/components/ViewAllColumn/columnTree/index.js +1 -2
- package/es/contentModal/components/ViewAllColumn/index.js +1 -2
- package/es/contentModal/components/storeBox/index.js +1 -2
- package/es/gif.worker.js +3 -0
- package/es/hooks/assets.d.ts +1 -0
- package/es/hooks/assets.js +9 -0
- package/es/hooks/user.d.ts +1 -3
- package/es/imageCrop/component.d.ts +0 -0
- package/es/imageCrop/component.js +472 -0
- package/es/imageCrop/index.d.ts +2 -0
- package/es/imageCrop/index.js +7 -0
- package/es/imageCrop/script/api.d.ts +1 -0
- package/es/imageCrop/script/api.js +11 -0
- package/es/imageCrop/style/cropper.less +291 -0
- package/es/imageCrop/style/css.js +1 -0
- package/es/imageCrop/style/imageCropper.less +133 -0
- package/es/imageCrop/style/index.css +366 -0
- package/es/imageCrop/style/index.d.ts +1 -0
- package/es/imageCrop/style/index.js +1 -0
- package/es/imageCrop/style/index.less +2 -0
- package/es/index.css +469 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/index.less +2 -0
- package/es/mediaFilter/component.js +1 -2
- package/es/mediaFilter/components/DocFilter.js +1 -2
- package/es/messageBox/list.js +1 -2
- package/es/previousVersion/component.js +1 -2
- package/es/resourceModal/component.js +4 -7
- package/es/resourceModal/components/MediaPreviewer/index.js +1 -2
- package/es/resourceModal/components/MediaSelection/DocAiMediaSelected/index.js +10 -19
- package/es/resourceModal/components/MediaSelection/MainContent/FileTypeThumb/index.js +4 -9
- package/es/resourceModal/components/MediaSelection/MainContent/index.js +7 -15
- package/es/resourceModal/components/MediaSelection/ToolbarSearch/index.js +1 -2
- package/es/resourceModal/components/MediaSelection/index.js +8 -12
- package/es/selectAvatarList/component.js +1 -2
- package/es/selectGategory/component.js +1 -2
- package/es/selectGategory/components/ColumnSelection/index.js +1 -2
- package/es/selectThumb/component.d.ts +0 -0
- package/es/selectThumb/component.js +410 -0
- package/es/selectThumb/components/card.d.ts +0 -0
- package/es/selectThumb/components/card.js +86 -0
- package/es/selectThumb/components/colorPalette.d.ts +0 -0
- package/es/selectThumb/components/colorPalette.js +75 -0
- package/es/selectThumb/index.d.ts +2 -0
- package/es/selectThumb/index.js +7 -0
- package/es/selectThumb/style/card.less +79 -0
- package/es/selectThumb/style/colorPalette.less +0 -0
- package/es/selectThumb/style/css.js +1 -0
- package/es/selectThumb/style/index.css +101 -0
- package/es/selectThumb/style/index.d.ts +1 -0
- package/es/selectThumb/style/index.js +1 -0
- package/es/selectThumb/style/index.less +27 -0
- package/es/uploadBefore/component.js +2 -3
- package/es/uploadBefore/components/UploadBefore.js +1 -2
- package/es/uploadBefore/components/UploadForClick.js +1 -2
- package/es/uploadStep/component.js +2 -3
- package/es/userDirector/component.js +1 -2
- package/es/userDirector/components/userTree.js +1 -2
- package/es/userDirector/style/index.css +2 -1
- package/es/userDirector/style/index.less +2 -1
- package/es/utils/doc.js +30 -7
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +6 -1
- package/es/utils/tusUpload.d.ts +1 -1
- package/es/utils/tusUpload.js +1 -1
- package/es/utils/uploadCatalog.d.ts +1 -0
- package/lib/contentDetailList/component.js +1 -2
- package/lib/contentDetailList/components/Content/CompoItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/ContentListItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/DocItem/ApprovalStateMap/index.js +1 -2
- package/lib/contentDetailList/components/Content/DocItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/KongoNavItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/LiveItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/MaccountItem/index.js +1 -2
- package/lib/contentDetailList/components/Content/index.js +1 -2
- package/lib/contentDetailList/components/Doc/index.js +1 -2
- package/lib/contentModal/component.js +1 -2
- package/lib/contentModal/components/CompoList/CompoFilter/index.js +2 -3
- package/lib/contentModal/components/CompoList/index.js +2 -3
- package/lib/contentModal/components/ViewAllColumn/MediaFilter/index.js +1 -2
- package/lib/contentModal/components/ViewAllColumn/columnTree/index.js +1 -2
- package/lib/contentModal/components/ViewAllColumn/index.js +1 -2
- package/lib/contentModal/components/storeBox/index.js +1 -2
- package/lib/hooks/assets.js +11 -0
- package/lib/imageCrop/component.js +479 -0
- package/lib/imageCrop/index.js +8 -0
- package/lib/imageCrop/script/api.js +13 -0
- package/lib/imageCrop/style/cropper.less +291 -0
- package/lib/imageCrop/style/css.js +2 -0
- package/lib/imageCrop/style/imageCropper.less +133 -0
- package/lib/imageCrop/style/index.css +366 -0
- package/lib/imageCrop/style/index.js +2 -0
- package/lib/imageCrop/style/index.less +2 -0
- package/lib/index.css +469 -1
- package/lib/index.js +16 -12
- package/lib/index.less +2 -0
- package/lib/mediaFilter/component.js +1 -2
- package/lib/mediaFilter/components/DocFilter.js +1 -2
- package/lib/messageBox/list.js +1 -2
- package/lib/previousVersion/component.js +1 -2
- package/lib/resourceModal/component.js +4 -7
- package/lib/resourceModal/components/MediaPreviewer/index.js +1 -2
- package/lib/resourceModal/components/MediaSelection/DocAiMediaSelected/index.js +10 -19
- package/lib/resourceModal/components/MediaSelection/MainContent/FileTypeThumb/index.js +4 -9
- package/lib/resourceModal/components/MediaSelection/MainContent/index.js +7 -15
- package/lib/resourceModal/components/MediaSelection/ToolbarSearch/index.js +1 -2
- package/lib/resourceModal/components/MediaSelection/index.js +8 -12
- package/lib/selectAvatarList/component.js +1 -2
- package/lib/selectGategory/component.js +1 -2
- package/lib/selectGategory/components/ColumnSelection/index.js +1 -2
- package/lib/selectThumb/component.js +411 -0
- package/lib/selectThumb/components/card.js +87 -0
- package/lib/selectThumb/components/colorPalette.js +76 -0
- package/lib/selectThumb/index.js +8 -0
- package/lib/selectThumb/style/card.less +79 -0
- package/lib/selectThumb/style/colorPalette.less +0 -0
- package/lib/selectThumb/style/css.js +2 -0
- package/lib/selectThumb/style/index.css +101 -0
- package/lib/selectThumb/style/index.js +2 -0
- package/lib/selectThumb/style/index.less +27 -0
- package/lib/uploadBefore/component.js +2 -3
- package/lib/uploadBefore/components/UploadBefore.js +1 -2
- package/lib/uploadBefore/components/UploadForClick.js +1 -2
- package/lib/uploadStep/component.js +2 -3
- package/lib/userDirector/component.js +1 -2
- package/lib/userDirector/components/userTree.js +1 -2
- package/lib/userDirector/style/index.css +2 -1
- package/lib/userDirector/style/index.less +2 -1
- package/lib/utils/doc.js +31 -6
- package/lib/utils/index.js +6 -0
- package/lib/utils/tusUpload.js +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, resolveDirective, openBlock, createBlock, unref, withCtx, createTextVNode, toDisplayString, createElementVNode, createVNode, withDirectives, vShow, createElementBlock, normalizeClass, createCommentVNode, Fragment, renderList } from "vue";
|
|
2
|
+
import { Modal, Tooltip, Button, Space } from "@arco-design/web-vue";
|
|
3
|
+
import { IconZoomIn, IconZoomOut, IconRotateLeft, IconRotateRight, IconSync } from "@arco-design/web-vue/es/icon";
|
|
4
|
+
import Cropper from "cropperjs";
|
|
5
|
+
import ColorThief from "colorthief";
|
|
6
|
+
import { GifToCanvas } from "gif-to-canvas";
|
|
7
|
+
import GIF from "gif.js/dist/gif";
|
|
8
|
+
import { uploadByTUS } from "../utils/tusUpload.js";
|
|
9
|
+
import { DEFAULT_BASE_API } from "../config.js";
|
|
10
|
+
import { replaceSuffix } from "../utils/index.js";
|
|
11
|
+
import { getFileRealUrl } from "./script/api.js";
|
|
12
|
+
import { useGenerateAssets } from "../hooks/assets.js";
|
|
13
|
+
const _hoisted_1 = { class: "image-cropper" };
|
|
14
|
+
const _hoisted_2 = { class: "edit-cropper" };
|
|
15
|
+
const _hoisted_3 = ["src"];
|
|
16
|
+
const _hoisted_4 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "tool"
|
|
19
|
+
};
|
|
20
|
+
const _hoisted_5 = ["onClick"];
|
|
21
|
+
const _hoisted_6 = {
|
|
22
|
+
key: 1,
|
|
23
|
+
class: "tool"
|
|
24
|
+
};
|
|
25
|
+
const _hoisted_7 = ["onClick"];
|
|
26
|
+
const _hoisted_8 = { class: "image-crop-modal-footer" };
|
|
27
|
+
const _hoisted_9 = { class: "left" };
|
|
28
|
+
const _hoisted_10 = { class: "right" };
|
|
29
|
+
const _sfc_main = defineComponent({
|
|
30
|
+
__name: "component",
|
|
31
|
+
props: {
|
|
32
|
+
BASE_API: {},
|
|
33
|
+
visible: { type: Boolean },
|
|
34
|
+
aspectRatioProp: {},
|
|
35
|
+
corpData: {},
|
|
36
|
+
userInfo: {},
|
|
37
|
+
generateAssets: { type: Boolean }
|
|
38
|
+
},
|
|
39
|
+
emits: ["update:visible", "confirm"],
|
|
40
|
+
setup(__props, { emit }) {
|
|
41
|
+
const props = __props;
|
|
42
|
+
const BASE_API = props.BASE_API || DEFAULT_BASE_API;
|
|
43
|
+
const saveLoading = ref(false);
|
|
44
|
+
const editImage = ref("");
|
|
45
|
+
const setVisible = (bool) => {
|
|
46
|
+
emit("update:visible", bool);
|
|
47
|
+
};
|
|
48
|
+
const cancelDialog = () => {
|
|
49
|
+
setVisible(false);
|
|
50
|
+
};
|
|
51
|
+
const croppering = ref(true);
|
|
52
|
+
const aspectRatioList = [
|
|
53
|
+
{ label: "\u81EA\u7531", value: null },
|
|
54
|
+
{ label: "1:1", value: 1 / 1 },
|
|
55
|
+
{ label: "4:3", value: 4 / 3 },
|
|
56
|
+
{ label: "3:4", value: 3 / 4 },
|
|
57
|
+
{ label: "16:9", value: 16 / 9 },
|
|
58
|
+
{ label: "9:16", value: 9 / 16 }
|
|
59
|
+
];
|
|
60
|
+
const customizedAspectRatioList = ref([]);
|
|
61
|
+
const aspectRatioActive = ref(null);
|
|
62
|
+
const mosaicObj = ref(null);
|
|
63
|
+
const cropperIndex = ref(0);
|
|
64
|
+
const selectedData = ref([]);
|
|
65
|
+
const loadImage = () => {
|
|
66
|
+
};
|
|
67
|
+
const getBase64 = (imgUrl) => {
|
|
68
|
+
window.URL = window.URL || window.webkitURL;
|
|
69
|
+
const xhr = new XMLHttpRequest();
|
|
70
|
+
xhr.open("get", imgUrl, true);
|
|
71
|
+
xhr.responseType = "blob";
|
|
72
|
+
xhr.send();
|
|
73
|
+
xhr.onload = function() {
|
|
74
|
+
if (xhr.status === 200) {
|
|
75
|
+
const blob = xhr.response;
|
|
76
|
+
const oFileReader = new FileReader();
|
|
77
|
+
oFileReader.onloadend = (e) => {
|
|
78
|
+
const base64 = e.target.result;
|
|
79
|
+
editImage.value = base64;
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
if (props.aspectRatioProp) {
|
|
82
|
+
if (Array.isArray(props.aspectRatioProp)) {
|
|
83
|
+
cropper(props.aspectRatioProp[0], 0);
|
|
84
|
+
} else {
|
|
85
|
+
cropper(props.aspectRatioProp, null);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, 300);
|
|
89
|
+
};
|
|
90
|
+
oFileReader.onerror = (e) => {
|
|
91
|
+
};
|
|
92
|
+
oFileReader.readAsDataURL(blob);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const cropper = (aspectRatio, index) => {
|
|
97
|
+
const image = document.getElementById("cropper_img");
|
|
98
|
+
aspectRatioActive.value = index;
|
|
99
|
+
cropperDestroy();
|
|
100
|
+
mosaicObj.value = new Cropper(image, {
|
|
101
|
+
crop() {
|
|
102
|
+
croppering.value = false;
|
|
103
|
+
},
|
|
104
|
+
initialAspectRatio: aspectRatio,
|
|
105
|
+
aspectRatio,
|
|
106
|
+
touchDragZoom: false,
|
|
107
|
+
autoCropArea: 1,
|
|
108
|
+
rotatable: true,
|
|
109
|
+
strict: false,
|
|
110
|
+
guides: false
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const cropperZoom = (ratio) => {
|
|
114
|
+
mosaicObj.value.zoom(ratio);
|
|
115
|
+
};
|
|
116
|
+
const cropperRotate = (degree) => {
|
|
117
|
+
mosaicObj.value.rotate(degree);
|
|
118
|
+
};
|
|
119
|
+
const cropperReset = () => {
|
|
120
|
+
mosaicObj.value.reset();
|
|
121
|
+
};
|
|
122
|
+
const cropperDestroy = () => {
|
|
123
|
+
mosaicObj.value && mosaicObj.value.destroy();
|
|
124
|
+
};
|
|
125
|
+
const dataURLtoBlob = (dataurl) => {
|
|
126
|
+
const arr = dataurl.split(",");
|
|
127
|
+
const mime = arr[0].match(/:(.*?);/)[1];
|
|
128
|
+
const bstr = atob(arr[1]);
|
|
129
|
+
let n = bstr.length;
|
|
130
|
+
const u8arr = new Uint8Array(n);
|
|
131
|
+
while (n--) {
|
|
132
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
133
|
+
}
|
|
134
|
+
return new Blob([u8arr], { type: mime });
|
|
135
|
+
};
|
|
136
|
+
const save = () => {
|
|
137
|
+
saveLoading.value = true;
|
|
138
|
+
if (mosaicObj.value) {
|
|
139
|
+
if (mosaicObj.value.url.includes("data:image/gif")) {
|
|
140
|
+
const url = URL.createObjectURL(dataURLtoBlob(mosaicObj.value.url));
|
|
141
|
+
const cropBoxData = mosaicObj.value.getCropBoxData();
|
|
142
|
+
const canvasData = mosaicObj.value.getCanvasData();
|
|
143
|
+
const gifToCanvas = new GifToCanvas(url, {
|
|
144
|
+
targetOffset: {
|
|
145
|
+
dx: cropBoxData.left - canvasData.left,
|
|
146
|
+
dy: cropBoxData.top - canvasData.top,
|
|
147
|
+
width: canvasData.width,
|
|
148
|
+
height: canvasData.height,
|
|
149
|
+
sWidth: cropBoxData.width,
|
|
150
|
+
sHeight: cropBoxData.height
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
gifToCanvas.init();
|
|
154
|
+
let gifWorker = "";
|
|
155
|
+
if (window.location.href.includes("localhost")) {
|
|
156
|
+
gifWorker = "./gif.worker.js";
|
|
157
|
+
} else {
|
|
158
|
+
gifWorker = `${BASE_API}/static/js/gif.worker.js`;
|
|
159
|
+
}
|
|
160
|
+
const gifObj = new GIF({
|
|
161
|
+
workers: 4,
|
|
162
|
+
quality: 10,
|
|
163
|
+
width: cropBoxData.width,
|
|
164
|
+
height: cropBoxData.height,
|
|
165
|
+
workerScript: gifWorker
|
|
166
|
+
});
|
|
167
|
+
const addFrame = (canvas, delay) => {
|
|
168
|
+
gifObj.addFrame(canvas, { copy: true, delay });
|
|
169
|
+
};
|
|
170
|
+
gifToCanvas.on("progress", (canvas, delay) => {
|
|
171
|
+
addFrame(canvas, delay);
|
|
172
|
+
});
|
|
173
|
+
gifToCanvas.on("finished", (canvas, delay) => {
|
|
174
|
+
addFrame(canvas, delay);
|
|
175
|
+
gifObj.render();
|
|
176
|
+
});
|
|
177
|
+
gifObj.on("finished", function(blob) {
|
|
178
|
+
handleUploadCropData(blob, "gif");
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
const CroppedCanvas = mosaicObj.value.getCroppedCanvas({});
|
|
182
|
+
CroppedCanvas.toBlob(
|
|
183
|
+
async (blob) => {
|
|
184
|
+
handleUploadCropData(blob, "png");
|
|
185
|
+
},
|
|
186
|
+
"image/jpeg",
|
|
187
|
+
0.75
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
saveLoading.value = false;
|
|
192
|
+
if (selectedData.value.length === cropperIndex.value + 1) {
|
|
193
|
+
emit("confirm", JSON.parse(JSON.stringify(selectedData.value)));
|
|
194
|
+
cancelDialog();
|
|
195
|
+
} else {
|
|
196
|
+
cropperIndex.value += 1;
|
|
197
|
+
cropperDestroy();
|
|
198
|
+
getMediaRealUrl();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const getUploadFileUrl = (file) => {
|
|
203
|
+
const pattern = /\+.*$/;
|
|
204
|
+
const result = file.url.replace(pattern, "").replace("upload", "static");
|
|
205
|
+
return { url: result, size: file.size || file.file.size };
|
|
206
|
+
};
|
|
207
|
+
const handleUploadCropData = async (blob, fileType) => {
|
|
208
|
+
const themeColors = getThemeColor();
|
|
209
|
+
const name = `\u88C1\u5207\u526F\u672C${new Date().getTime()}.${fileType}`;
|
|
210
|
+
const file = new File([blob], name, { type: blob.type });
|
|
211
|
+
const result = await uploadByTUS(file);
|
|
212
|
+
const resImg = getUploadFileUrl(result);
|
|
213
|
+
if (!props.generateAssets) {
|
|
214
|
+
afterCropperAndUploadFile({
|
|
215
|
+
url: resImg.url,
|
|
216
|
+
banner_theme_color: themeColors
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (props.userInfo) {
|
|
221
|
+
const param = {
|
|
222
|
+
url: resImg.url,
|
|
223
|
+
size: resImg.size,
|
|
224
|
+
alias: replaceSuffix(
|
|
225
|
+
selectedData.value[cropperIndex.value].alias,
|
|
226
|
+
"\u88C1\u5207\u526F\u672C"
|
|
227
|
+
),
|
|
228
|
+
repository_id: props.userInfo.repository_id,
|
|
229
|
+
directory_id: selectedData.value[cropperIndex.value].directory_id,
|
|
230
|
+
banner_theme_color: themeColors
|
|
231
|
+
};
|
|
232
|
+
useGenerateAssets(BASE_API, param).then((response) => {
|
|
233
|
+
response.message.banner_theme_color = themeColors;
|
|
234
|
+
afterCropperAndUploadFile(response.message);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const afterCropperAndUploadFile = (data) => {
|
|
239
|
+
selectedData.value[cropperIndex.value] = { ...data };
|
|
240
|
+
saveLoading.value = false;
|
|
241
|
+
if (selectedData.value.length === cropperIndex.value + 1) {
|
|
242
|
+
emit("confirm", JSON.parse(JSON.stringify(selectedData.value)));
|
|
243
|
+
cancelDialog();
|
|
244
|
+
} else {
|
|
245
|
+
cropperIndex.value += 1;
|
|
246
|
+
cropperDestroy();
|
|
247
|
+
getMediaRealUrl();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const getThemeColor = () => {
|
|
251
|
+
const colorThief = new ColorThief();
|
|
252
|
+
const img = document.getElementById("cropper_img");
|
|
253
|
+
let themeColors = [];
|
|
254
|
+
const Palette = colorThief.getPalette(img);
|
|
255
|
+
if (Palette) {
|
|
256
|
+
themeColors = Palette.slice(0, 8);
|
|
257
|
+
} else {
|
|
258
|
+
themeColors = [[255, 255, 255]];
|
|
259
|
+
}
|
|
260
|
+
return themeColors;
|
|
261
|
+
};
|
|
262
|
+
const getMediaRealUrl = () => {
|
|
263
|
+
const item = selectedData.value[cropperIndex.value];
|
|
264
|
+
const flag = !item.url.includes("/poplar/v2");
|
|
265
|
+
const cape = item.url.includes("cape/v1/upload");
|
|
266
|
+
croppering.value = true;
|
|
267
|
+
getBase64(item.url);
|
|
268
|
+
if (item.realUrl && flag || cape) {
|
|
269
|
+
getBase64(item.url);
|
|
270
|
+
} else {
|
|
271
|
+
getFileRealUrl(BASE_API, item.url).then((res) => {
|
|
272
|
+
getBase64(res.message);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
watch(
|
|
277
|
+
() => props.visible,
|
|
278
|
+
(newVal) => {
|
|
279
|
+
if (newVal) {
|
|
280
|
+
init();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
const init = () => {
|
|
285
|
+
cropperIndex.value = 0;
|
|
286
|
+
selectedData.value = props.corpData;
|
|
287
|
+
if (props.aspectRatioProp && Array.isArray(props.aspectRatioProp)) {
|
|
288
|
+
const aspectRatioLists = aspectRatioList.map((item) => {
|
|
289
|
+
item.buttonIndex = cropperIndex.value++;
|
|
290
|
+
return item;
|
|
291
|
+
}).filter((item) => {
|
|
292
|
+
return props.aspectRatioProp.includes(item.value);
|
|
293
|
+
});
|
|
294
|
+
if (aspectRatioLists.length) {
|
|
295
|
+
customizedAspectRatioList.value = aspectRatioLists;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
getMediaRealUrl();
|
|
299
|
+
};
|
|
300
|
+
return (_ctx, _cache) => {
|
|
301
|
+
const _directive_loading = resolveDirective("loading");
|
|
302
|
+
return openBlock(), createBlock(unref(Modal), {
|
|
303
|
+
visible: _ctx.visible,
|
|
304
|
+
width: "986px",
|
|
305
|
+
"mask-closable": false,
|
|
306
|
+
"title-align": "center",
|
|
307
|
+
"unmount-on-close": "",
|
|
308
|
+
"modal-class": "image-crop-modal-wrapper",
|
|
309
|
+
"body-class": "image-crop-modal-body"
|
|
310
|
+
}, {
|
|
311
|
+
title: withCtx(() => [
|
|
312
|
+
createTextVNode(toDisplayString(_ctx.aspectRatioProp ? "\u88C1\u526A\u56FE\u7247" : "\u8BF7\u9009\u62E9\u88C1\u526A\u6BD4\u4F8B"), 1)
|
|
313
|
+
]),
|
|
314
|
+
footer: withCtx(() => [
|
|
315
|
+
createElementVNode("span", _hoisted_8, [
|
|
316
|
+
createElementVNode("div", _hoisted_9, [
|
|
317
|
+
createVNode(unref(Tooltip), { content: "\u653E\u5927" }, {
|
|
318
|
+
default: withCtx(() => [
|
|
319
|
+
createVNode(unref(Button), {
|
|
320
|
+
class: "cropper-btn",
|
|
321
|
+
shape: "circle",
|
|
322
|
+
onClick: _cache[0] || (_cache[0] = ($event) => cropperZoom(0.1))
|
|
323
|
+
}, {
|
|
324
|
+
default: withCtx(() => [
|
|
325
|
+
createVNode(unref(IconZoomIn))
|
|
326
|
+
]),
|
|
327
|
+
_: 1
|
|
328
|
+
})
|
|
329
|
+
]),
|
|
330
|
+
_: 1
|
|
331
|
+
}),
|
|
332
|
+
createVNode(unref(Tooltip), { content: "\u7F29\u5C0F" }, {
|
|
333
|
+
default: withCtx(() => [
|
|
334
|
+
createVNode(unref(Button), {
|
|
335
|
+
class: "cropper-btn",
|
|
336
|
+
shape: "circle",
|
|
337
|
+
onClick: _cache[1] || (_cache[1] = ($event) => cropperZoom(-0.1))
|
|
338
|
+
}, {
|
|
339
|
+
default: withCtx(() => [
|
|
340
|
+
createVNode(unref(IconZoomOut))
|
|
341
|
+
]),
|
|
342
|
+
_: 1
|
|
343
|
+
})
|
|
344
|
+
]),
|
|
345
|
+
_: 1
|
|
346
|
+
}),
|
|
347
|
+
createVNode(unref(Tooltip), { content: "\u5411\u5DE6\u65CB\u8F6C45\u5EA6" }, {
|
|
348
|
+
default: withCtx(() => [
|
|
349
|
+
createVNode(unref(Button), {
|
|
350
|
+
class: "cropper-btn",
|
|
351
|
+
shape: "circle",
|
|
352
|
+
onClick: _cache[2] || (_cache[2] = ($event) => cropperRotate(-45))
|
|
353
|
+
}, {
|
|
354
|
+
default: withCtx(() => [
|
|
355
|
+
createVNode(unref(IconRotateLeft))
|
|
356
|
+
]),
|
|
357
|
+
_: 1
|
|
358
|
+
})
|
|
359
|
+
]),
|
|
360
|
+
_: 1
|
|
361
|
+
}),
|
|
362
|
+
createVNode(unref(Tooltip), { content: "\u5411\u53F3\u65CB\u8F6C45\u5EA6" }, {
|
|
363
|
+
default: withCtx(() => [
|
|
364
|
+
createVNode(unref(Button), {
|
|
365
|
+
class: "cropper-btn",
|
|
366
|
+
shape: "circle",
|
|
367
|
+
onClick: _cache[3] || (_cache[3] = ($event) => cropperRotate(45))
|
|
368
|
+
}, {
|
|
369
|
+
default: withCtx(() => [
|
|
370
|
+
createVNode(unref(IconRotateRight))
|
|
371
|
+
]),
|
|
372
|
+
_: 1
|
|
373
|
+
})
|
|
374
|
+
]),
|
|
375
|
+
_: 1
|
|
376
|
+
}),
|
|
377
|
+
createVNode(unref(Tooltip), { content: "\u91CD\u7F6E" }, {
|
|
378
|
+
default: withCtx(() => [
|
|
379
|
+
createVNode(unref(Button), {
|
|
380
|
+
class: "cropper-btn",
|
|
381
|
+
shape: "circle",
|
|
382
|
+
onClick: cropperReset
|
|
383
|
+
}, {
|
|
384
|
+
default: withCtx(() => [
|
|
385
|
+
createVNode(unref(IconSync))
|
|
386
|
+
]),
|
|
387
|
+
_: 1
|
|
388
|
+
})
|
|
389
|
+
]),
|
|
390
|
+
_: 1
|
|
391
|
+
})
|
|
392
|
+
]),
|
|
393
|
+
createElementVNode("div", _hoisted_10, [
|
|
394
|
+
createVNode(unref(Space), null, {
|
|
395
|
+
default: withCtx(() => [
|
|
396
|
+
createVNode(unref(Button), {
|
|
397
|
+
size: "medium",
|
|
398
|
+
onClick: cancelDialog
|
|
399
|
+
}, {
|
|
400
|
+
default: withCtx(() => [
|
|
401
|
+
createTextVNode("\u53D6\u6D88")
|
|
402
|
+
]),
|
|
403
|
+
_: 1
|
|
404
|
+
}),
|
|
405
|
+
withDirectives(createVNode(unref(Button), {
|
|
406
|
+
size: "medium",
|
|
407
|
+
type: "primary",
|
|
408
|
+
loading: saveLoading.value,
|
|
409
|
+
onClick: save
|
|
410
|
+
}, {
|
|
411
|
+
default: withCtx(() => [
|
|
412
|
+
createTextVNode("\u88C1\u526A")
|
|
413
|
+
]),
|
|
414
|
+
_: 1
|
|
415
|
+
}, 8, ["loading"]), [
|
|
416
|
+
[vShow, !croppering.value]
|
|
417
|
+
])
|
|
418
|
+
]),
|
|
419
|
+
_: 1
|
|
420
|
+
})
|
|
421
|
+
])
|
|
422
|
+
])
|
|
423
|
+
]),
|
|
424
|
+
default: withCtx(() => [
|
|
425
|
+
createElementVNode("div", _hoisted_1, [
|
|
426
|
+
withDirectives((openBlock(), createElementBlock("div", {
|
|
427
|
+
class: normalizeClass(["edit", {
|
|
428
|
+
fullHeight: _ctx.aspectRatioProp && !Array.isArray(_ctx.aspectRatioProp)
|
|
429
|
+
}])
|
|
430
|
+
}, [
|
|
431
|
+
createElementVNode("div", _hoisted_2, [
|
|
432
|
+
editImage.value ? (openBlock(), createElementBlock("img", {
|
|
433
|
+
key: 0,
|
|
434
|
+
id: "cropper_img",
|
|
435
|
+
class: "position",
|
|
436
|
+
crossorigin: "anonymous",
|
|
437
|
+
src: editImage.value,
|
|
438
|
+
onLoad: loadImage
|
|
439
|
+
}, null, 40, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
440
|
+
])
|
|
441
|
+
], 2)), [
|
|
442
|
+
[_directive_loading, croppering.value]
|
|
443
|
+
]),
|
|
444
|
+
!_ctx.aspectRatioProp ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
445
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(aspectRatioList, (item, i) => {
|
|
446
|
+
return createElementVNode("div", {
|
|
447
|
+
key: item.lable,
|
|
448
|
+
class: normalizeClass(["btn btn" + (i + 1), { active: aspectRatioActive.value === i }]),
|
|
449
|
+
onClick: ($event) => cropper(item.value, i)
|
|
450
|
+
}, toDisplayString(item.label), 11, _hoisted_5);
|
|
451
|
+
}), 64))
|
|
452
|
+
])) : createCommentVNode("v-if", true),
|
|
453
|
+
_ctx.aspectRatioProp && Array.isArray(_ctx.aspectRatioProp) && customizedAspectRatioList.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
454
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(customizedAspectRatioList.value, (item, i) => {
|
|
455
|
+
return openBlock(), createElementBlock("div", {
|
|
456
|
+
key: item.lable,
|
|
457
|
+
class: normalizeClass([
|
|
458
|
+
"btn btn" + (item.buttonIndex + 1),
|
|
459
|
+
{ active: aspectRatioActive.value === i }
|
|
460
|
+
]),
|
|
461
|
+
onClick: ($event) => cropper(item.value, i)
|
|
462
|
+
}, toDisplayString(item.label), 11, _hoisted_7);
|
|
463
|
+
}), 128))
|
|
464
|
+
])) : createCommentVNode("v-if", true)
|
|
465
|
+
])
|
|
466
|
+
]),
|
|
467
|
+
_: 1
|
|
468
|
+
}, 8, ["visible"]);
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileRealUrl(BASE_API: string, url: string): import("axios").AxiosPromise<any>;
|