yc-ui2 0.1.0-beta3 → 0.1.0-beta4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,113 +1,6 @@
1
1
  /******/ (function() { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 1001:
5
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
-
7
- "use strict";
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ Z: function() { return /* binding */ normalizeComponent; }
10
- /* harmony export */ });
11
- /* globals __VUE_SSR_CONTEXT__ */
12
-
13
- // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
14
- // This module is a runtime utility for cleaner component module output and will
15
- // be included in the final webpack user bundle.
16
-
17
- function normalizeComponent(
18
- scriptExports,
19
- render,
20
- staticRenderFns,
21
- functionalTemplate,
22
- injectStyles,
23
- scopeId,
24
- moduleIdentifier /* server only */,
25
- shadowMode /* vue-cli only */
26
- ) {
27
- // Vue.extend constructor export interop
28
- var options =
29
- typeof scriptExports === 'function' ? scriptExports.options : scriptExports
30
-
31
- // render functions
32
- if (render) {
33
- options.render = render
34
- options.staticRenderFns = staticRenderFns
35
- options._compiled = true
36
- }
37
-
38
- // functional template
39
- if (functionalTemplate) {
40
- options.functional = true
41
- }
42
-
43
- // scopedId
44
- if (scopeId) {
45
- options._scopeId = 'data-v-' + scopeId
46
- }
47
-
48
- var hook
49
- if (moduleIdentifier) {
50
- // server build
51
- hook = function (context) {
52
- // 2.3 injection
53
- context =
54
- context || // cached call
55
- (this.$vnode && this.$vnode.ssrContext) || // stateful
56
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
57
- // 2.2 with runInNewContext: true
58
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
59
- context = __VUE_SSR_CONTEXT__
60
- }
61
- // inject component styles
62
- if (injectStyles) {
63
- injectStyles.call(this, context)
64
- }
65
- // register component module identifier for async chunk inferrence
66
- if (context && context._registeredComponents) {
67
- context._registeredComponents.add(moduleIdentifier)
68
- }
69
- }
70
- // used by ssr in case component is cached and beforeCreate
71
- // never gets called
72
- options._ssrRegister = hook
73
- } else if (injectStyles) {
74
- hook = shadowMode
75
- ? function () {
76
- injectStyles.call(
77
- this,
78
- (options.functional ? this.parent : this).$root.$options.shadowRoot
79
- )
80
- }
81
- : injectStyles
82
- }
83
-
84
- if (hook) {
85
- if (options.functional) {
86
- // for template-only hot-reload because in that case the render fn doesn't
87
- // go through the normalizer
88
- options._injectStyles = hook
89
- // register for functional component in vue file
90
- var originalRender = options.render
91
- options.render = function renderWithStyleInjection(h, context) {
92
- hook.call(context)
93
- return originalRender(h, context)
94
- }
95
- } else {
96
- // inject component registration as beforeCreate hook
97
- var existing = options.beforeCreate
98
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
99
- }
100
- }
101
-
102
- return {
103
- exports: scriptExports,
104
- options: options
105
- }
106
- }
107
-
108
-
109
- /***/ }),
110
-
111
4
  /***/ 9662:
112
5
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
113
6
 
@@ -1874,9 +1767,6 @@ module.exports = __webpack_require__.p + "img/8.63e261ca.jpg";
1874
1767
  /******/ return module.exports;
1875
1768
  /******/ }
1876
1769
  /******/
1877
- /******/ // expose the modules object (__webpack_modules__)
1878
- /******/ __webpack_require__.m = __webpack_modules__;
1879
- /******/
1880
1770
  /************************************************************************/
1881
1771
  /******/ /* webpack/runtime/define property getters */
1882
1772
  /******/ !function() {
@@ -1890,37 +1780,6 @@ module.exports = __webpack_require__.p + "img/8.63e261ca.jpg";
1890
1780
  /******/ };
1891
1781
  /******/ }();
1892
1782
  /******/
1893
- /******/ /* webpack/runtime/ensure chunk */
1894
- /******/ !function() {
1895
- /******/ __webpack_require__.f = {};
1896
- /******/ // This file contains only the entry chunk.
1897
- /******/ // The chunk loading function for additional chunks
1898
- /******/ __webpack_require__.e = function(chunkId) {
1899
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
1900
- /******/ __webpack_require__.f[key](chunkId, promises);
1901
- /******/ return promises;
1902
- /******/ }, []));
1903
- /******/ };
1904
- /******/ }();
1905
- /******/
1906
- /******/ /* webpack/runtime/get javascript chunk filename */
1907
- /******/ !function() {
1908
- /******/ // This function allow to reference async chunks
1909
- /******/ __webpack_require__.u = function(chunkId) {
1910
- /******/ // return url for filenames based on template
1911
- /******/ return "yc-ui2.common." + chunkId + ".js";
1912
- /******/ };
1913
- /******/ }();
1914
- /******/
1915
- /******/ /* webpack/runtime/get mini-css chunk filename */
1916
- /******/ !function() {
1917
- /******/ // This function allow to reference async chunks
1918
- /******/ __webpack_require__.miniCssF = function(chunkId) {
1919
- /******/ // return url for filenames based on template
1920
- /******/ return "css/" + chunkId + "." + "de9a931f" + ".css";
1921
- /******/ };
1922
- /******/ }();
1923
- /******/
1924
1783
  /******/ /* webpack/runtime/global */
1925
1784
  /******/ !function() {
1926
1785
  /******/ __webpack_require__.g = (function() {
@@ -1938,52 +1797,6 @@ module.exports = __webpack_require__.p + "img/8.63e261ca.jpg";
1938
1797
  /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
1939
1798
  /******/ }();
1940
1799
  /******/
1941
- /******/ /* webpack/runtime/load script */
1942
- /******/ !function() {
1943
- /******/ var inProgress = {};
1944
- /******/ var dataWebpackPrefix = "yc-ui2:";
1945
- /******/ // loadScript function to load a script via script tag
1946
- /******/ __webpack_require__.l = function(url, done, key, chunkId) {
1947
- /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
1948
- /******/ var script, needAttach;
1949
- /******/ if(key !== undefined) {
1950
- /******/ var scripts = document.getElementsByTagName("script");
1951
- /******/ for(var i = 0; i < scripts.length; i++) {
1952
- /******/ var s = scripts[i];
1953
- /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
1954
- /******/ }
1955
- /******/ }
1956
- /******/ if(!script) {
1957
- /******/ needAttach = true;
1958
- /******/ script = document.createElement('script');
1959
- /******/
1960
- /******/ script.charset = 'utf-8';
1961
- /******/ script.timeout = 120;
1962
- /******/ if (__webpack_require__.nc) {
1963
- /******/ script.setAttribute("nonce", __webpack_require__.nc);
1964
- /******/ }
1965
- /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
1966
- /******/
1967
- /******/ script.src = url;
1968
- /******/ }
1969
- /******/ inProgress[url] = [done];
1970
- /******/ var onScriptComplete = function(prev, event) {
1971
- /******/ // avoid mem leaks in IE.
1972
- /******/ script.onerror = script.onload = null;
1973
- /******/ clearTimeout(timeout);
1974
- /******/ var doneFns = inProgress[url];
1975
- /******/ delete inProgress[url];
1976
- /******/ script.parentNode && script.parentNode.removeChild(script);
1977
- /******/ doneFns && doneFns.forEach(function(fn) { return fn(event); });
1978
- /******/ if(prev) return prev(event);
1979
- /******/ }
1980
- /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
1981
- /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
1982
- /******/ script.onload = onScriptComplete.bind(null, script.onload);
1983
- /******/ needAttach && document.head.appendChild(script);
1984
- /******/ };
1985
- /******/ }();
1986
- /******/
1987
1800
  /******/ /* webpack/runtime/make namespace object */
1988
1801
  /******/ !function() {
1989
1802
  /******/ // define __esModule on exports
@@ -2000,175 +1813,6 @@ module.exports = __webpack_require__.p + "img/8.63e261ca.jpg";
2000
1813
  /******/ __webpack_require__.p = "";
2001
1814
  /******/ }();
2002
1815
  /******/
2003
- /******/ /* webpack/runtime/css loading */
2004
- /******/ !function() {
2005
- /******/ if (typeof document === "undefined") return;
2006
- /******/ var createStylesheet = function(chunkId, fullhref, oldTag, resolve, reject) {
2007
- /******/ var linkTag = document.createElement("link");
2008
- /******/
2009
- /******/ linkTag.rel = "stylesheet";
2010
- /******/ linkTag.type = "text/css";
2011
- /******/ var onLinkComplete = function(event) {
2012
- /******/ // avoid mem leaks.
2013
- /******/ linkTag.onerror = linkTag.onload = null;
2014
- /******/ if (event.type === 'load') {
2015
- /******/ resolve();
2016
- /******/ } else {
2017
- /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
2018
- /******/ var realHref = event && event.target && event.target.href || fullhref;
2019
- /******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + realHref + ")");
2020
- /******/ err.code = "CSS_CHUNK_LOAD_FAILED";
2021
- /******/ err.type = errorType;
2022
- /******/ err.request = realHref;
2023
- /******/ if (linkTag.parentNode) linkTag.parentNode.removeChild(linkTag)
2024
- /******/ reject(err);
2025
- /******/ }
2026
- /******/ }
2027
- /******/ linkTag.onerror = linkTag.onload = onLinkComplete;
2028
- /******/ linkTag.href = fullhref;
2029
- /******/
2030
- /******/ if (oldTag) {
2031
- /******/ oldTag.parentNode.insertBefore(linkTag, oldTag.nextSibling);
2032
- /******/ } else {
2033
- /******/ document.head.appendChild(linkTag);
2034
- /******/ }
2035
- /******/ return linkTag;
2036
- /******/ };
2037
- /******/ var findStylesheet = function(href, fullhref) {
2038
- /******/ var existingLinkTags = document.getElementsByTagName("link");
2039
- /******/ for(var i = 0; i < existingLinkTags.length; i++) {
2040
- /******/ var tag = existingLinkTags[i];
2041
- /******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");
2042
- /******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return tag;
2043
- /******/ }
2044
- /******/ var existingStyleTags = document.getElementsByTagName("style");
2045
- /******/ for(var i = 0; i < existingStyleTags.length; i++) {
2046
- /******/ var tag = existingStyleTags[i];
2047
- /******/ var dataHref = tag.getAttribute("data-href");
2048
- /******/ if(dataHref === href || dataHref === fullhref) return tag;
2049
- /******/ }
2050
- /******/ };
2051
- /******/ var loadStylesheet = function(chunkId) {
2052
- /******/ return new Promise(function(resolve, reject) {
2053
- /******/ var href = __webpack_require__.miniCssF(chunkId);
2054
- /******/ var fullhref = __webpack_require__.p + href;
2055
- /******/ if(findStylesheet(href, fullhref)) return resolve();
2056
- /******/ createStylesheet(chunkId, fullhref, null, resolve, reject);
2057
- /******/ });
2058
- /******/ }
2059
- /******/ // object to store loaded CSS chunks
2060
- /******/ var installedCssChunks = {
2061
- /******/ 61: 0
2062
- /******/ };
2063
- /******/
2064
- /******/ __webpack_require__.f.miniCss = function(chunkId, promises) {
2065
- /******/ var cssChunks = {"94":1};
2066
- /******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);
2067
- /******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {
2068
- /******/ promises.push(installedCssChunks[chunkId] = loadStylesheet(chunkId).then(function() {
2069
- /******/ installedCssChunks[chunkId] = 0;
2070
- /******/ }, function(e) {
2071
- /******/ delete installedCssChunks[chunkId];
2072
- /******/ throw e;
2073
- /******/ }));
2074
- /******/ }
2075
- /******/ };
2076
- /******/
2077
- /******/ // no hmr
2078
- /******/ }();
2079
- /******/
2080
- /******/ /* webpack/runtime/jsonp chunk loading */
2081
- /******/ !function() {
2082
- /******/ // no baseURI
2083
- /******/
2084
- /******/ // object to store loaded and loading chunks
2085
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
2086
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
2087
- /******/ var installedChunks = {
2088
- /******/ 61: 0
2089
- /******/ };
2090
- /******/
2091
- /******/ __webpack_require__.f.j = function(chunkId, promises) {
2092
- /******/ // JSONP chunk loading for javascript
2093
- /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
2094
- /******/ if(installedChunkData !== 0) { // 0 means "already installed".
2095
- /******/
2096
- /******/ // a Promise means "currently loading".
2097
- /******/ if(installedChunkData) {
2098
- /******/ promises.push(installedChunkData[2]);
2099
- /******/ } else {
2100
- /******/ if(true) { // all chunks have JS
2101
- /******/ // setup Promise in chunk cache
2102
- /******/ var promise = new Promise(function(resolve, reject) { installedChunkData = installedChunks[chunkId] = [resolve, reject]; });
2103
- /******/ promises.push(installedChunkData[2] = promise);
2104
- /******/
2105
- /******/ // start chunk loading
2106
- /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
2107
- /******/ // create error before stack unwound to get useful stacktrace later
2108
- /******/ var error = new Error();
2109
- /******/ var loadingEnded = function(event) {
2110
- /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
2111
- /******/ installedChunkData = installedChunks[chunkId];
2112
- /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
2113
- /******/ if(installedChunkData) {
2114
- /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
2115
- /******/ var realSrc = event && event.target && event.target.src;
2116
- /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
2117
- /******/ error.name = 'ChunkLoadError';
2118
- /******/ error.type = errorType;
2119
- /******/ error.request = realSrc;
2120
- /******/ installedChunkData[1](error);
2121
- /******/ }
2122
- /******/ }
2123
- /******/ };
2124
- /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
2125
- /******/ }
2126
- /******/ }
2127
- /******/ }
2128
- /******/ };
2129
- /******/
2130
- /******/ // no prefetching
2131
- /******/
2132
- /******/ // no preloaded
2133
- /******/
2134
- /******/ // no HMR
2135
- /******/
2136
- /******/ // no HMR manifest
2137
- /******/
2138
- /******/ // no on chunks loaded
2139
- /******/
2140
- /******/ // install a JSONP callback for chunk loading
2141
- /******/ var webpackJsonpCallback = function(parentChunkLoadingFunction, data) {
2142
- /******/ var chunkIds = data[0];
2143
- /******/ var moreModules = data[1];
2144
- /******/ var runtime = data[2];
2145
- /******/ // add "moreModules" to the modules object,
2146
- /******/ // then flag all "chunkIds" as loaded and fire callback
2147
- /******/ var moduleId, chunkId, i = 0;
2148
- /******/ if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {
2149
- /******/ for(moduleId in moreModules) {
2150
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
2151
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
2152
- /******/ }
2153
- /******/ }
2154
- /******/ if(runtime) var result = runtime(__webpack_require__);
2155
- /******/ }
2156
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
2157
- /******/ for(;i < chunkIds.length; i++) {
2158
- /******/ chunkId = chunkIds[i];
2159
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
2160
- /******/ installedChunks[chunkId][0]();
2161
- /******/ }
2162
- /******/ installedChunks[chunkId] = 0;
2163
- /******/ }
2164
- /******/
2165
- /******/ }
2166
- /******/
2167
- /******/ var chunkLoadingGlobal = (typeof self !== 'undefined' ? self : this)["webpackChunkyc_ui2"] = (typeof self !== 'undefined' ? self : this)["webpackChunkyc_ui2"] || [];
2168
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
2169
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
2170
- /******/ }();
2171
- /******/
2172
1816
  /************************************************************************/
2173
1817
  var __webpack_exports__ = {};
2174
1818
  // This entry need to be wrapped in an IIFE because it need to be in strict mode.
@@ -2199,7 +1843,7 @@ if (typeof window !== 'undefined') {
2199
1843
  // Indicate to webpack that this file can be concatenated
2200
1844
  /* harmony default export */ var setPublicPath = (null);
2201
1845
 
2202
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/YcSlideVerify/index.vue?vue&type=template&id=69e287d4&
1846
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/YcSlideVerify/index.vue?vue&type=template&id=59bbdcfe&
2203
1847
  var render = function render() {
2204
1848
  var _vm = this,
2205
1849
  _c = _vm._self._c;
@@ -2228,12 +1872,530 @@ var staticRenderFns = [];
2228
1872
 
2229
1873
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
2230
1874
  var es_array_push = __webpack_require__(7658);
1875
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue?vue&type=template&id=b67196d8&scoped=true&
1876
+ var slide_verifyvue_type_template_id_b67196d8_scoped_true_render = function render() {
1877
+ var _vm = this,
1878
+ _c = _vm._self._c;
1879
+ return _c('div', {
1880
+ staticClass: "slide-verify",
1881
+ style: {
1882
+ width: _vm.w + 'px'
1883
+ },
1884
+ attrs: {
1885
+ "id": "slideVerify",
1886
+ "onselectstart": "return false;"
1887
+ }
1888
+ }, [_c('div', {
1889
+ class: {
1890
+ 'slider-verify-loading': _vm.loadBlock
1891
+ }
1892
+ }), _c('canvas', {
1893
+ ref: "canvas",
1894
+ attrs: {
1895
+ "width": _vm.w,
1896
+ "height": _vm.h
1897
+ }
1898
+ }), _vm.show ? _c('div', {
1899
+ staticClass: "slide-verify-refresh-icon",
1900
+ on: {
1901
+ "click": _vm.refresh
1902
+ }
1903
+ }) : _vm._e(), _c('canvas', {
1904
+ ref: "block",
1905
+ staticClass: "slide-verify-block",
1906
+ attrs: {
1907
+ "width": _vm.w,
1908
+ "height": _vm.h
1909
+ }
1910
+ }), _c('div', {
1911
+ staticClass: "slide-verify-slider",
1912
+ class: {
1913
+ 'container-active': _vm.containerActive,
1914
+ 'container-success': _vm.containerSuccess,
1915
+ 'container-fail': _vm.containerFail
1916
+ }
1917
+ }, [_c('div', {
1918
+ staticClass: "slide-verify-slider-mask",
1919
+ style: {
1920
+ width: _vm.sliderMaskWidth
1921
+ }
1922
+ }, [_c('div', {
1923
+ staticClass: "slide-verify-slider-mask-item",
1924
+ style: {
1925
+ left: _vm.sliderLeft
1926
+ },
1927
+ on: {
1928
+ "mousedown": _vm.sliderDown,
1929
+ "touchstart": _vm.touchStartEvent,
1930
+ "touchmove": function ($event) {
1931
+ return _vm.handleMoveEvent($event, 'touch');
1932
+ },
1933
+ "touchend": function ($event) {
1934
+ return _vm.handleMoveEndEvent($event, 'touch');
1935
+ }
1936
+ }
1937
+ }, [_c('div', {
1938
+ staticClass: "slide-verify-slider-mask-item-icon"
1939
+ })])]), _c('span', {
1940
+ staticClass: "slide-verify-slider-text"
1941
+ }, [_vm._v(_vm._s(_vm.sliderText))])])]);
1942
+ };
1943
+ var slide_verifyvue_type_template_id_b67196d8_scoped_true_staticRenderFns = [];
1944
+
1945
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue?vue&type=script&lang=js&
1946
+
1947
+ const PI = Math.PI;
1948
+ function sum(x, y) {
1949
+ return x + y;
1950
+ }
1951
+ function square(x) {
1952
+ return x * x;
1953
+ }
1954
+ /* harmony default export */ var slide_verifyvue_type_script_lang_js_ = ({
1955
+ name: "SlideVerify",
1956
+ props: {
1957
+ // block length
1958
+ l: {
1959
+ type: Number,
1960
+ default: 42
1961
+ },
1962
+ // block radius
1963
+ r: {
1964
+ type: Number,
1965
+ default: 10
1966
+ },
1967
+ // canvas width
1968
+ w: {
1969
+ type: Number,
1970
+ default: 310
1971
+ },
1972
+ // canvas height
1973
+ h: {
1974
+ type: Number,
1975
+ default: 155
1976
+ },
1977
+ sliderText: {
1978
+ type: String,
1979
+ default: "Slide filled right"
1980
+ },
1981
+ accuracy: {
1982
+ type: Number,
1983
+ default: 5 // 若为 -1 则不进行机器判断
1984
+ },
1985
+
1986
+ show: {
1987
+ type: Boolean,
1988
+ default: true
1989
+ },
1990
+ imgs: {
1991
+ type: Array,
1992
+ default: () => []
1993
+ }
1994
+ },
1995
+ data() {
1996
+ return {
1997
+ containerActive: false,
1998
+ // container active class
1999
+ containerSuccess: false,
2000
+ // container success class
2001
+ containerFail: false,
2002
+ // container fail class
2003
+ canvasCtx: null,
2004
+ blockCtx: null,
2005
+ block: null,
2006
+ block_x: undefined,
2007
+ // container random position
2008
+ block_y: undefined,
2009
+ L: this.l + this.r * 2 + 3,
2010
+ // block real length
2011
+ img: undefined,
2012
+ originX: undefined,
2013
+ originY: undefined,
2014
+ isMouseDown: false,
2015
+ trail: [],
2016
+ sliderLeft: 0,
2017
+ // block right offset
2018
+ sliderMaskWidth: 0,
2019
+ // mask width,
2020
+ success: false,
2021
+ // Bug Fixes 修复了验证成功后还能滑动
2022
+ loadBlock: true,
2023
+ // Features 图片加载提示,防止图片没加载完就开始验证
2024
+ timestamp: null
2025
+ };
2026
+ },
2027
+ mounted() {
2028
+ this.init();
2029
+ },
2030
+ methods: {
2031
+ init() {
2032
+ this.initDom();
2033
+ this.initImg();
2034
+ this.bindEvents();
2035
+ },
2036
+ initDom() {
2037
+ this.block = this.$refs.block;
2038
+ this.canvasCtx = this.$refs.canvas.getContext("2d");
2039
+ this.blockCtx = this.block.getContext("2d");
2040
+ },
2041
+ initImg() {
2042
+ const img = this.createImg(() => {
2043
+ // 图片加载完关闭遮蔽罩
2044
+ this.loadBlock = false;
2045
+ this.drawBlock();
2046
+ this.canvasCtx.drawImage(img, 0, 0, this.w, this.h);
2047
+ this.blockCtx.drawImage(img, 0, 0, this.w, this.h);
2048
+ let {
2049
+ block_x: x,
2050
+ block_y: y,
2051
+ r,
2052
+ L
2053
+ } = this;
2054
+ let _y = y - r * 2 - 1;
2055
+ let ImageData = this.blockCtx.getImageData(x, _y, L, L);
2056
+ this.block.width = L;
2057
+ this.blockCtx.putImageData(ImageData, 0, _y);
2058
+ });
2059
+ this.img = img;
2060
+ },
2061
+ drawBlock() {
2062
+ this.block_x = this.getRandomNumberByRange(this.L + 10, this.w - (this.L + 10));
2063
+ this.block_y = this.getRandomNumberByRange(10 + this.r * 2, this.h - (this.L + 10));
2064
+ this.draw(this.canvasCtx, this.block_x, this.block_y, "fill");
2065
+ this.draw(this.blockCtx, this.block_x, this.block_y, "clip");
2066
+ },
2067
+ draw(ctx, x, y, operation) {
2068
+ let {
2069
+ l,
2070
+ r
2071
+ } = this;
2072
+ ctx.beginPath();
2073
+ ctx.moveTo(x, y);
2074
+ ctx.arc(x + l / 2, y - r + 2, r, 0.72 * PI, 2.26 * PI);
2075
+ ctx.lineTo(x + l, y);
2076
+ ctx.arc(x + l + r - 2, y + l / 2, r, 1.21 * PI, 2.78 * PI);
2077
+ ctx.lineTo(x + l, y + l);
2078
+ ctx.lineTo(x, y + l);
2079
+ ctx.arc(x + r - 2, y + l / 2, r + 0.4, 2.76 * PI, 1.24 * PI, true);
2080
+ ctx.lineTo(x, y);
2081
+ ctx.lineWidth = 2;
2082
+ ctx.fillStyle = "rgba(255, 255, 255, 0.7)";
2083
+ ctx.strokeStyle = "rgba(255, 255, 255, 0.7)";
2084
+ ctx.stroke();
2085
+ ctx[operation]();
2086
+ // Bug Fixes 修复了火狐和ie显示问题
2087
+ ctx.globalCompositeOperation = "destination-over";
2088
+ },
2089
+ createImg(onload) {
2090
+ const img = document.createElement("img");
2091
+ img.crossOrigin = "Anonymous";
2092
+ img.onload = onload;
2093
+ img.onerror = () => {
2094
+ img.src = this.getRandomImg();
2095
+ };
2096
+ img.src = this.getRandomImg();
2097
+ return img;
2098
+ },
2099
+ // 随机生成img src
2100
+ getRandomImg() {
2101
+ // return require('../assets/img.jpg')
2102
+ const len = this.imgs.length;
2103
+ return len > 0 ? this.imgs[this.getRandomNumberByRange(0, len - 1)] :
2104
+ // "https://bing.ioliu.cn/v1/rand?w=300&h=150";
2105
+ "https://source.unsplash.com/300x150/?book,library";
2106
+ // "https://api.dujin.org/pic/fengjing";
2107
+ },
2108
+
2109
+ getRandomNumberByRange(start, end) {
2110
+ return Math.round(Math.random() * (end - start) + start);
2111
+ },
2112
+ refresh() {
2113
+ this.reset();
2114
+ this.$emit("refresh");
2115
+ },
2116
+ sliderDown(event) {
2117
+ if (this.success) return;
2118
+ this.originX = event.clientX;
2119
+ this.originY = event.clientY;
2120
+ this.isMouseDown = true;
2121
+ this.timestamp = +new Date();
2122
+ },
2123
+ touchStartEvent(e) {
2124
+ if (this.success) return;
2125
+ this.originX = e.changedTouches[0].pageX;
2126
+ this.originY = e.changedTouches[0].pageY;
2127
+ this.isMouseDown = true;
2128
+ this.timestamp = +new Date();
2129
+ },
2130
+ bindEvents() {
2131
+ document.addEventListener("mousemove", this.handleMoveEvent);
2132
+ document.addEventListener("mouseup", this.handleMoveEndEvent);
2133
+ },
2134
+ // 处理函数抽离
2135
+ handleMoveEvent: throttle(function (e, type = "mouse") {
2136
+ if (!this.isMouseDown) return false;
2137
+ const moveX = type === "mouse" ? e.clientX - this.originX : e.changedTouches[0].pageX - this.originX;
2138
+ const moveY = type === "mouse" ? e.clientY - this.originY : e.changedTouches[0].pageY - this.originY;
2139
+ if (moveX < 0 || moveX + 38 >= this.w) return false;
2140
+ this.sliderLeft = moveX + "px";
2141
+ let blockLeft = (this.w - 40 - 20) / (this.w - 40) * moveX;
2142
+ this.block.style.left = blockLeft + "px";
2143
+ this.containerActive = true; // add active
2144
+ this.sliderMaskWidth = moveX + "px";
2145
+ this.trail.push(moveY);
2146
+ }),
2147
+ handleMoveEndEvent(e, type = "mouse") {
2148
+ if (!this.isMouseDown) return false;
2149
+ this.isMouseDown = false;
2150
+ if (type === "mouse" && e.clientX === this.originX || type === "touch" && e.changedTouches[0].pageX === this.originX) return false;
2151
+ this.containerActive = false; // remove active
2152
+ this.timestamp = +new Date() - this.timestamp;
2153
+ const {
2154
+ spliced,
2155
+ TuringTest
2156
+ } = this.verify();
2157
+ if (spliced) {
2158
+ if (this.accuracy === -1) {
2159
+ this.containerSuccess = true;
2160
+ this.success = true;
2161
+ this.$emit("success", this.timestamp);
2162
+ return;
2163
+ }
2164
+ if (TuringTest) {
2165
+ // succ
2166
+ this.containerSuccess = true;
2167
+ this.success = true;
2168
+ this.$emit("success", this.timestamp);
2169
+ } else {
2170
+ this.containerFail = true;
2171
+ this.$emit("again");
2172
+ }
2173
+ } else {
2174
+ this.containerFail = true;
2175
+ this.$emit("fail");
2176
+ setTimeout(() => {
2177
+ this.reset();
2178
+ }, 1000);
2179
+ }
2180
+ },
2181
+ verify() {
2182
+ const arr = this.trail; // drag y move distance
2183
+ const average = arr.reduce(sum) / arr.length; // average
2184
+ const deviations = arr.map(x => x - average); // deviation array
2185
+ const stddev = Math.sqrt(deviations.map(square).reduce(sum) / arr.length); // standard deviation
2186
+ const left = parseInt(this.block.style.left);
2187
+ const accuracy = this.accuracy <= 1 ? 1 : this.accuracy > 10 ? 10 : this.accuracy;
2188
+ return {
2189
+ spliced: Math.abs(left - this.block_x) <= accuracy,
2190
+ TuringTest: average !== stddev // equal => not person operate
2191
+ };
2192
+ },
2193
+
2194
+ reset() {
2195
+ this.success = false;
2196
+ this.containerActive = false;
2197
+ this.containerSuccess = false;
2198
+ this.containerFail = false;
2199
+ this.sliderLeft = 0;
2200
+ this.block.style.left = 0;
2201
+ this.sliderMaskWidth = 0;
2202
+ // canvas
2203
+ let {
2204
+ w,
2205
+ h
2206
+ } = this;
2207
+ this.canvasCtx.clearRect(0, 0, w, h);
2208
+ this.blockCtx.clearRect(0, 0, w, h);
2209
+ this.block.width = w;
2210
+
2211
+ // generate img
2212
+ this.img.src = this.getRandomImg();
2213
+ this.$emit("fulfilled");
2214
+ }
2215
+ },
2216
+ destroyed() {
2217
+ document.removeEventListener("mousemove", this.handleMoveEvent);
2218
+ document.removeEventListener("mouseup", this.handleMoveEndEvent);
2219
+ }
2220
+ });
2221
+ function throttle(fn, interval = 50, options = {
2222
+ leading: true,
2223
+ trailing: true
2224
+ }) {
2225
+ const {
2226
+ leading,
2227
+ trailing,
2228
+ resultCallback
2229
+ } = options;
2230
+ let lastTime = 0;
2231
+ let timer = null;
2232
+ const _throttle = function (...args) {
2233
+ return new Promise((resolve, reject) => {
2234
+ const nowTime = new Date().getTime();
2235
+ if (!lastTime && !leading) lastTime = nowTime;
2236
+ const remainTime = interval - (nowTime - lastTime);
2237
+ if (remainTime <= 0) {
2238
+ if (timer) {
2239
+ clearTimeout(timer);
2240
+ timer = null;
2241
+ }
2242
+ const result = fn.apply(this, args);
2243
+ if (resultCallback) resultCallback(result);
2244
+ resolve(result);
2245
+ lastTime = nowTime;
2246
+ return;
2247
+ }
2248
+ if (trailing && !timer) {
2249
+ timer = setTimeout(() => {
2250
+ timer = null;
2251
+ lastTime = !leading ? 0 : new Date().getTime();
2252
+ const result = fn.apply(this, args);
2253
+ if (resultCallback) resultCallback(result);
2254
+ resolve(result);
2255
+ }, remainTime);
2256
+ }
2257
+ });
2258
+ };
2259
+ _throttle.cancel = function () {
2260
+ if (timer) clearTimeout(timer);
2261
+ timer = null;
2262
+ lastTime = 0;
2263
+ };
2264
+ return _throttle;
2265
+ }
2266
+ ;// CONCATENATED MODULE: ./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue?vue&type=script&lang=js&
2267
+ /* harmony default export */ var lib_slide_verifyvue_type_script_lang_js_ = (slide_verifyvue_type_script_lang_js_);
2268
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue?vue&type=style&index=0&id=b67196d8&prod&scoped=true&lang=css&
2269
+ // extracted by mini-css-extract-plugin
2270
+
2271
+ ;// CONCATENATED MODULE: ./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue?vue&type=style&index=0&id=b67196d8&prod&scoped=true&lang=css&
2272
+
2273
+ ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
2274
+ /* globals __VUE_SSR_CONTEXT__ */
2275
+
2276
+ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
2277
+ // This module is a runtime utility for cleaner component module output and will
2278
+ // be included in the final webpack user bundle.
2279
+
2280
+ function normalizeComponent(
2281
+ scriptExports,
2282
+ render,
2283
+ staticRenderFns,
2284
+ functionalTemplate,
2285
+ injectStyles,
2286
+ scopeId,
2287
+ moduleIdentifier /* server only */,
2288
+ shadowMode /* vue-cli only */
2289
+ ) {
2290
+ // Vue.extend constructor export interop
2291
+ var options =
2292
+ typeof scriptExports === 'function' ? scriptExports.options : scriptExports
2293
+
2294
+ // render functions
2295
+ if (render) {
2296
+ options.render = render
2297
+ options.staticRenderFns = staticRenderFns
2298
+ options._compiled = true
2299
+ }
2300
+
2301
+ // functional template
2302
+ if (functionalTemplate) {
2303
+ options.functional = true
2304
+ }
2305
+
2306
+ // scopedId
2307
+ if (scopeId) {
2308
+ options._scopeId = 'data-v-' + scopeId
2309
+ }
2310
+
2311
+ var hook
2312
+ if (moduleIdentifier) {
2313
+ // server build
2314
+ hook = function (context) {
2315
+ // 2.3 injection
2316
+ context =
2317
+ context || // cached call
2318
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
2319
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
2320
+ // 2.2 with runInNewContext: true
2321
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
2322
+ context = __VUE_SSR_CONTEXT__
2323
+ }
2324
+ // inject component styles
2325
+ if (injectStyles) {
2326
+ injectStyles.call(this, context)
2327
+ }
2328
+ // register component module identifier for async chunk inferrence
2329
+ if (context && context._registeredComponents) {
2330
+ context._registeredComponents.add(moduleIdentifier)
2331
+ }
2332
+ }
2333
+ // used by ssr in case component is cached and beforeCreate
2334
+ // never gets called
2335
+ options._ssrRegister = hook
2336
+ } else if (injectStyles) {
2337
+ hook = shadowMode
2338
+ ? function () {
2339
+ injectStyles.call(
2340
+ this,
2341
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
2342
+ )
2343
+ }
2344
+ : injectStyles
2345
+ }
2346
+
2347
+ if (hook) {
2348
+ if (options.functional) {
2349
+ // for template-only hot-reload because in that case the render fn doesn't
2350
+ // go through the normalizer
2351
+ options._injectStyles = hook
2352
+ // register for functional component in vue file
2353
+ var originalRender = options.render
2354
+ options.render = function renderWithStyleInjection(h, context) {
2355
+ hook.call(context)
2356
+ return originalRender(h, context)
2357
+ }
2358
+ } else {
2359
+ // inject component registration as beforeCreate hook
2360
+ var existing = options.beforeCreate
2361
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
2362
+ }
2363
+ }
2364
+
2365
+ return {
2366
+ exports: scriptExports,
2367
+ options: options
2368
+ }
2369
+ }
2370
+
2371
+ ;// CONCATENATED MODULE: ./node_modules/vue-monoplasty-slide-verify/src/lib/slide-verify.vue
2372
+
2373
+
2374
+
2375
+ ;
2376
+
2377
+
2378
+ /* normalize component */
2379
+
2380
+ var component = normalizeComponent(
2381
+ lib_slide_verifyvue_type_script_lang_js_,
2382
+ slide_verifyvue_type_template_id_b67196d8_scoped_true_render,
2383
+ slide_verifyvue_type_template_id_b67196d8_scoped_true_staticRenderFns,
2384
+ false,
2385
+ null,
2386
+ "b67196d8",
2387
+ null
2388
+
2389
+ )
2390
+
2391
+ /* harmony default export */ var slide_verify = (component.exports);
2231
2392
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/YcSlideVerify/index.vue?vue&type=script&lang=js&
2232
2393
 
2394
+
2233
2395
  /* harmony default export */ var YcSlideVerifyvue_type_script_lang_js_ = ({
2234
2396
  name: "YcSlideVerify",
2235
2397
  components: {
2236
- SlideVerify: () => __webpack_require__.e(/* import() */ 94).then(__webpack_require__.bind(__webpack_require__, 9094))
2398
+ SlideVerify: slide_verify
2237
2399
  },
2238
2400
  data() {
2239
2401
  return {
@@ -2269,8 +2431,6 @@ var es_array_push = __webpack_require__(7658);
2269
2431
  });
2270
2432
  ;// CONCATENATED MODULE: ./src/components/YcSlideVerify/index.vue?vue&type=script&lang=js&
2271
2433
  /* harmony default export */ var components_YcSlideVerifyvue_type_script_lang_js_ = (YcSlideVerifyvue_type_script_lang_js_);
2272
- // EXTERNAL MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
2273
- var componentNormalizer = __webpack_require__(1001);
2274
2434
  ;// CONCATENATED MODULE: ./src/components/YcSlideVerify/index.vue
2275
2435
 
2276
2436
 
@@ -2279,7 +2439,7 @@ var componentNormalizer = __webpack_require__(1001);
2279
2439
 
2280
2440
  /* normalize component */
2281
2441
  ;
2282
- var component = (0,componentNormalizer/* default */.Z)(
2442
+ var YcSlideVerify_component = normalizeComponent(
2283
2443
  components_YcSlideVerifyvue_type_script_lang_js_,
2284
2444
  render,
2285
2445
  staticRenderFns,
@@ -2290,7 +2450,7 @@ var component = (0,componentNormalizer/* default */.Z)(
2290
2450
 
2291
2451
  )
2292
2452
 
2293
- /* harmony default export */ var YcSlideVerify = (component.exports);
2453
+ /* harmony default export */ var YcSlideVerify = (YcSlideVerify_component.exports);
2294
2454
  ;// CONCATENATED MODULE: ./src/packages/index.js
2295
2455
 
2296
2456
  const components = [YcSlideVerify];