yc-ui2 0.1.0-beta3 → 0.1.0-beta5

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