yuang-framework-ui-pc 1.1.29 → 1.1.31

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.
@@ -21,7 +21,7 @@ const _hoisted_1 = {
21
21
  };
22
22
  const _hoisted_2 = /* @__PURE__ */ createElementVNode("path", {
23
23
  d: "M793.751 733.16l0-181.775-145.42 0 0-96.948L787.69199999 454.437l0-187.833L1024 502.911zM230.248 733.16l0-181.775L375.669 551.385l0-96.948-139.36099999 0 0-187.833L0 502.911zM575.621 757.396L442.32 757.396l0-490.793L575.621 266.603z",
24
- fill: "#409EFF",
24
+ fill: "currentColor",
25
25
  "p-id": "2866"
26
26
  }, null, -1);
27
27
  const _hoisted_3 = [
@@ -21,7 +21,7 @@ const _hoisted_1 = {
21
21
  };
22
22
  const _hoisted_2 = /* @__PURE__ */ createElementVNode("path", {
23
23
  d: "M883.2 723.2a44.8 44.8 0 0 1 0 89.6H140.8a44.8 44.8 0 0 1 0-89.6h742.4z m0-256a44.8 44.8 0 0 1 0 89.6H140.8a44.8 44.8 0 0 1 0-89.6h742.4z m0-256a44.8 44.8 0 0 1 0 89.6H140.8a44.8 44.8 0 0 1 0-89.6h742.4z",
24
- fill: "#409EFF",
24
+ fill: "currentColor",
25
25
  "p-id": "3008"
26
26
  }, null, -1);
27
27
  const _hoisted_3 = [
@@ -0,0 +1,77 @@
1
+
2
+ .yu-hidden {
3
+ display: none;
4
+ }
5
+
6
+ .yu-block {
7
+ display: block;
8
+ }
9
+
10
+ .yu-text-center {
11
+ text-align: center;
12
+ }
13
+
14
+ .yu-text-left {
15
+ text-align: left;
16
+ }
17
+
18
+ .yu-text-right {
19
+ text-align: right;
20
+ }
21
+
22
+ .yu-color-red {
23
+ color: #ff4d4f;
24
+ }
25
+
26
+ .yu-color-yellow {
27
+ color: #FAAD14;
28
+ }
29
+
30
+ .yu-color-green {
31
+ color: #33CC99;
32
+ }
33
+
34
+
35
+ .yu-color-primary {
36
+ color: #409EFF;
37
+ }
38
+
39
+ .yu-color-info {
40
+ color: #1989fa;
41
+ }
42
+
43
+ .yu-color-default {
44
+ color: #fff;
45
+ }
46
+
47
+ .yu-color-danger {
48
+ color: #ee0a24;
49
+ }
50
+
51
+ .yu-color-warning {
52
+ color: #ff976a;
53
+ }
54
+
55
+
56
+ .yu-bgc-red {
57
+ background-color: #ff4d4f;
58
+ }
59
+
60
+ .yu-bgc-yellow {
61
+ background-color: #FAAD14;
62
+ }
63
+
64
+ .yu-bgc-green {
65
+ background-color: #33CC99;
66
+ }
67
+
68
+
69
+ .yu-overfow-hidden {
70
+ display: block !important;
71
+ overflow: hidden;
72
+ text-overflow: ellipsis;
73
+ }
74
+
75
+ .yu-link {
76
+ cursor: pointer;
77
+ }
@@ -1,2 +1,3 @@
1
1
  @use '../ele-app/style/index.scss' as app;
2
+ @use './default.scss' as *;
2
3
  @use './plus.scss' as *;
@@ -1,14 +1,11 @@
1
- import { defineComponent, ref, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, unref, normalizeStyle, normalizeClass, createCommentVNode, toDisplayString, Fragment, createBlock } from "vue";
1
+ import { defineComponent, ref, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, unref, normalizeStyle, normalizeClass, createCommentVNode, toDisplayString, createBlock } from "vue";
2
2
  import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
3
- import { getBaseUrl } from "yuang-framework-ui-common/lib/utils/urlUtils";
4
3
  import { RefreshRight, CircleClose } from "@element-plus/icons-vue";
5
4
  import { SliderArrowStatic, SliderArrowSlide } from "../icons";
6
- const _hoisted_1 = { class: "slider-captcha-container" };
7
- const _hoisted_2 = { class: "slider-captcha-title" };
5
+ const _hoisted_1 = { class: "yu-slider-captcha-container" };
6
+ const _hoisted_2 = { class: "yu-slider-captcha-title" };
8
7
  const _hoisted_3 = ["width", "height"];
9
- const _hoisted_4 = ["width", "height"];
10
- const _hoisted_5 = ["width", "height"];
11
- const _hoisted_6 = { class: "slider-hint" };
8
+ const _hoisted_4 = { class: "slider-hint" };
12
9
  const _sfc_main = /* @__PURE__ */ defineComponent({
13
10
  ...{ name: "SliderCaptcha" },
14
11
  __name: "SliderCaptcha",
@@ -27,16 +24,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27
24
  const emit = __emit;
28
25
  const canvas = ref(null);
29
26
  const block = ref(null);
30
- const isFrontCheck = ref(false);
31
- const verifyActive = ref(false);
32
- const verifySuccess = ref(false);
33
- const verifyFail = ref(false);
34
- const canvasCtx = ref(null);
35
- const blockCtx = ref(null);
36
- const blockWidth = ref(props.blockLength * 2);
37
- const blockX = ref(void 0);
38
- const blockY = ref(void 0);
39
- const image = ref(void 0);
27
+ const isVerifyActive = ref(false);
28
+ const isVerifySuccess = ref(false);
29
+ const isVerifyFail = ref(false);
30
+ ref(null);
31
+ ref(null);
32
+ ref(props.blockLength * 2);
33
+ ref(void 0);
34
+ ref(void 0);
40
35
  const originX = ref(void 0);
41
36
  const originY = ref(void 0);
42
37
  const dragDistanceList = ref([]);
@@ -56,13 +51,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
51
  bindEvents();
57
52
  };
58
53
  const initDom = () => {
59
- if (isFrontCheck.value) {
60
- canvasCtx.value = canvas.value.getContext("2d");
61
- blockCtx.value = block.value.getContext("2d");
62
- initImage();
63
- } else {
64
- getCaptcha();
65
- }
54
+ getCaptcha();
66
55
  };
67
56
  const getCaptcha = () => {
68
57
  http.get("/sso-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
@@ -75,63 +64,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
75
64
  }, 200);
76
65
  });
77
66
  };
78
- const initImage = () => {
79
- const imageObject = createImage(() => {
80
- drawBlock();
81
- let { canvasWidth, canvasHeight, blockX: blockX2, blockY: blockY2, blockRadius, blockWidth: blockWidth2 } = this;
82
- canvasCtx.value.drawImage(image, 0, 0, canvasWidth, canvasHeight);
83
- blockCtx.value.drawImage(image, 0, 0, canvasWidth, canvasHeight);
84
- let yAxle = blockY2 - blockRadius * 2;
85
- let ImageData = blockCtx.value.getImageData(blockX2, yAxle, blockWidth2, blockWidth2);
86
- block.value.width = blockWidth2;
87
- blockCtx.value.putImageData(ImageData, 0, yAxle);
88
- isLoading.value = false;
89
- key.value = "loyer";
90
- });
91
- image.value = imageObject;
92
- };
93
- const createImage = (onload) => {
94
- const image2 = document.createElement("img");
95
- image2.crossOrigin = "Anonymous";
96
- image2.onload = onload;
97
- image2.onerror = () => {
98
- image2.src = `${getBaseUrl()}/img/slider-captcha/pic-0.jpeg`;
99
- };
100
- image2.src = getImageSrc();
101
- return image2;
102
- };
103
- const getImageSrc = () => {
104
- const len = props.imageList.length;
105
- return len > 0 ? props.imageList[getNonceByRange(0, len)] : `https://loyer.wang/view/ftp/wallpaper/${getNonceByRange(1, 1e3)}.jpg`;
106
- };
107
- const getNonceByRange = (start, end) => {
108
- return Math.round(Math.random() * (end - start) + start);
109
- };
110
- const drawBlock = () => {
111
- blockX.value = getNonceByRange(blockWidth.value + 10, props.canvasWidth - (blockWidth.value + 10));
112
- blockY.value = getNonceByRange(10 + props.blockRadius * 2, props.canvasHeight - (blockWidth.value + 10));
113
- draw(canvasCtx.value, "fill");
114
- draw(blockCtx.value, "clip");
115
- };
116
- const draw = (ctx, operation) => {
117
- const PI = Math.PI;
118
- let { blockX: x, blockY: y, blockLength: l, blockRadius: r } = this;
119
- ctx.beginPath();
120
- ctx.moveTo(x, y);
121
- ctx.arc(x + l / 2, y - r + 2, r, 0.72 * PI, 2.26 * PI);
122
- ctx.lineTo(x + l, y);
123
- ctx.arc(x + l + r - 2, y + l / 2, r, 1.21 * PI, 2.78 * PI);
124
- ctx.lineTo(x + l, y + l);
125
- ctx.lineTo(x, y + l);
126
- ctx.arc(x + r - 2, y + l / 2, r + 0.4, 2.76 * PI, 1.24 * PI, true);
127
- ctx.lineTo(x, y);
128
- ctx.lineWidth = 2;
129
- ctx.fillStyle = "rgba(255, 255, 255, 0.9)";
130
- ctx.strokeStyle = "rgba(255, 255, 255, 0.9)";
131
- ctx.stroke();
132
- ctx[operation]();
133
- ctx.globalCompositeOperation = "destination-over";
134
- };
135
67
  const bindEvents = () => {
136
68
  var _a, _b, _c;
137
69
  (_a = document.getElementById("slider-button")) == null ? void 0 : _a.addEventListener("mousedown", (event) => {
@@ -165,13 +97,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
165
97
  }
166
98
  };
167
99
  const checkImgSrc = () => {
168
- if (isFrontCheck.value) {
169
- return true;
170
- }
171
100
  return !!canvas.value.src;
172
101
  };
173
102
  const startEvent = (clientX, clientY) => {
174
- if (!checkImgSrc() || isLoading.value || verifySuccess.value) {
103
+ if (!checkImgSrc() || isLoading.value || isVerifySuccess.value) {
175
104
  return;
176
105
  }
177
106
  originX.value = clientX;
@@ -192,7 +121,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
192
121
  sliderButtonLeft.value = moveX > props.canvasWidth - 56 ? props.canvasWidth - 56 : moveX;
193
122
  let blockLeft = (props.canvasWidth - 40 - 20) / (props.canvasWidth - 40) * moveX;
194
123
  block.value.style.left = (blockLeft > props.canvasWidth - 56 - 18 - 7 ? props.canvasWidth - 56 - 18 - 7 : blockLeft) + "px";
195
- verifyActive.value = true;
124
+ isVerifyActive.value = true;
196
125
  sliderBoxWidth.value = moveX + 28;
197
126
  dragDistanceList.value.push(moveY);
198
127
  };
@@ -205,7 +134,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
205
134
  return false;
206
135
  }
207
136
  isLoading.value = true;
208
- verifyActive.value = false;
137
+ isVerifyActive.value = false;
209
138
  timestamp.value = +/* @__PURE__ */ new Date() - timestamp.value;
210
139
  const moveLength = parseInt(block.value.style.left);
211
140
  if (timestamp.value > 1e4) {
@@ -214,22 +143,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
214
143
  if (!turingTest()) {
215
144
  verifyFailEvent();
216
145
  } else {
217
- if (isFrontCheck.value) {
218
- const accuracyValue = props.accuracy <= 1 ? 1 : props.accuracy > 10 ? 10 : props.accuracy;
219
- const spliced = Math.abs(moveLength - blockX.value) <= accuracyValue;
220
- if (!spliced) {
221
- verifyFailEvent();
222
- } else {
223
- emit("success", { key: key.value, value: moveLength });
224
- }
225
- return;
226
- }
227
146
  let params = {
228
147
  key: key.value,
229
148
  captcha: moveLength
230
149
  };
231
150
  http.get("/sso-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
232
- emit("success", { key: key.value, value: moveLength });
151
+ verifySuccessEvent();
152
+ setTimeout(() => {
153
+ emit("success", { key: key.value, value: moveLength });
154
+ }, 500);
233
155
  }).catch(() => {
234
156
  verifyFailEvent();
235
157
  });
@@ -244,31 +166,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
244
166
  const stdDev = Math.sqrt(deviations.map(calcSquare).reduce(calcSum) / arr.length);
245
167
  return average !== stdDev;
246
168
  };
169
+ const verifySuccessEvent = () => {
170
+ isLoading.value = false;
171
+ isVerifySuccess.value = true;
172
+ const elapsedTime = (timestamp.value / 1e3).toFixed(1);
173
+ if (elapsedTime < 1) {
174
+ successHint.value = `仅仅${elapsedTime}S,你的速度快如闪电`;
175
+ } else if (elapsedTime < 2) {
176
+ successHint.value = `只用了${elapsedTime}S,这速度简直完美`;
177
+ } else {
178
+ successHint.value = `耗时${elapsedTime}S,争取下次再快一点`;
179
+ }
180
+ };
247
181
  const verifyFailEvent = () => {
248
- verifyFail.value = true;
182
+ isVerifyFail.value = true;
249
183
  emit("fail", {});
250
184
  refresh();
251
185
  };
252
186
  const refresh = () => {
253
187
  setTimeout(() => {
254
- verifyFail.value = false;
188
+ isVerifyFail.value = false;
255
189
  }, 300);
256
190
  isLoading.value = true;
257
- verifyActive.value = false;
258
- verifySuccess.value = false;
191
+ isVerifyActive.value = false;
192
+ isVerifySuccess.value = false;
259
193
  block.value.style.left = 0;
260
194
  sliderBoxWidth.value = 0;
261
195
  sliderButtonLeft.value = 0;
262
196
  nextTick(() => {
263
- if (isFrontCheck.value) {
264
- let { canvasWidth, canvasHeight } = this;
265
- canvasCtx.value.clearRect(0, 0, canvasWidth, canvasHeight);
266
- blockCtx.value.clearRect(0, 0, canvasWidth, canvasHeight);
267
- block.value.width = canvasWidth;
268
- image.value.src = getImageSrc();
269
- } else {
270
- getCaptcha();
271
- }
197
+ getCaptcha();
272
198
  });
273
199
  };
274
200
  const close = () => {
@@ -286,83 +212,66 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
286
212
  createTextVNode(" 完成拼图验证 "),
287
213
  createElementVNode("div", {
288
214
  onClick: refresh,
289
- class: "slider-captcha-refresh-icon"
215
+ class: "yu-slider-captcha-refresh-icon"
290
216
  }, [
291
217
  createVNode(unref(RefreshRight))
292
218
  ]),
293
219
  createElementVNode("div", {
294
220
  onClick: close,
295
- class: "slider-captcha-close-icon"
221
+ class: "yu-slider-captcha-close-icon"
296
222
  }, [
297
223
  createVNode(unref(CircleClose))
298
224
  ])
299
225
  ]),
300
226
  createElementVNode("div", {
301
- class: "slider-captcha",
227
+ class: "yu-slider-captcha",
302
228
  style: normalizeStyle({ width: _ctx.canvasWidth + "px" }),
303
229
  onselectstart: "return false;"
304
230
  }, [
305
231
  isLoading.value ? (openBlock(), createElementBlock("div", {
306
232
  key: 0,
307
- class: normalizeClass({ "img-loading": isLoading.value }),
233
+ class: normalizeClass({ "yu-slider-captcha-img-loading": isLoading.value }),
308
234
  style: normalizeStyle({ height: _ctx.canvasHeight + "px" })
309
235
  }, null, 6)) : createCommentVNode("", true),
310
- verifySuccess.value ? (openBlock(), createElementBlock("div", {
236
+ isVerifySuccess.value ? (openBlock(), createElementBlock("div", {
311
237
  key: 1,
312
238
  class: "success-hint",
313
239
  style: normalizeStyle({ height: _ctx.canvasHeight + "px" })
314
240
  }, toDisplayString(successHint.value), 5)) : createCommentVNode("", true),
315
- isFrontCheck.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
316
- createElementVNode("canvas", {
317
- ref_key: "canvas",
318
- ref: canvas,
319
- class: "slide-canvas",
320
- width: _ctx.canvasWidth,
321
- height: _ctx.canvasHeight
322
- }, null, 8, _hoisted_3),
323
- createElementVNode("canvas", {
324
- ref_key: "block",
325
- ref: block,
326
- class: "slide-block",
327
- width: _ctx.canvasWidth,
328
- height: _ctx.canvasHeight
329
- }, null, 8, _hoisted_4)
330
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
331
- createElementVNode("img", {
332
- ref_key: "canvas",
333
- ref: canvas,
334
- class: "slide-canvas",
335
- width: _ctx.canvasWidth,
336
- height: _ctx.canvasHeight
337
- }, null, 8, _hoisted_5),
338
- createElementVNode("img", {
339
- ref_key: "block",
340
- ref: block,
341
- class: normalizeClass(["slide-block", { "verify-fail": verifyFail.value }])
342
- }, null, 2)
343
- ], 64)),
241
+ createElementVNode("img", {
242
+ ref_key: "canvas",
243
+ ref: canvas,
244
+ class: "yu-slider-captcha-canvas",
245
+ width: _ctx.canvasWidth,
246
+ height: _ctx.canvasHeight
247
+ }, null, 8, _hoisted_3),
248
+ createElementVNode("img", {
249
+ ref_key: "block",
250
+ ref: block,
251
+ class: normalizeClass(["yu-slider-captcha-block", { "is-verify-fail": isVerifyFail.value }])
252
+ }, null, 2),
344
253
  createElementVNode("div", {
345
- class: normalizeClass(["slider", { "verify-active": verifyActive.value, "verify-success": verifySuccess.value, "verify-fail": verifyFail.value }])
254
+ class: normalizeClass(["yu-slider-captcha-slider", { "is-verify-active": isVerifyActive.value, "is-verify-success": isVerifySuccess.value, "is-verify-fail": isVerifyFail.value }])
346
255
  }, [
347
256
  createElementVNode("div", {
348
- class: "slider-box background-primary",
257
+ class: "yu-slider-captcha-slider-box",
349
258
  style: normalizeStyle({ width: sliderBoxWidth.value + "px" })
350
259
  }, [
351
260
  createElementVNode("div", {
352
- class: "slider-button",
261
+ class: "yu-slider-captcha-slider-button",
353
262
  id: "slider-button",
354
263
  style: normalizeStyle({ left: sliderButtonLeft.value + "px" })
355
264
  }, [
356
265
  !isSliderSlide.value ? (openBlock(), createBlock(unref(SliderArrowStatic), {
357
266
  key: 0,
358
- class: "slider-button-icon yu-color-primary"
267
+ class: "yu-slider-captcha-slider-button-icon yu-color-primary"
359
268
  })) : (openBlock(), createBlock(unref(SliderArrowSlide), {
360
269
  key: 1,
361
- class: "slider-button-icon yu-color-primary"
270
+ class: "yu-slider-captcha-slider-button-icon yu-color-primary"
362
271
  }))
363
272
  ], 4)
364
273
  ], 4),
365
- createElementVNode("span", _hoisted_6, toDisplayString(_ctx.sliderHint), 1)
274
+ createElementVNode("span", _hoisted_4, toDisplayString(_ctx.sliderHint), 1)
366
275
  ], 2)
367
276
  ], 4)
368
277
  ]);
@@ -2,12 +2,12 @@ import { defineComponent, ref, openBlock, createElementBlock, createElementVNode
2
2
  import SliderCaptcha from "./SliderCaptcha";
3
3
  const _hoisted_1 = {
4
4
  key: 0,
5
- class: "slider-captcha-dialog-container"
5
+ class: "yu-slider-captcha-dialog"
6
6
  };
7
- const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "slider-captcha-dialog-modal" }, null, -1);
8
- const _hoisted_3 = { class: "slider-captcha-dialog-wrapper" };
9
- const _hoisted_4 = { class: "slider-captcha-dialog slide-up" };
10
- const _hoisted_5 = { class: "slider-captcha" };
7
+ const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "yu-slider-captcha-dialog-modal" }, null, -1);
8
+ const _hoisted_3 = { class: "yu-slider-captcha-dialog-wrapper" };
9
+ const _hoisted_4 = { class: "yu-slider-captcha-dialog yu-slider-captcha-slide-up" };
10
+ const _hoisted_5 = { class: "yu-slider-captcha" };
11
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  ...{ name: "YuSliderCaptchaDialog" },
13
13
  __name: "index",