centaline-data-driven 1.4.58 → 1.4.60
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/build/centaline/centaline.path.js +1 -0
- package/package.json +2 -1
- package/src/centaline/dynamicEditPictures/index.js +11 -0
- package/src/centaline/dynamicEditPictures/src/dynamicEditPictures.vue +603 -0
- package/src/centaline/dynamicFile/src/dynamicFile.vue +60 -10
- package/src/centaline/dynamicSearchList/src/dynamicSearchTable.vue +4 -1
- package/src/centaline/dynamicViewerFile/src/dynamicViewerFile.vue +3 -0
- package/src/centaline/loader/src/ctl/File.js +61 -2
- package/src/centaline/loader/src/ctl/SliceUpload.js +1 -1
- package/wwwroot/static/centaline/centaline-data-driven.js +12 -3
- package/wwwroot/static/centaline/centaline-data-driven.js.map +1 -1
|
@@ -56,6 +56,7 @@ const paths = {
|
|
|
56
56
|
"browseIframe": "./src/centaline/browseIframe/index.js", //URL弹层
|
|
57
57
|
"dynamicViewerFile": "./src/centaline/dynamicViewerFile/index.js", //图片预览框组件
|
|
58
58
|
"dynamicDragSort": "./src/centaline/dynamicDragSort/index.js", //上下拖拽排序组件
|
|
59
|
+
"dynamicEditPictures": "./src/centaline/dynamicEditPictures/index.js", //图片编辑组件
|
|
59
60
|
},
|
|
60
61
|
"plugs": {
|
|
61
62
|
"api": "./src/centaline/api/index.js", //调用API插件
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "centaline-data-driven",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.60",
|
|
4
4
|
"description": "ccai",
|
|
5
5
|
"author": "hjc <3226136347@qq.com>",
|
|
6
6
|
"private": false,
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"axios": "^0.24.0",
|
|
16
16
|
"babel-polyfill": "^6.26.0",
|
|
17
17
|
"compression-webpack-plugin": "^2.0.0",
|
|
18
|
+
"cropperjs": "^1.5.13",
|
|
18
19
|
"element-ui": "^2.15.7",
|
|
19
20
|
"module": "^1.2.5",
|
|
20
21
|
"sass": "^1.34.0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import dynamicEditPictures from './src/dynamicEditPictures'
|
|
2
|
+
|
|
3
|
+
dynamicEditPictures.install = function (Vue) {
|
|
4
|
+
Vue.component(dynamicEditPictures.name, dynamicEditPictures);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
8
|
+
window.Vue.use(dynamicEditPictures);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default dynamicEditPictures;
|
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="picedit-modal" style="width:100%; height:100%;background-color: #1e1e1e">
|
|
3
|
+
<div class="picedit-stage">
|
|
4
|
+
<canvas id="drawCanvas" ref="canvas" style="position:absolute;"></canvas>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="picedit-Original" v-if="flagOriginal">
|
|
7
|
+
<el-row>
|
|
8
|
+
<el-button type="success" @click="Original()">原图</el-button>
|
|
9
|
+
</el-row>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="picedit-cropper" v-if="croppShow">
|
|
12
|
+
<el-row>
|
|
13
|
+
<el-button type="success" @click="sureCropper()"><i class="el-icon-check"></i></el-button>
|
|
14
|
+
<el-button type="primary" @click="cancelCropper()"><i class="el-icon-close"></i></el-button>
|
|
15
|
+
</el-row>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="picedit-footer" v-else>
|
|
18
|
+
<div class="picedit-toolbar">
|
|
19
|
+
<a @click="rotLeft" class="magnify-btn" title="左旋转">
|
|
20
|
+
<span class="el-icon-refresh-left"></span>
|
|
21
|
+
</a>
|
|
22
|
+
<a @click="rotRight" class="magnify-btn" title="右旋转">
|
|
23
|
+
<span class="el-icon-refresh-right"></span>
|
|
24
|
+
</a>
|
|
25
|
+
<a @click="Crop" class="magnify-btn" title="裁剪">
|
|
26
|
+
<span class="el-icon-crop"></span>
|
|
27
|
+
</a>
|
|
28
|
+
<a @click="Drag" class="magnify-btn" title="拖动">
|
|
29
|
+
<span class="el-icon-rank"></span>
|
|
30
|
+
</a>
|
|
31
|
+
<a @click="Apply" class="magnify-btn" title="涂抹">
|
|
32
|
+
<span class="el-icon-brush"></span>
|
|
33
|
+
</a>
|
|
34
|
+
<a @click="enlarge" class="magnify-btn" title="放大">
|
|
35
|
+
<span class="el-icon-zoom-in"></span>
|
|
36
|
+
</a>
|
|
37
|
+
<a @click="narrow" class="magnify-btn" title="缩小">
|
|
38
|
+
<span class="el-icon-zoom-out"></span>
|
|
39
|
+
</a>
|
|
40
|
+
<a @click="clear" class="magnify-btn" title="清除">
|
|
41
|
+
<span class="el-icon-refresh"></span>
|
|
42
|
+
</a>
|
|
43
|
+
<a @click="preservation" class="magnify-btn" title="保存">
|
|
44
|
+
<span class="el-icon-check"></span>
|
|
45
|
+
</a>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="stream-total-tips" v-if="progressFlag">
|
|
50
|
+
<el-progress type="circle"
|
|
51
|
+
:percentage="typeof loadProgress !== 'undefined' && loadProgress !== null ? loadProgress : 0.00"
|
|
52
|
+
:width="150" :height="150" class="file-cirle"></el-progress>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="mask" v-if="progressFlag"></div>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
57
|
+
<script>
|
|
58
|
+
import dynamicElement from "../../mixins/dynamicElement";
|
|
59
|
+
import { upload, uploadByPieces } from "../../loader/src/ctl/SliceUpload";
|
|
60
|
+
import Enum from '../../loader/src/ctl/lib/Enum';
|
|
61
|
+
import Cropper from 'cropperjs'
|
|
62
|
+
import 'cropperjs/dist/cropper.min.css'
|
|
63
|
+
export default {
|
|
64
|
+
name: "ct-editpictures",
|
|
65
|
+
mixins: [dynamicElement],
|
|
66
|
+
props: {
|
|
67
|
+
file: Object,
|
|
68
|
+
api: String,
|
|
69
|
+
minWidth: Number,
|
|
70
|
+
minHeight: Number
|
|
71
|
+
},
|
|
72
|
+
data() {
|
|
73
|
+
return {
|
|
74
|
+
flagOriginal: false,
|
|
75
|
+
progressFlag: false,
|
|
76
|
+
loadProgress: 0,
|
|
77
|
+
cropper: null,
|
|
78
|
+
croppShow: false,
|
|
79
|
+
canvas: Object,
|
|
80
|
+
ctx: Object,
|
|
81
|
+
imgObj: Object,
|
|
82
|
+
rot: 0,
|
|
83
|
+
canMove: false,
|
|
84
|
+
PaintMove: false,
|
|
85
|
+
isActive: false,
|
|
86
|
+
tx: 0,
|
|
87
|
+
ty: 0,
|
|
88
|
+
tl: 0,
|
|
89
|
+
tt: 0,
|
|
90
|
+
startX: 0,
|
|
91
|
+
startY: 0,
|
|
92
|
+
nl: 0,
|
|
93
|
+
nt: 0,
|
|
94
|
+
ratio: 0,
|
|
95
|
+
cropBoxResizable: false,
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
computed: {
|
|
99
|
+
|
|
100
|
+
},
|
|
101
|
+
mounted() {
|
|
102
|
+
this.progressFlag = false;
|
|
103
|
+
this.loadProgress = 0;
|
|
104
|
+
if (typeof this.minWidth == 'undefined' || typeof this.minWidth == 'undefined') {
|
|
105
|
+
this.cropBoxResizable = true;
|
|
106
|
+
}
|
|
107
|
+
if (typeof this.file.originalSavedFileName !== 'undefined' && this.file.originalSavedFileName !== this.file.savedFileName) {
|
|
108
|
+
this.flagOriginal = true;
|
|
109
|
+
}
|
|
110
|
+
this.drawCanv();
|
|
111
|
+
},
|
|
112
|
+
methods: {
|
|
113
|
+
drawCanv(href) {
|
|
114
|
+
this.$nextTick(() => {
|
|
115
|
+
let _this = this
|
|
116
|
+
_this.canvas = document.getElementById('drawCanvas');
|
|
117
|
+
_this.ctx = _this.canvas.getContext("2d");
|
|
118
|
+
|
|
119
|
+
_this.canvas.width = 0;
|
|
120
|
+
_this.canvas.height = 0;
|
|
121
|
+
|
|
122
|
+
_this.imgObj = new Image()
|
|
123
|
+
_this.imgObj.src = href||_this.file.mediaUrl;
|
|
124
|
+
_this.imgObj.setAttribute("crossOrigin", 'Anonymous')
|
|
125
|
+
_this.imgObj.onload = function (e) {
|
|
126
|
+
//获取原始宽高
|
|
127
|
+
let naturalWidth = (e.path)[0].naturalWidth
|
|
128
|
+
let naturalHeight = (e.path)[0].naturalHeight
|
|
129
|
+
|
|
130
|
+
_this.canvas.width = naturalWidth;
|
|
131
|
+
_this.canvas.height = naturalHeight;
|
|
132
|
+
_this.ctx.drawImage(_this.imgObj, 0, 0, naturalWidth, naturalHeight)
|
|
133
|
+
|
|
134
|
+
var scale = 1;
|
|
135
|
+
var scalew = 900 / _this.imgObj.width;
|
|
136
|
+
var scaleh = window.document.body.clientHeight / _this.imgObj.height;
|
|
137
|
+
if (scalew < 1 && scaleh < 1) {
|
|
138
|
+
if (scalew < scaleh) {
|
|
139
|
+
scale = scalew;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
scale = scaleh;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (scalew > 1 && scaleh < 1) {
|
|
146
|
+
scale = scaleh;
|
|
147
|
+
}
|
|
148
|
+
else if (scalew < 1 && scaleh > 1) {
|
|
149
|
+
scale = scalew;
|
|
150
|
+
}
|
|
151
|
+
_this.scaleDomSize(_this.canvas, scale);
|
|
152
|
+
}
|
|
153
|
+
this.canvas.addEventListener("pointerdown", _this.startDraw, false);
|
|
154
|
+
this.canvas.addEventListener("pointermove", _this.draw, false);
|
|
155
|
+
this.canvas.addEventListener("pointerup", _this.endDraw, false);
|
|
156
|
+
this.canvas.addEventListener("pointerout", _this.outdraw, false);
|
|
157
|
+
})
|
|
158
|
+
},
|
|
159
|
+
outdraw() {
|
|
160
|
+
this.isActive = false;
|
|
161
|
+
},
|
|
162
|
+
draw(e) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
if (this.isActive && this.PaintMove) {
|
|
165
|
+
var x = e.offsetX || e.layerX - canvas.offsetLeft;
|
|
166
|
+
var y = e.offsetY || e.layerY - canvas.offsetTop;
|
|
167
|
+
var sw = 0;
|
|
168
|
+
var sh = 0;
|
|
169
|
+
var sx = 0;
|
|
170
|
+
var sy = 0;
|
|
171
|
+
|
|
172
|
+
if (x >= this.startX) {
|
|
173
|
+
sw = x - this.startX;
|
|
174
|
+
sx = this.startX;
|
|
175
|
+
}
|
|
176
|
+
else if (x < this.startX) {
|
|
177
|
+
sw = this.startX - x;
|
|
178
|
+
sx = x;
|
|
179
|
+
}
|
|
180
|
+
if (y >= this.startY) {
|
|
181
|
+
sh = y - this.startY;
|
|
182
|
+
sy = this.startY;
|
|
183
|
+
}
|
|
184
|
+
else if (y < this.startY) {
|
|
185
|
+
sh = this.startY - y;
|
|
186
|
+
sy = y;
|
|
187
|
+
}
|
|
188
|
+
if (sw != 0 && sh != 0) {
|
|
189
|
+
var data = this.ctx.getImageData(sx, sy, sw, sh);
|
|
190
|
+
//将图像数据进行高斯模糊 data.data是一个数组,每四个值代表一个像素点的rgba的值,data.width data.height 分别代表图像数据的宽高
|
|
191
|
+
var emptyData = this.gaussBlur(data);
|
|
192
|
+
//将模糊的图像数据再渲染到画布上面
|
|
193
|
+
this.ctx.putImageData(emptyData, sx, sy);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
else if (this.isActive && this.canMove) {
|
|
198
|
+
//获取x和y
|
|
199
|
+
var nx = e.clientX;
|
|
200
|
+
var ny = e.clientY;
|
|
201
|
+
//计算移动后的左偏移量和顶部的偏移量
|
|
202
|
+
this.nl = nx - (this.tx - this.tl);
|
|
203
|
+
this.nt = ny - (this.ty - this.tt);
|
|
204
|
+
this.canvas.style.left = this.nl + 'px';
|
|
205
|
+
this.canvas.style.top = this.nt + 'px';
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
startDraw(e) {
|
|
209
|
+
if (this.canMove) {
|
|
210
|
+
//获取x坐标和y坐标
|
|
211
|
+
this.tx = e.clientX;
|
|
212
|
+
this.ty = e.clientY;
|
|
213
|
+
//获取左部和顶部的偏移量
|
|
214
|
+
this.tl = this.canvas.offsetLeft;
|
|
215
|
+
this.tt = this.canvas.offsetTop;
|
|
216
|
+
//设置样式
|
|
217
|
+
this.canvas.style.cursor = 'move';
|
|
218
|
+
}
|
|
219
|
+
else if (this.PaintMove) {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
this.startX = e.offsetX;
|
|
222
|
+
this.startY = e.offsetY;
|
|
223
|
+
this.ctx.beginPath();
|
|
224
|
+
}
|
|
225
|
+
this.isActive = true;
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
endDraw(e) {
|
|
229
|
+
if (this.canMove) {
|
|
230
|
+
this.canvas.style.cursor = 'default';
|
|
231
|
+
}
|
|
232
|
+
else if (this.PaintMove) {
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
}
|
|
235
|
+
this.isActive = false;
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
enlarge() {
|
|
239
|
+
this.scaleDom(this.canvas, "+");
|
|
240
|
+
},
|
|
241
|
+
narrow() {
|
|
242
|
+
this.scaleDom(this.canvas, "-");
|
|
243
|
+
},
|
|
244
|
+
//放大缩小
|
|
245
|
+
scaleDom(canvas, type) {
|
|
246
|
+
let scale = parseFloat((canvas.style.transform || `scale(1)`).replace(/[^0-9.]/gi, ''))
|
|
247
|
+
if (type == "-") {
|
|
248
|
+
scale += -0.1;
|
|
249
|
+
if ((scale <= 1 && canvas.width > 900) || (scale <= 1 && canvas.height > (window.document.body.clientHeight))) {
|
|
250
|
+
canvas.style.left = - canvas.width * 0.05 * ((1 - scale) * 10) + 'px';
|
|
251
|
+
canvas.style.top = -canvas.height * 0.05 * ((1 - scale) * 10) + 'px';
|
|
252
|
+
}
|
|
253
|
+
} else if (type == "+") {
|
|
254
|
+
scale += 0.1;
|
|
255
|
+
if ((scale <= 1 && canvas.width > 900) || (scale <= 1 && canvas.height > (window.document.body.clientHeight))) {
|
|
256
|
+
canvas.style.left = - canvas.width * 0.05 * ((1 - scale) * 10) + 'px';
|
|
257
|
+
canvas.style.top = -canvas.height * 0.05 * ((1 - scale) * 10) + 'px';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
scale = 1;
|
|
262
|
+
}
|
|
263
|
+
if (scale >= 0.1) canvas.style.transform = `scale(${scale})`;
|
|
264
|
+
|
|
265
|
+
},
|
|
266
|
+
rotLeft() {
|
|
267
|
+
this.rot -= 90;
|
|
268
|
+
if (this.rot === -90) {
|
|
269
|
+
this.rot = 270;
|
|
270
|
+
}
|
|
271
|
+
this.rotate(this.canvas, this.imgObj, this.rot);
|
|
272
|
+
},
|
|
273
|
+
rotRight() {
|
|
274
|
+
this.rot += 90;
|
|
275
|
+
this.rotate(this.canvas, this.imgObj, this.rot);
|
|
276
|
+
if (this.rot === 270) {
|
|
277
|
+
this.rot = -90;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
rotate(canvas, img, rot) {
|
|
281
|
+
//获取图片的高宽
|
|
282
|
+
var w = img.width;
|
|
283
|
+
var h = img.height;
|
|
284
|
+
//角度转为弧度
|
|
285
|
+
if (!rot) {
|
|
286
|
+
rot = 0;
|
|
287
|
+
}
|
|
288
|
+
var rotation = Math.PI * rot / 180;
|
|
289
|
+
var c = Math.round(Math.cos(rotation) * 1000) / 1000;
|
|
290
|
+
var s = Math.round(Math.sin(rotation) * 1000) / 1000;
|
|
291
|
+
//旋转后canvas标签的大小
|
|
292
|
+
canvas.height = Math.abs(c * h) + Math.abs(s * w);
|
|
293
|
+
canvas.width = Math.abs(c * w) + Math.abs(s * h);
|
|
294
|
+
//绘图开始
|
|
295
|
+
var context = canvas.getContext("2d");
|
|
296
|
+
context.save();
|
|
297
|
+
//改变中心点
|
|
298
|
+
if (rotation <= Math.PI / 2) {
|
|
299
|
+
context.translate(s * h, 0);
|
|
300
|
+
} else if (rotation <= Math.PI) {
|
|
301
|
+
context.translate(canvas.width, -c * h);
|
|
302
|
+
} else if (rotation <= 1.5 * Math.PI) {
|
|
303
|
+
context.translate(-c * w, canvas.height);
|
|
304
|
+
} else {
|
|
305
|
+
context.translate(0, -s * w);
|
|
306
|
+
}
|
|
307
|
+
//旋转90°
|
|
308
|
+
context.rotate(rotation);
|
|
309
|
+
//绘制
|
|
310
|
+
context.drawImage(img, 0, 0, w, h);
|
|
311
|
+
context.restore();
|
|
312
|
+
img.style.display = "none";
|
|
313
|
+
},
|
|
314
|
+
Crop() {
|
|
315
|
+
let _this = this
|
|
316
|
+
this.drawCanv()
|
|
317
|
+
this.croppShow = true
|
|
318
|
+
let cropper = new Cropper(this.$refs.canvas, {
|
|
319
|
+
checkCrossOrigin: true,
|
|
320
|
+
viewMode: 1,
|
|
321
|
+
dragMode: 'move',
|
|
322
|
+
cropBoxResizable: _this.cropBoxResizable,
|
|
323
|
+
data: {
|
|
324
|
+
width: this.minWidth || 800,
|
|
325
|
+
height: this.minHeight || 600
|
|
326
|
+
},
|
|
327
|
+
zoom(e) {
|
|
328
|
+
if (_this.ratio == 0) {
|
|
329
|
+
_this.ratio = e.detail.oldRatio
|
|
330
|
+
}
|
|
331
|
+
if (e.detail.ratio > _this.ratio) {
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
})
|
|
336
|
+
this.cropper = cropper
|
|
337
|
+
},
|
|
338
|
+
// 确认裁剪
|
|
339
|
+
sureCropper() {
|
|
340
|
+
let _this = this
|
|
341
|
+
this.cropper.getCroppedCanvas().toBlob(function (blob) {
|
|
342
|
+
const href = window.URL.createObjectURL(blob)
|
|
343
|
+
_this.drawCanv(href)
|
|
344
|
+
}, 'image/jpeg')
|
|
345
|
+
this.cancelCropper()
|
|
346
|
+
},
|
|
347
|
+
// 销毁裁剪框
|
|
348
|
+
cancelCropper() {
|
|
349
|
+
this.cropper.destroy()
|
|
350
|
+
this.croppShow = false
|
|
351
|
+
this.cropper = null
|
|
352
|
+
},
|
|
353
|
+
Original() {
|
|
354
|
+
var url = this.file.mediaUrl.replace(this.file.savedFileName, this.file.originalSavedFileName);
|
|
355
|
+
this.drawCanv(url);
|
|
356
|
+
},
|
|
357
|
+
Drag() {
|
|
358
|
+
this.canMove = true;
|
|
359
|
+
this.PaintMove = false;
|
|
360
|
+
},
|
|
361
|
+
Apply() {
|
|
362
|
+
this.PaintMove = true;
|
|
363
|
+
this.canMove = false;
|
|
364
|
+
},
|
|
365
|
+
clear() {
|
|
366
|
+
this.drawCanv();
|
|
367
|
+
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
368
|
+
this.canvas.style.left = '0px';
|
|
369
|
+
this.canvas.style.top = '0px';
|
|
370
|
+
this.rot = 0;
|
|
371
|
+
this.nl = 0;
|
|
372
|
+
this.nt = 0;
|
|
373
|
+
this.scaleDom(this.canvas, "");
|
|
374
|
+
this.rotate(this.canvas, this.imgObj, this.rot);
|
|
375
|
+
},
|
|
376
|
+
scaleDomSize(canvas, scale) {
|
|
377
|
+
if ((scale <= 1 && canvas.width > 900) || (scale <= 1 && canvas.height > (window.document.body.clientHeight))) {
|
|
378
|
+
canvas.style.left = - canvas.width * 0.05 * ((1 - scale) * 10) + 'px';
|
|
379
|
+
canvas.style.top = -canvas.height * 0.05 * ((1 - scale) * 10) + 'px';
|
|
380
|
+
}
|
|
381
|
+
if (scale >= 0.1) canvas.style.transform = `scale(${scale})`;
|
|
382
|
+
},
|
|
383
|
+
async preservation() {
|
|
384
|
+
this.progressFlag = true;
|
|
385
|
+
this.loadProgress = 0;
|
|
386
|
+
var url = this.canvas.toDataURL('image/jpeg');
|
|
387
|
+
var files = this.convertBase64UrlToFile(url, this.file.fileName);
|
|
388
|
+
// data是上传时附带的额外参数,file是文件
|
|
389
|
+
let uid = this.uploadguid();
|
|
390
|
+
try {
|
|
391
|
+
files.uid = uid;
|
|
392
|
+
const res = await uploadByPieces(this.api, files, this.uploadpro, files.size);
|
|
393
|
+
return res;
|
|
394
|
+
|
|
395
|
+
} catch (e) {
|
|
396
|
+
return e;
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
uploadpro(filesize, res, xhr, flagError) {
|
|
400
|
+
if (flagError) {
|
|
401
|
+
this.$message.error(res);
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
else if (xhr.status == 200) {
|
|
405
|
+
if (res.rtnCode != 200 && res.rtnMsg != "") {
|
|
406
|
+
this.$message.error(res.rtnMsg);
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
const Progress = Math.min(100, Math.floor(1E4 * parseInt(res.content.nextOffSet) / parseInt(filesize)) / 100);
|
|
410
|
+
|
|
411
|
+
this.progressFlag = true;
|
|
412
|
+
this.loadProgress = Progress;
|
|
413
|
+
|
|
414
|
+
if (res.content.finished == 1) {
|
|
415
|
+
this.loadProgress = 100;
|
|
416
|
+
this.progressFlag = false;
|
|
417
|
+
this.file.mediaUrl = res.content.media.mediaUrl;
|
|
418
|
+
this.file.savedFileName = res.content.media.savedFileName;
|
|
419
|
+
this.file.mediaDate = res.content.media.mediaDate;
|
|
420
|
+
this.$emit('handleEditPhoto', this.file);
|
|
421
|
+
}
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
S4() {
|
|
426
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
427
|
+
},
|
|
428
|
+
uploadguid() {
|
|
429
|
+
return (this.S4() + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + this.S4() + this.S4());
|
|
430
|
+
},
|
|
431
|
+
convertBase64UrlToFile(urlData, filename) {
|
|
432
|
+
const bytes = window.atob(urlData.split(',')[1]); // 去掉url的头,并转换为byte // 处理异常,将ascii码小于0的转换为大于0
|
|
433
|
+
const ab = new ArrayBuffer(bytes.length);
|
|
434
|
+
const ia = new Uint8Array(ab);
|
|
435
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
436
|
+
ia[i] = bytes.charCodeAt(i);
|
|
437
|
+
}
|
|
438
|
+
return new File([ab], filename, { type: 'image/' + this.file.fileExtension });
|
|
439
|
+
},
|
|
440
|
+
gaussBlur(imgData) {
|
|
441
|
+
var pixes = imgData.data;
|
|
442
|
+
var width = imgData.width;
|
|
443
|
+
var height = imgData.height;
|
|
444
|
+
var gaussMatrix = [],
|
|
445
|
+
gaussSum = 0,
|
|
446
|
+
x, y,
|
|
447
|
+
r, g, b, a,
|
|
448
|
+
i, j, k, len;
|
|
449
|
+
var radius = Math.floor(this.imgObj.width / 100);
|
|
450
|
+
if (radius < 10) {
|
|
451
|
+
radius = 10;
|
|
452
|
+
}
|
|
453
|
+
var sigma = Math.floor(radius / 3);
|
|
454
|
+
|
|
455
|
+
a = 1 / (Math.sqrt(2 * Math.PI) * sigma);
|
|
456
|
+
b = -1 / (2 * sigma * sigma);
|
|
457
|
+
//生成高斯矩阵
|
|
458
|
+
for (i = 0, x = -radius; x <= radius; x++, i++) {
|
|
459
|
+
g = a * Math.exp(b * x * x);
|
|
460
|
+
gaussMatrix[i] = g;
|
|
461
|
+
gaussSum += g;
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
//归一化, 保证高斯矩阵的值在[0,1]之间
|
|
466
|
+
for (i = 0, len = gaussMatrix.length; i < len; i++) {
|
|
467
|
+
gaussMatrix[i] /= gaussSum;
|
|
468
|
+
}
|
|
469
|
+
//x 方向一维高斯运算
|
|
470
|
+
for (y = 0; y < height; y++) {
|
|
471
|
+
for (x = 0; x < width; x++) {
|
|
472
|
+
r = g = b = a = 0;
|
|
473
|
+
gaussSum = 0;
|
|
474
|
+
for (j = -radius; j <= radius; j++) {
|
|
475
|
+
k = x + j;
|
|
476
|
+
if (k >= 0 && k < width) {//确保 k 没超出 x 的范围
|
|
477
|
+
//r,g,b,a 四个一组
|
|
478
|
+
i = (y * width + k) * 4;
|
|
479
|
+
r += pixes[i] * gaussMatrix[j + radius];
|
|
480
|
+
g += pixes[i + 1] * gaussMatrix[j + radius];
|
|
481
|
+
b += pixes[i + 2] * gaussMatrix[j + radius];
|
|
482
|
+
// a += pixes[i + 3] * gaussMatrix[j];
|
|
483
|
+
gaussSum += gaussMatrix[j + radius];
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
i = (y * width + x) * 4;
|
|
487
|
+
// 除以 gaussSum 是为了消除处于边缘的像素, 高斯运算不足的问题
|
|
488
|
+
pixes[i] = r / gaussSum;
|
|
489
|
+
pixes[i + 1] = g / gaussSum;
|
|
490
|
+
pixes[i + 2] = b / gaussSum;
|
|
491
|
+
// pixes[i + 3] = a ;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
//y 方向一维高斯运算
|
|
495
|
+
for (x = 0; x < width; x++) {
|
|
496
|
+
for (y = 0; y < height; y++) {
|
|
497
|
+
r = g = b = a = 0;
|
|
498
|
+
gaussSum = 0;
|
|
499
|
+
for (j = -radius; j <= radius; j++) {
|
|
500
|
+
k = y + j;
|
|
501
|
+
if (k >= 0 && k < height) {//确保 k 没超出 y 的范围
|
|
502
|
+
i = (k * width + x) * 4;
|
|
503
|
+
r += pixes[i] * gaussMatrix[j + radius];
|
|
504
|
+
g += pixes[i + 1] * gaussMatrix[j + radius];
|
|
505
|
+
b += pixes[i + 2] * gaussMatrix[j + radius];
|
|
506
|
+
// a += pixes[i + 3] * gaussMatrix[j];
|
|
507
|
+
gaussSum += gaussMatrix[j + radius];
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
i = (y * width + x) * 4;
|
|
511
|
+
pixes[i] = r / gaussSum;
|
|
512
|
+
pixes[i + 1] = g / gaussSum;
|
|
513
|
+
pixes[i + 2] = b / gaussSum;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return imgData;
|
|
517
|
+
},
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
</script>
|
|
521
|
+
<style>
|
|
522
|
+
.picedit-stage {
|
|
523
|
+
position: absolute;
|
|
524
|
+
left: 0;
|
|
525
|
+
right: 0;
|
|
526
|
+
bottom: 0;
|
|
527
|
+
top: 50px;
|
|
528
|
+
border: none;
|
|
529
|
+
overflow: hidden;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
.picedit-footer {
|
|
533
|
+
height: 50px;
|
|
534
|
+
bottom: 0;
|
|
535
|
+
position: absolute;
|
|
536
|
+
width: 100%;
|
|
537
|
+
text-align: center;
|
|
538
|
+
color: #fff;
|
|
539
|
+
z-index: 9;
|
|
540
|
+
}
|
|
541
|
+
.picedit-cropper {
|
|
542
|
+
height: 50px;
|
|
543
|
+
bottom: 0;
|
|
544
|
+
position: absolute;
|
|
545
|
+
width: 100%;
|
|
546
|
+
text-align: center;
|
|
547
|
+
color: #fff;
|
|
548
|
+
z-index: 9;
|
|
549
|
+
}
|
|
550
|
+
.picedit-Original {
|
|
551
|
+
height: 50px;
|
|
552
|
+
top: 50px;
|
|
553
|
+
right: 20px;
|
|
554
|
+
position: absolute;
|
|
555
|
+
color: #fff;
|
|
556
|
+
z-index: 9;
|
|
557
|
+
}
|
|
558
|
+
.picedit-toolbar {
|
|
559
|
+
display: inline-block;
|
|
560
|
+
height: 50px;
|
|
561
|
+
background-color: rgba(0, 0, 0, .5);
|
|
562
|
+
-webkit-border-radius: 5px 5px 0 0;
|
|
563
|
+
-moz-border-radius: 5px 5px 0 0;
|
|
564
|
+
border-radius: 5px 5px 0 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.picedit-toolbar .magnify-btn {
|
|
568
|
+
display: inline-block;
|
|
569
|
+
width: 50px;
|
|
570
|
+
height: 50px;
|
|
571
|
+
margin: 0;
|
|
572
|
+
color: #999;
|
|
573
|
+
line-height: 50px;
|
|
574
|
+
color: #ffffff;
|
|
575
|
+
font-size: 24px;
|
|
576
|
+
cursor: pointer;
|
|
577
|
+
}
|
|
578
|
+
.rc-cropper {
|
|
579
|
+
position: relative;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.rc-cropper__iconCrop1 {
|
|
583
|
+
position: absolute;
|
|
584
|
+
right: 4%;
|
|
585
|
+
top: 0%;
|
|
586
|
+
}
|
|
587
|
+
.mask {
|
|
588
|
+
position: fixed;
|
|
589
|
+
z-index: 9998;
|
|
590
|
+
top: 0;
|
|
591
|
+
right: 0;
|
|
592
|
+
bottom: 0;
|
|
593
|
+
left: 0;
|
|
594
|
+
background-color: rgba(0, 0, 0, .3);
|
|
595
|
+
}
|
|
596
|
+
.stream-total-tips {
|
|
597
|
+
position: fixed;
|
|
598
|
+
top: 40%;
|
|
599
|
+
left: 40%;
|
|
600
|
+
z-index: 9999;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
</style>
|