dpzvc-ui 1.0.0 → 1.1.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 +1 -1
- package/build-style.js +0 -24
- package/dist/dpzvc.js +9004 -13095
- package/dist/dpzvc.js.map +1 -0
- package/dist/dpzvc.min.js +2 -0
- package/dist/dpzvc.min.js.map +1 -0
- package/dist-prod/968.b06f8ff038ced2ac25a8.js +3 -0
- package/dist-prod/968.b06f8ff038ced2ac25a8.js.LICENSE.txt +5 -0
- package/dist-prod/968.b06f8ff038ced2ac25a8.js.map +1 -0
- package/dist-prod/actionsheet.6c90edde5704622a1342.chunk.js +2 -0
- package/dist-prod/actionsheet.6c90edde5704622a1342.chunk.js.map +1 -0
- package/dist-prod/badge.c84c021f3e486ef7d942.chunk.js +2 -0
- package/dist-prod/badge.c84c021f3e486ef7d942.chunk.js.map +1 -0
- package/dist-prod/button.367cc8c72a5fe6ab23f9.chunk.js +2 -0
- package/dist-prod/button.367cc8c72a5fe6ab23f9.chunk.js.map +1 -0
- package/dist-prod/card.9408612c4388b6dfa16c.chunk.js +2 -0
- package/dist-prod/card.9408612c4388b6dfa16c.chunk.js.map +1 -0
- package/dist-prod/cell.9a4993caa97ef40ff5c1.chunk.js +2 -0
- package/dist-prod/cell.9a4993caa97ef40ff5c1.chunk.js.map +1 -0
- package/dist-prod/cellswipe.2f66e4563a8b0ea4e66a.chunk.js +2 -0
- package/dist-prod/cellswipe.2f66e4563a8b0ea4e66a.chunk.js.map +1 -0
- package/dist-prod/checkbox.bfb070917fbd916b9246.chunk.js +2 -0
- package/dist-prod/checkbox.bfb070917fbd916b9246.chunk.js.map +1 -0
- package/dist-prod/guide.92857dbbd3214f172073.chunk.js +2 -0
- package/dist-prod/guide.92857dbbd3214f172073.chunk.js.map +1 -0
- package/dist-prod/header.ad70269632b1900dc1f0.chunk.js +2 -0
- package/dist-prod/header.ad70269632b1900dc1f0.chunk.js.map +1 -0
- package/dist-prod/index.html +19 -26
- package/dist-prod/indicator.791ff82f539499ebcc6b.chunk.js +2 -0
- package/dist-prod/indicator.791ff82f539499ebcc6b.chunk.js.map +1 -0
- package/dist-prod/loadmore.766550bbcff49be9ca23.chunk.js +2 -0
- package/dist-prod/loadmore.766550bbcff49be9ca23.chunk.js.map +1 -0
- package/dist-prod/main.87546d094b4cc2de2d01.js +2 -0
- package/dist-prod/main.87546d094b4cc2de2d01.js.map +1 -0
- package/dist-prod/main.c3a7cb52315b8816357b.js +2 -0
- package/dist-prod/main.c3a7cb52315b8816357b.js.map +1 -0
- package/dist-prod/message.878a621e560c57ca9f90.chunk.js +2 -0
- package/dist-prod/message.878a621e560c57ca9f90.chunk.js.map +1 -0
- package/dist-prod/modal.e4087ee82601de76b61d.chunk.js +2 -0
- package/dist-prod/modal.e4087ee82601de76b61d.chunk.js.map +1 -0
- package/dist-prod/picker.3cfdf594676698f7ef0b.chunk.js +2 -0
- package/dist-prod/picker.3cfdf594676698f7ef0b.chunk.js.map +1 -0
- package/dist-prod/popup.f46d0b3c57b2f2d0dfe3.chunk.js +2 -0
- package/dist-prod/popup.f46d0b3c57b2f2d0dfe3.chunk.js.map +1 -0
- package/dist-prod/progress.dd5c95445a81a94ae446.chunk.js +2 -0
- package/dist-prod/progress.dd5c95445a81a94ae446.chunk.js.map +1 -0
- package/dist-prod/prompt.793312afaee597d3e887.chunk.js +2 -0
- package/dist-prod/prompt.793312afaee597d3e887.chunk.js.map +1 -0
- package/dist-prod/radiobox.f684060ebfc8df084d9c.chunk.js +2 -0
- package/dist-prod/radiobox.f684060ebfc8df084d9c.chunk.js.map +1 -0
- package/dist-prod/rater.18672a3b68842b5ec0ae.chunk.js +2 -0
- package/dist-prod/rater.18672a3b68842b5ec0ae.chunk.js.map +1 -0
- package/dist-prod/slidebar.58eb1b07a6995df3fc47.chunk.js +2 -0
- package/dist-prod/slidebar.58eb1b07a6995df3fc47.chunk.js.map +1 -0
- package/dist-prod/spinner.2c686ac402a1e1b29270.chunk.js +2 -0
- package/dist-prod/spinner.2c686ac402a1e1b29270.chunk.js.map +1 -0
- package/dist-prod/swipe.dcc1ebcc206dae26a67e.chunk.js +2 -0
- package/dist-prod/swipe.dcc1ebcc206dae26a67e.chunk.js.map +1 -0
- package/dist-prod/switchbar.91b45e05df73e20227ce.chunk.js +2 -0
- package/dist-prod/switchbar.91b45e05df73e20227ce.chunk.js.map +1 -0
- package/dist-prod/tab.b351fd11783b6de80246.chunk.js +2 -0
- package/dist-prod/tab.b351fd11783b6de80246.chunk.js.map +1 -0
- package/dist-prod/text.c41d6ba9644f7037d1e3.chunk.js +2 -0
- package/dist-prod/text.c41d6ba9644f7037d1e3.chunk.js.map +1 -0
- package/dist-prod/totop.cb15a38b541189094b32.chunk.js +2 -0
- package/dist-prod/totop.cb15a38b541189094b32.chunk.js.map +1 -0
- package/dist-prod/upload.e953d4a54b0a230de7d6.chunk.js +2 -0
- package/dist-prod/upload.e953d4a54b0a230de7d6.chunk.js.map +1 -0
- package/dist-prod/vendors.5b7cff021a01dbbbcdf2.js +3 -0
- package/dist-prod/vendors.5b7cff021a01dbbbcdf2.js.LICENSE.txt +5 -0
- package/dist-prod/vendors.5b7cff021a01dbbbcdf2.js.map +1 -0
- package/package.json +32 -27
- package/postcss.config.js +5 -0
- package/src/components/app.vue +1 -1
- package/src/components/upload/upload.vue +2 -1
- package/src/config/config.js +1 -1
- package/src/index.js +6 -5
- package/src/lib/MegaPixImage.js +59 -154
- package/src/main.js +18 -60
- package/src/router.js +30 -223
- package/src/styles/utils/nowrap.less +1 -1
- package/src/template/index.ejs +34 -20
- package/src/utils/util.js +1 -1
- package/src/views/Header.vue +6 -6
- package/src/views/Progress.vue +2 -2
- package/webpack.base.config.js +77 -70
- package/webpack.dev.config.js +39 -66
- package/webpack.dist.dev.config.js +45 -40
- package/webpack.dist.prod.config.js +54 -46
- package/webpack.prod.config.js +41 -70
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dpzvc-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Vue组件库",
|
|
5
5
|
"main": "dist/dpzvc.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"init": "webpack --progress --config webpack.dev.config.js",
|
|
8
|
-
"dev": "webpack
|
|
8
|
+
"dev": "webpack serve --config webpack.dev.config.js --open",
|
|
9
9
|
"build:style": "gulp --gulpfile build-style.js",
|
|
10
10
|
"build:dev": "webpack --config webpack.dist.dev.config.js",
|
|
11
|
-
"build:prod": "webpack
|
|
11
|
+
"build:prod": "webpack --config webpack.dist.prod.config.js",
|
|
12
12
|
"build": "npm run build:style && npm run build:dev && npm run build:prod",
|
|
13
|
-
"dist": "webpack --progress --
|
|
13
|
+
"dist": "webpack --progress --config webpack.prod.config.js"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -26,29 +26,30 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"china-area-data": "^3.0.0",
|
|
28
28
|
"core-js": "^2.4.1",
|
|
29
|
-
"deepmerge": "^1.3.1"
|
|
30
|
-
"vue": "^2.3.2"
|
|
29
|
+
"deepmerge": "^1.3.1"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
32
|
+
"@babel/core": "^7.28.5",
|
|
33
|
+
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
34
|
+
"@babel/preset-env": "^7.28.5",
|
|
35
|
+
"@babel/runtime": "^7.28.4",
|
|
33
36
|
"autoprefixer": "^10.4.23",
|
|
34
37
|
"autoprefixer-loader": "^2.0.0",
|
|
35
38
|
"babel": "^6.23.0",
|
|
36
|
-
"babel-core": "^6.
|
|
37
|
-
"babel-loader": "^
|
|
39
|
+
"babel-core": "^6.26.3",
|
|
40
|
+
"babel-loader": "^8.4.1",
|
|
38
41
|
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
|
39
|
-
"babel-plugin-transform-runtime": "^6.
|
|
40
|
-
"babel-preset-es2015": "^6.
|
|
42
|
+
"babel-plugin-transform-runtime": "^6.23.0",
|
|
43
|
+
"babel-preset-es2015": "^6.24.1",
|
|
41
44
|
"babel-preset-latest": "^6.24.1",
|
|
42
45
|
"babel-preset-stage-0": "^6.24.1",
|
|
43
|
-
"babel-runtime": "^6.
|
|
46
|
+
"babel-runtime": "^6.26.0",
|
|
44
47
|
"cross-env": "^3.1.4",
|
|
45
|
-
"css-loader": "^
|
|
48
|
+
"css-loader": "^6.11.0",
|
|
46
49
|
"eslint": "^3.12.2",
|
|
47
50
|
"eslint-plugin-html": "^1.7.0",
|
|
48
51
|
"exif-js": "^2.2.1",
|
|
49
|
-
"extract-text-webpack-plugin": "^2.1.2",
|
|
50
52
|
"file-loader": "^0.8.5",
|
|
51
|
-
"friendly-errors-webpack-plugin": "^1.6.1",
|
|
52
53
|
"function-bind": "^1.1.0",
|
|
53
54
|
"gh-pages": "^6.3.0",
|
|
54
55
|
"gulp": "^4.0.2",
|
|
@@ -58,23 +59,27 @@
|
|
|
58
59
|
"gulp-postcss": "^10.0.0",
|
|
59
60
|
"gulp-rename": "^2.1.0",
|
|
60
61
|
"html-loader": "^0.3.0",
|
|
61
|
-
"html-webpack-plugin": "^
|
|
62
|
+
"html-webpack-plugin": "^5.6.5",
|
|
62
63
|
"less": "^4.5.1",
|
|
63
|
-
"less-loader": "^
|
|
64
|
+
"less-loader": "^11.1.4",
|
|
64
65
|
"lolex": "^1.5.2",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
66
|
+
"mini-css-extract-plugin": "^2.9.4",
|
|
67
|
+
"postcss": "^8.5.6",
|
|
68
|
+
"postcss-loader": "^6.2.1",
|
|
69
|
+
"style-loader": "^3.3.4",
|
|
70
|
+
"terser-webpack-plugin": "^4.2.3",
|
|
71
|
+
"url-loader": "^0.5.9",
|
|
72
|
+
"vue": "^2.7.16",
|
|
69
73
|
"vue-hot-reload-api": "^1.3.3",
|
|
70
74
|
"vue-html-loader": "^1.2.3",
|
|
71
|
-
"vue-loader": "^11.
|
|
72
|
-
"vue-router": "^
|
|
73
|
-
"vue-style-loader": "^1.
|
|
74
|
-
"vue-template-compiler": "^2.
|
|
75
|
-
"webpack": "^
|
|
76
|
-
"webpack-
|
|
77
|
-
"webpack-
|
|
75
|
+
"vue-loader": "^15.11.1",
|
|
76
|
+
"vue-router": "^3.6.5",
|
|
77
|
+
"vue-style-loader": "^4.1.3",
|
|
78
|
+
"vue-template-compiler": "^2.7.16",
|
|
79
|
+
"webpack": "^5.104.1",
|
|
80
|
+
"webpack-cli": "^5.1.4",
|
|
81
|
+
"webpack-dev-server": "^4.15.2",
|
|
82
|
+
"webpack-merge": "^5.10.0"
|
|
78
83
|
},
|
|
79
84
|
"author": "yishide",
|
|
80
85
|
"license": "MIT",
|
package/src/components/app.vue
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
<script>
|
|
11
11
|
|
|
12
12
|
import EXIF from 'exif-js'
|
|
13
|
-
import MegaPixImage from '../../lib/MegaPixImage'
|
|
13
|
+
// import MegaPixImage from '../../lib/MegaPixImage'
|
|
14
|
+
import * as MegaPixImage from '../../lib/MegaPixImage';
|
|
14
15
|
import { JPEG } from '../../utils/util'
|
|
15
16
|
const prefixCls = 'dpzvc-upload';
|
|
16
17
|
export default {
|
package/src/config/config.js
CHANGED
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Created by admin on 2017/5/15.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import VButton from '
|
|
5
|
+
import VButton from './components/button'
|
|
6
6
|
import CheckBox from './components/checkBox'
|
|
7
7
|
import Header from './components/Header'
|
|
8
8
|
import Message from './components/message'
|
|
@@ -15,7 +15,7 @@ import Prompt from './components/prompt'
|
|
|
15
15
|
import SlideBar from './components/slideBar'
|
|
16
16
|
import TextBar from './components/Text'
|
|
17
17
|
import Upload from './components/upload'
|
|
18
|
-
import ActionSheet from '
|
|
18
|
+
import ActionSheet from './components/action-sheet'
|
|
19
19
|
import SwitchBar from './components/switchbar'
|
|
20
20
|
import Rater from './components/rater'
|
|
21
21
|
import Spinner from './components/spinner'
|
|
@@ -36,7 +36,7 @@ const dpzvc = {
|
|
|
36
36
|
CheckBoxGroup:CheckBox.group,
|
|
37
37
|
Radio,
|
|
38
38
|
RadioGroup:Radio.group,
|
|
39
|
-
Header,
|
|
39
|
+
DpHeader:Header,
|
|
40
40
|
Message,
|
|
41
41
|
Modal,
|
|
42
42
|
Prompt,
|
|
@@ -54,7 +54,7 @@ const dpzvc = {
|
|
|
54
54
|
LoadMore,
|
|
55
55
|
Popup,
|
|
56
56
|
Indicator,
|
|
57
|
-
Progress,
|
|
57
|
+
DpProgress:Progress,
|
|
58
58
|
ToTop,
|
|
59
59
|
Cell,
|
|
60
60
|
CellSwipe,
|
|
@@ -80,4 +80,5 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
80
80
|
install(window.Vue);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
const exportObj = Object.assign(dpzvc, {install});
|
|
84
|
+
export default exportObj;
|
package/src/lib/MegaPixImage.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
// MegaPixImage.js
|
|
2
|
+
(function (global, factory) {
|
|
3
|
+
if (typeof module === 'object' && typeof module.exports === 'object') {
|
|
4
|
+
module.exports = factory(); // CommonJS
|
|
5
|
+
} else if (typeof define === 'function' && define.amd) {
|
|
6
|
+
define([], factory); // AMD
|
|
7
|
+
} else {
|
|
8
|
+
global.MegaPixImage = factory(); // Browser global
|
|
9
|
+
}
|
|
10
|
+
}(typeof window !== 'undefined' ? window : this, function () {
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
12
|
+
// -------------------------
|
|
13
|
+
// Helper functions
|
|
14
|
+
// -------------------------
|
|
7
15
|
function detectSubsampling(img) {
|
|
8
16
|
var iw = img.naturalWidth, ih = img.naturalHeight;
|
|
9
|
-
if (iw * ih > 1024 * 1024) {
|
|
17
|
+
if (iw * ih > 1024 * 1024) {
|
|
10
18
|
var canvas = document.createElement('canvas');
|
|
11
19
|
canvas.width = canvas.height = 1;
|
|
12
20
|
var ctx = canvas.getContext('2d');
|
|
13
21
|
ctx.drawImage(img, -iw + 1, 0);
|
|
14
|
-
// subsampled image becomes half smaller in rendering size.
|
|
15
|
-
// check alpha channel value to confirm image is covering edge pixel or not.
|
|
16
|
-
// if alpha value is 0 image is not covering, hence subsampled.
|
|
17
22
|
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
|
|
18
23
|
} else {
|
|
19
24
|
return false;
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
/**
|
|
24
|
-
* Detecting vertical squash in loaded image.
|
|
25
|
-
* Fixes a bug which squash image vertically while drawing into canvas for some images.
|
|
26
|
-
*/
|
|
27
28
|
function detectVerticalSquash(img, iw, ih) {
|
|
28
29
|
var canvas = document.createElement('canvas');
|
|
29
30
|
canvas.width = 1;
|
|
@@ -31,142 +32,78 @@
|
|
|
31
32
|
var ctx = canvas.getContext('2d');
|
|
32
33
|
ctx.drawImage(img, 0, 0);
|
|
33
34
|
var data = ctx.getImageData(0, 0, 1, ih).data;
|
|
34
|
-
|
|
35
|
-
var sy = 0;
|
|
36
|
-
var ey = ih;
|
|
37
|
-
var py = ih;
|
|
35
|
+
var sy = 0, ey = ih, py = ih;
|
|
38
36
|
while (py > sy) {
|
|
39
37
|
var alpha = data[(py - 1) * 4 + 3];
|
|
40
|
-
if (alpha === 0) {
|
|
41
|
-
ey = py;
|
|
42
|
-
} else {
|
|
43
|
-
sy = py;
|
|
44
|
-
}
|
|
38
|
+
if (alpha === 0) { ey = py; } else { sy = py; }
|
|
45
39
|
py = (ey + sy) >> 1;
|
|
46
40
|
}
|
|
47
|
-
var ratio =
|
|
48
|
-
return (ratio===0)?1:ratio;
|
|
41
|
+
var ratio = py / ih;
|
|
42
|
+
return (ratio === 0) ? 1 : ratio;
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
/**
|
|
52
|
-
* Rendering image element (with resizing) and get its data URL
|
|
53
|
-
*/
|
|
54
45
|
function renderImageToDataURL(img, options, doSquash) {
|
|
55
46
|
var canvas = document.createElement('canvas');
|
|
56
47
|
renderImageToCanvas(img, canvas, options, doSquash);
|
|
57
48
|
return canvas.toDataURL("image/jpeg", options.quality || 0.8);
|
|
58
49
|
}
|
|
59
50
|
|
|
60
|
-
/**
|
|
61
|
-
* Rendering image element (with resizing) into the canvas element
|
|
62
|
-
*/
|
|
63
51
|
function renderImageToCanvas(img, canvas, options, doSquash) {
|
|
64
52
|
var iw = img.naturalWidth, ih = img.naturalHeight;
|
|
65
|
-
if (!(iw+ih)) return;
|
|
53
|
+
if (!(iw + ih)) return;
|
|
66
54
|
var width = options.width, height = options.height;
|
|
67
55
|
var ctx = canvas.getContext('2d');
|
|
68
56
|
ctx.save();
|
|
69
57
|
transformCoordinate(canvas, ctx, width, height, options.orientation);
|
|
70
58
|
var subsampled = detectSubsampling(img);
|
|
71
|
-
if (subsampled) {
|
|
72
|
-
|
|
73
|
-
ih /= 2;
|
|
74
|
-
}
|
|
75
|
-
var d = 1024; // size of tiling canvas
|
|
59
|
+
if (subsampled) { iw /= 2; ih /= 2; }
|
|
60
|
+
var d = 1024;
|
|
76
61
|
var tmpCanvas = document.createElement('canvas');
|
|
77
62
|
tmpCanvas.width = tmpCanvas.height = d;
|
|
78
63
|
var tmpCtx = tmpCanvas.getContext('2d');
|
|
79
64
|
var vertSquashRatio = doSquash ? detectVerticalSquash(img, iw, ih) : 1;
|
|
80
65
|
var dw = Math.ceil(d * width / iw);
|
|
81
66
|
var dh = Math.ceil(d * height / ih / vertSquashRatio);
|
|
82
|
-
var sy = 0;
|
|
83
|
-
var dy = 0;
|
|
67
|
+
var sy = 0, dy = 0;
|
|
84
68
|
while (sy < ih) {
|
|
85
|
-
var sx = 0;
|
|
86
|
-
var dx = 0;
|
|
69
|
+
var sx = 0, dx = 0;
|
|
87
70
|
while (sx < iw) {
|
|
88
71
|
tmpCtx.clearRect(0, 0, d, d);
|
|
89
72
|
tmpCtx.drawImage(img, -sx, -sy);
|
|
90
73
|
ctx.drawImage(tmpCanvas, 0, 0, d, d, dx, dy, dw, dh);
|
|
91
|
-
sx += d;
|
|
92
|
-
dx += dw;
|
|
74
|
+
sx += d; dx += dw;
|
|
93
75
|
}
|
|
94
|
-
sy += d;
|
|
95
|
-
dy += dh;
|
|
76
|
+
sy += d; dy += dh;
|
|
96
77
|
}
|
|
97
78
|
ctx.restore();
|
|
98
79
|
tmpCanvas = tmpCtx = null;
|
|
99
80
|
}
|
|
100
81
|
|
|
101
|
-
/**
|
|
102
|
-
* Transform canvas coordination according to specified frame size and orientation
|
|
103
|
-
* Orientation value is from EXIF tag
|
|
104
|
-
*/
|
|
105
82
|
function transformCoordinate(canvas, ctx, width, height, orientation) {
|
|
106
83
|
switch (orientation) {
|
|
107
|
-
case 5:
|
|
108
|
-
|
|
109
|
-
case 7:
|
|
110
|
-
case 8:
|
|
111
|
-
canvas.width = height;
|
|
112
|
-
canvas.height = width;
|
|
113
|
-
break;
|
|
114
|
-
default:
|
|
115
|
-
canvas.width = width;
|
|
116
|
-
canvas.height = height;
|
|
84
|
+
case 5: case 6: case 7: case 8: canvas.width = height; canvas.height = width; break;
|
|
85
|
+
default: canvas.width = width; canvas.height = height;
|
|
117
86
|
}
|
|
118
87
|
switch (orientation) {
|
|
119
|
-
case 2:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
case
|
|
125
|
-
|
|
126
|
-
ctx.translate(width, height);
|
|
127
|
-
ctx.rotate(Math.PI);
|
|
128
|
-
break;
|
|
129
|
-
case 4:
|
|
130
|
-
// vertical flip
|
|
131
|
-
ctx.translate(0, height);
|
|
132
|
-
ctx.scale(1, -1);
|
|
133
|
-
break;
|
|
134
|
-
case 5:
|
|
135
|
-
// vertical flip + 90 rotate right
|
|
136
|
-
ctx.rotate(0.5 * Math.PI);
|
|
137
|
-
ctx.scale(1, -1);
|
|
138
|
-
break;
|
|
139
|
-
case 6:
|
|
140
|
-
// 90 rotate right
|
|
141
|
-
ctx.rotate(0.5 * Math.PI);
|
|
142
|
-
ctx.translate(0, -height);
|
|
143
|
-
break;
|
|
144
|
-
case 7:
|
|
145
|
-
// horizontal flip + 90 rotate right
|
|
146
|
-
ctx.rotate(0.5 * Math.PI);
|
|
147
|
-
ctx.translate(width, -height);
|
|
148
|
-
ctx.scale(-1, 1);
|
|
149
|
-
break;
|
|
150
|
-
case 8:
|
|
151
|
-
// 90 rotate left
|
|
152
|
-
ctx.rotate(-0.5 * Math.PI);
|
|
153
|
-
ctx.translate(-width, 0);
|
|
154
|
-
break;
|
|
155
|
-
default:
|
|
156
|
-
break;
|
|
88
|
+
case 2: ctx.translate(width, 0); ctx.scale(-1, 1); break;
|
|
89
|
+
case 3: ctx.translate(width, height); ctx.rotate(Math.PI); break;
|
|
90
|
+
case 4: ctx.translate(0, height); ctx.scale(1, -1); break;
|
|
91
|
+
case 5: ctx.rotate(0.5 * Math.PI); ctx.scale(1, -1); break;
|
|
92
|
+
case 6: ctx.rotate(0.5 * Math.PI); ctx.translate(0, -height); break;
|
|
93
|
+
case 7: ctx.rotate(0.5 * Math.PI); ctx.translate(width, -height); ctx.scale(-1, 1); break;
|
|
94
|
+
case 8: ctx.rotate(-0.5 * Math.PI); ctx.translate(-width, 0); break;
|
|
157
95
|
}
|
|
158
96
|
}
|
|
159
97
|
|
|
160
98
|
var URL = window.URL && window.URL.createObjectURL ? window.URL :
|
|
161
|
-
window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL :
|
|
162
|
-
null;
|
|
99
|
+
window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL : null;
|
|
163
100
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
101
|
+
// -------------------------
|
|
102
|
+
// MegaPixImage class
|
|
103
|
+
// -------------------------
|
|
167
104
|
function MegaPixImage(srcImage) {
|
|
168
105
|
if (window.Blob && srcImage instanceof Blob) {
|
|
169
|
-
if (!URL) { throw Error("No createObjectURL function found
|
|
106
|
+
if (!URL) { throw Error("No createObjectURL function found"); }
|
|
170
107
|
var img = new Image();
|
|
171
108
|
img.src = URL.createObjectURL(srcImage);
|
|
172
109
|
this.blob = srcImage;
|
|
@@ -174,13 +111,11 @@
|
|
|
174
111
|
}
|
|
175
112
|
if (!srcImage.naturalWidth && !srcImage.naturalHeight) {
|
|
176
113
|
var _this = this;
|
|
177
|
-
srcImage.onload = srcImage.onerror = function() {
|
|
114
|
+
srcImage.onload = srcImage.onerror = function () {
|
|
178
115
|
var listeners = _this.imageLoadListeners;
|
|
179
116
|
if (listeners) {
|
|
180
117
|
_this.imageLoadListeners = null;
|
|
181
|
-
for (var i=0
|
|
182
|
-
listeners[i]();
|
|
183
|
-
}
|
|
118
|
+
for (var i = 0; i < listeners.length; i++) { listeners[i](); }
|
|
184
119
|
}
|
|
185
120
|
};
|
|
186
121
|
this.imageLoadListeners = [];
|
|
@@ -188,13 +123,10 @@
|
|
|
188
123
|
this.srcImage = srcImage;
|
|
189
124
|
}
|
|
190
125
|
|
|
191
|
-
|
|
192
|
-
* Rendering megapix image into specified target element
|
|
193
|
-
*/
|
|
194
|
-
MegaPixImage.prototype.render = function(target, options, callback) {
|
|
126
|
+
MegaPixImage.prototype.render = function (target, options, callback) {
|
|
195
127
|
if (this.imageLoadListeners) {
|
|
196
128
|
var _this = this;
|
|
197
|
-
this.imageLoadListeners.push(function() { _this.render(target, options, callback); });
|
|
129
|
+
this.imageLoadListeners.push(function () { _this.render(target, options, callback); });
|
|
198
130
|
return;
|
|
199
131
|
}
|
|
200
132
|
options = options || {};
|
|
@@ -202,52 +134,25 @@
|
|
|
202
134
|
width = options.width, height = options.height,
|
|
203
135
|
maxWidth = options.maxWidth, maxHeight = options.maxHeight,
|
|
204
136
|
doSquash = !this.blob || this.blob.type === 'image/jpeg';
|
|
205
|
-
if (width && !height) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
height = imgHeight;
|
|
212
|
-
}
|
|
213
|
-
if (maxWidth && width > maxWidth) {
|
|
214
|
-
width = maxWidth;
|
|
215
|
-
height = (imgHeight * width / imgWidth) << 0;
|
|
216
|
-
}
|
|
217
|
-
if (maxHeight && height > maxHeight) {
|
|
218
|
-
height = maxHeight;
|
|
219
|
-
width = (imgWidth * height / imgHeight) << 0;
|
|
220
|
-
}
|
|
221
|
-
var opt = { width : width, height : height };
|
|
137
|
+
if (width && !height) { height = (imgHeight * width / imgWidth) << 0; }
|
|
138
|
+
else if (height && !width) { width = (imgWidth * height / imgHeight) << 0; }
|
|
139
|
+
else { width = imgWidth; height = imgHeight; }
|
|
140
|
+
if (maxWidth && width > maxWidth) { width = maxWidth; height = (imgHeight * width / imgWidth) << 0; }
|
|
141
|
+
if (maxHeight && height > maxHeight) { height = maxHeight; width = (imgWidth * height / imgHeight) << 0; }
|
|
142
|
+
var opt = { width: width, height: height };
|
|
222
143
|
for (var k in options) opt[k] = options[k];
|
|
223
144
|
|
|
224
145
|
var tagName = target.tagName.toLowerCase();
|
|
225
|
-
if (tagName === 'img') {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
if (typeof this.onrender === 'function') {
|
|
231
|
-
this.onrender(target);
|
|
232
|
-
}
|
|
233
|
-
if (callback) {
|
|
234
|
-
callback();
|
|
235
|
-
}
|
|
236
|
-
if (this.blob) {
|
|
237
|
-
this.blob = null;
|
|
238
|
-
URL.revokeObjectURL(this.srcImage.src);
|
|
239
|
-
}
|
|
146
|
+
if (tagName === 'img') { target.src = renderImageToDataURL(this.srcImage, opt, doSquash); }
|
|
147
|
+
else if (tagName === 'canvas') { renderImageToCanvas(this.srcImage, target, opt, doSquash); }
|
|
148
|
+
if (typeof this.onrender === 'function') { this.onrender(target); }
|
|
149
|
+
if (callback) { callback(); }
|
|
150
|
+
if (this.blob) { this.blob = null; URL.revokeObjectURL(this.srcImage.src); }
|
|
240
151
|
};
|
|
241
152
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
define([], function() { return MegaPixImage; }); // for AMD loader
|
|
247
|
-
} else if (typeof exports === 'object') {
|
|
248
|
-
module.exports = MegaPixImage; // for CommonJS
|
|
249
|
-
} else {
|
|
250
|
-
this.MegaPixImage = MegaPixImage;
|
|
251
|
-
}
|
|
153
|
+
// -------------------------
|
|
154
|
+
// Export as ESM default
|
|
155
|
+
// -------------------------
|
|
156
|
+
return MegaPixImage;
|
|
252
157
|
|
|
253
|
-
})
|
|
158
|
+
}));
|
package/src/main.js
CHANGED
|
@@ -1,76 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by yishide .
|
|
3
|
-
*/
|
|
4
1
|
import Vue from 'vue';
|
|
5
2
|
import VueRouter from 'vue-router';
|
|
6
3
|
import App from './components/app.vue';
|
|
7
4
|
import Routers from './router';
|
|
5
|
+
import Config from './config/config';
|
|
6
|
+
import dpzvc from './index';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// import Prompt from './components/prompt/index'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// import Message from './components/message/index'
|
|
15
|
-
|
|
16
|
-
import dpzvc from './index'
|
|
17
|
-
|
|
18
|
-
Vue.use(dpzvc)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// var log = console.log;
|
|
22
|
-
// console.log = function () {
|
|
23
|
-
// var args = Array.from(arguments);
|
|
24
|
-
// args = args.map(arg => {
|
|
25
|
-
// try {
|
|
26
|
-
// return JSON.parse(JSON.stringify(arg));
|
|
27
|
-
// } catch (e) {
|
|
28
|
-
// return arg;
|
|
29
|
-
// }
|
|
30
|
-
// });
|
|
31
|
-
//
|
|
32
|
-
// log.apply(console, args);
|
|
33
|
-
// };
|
|
34
|
-
//
|
|
35
|
-
// window.vConsole = require('./vconsole.min');
|
|
36
|
-
// require('./vconsole-resources.min');
|
|
37
|
-
// require('./vconsole-sources.min');
|
|
38
|
-
|
|
8
|
+
// 安装自定义组件库
|
|
9
|
+
Vue.use(dpzvc);
|
|
39
10
|
|
|
40
11
|
Vue.use(VueRouter);
|
|
41
|
-
// Vue.use(VueTouch);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// 开启debug模式
|
|
45
|
-
|
|
46
12
|
|
|
13
|
+
// 配置全局变量
|
|
47
14
|
Vue.prototype.$Config = Config;
|
|
48
15
|
|
|
16
|
+
// 创建全局事件总线
|
|
17
|
+
window.EventBus = new Vue();
|
|
49
18
|
|
|
50
|
-
let EventBus = new Vue();
|
|
51
19
|
// 路由配置
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
routes:Routers
|
|
20
|
+
const router = new VueRouter({
|
|
21
|
+
mode: process.env.NODE_ENV !== 'production' ? 'hash' : 'hash', // VueRouter 3 兼容写法
|
|
22
|
+
routes: Routers
|
|
56
23
|
});
|
|
57
24
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// setPageTitle(title);
|
|
62
|
-
window.scrollTo(0, 0);
|
|
63
|
-
next();
|
|
25
|
+
router.beforeEach((to, from, next) => {
|
|
26
|
+
window.scrollTo(0, 0);
|
|
27
|
+
next();
|
|
64
28
|
});
|
|
65
|
-
|
|
66
|
-
router.afterEach(() => {
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
window.EventBus = new Vue();
|
|
71
|
-
|
|
29
|
+
// 根实例
|
|
72
30
|
new Vue({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
31
|
+
el: '#app',
|
|
32
|
+
router,
|
|
33
|
+
render: h => h(App)
|
|
34
|
+
});
|