yc-ui2 0.1.0-beta6 → 0.1.0-beta8

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.
@@ -1853,7 +1853,7 @@ if (typeof window !== 'undefined') {
1853
1853
  // Indicate to webpack that this file can be concatenated
1854
1854
  /* harmony default export */ var setPublicPath = (null);
1855
1855
 
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&
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=645ac48a&
1857
1857
  var render = function render() {
1858
1858
  var _vm = this,
1859
1859
  _c = _vm._self._c;
@@ -1882,404 +1882,48 @@ var staticRenderFns = [];
1882
1882
 
1883
1883
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
1884
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
- },
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/index.js??vue-loader-options!./src/components/YcSlideVerify/index.vue?vue&type=script&lang=js&
1995
1886
 
1996
- show: {
1997
- type: Boolean,
1998
- default: true
1999
- },
2000
- imgs: {
2001
- type: Array,
2002
- default: () => []
2003
- }
1887
+ // import SlideVerify from "vue-monoplasty-slide-verify/src/lib/slide-verify.vue"
1888
+ /* harmony default export */ var YcSlideVerifyvue_type_script_lang_js_ = ({
1889
+ name: "YcSlideVerify",
1890
+ components: {
1891
+ // SlideVerify,
2004
1892
  },
2005
1893
  data() {
2006
1894
  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
1895
+ show: true,
1896
+ isShow: false,
1897
+ accuracy: 5,
1898
+ sliderText: "拖动完成上方拼图",
1899
+ countDownNum: 120
2035
1900
  };
2036
1901
  },
2037
- mounted() {
2038
- this.init();
1902
+ computed: {
1903
+ imgs() {
1904
+ const list = [];
1905
+ for (let i = 1; i < 9; i++) {
1906
+ list.push(__webpack_require__(4359)(`./${i}.jpg`));
1907
+ }
1908
+ return list;
1909
+ }
2039
1910
  },
2040
1911
  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
- };
1912
+ onSuccess() {
1913
+ this.isShow = false;
1914
+ console.log(344444);
2202
1915
  },
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");
1916
+ onFail() {},
1917
+ onAgain() {},
1918
+ onRefresh() {},
1919
+ onFulfilled() {},
1920
+ handleClose() {
1921
+ this.isShow = false;
2224
1922
  }
2225
- },
2226
- destroyed() {
2227
- document.removeEventListener("mousemove", this.handleMoveEvent);
2228
- document.removeEventListener("mouseup", this.handleMoveEndEvent);
2229
1923
  }
2230
1924
  });
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
-
1925
+ ;// CONCATENATED MODULE: ./src/components/YcSlideVerify/index.vue?vue&type=script&lang=js&
1926
+ /* harmony default export */ var components_YcSlideVerifyvue_type_script_lang_js_ = (YcSlideVerifyvue_type_script_lang_js_);
2283
1927
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
2284
1928
  /* globals __VUE_SSR_CONTEXT__ */
2285
1929
 
@@ -2378,69 +2022,6 @@ function normalizeComponent(
2378
2022
  }
2379
2023
  }
2380
2024
 
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);
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&
2403
-
2404
-
2405
- /* harmony default export */ var YcSlideVerifyvue_type_script_lang_js_ = ({
2406
- name: "YcSlideVerify",
2407
- components: {
2408
- SlideVerify: slide_verify
2409
- },
2410
- data() {
2411
- return {
2412
- show: true,
2413
- isShow: false,
2414
- accuracy: 5,
2415
- sliderText: "拖动完成上方拼图",
2416
- countDownNum: 120
2417
- };
2418
- },
2419
- computed: {
2420
- imgs() {
2421
- const list = [];
2422
- for (let i = 1; i < 9; i++) {
2423
- list.push(__webpack_require__(4359)(`./${i}.jpg`));
2424
- }
2425
- return list;
2426
- }
2427
- },
2428
- methods: {
2429
- onSuccess() {
2430
- this.isShow = false;
2431
- console.log(344444);
2432
- },
2433
- onFail() {},
2434
- onAgain() {},
2435
- onRefresh() {},
2436
- onFulfilled() {},
2437
- handleClose() {
2438
- this.isShow = false;
2439
- }
2440
- }
2441
- });
2442
- ;// CONCATENATED MODULE: ./src/components/YcSlideVerify/index.vue?vue&type=script&lang=js&
2443
- /* harmony default export */ var components_YcSlideVerifyvue_type_script_lang_js_ = (YcSlideVerifyvue_type_script_lang_js_);
2444
2025
  ;// CONCATENATED MODULE: ./src/components/YcSlideVerify/index.vue
2445
2026
 
2446
2027
 
@@ -2449,7 +2030,7 @@ var component = normalizeComponent(
2449
2030
 
2450
2031
  /* normalize component */
2451
2032
  ;
2452
- var YcSlideVerify_component = normalizeComponent(
2033
+ var component = normalizeComponent(
2453
2034
  components_YcSlideVerifyvue_type_script_lang_js_,
2454
2035
  render,
2455
2036
  staticRenderFns,
@@ -2460,7 +2041,7 @@ var YcSlideVerify_component = normalizeComponent(
2460
2041
 
2461
2042
  )
2462
2043
 
2463
- /* harmony default export */ var YcSlideVerify = (YcSlideVerify_component.exports);
2044
+ /* harmony default export */ var YcSlideVerify = (component.exports);
2464
2045
  ;// CONCATENATED MODULE: ./src/packages/index.js
2465
2046
 
2466
2047
  const components = [YcSlideVerify];