yuang-framework-ui-pc 1.1.16 → 1.1.18

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.
@@ -51,3 +51,5 @@ export { default as EleTreeSelect } from './ele-tree-select/index';
51
51
  export { default as EleUploadList } from './ele-upload-list/index';
52
52
  export { default as EleVirtualTable } from './ele-virtual-table/index';
53
53
  export { default as EleWatermark } from './ele-watermark/index';
54
+
55
+ export { default as YuSliderCaptchaDialog } from './yu-slider-captcha-dialog/index';
@@ -50,6 +50,7 @@ import { default as default51 } from "./ele-tree-select/index";
50
50
  import { default as default52 } from "./ele-upload-list/index";
51
51
  import { default as default53 } from "./ele-virtual-table/index";
52
52
  import { default as default54 } from "./ele-watermark/index";
53
+ import { default as default55 } from "./yu-slider-captcha-dialog/index";
53
54
  export {
54
55
  default2 as EleAdminLayout,
55
56
  default3 as EleAlert,
@@ -103,5 +104,6 @@ export {
103
104
  default51 as EleTreeSelect,
104
105
  default52 as EleUploadList,
105
106
  default53 as EleVirtualTable,
106
- default54 as EleWatermark
107
+ default54 as EleWatermark,
108
+ default55 as YuSliderCaptchaDialog
107
109
  };
@@ -0,0 +1,67 @@
1
+ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
+ blockLength?: number;
3
+ blockRadius?: number;
4
+ canvasWidth?: number;
5
+ canvasHeight?: number;
6
+ sliderHint?: string;
7
+ accuracy?: number;
8
+ imageList?: string[];
9
+ }>, {
10
+ blockLength: number;
11
+ blockRadius: number;
12
+ canvasWidth: number;
13
+ canvasHeight: number;
14
+ sliderHint: string;
15
+ accuracy: number;
16
+ imageList: any;
17
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
18
+ success: (data: Object) => void;
19
+ fail: (data: Object) => void;
20
+ close: () => void;
21
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
22
+ blockLength?: number;
23
+ blockRadius?: number;
24
+ canvasWidth?: number;
25
+ canvasHeight?: number;
26
+ sliderHint?: string;
27
+ accuracy?: number;
28
+ imageList?: string[];
29
+ }>, {
30
+ blockLength: number;
31
+ blockRadius: number;
32
+ canvasWidth: number;
33
+ canvasHeight: number;
34
+ sliderHint: string;
35
+ accuracy: number;
36
+ imageList: any;
37
+ }>>> & {
38
+ onClose?: (() => any) | undefined;
39
+ onSuccess?: ((data: Object) => any) | undefined;
40
+ onFail?: ((data: Object) => any) | undefined;
41
+ }, {
42
+ blockLength: number;
43
+ blockRadius: number;
44
+ canvasWidth: number;
45
+ canvasHeight: number;
46
+ sliderHint: string;
47
+ accuracy: number;
48
+ imageList: string[];
49
+ }, {}>;
50
+ export default _default;
51
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
52
+ type __VLS_TypePropsToRuntimeProps<T> = {
53
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
54
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
55
+ } : {
56
+ type: import('vue').PropType<T[K]>;
57
+ required: true;
58
+ };
59
+ };
60
+ type __VLS_WithDefaults<P, D> = {
61
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
62
+ default: D[K];
63
+ }> : P[K];
64
+ };
65
+ type __VLS_Prettify<T> = {
66
+ [K in keyof T]: T[K];
67
+ } & {};
@@ -0,0 +1,528 @@
1
+ import { defineComponent, ref, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, unref, normalizeStyle, normalizeClass, createCommentVNode, toDisplayString, Fragment, pushScopeId, popScopeId } from "vue";
2
+ import axios from "../../node_modules/axios/lib/axios.js";
3
+ import { useRouter } from "vue-router";
4
+ import { showErrorMessage } from "../../node_modules/yuang-framework-ui-common/lib/utils/messageUtils";
5
+ import { alertMessageBox } from "../../node_modules/yuang-framework-ui-common/lib/utils/messageBoxUtils";
6
+ import { clearSsoAccessToken, getSsoLoginUrl, setSsoAccessToken } from "../../node_modules/yuang-framework-ui-common/lib/utils/ssoUtils";
7
+ import { getGatewayConfigUrl, initGatewayConfig, clearGatewayConfig } from "../../node_modules/yuang-framework-ui-common/lib/config/gatewayConfig";
8
+ import { getLocalStorageItem } from "../../node_modules/yuang-framework-ui-common/lib/utils/storageUtils";
9
+ import { CircleClose } from "@element-plus/icons-vue";
10
+ const router = useRouter();
11
+ const messageMap = {
12
+ requestError: "请求异常",
13
+ responseSturctError: "响应结构错误"
14
+ };
15
+ const apiBaseUrl = "/gateway-server";
16
+ const http = axios.create({
17
+ baseURL: apiBaseUrl,
18
+ timeout: 1e4,
19
+ headers: {}
20
+ });
21
+ http.interceptors.request.use(async (config) => {
22
+ let gatewayAccessToken = getLocalStorageItem("gatewayAccessToken") ?? "";
23
+ if (!gatewayAccessToken && config.url != getGatewayConfigUrl) {
24
+ await initGatewayConfig();
25
+ }
26
+ beforeRequestConfig(config);
27
+ return config;
28
+ }, (error) => {
29
+ showErrorMessage((error == null ? void 0 : error.message) || messageMap.requestError);
30
+ return Promise.reject(error);
31
+ });
32
+ http.interceptors.response.use(async (res) => {
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
34
+ if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.statusCode)) {
35
+ showErrorMessage(messageMap.responseSturctError);
36
+ return Promise.reject(new Error(messageMap.responseSturctError));
37
+ }
38
+ if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.statusCode) !== 200) {
39
+ if (((_c = res == null ? void 0 : res.data) == null ? void 0 : _c.statusCode) === 401) {
40
+ alertMessageBox({
41
+ title: "系统提示",
42
+ message: "登录状态已过期, 请退出重新登录!",
43
+ confirmButtonText: "重新登录",
44
+ callback: (action) => {
45
+ if (action === "confirm") {
46
+ clearSsoAccessToken();
47
+ window.location.href = getSsoLoginUrl() || "";
48
+ }
49
+ }
50
+ });
51
+ return Promise.reject(new Error((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.message));
52
+ } else if (((_e = res == null ? void 0 : res.data) == null ? void 0 : _e.statusCode) === 500822001) {
53
+ clearGatewayConfig();
54
+ window.location.reload();
55
+ return Promise.reject(new Error((_f = res == null ? void 0 : res.data) == null ? void 0 : _f.message));
56
+ } else if (((_g = res == null ? void 0 : res.data) == null ? void 0 : _g.statusCode) === 500815001) {
57
+ showErrorMessage(((_h = res == null ? void 0 : res.data) == null ? void 0 : _h.message) || messageMap.requestError);
58
+ clearSsoAccessToken();
59
+ window.location.href = getSsoLoginUrl() || "";
60
+ return Promise.reject(new Error((_i = res == null ? void 0 : res.data) == null ? void 0 : _i.message));
61
+ } else if (((_j = res == null ? void 0 : res.data) == null ? void 0 : _j.statusCode) === 500815005) {
62
+ await refreshSsoAccessToken(res);
63
+ return axios.request(res.config);
64
+ } else if (((_k = res == null ? void 0 : res.data) == null ? void 0 : _k.statusCode) === 500815006) {
65
+ const fullPath = router.currentRoute.value.fullPath;
66
+ router.push(`/sso/auth/index?ssoRedirectRoutePath=${encodeURIComponent(fullPath)}`);
67
+ return;
68
+ } else if (((_l = res == null ? void 0 : res.data) == null ? void 0 : _l.statusCode) === 500815003) {
69
+ showErrorMessage(((_m = res == null ? void 0 : res.data) == null ? void 0 : _m.message) || messageMap.requestError);
70
+ return Promise.reject(new Error((_n = res == null ? void 0 : res.data) == null ? void 0 : _n.message));
71
+ }
72
+ showErrorMessage(((_o = res == null ? void 0 : res.data) == null ? void 0 : _o.message) || messageMap.requestError);
73
+ return Promise.reject(new Error((_p = res == null ? void 0 : res.data) == null ? void 0 : _p.message));
74
+ }
75
+ return res;
76
+ }, (error) => {
77
+ var _a, _b;
78
+ let errorMessage = "";
79
+ if ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) {
80
+ let { statusCode, message } = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
81
+ if (statusCode !== 200) {
82
+ errorMessage = message;
83
+ }
84
+ errorMessage = errorMessage || messageMap.requestError;
85
+ } else {
86
+ errorMessage = (error == null ? void 0 : error.message) || messageMap.requestError;
87
+ }
88
+ showErrorMessage(errorMessage);
89
+ return Promise.reject(error);
90
+ });
91
+ const beforeRequestConfig = (config) => {
92
+ if (!config.url) {
93
+ return console.error("参数[url]不存在");
94
+ }
95
+ config.headers["X-Requested-With"] = "XMLHttpRequest";
96
+ let gatewayAccessToken = getLocalStorageItem("gatewayAccessToken") ?? "";
97
+ let gatewayPublicKey = getLocalStorageItem("gatewayPublicKey") ?? "";
98
+ let ssoAccessToken = getLocalStorageItem("ssoAccessToken") ?? "";
99
+ if (gatewayAccessToken) {
100
+ config.headers["Gateway-Access-Token"] = gatewayAccessToken;
101
+ }
102
+ if (gatewayPublicKey) {
103
+ config.headers["Gateway-Public-Key"] = gatewayPublicKey;
104
+ }
105
+ if (ssoAccessToken) {
106
+ config.headers["Sso-Access-Token"] = ssoAccessToken;
107
+ }
108
+ config.headers["Request-Id"] = (/* @__PURE__ */ new Date()).getTime().toString() + parseInt((Math.random() * 1e4).toString()).toString();
109
+ };
110
+ const refreshSsoAccessToken = (res) => {
111
+ let ssoRefreshToken = encodeURIComponent(getLocalStorageItem("ssoRefreshToken") ?? "");
112
+ if (!ssoRefreshToken) {
113
+ return showErrorMessage("参数[ssoRefreshToken]为空");
114
+ }
115
+ return new Promise((resolve, reject) => {
116
+ const config = res.config;
117
+ config.params = {
118
+ ssoRefreshToken
119
+ };
120
+ axios.get(`/sso-api/client/sso-auth/getSsoRefreshToken`, config).then((res2) => {
121
+ var _a;
122
+ if (((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.statusCode) !== 200) {
123
+ return reject();
124
+ }
125
+ setSsoAccessToken(res2.data.data);
126
+ return resolve(void 0);
127
+ });
128
+ });
129
+ };
130
+ const getBaseUrl = (url) => {
131
+ url = url || location.href;
132
+ let arr = url.split("/");
133
+ if (arr.length > 3) {
134
+ var baseUrl = "";
135
+ for (let i = 0; i < arr.length; i++) {
136
+ if (i <= 3) {
137
+ baseUrl += arr[i] + "/";
138
+ }
139
+ }
140
+ if (baseUrl) {
141
+ return baseUrl.substring(0, baseUrl.length - 1);
142
+ }
143
+ } else {
144
+ console.error("地址存在问题");
145
+ }
146
+ };
147
+ const _withScopeId = (n) => (pushScopeId("data-v-894ffd06"), n = n(), popScopeId(), n);
148
+ const _hoisted_1 = { class: "slider-captcha-container" };
149
+ const _hoisted_2 = { class: "slider-captcha-title" };
150
+ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("i", { class: "el-icon-refresh" }, null, -1));
151
+ const _hoisted_4 = [
152
+ _hoisted_3
153
+ ];
154
+ const _hoisted_5 = ["width", "height"];
155
+ const _hoisted_6 = ["width", "height"];
156
+ const _hoisted_7 = ["width", "height"];
157
+ const _hoisted_8 = {
158
+ key: 0,
159
+ class: "slider-button-icon iconfont icon-slider-init yu-color-primary"
160
+ };
161
+ const _hoisted_9 = {
162
+ key: 1,
163
+ class: "slider-button-icon iconfont icon-slider-slide yu-color-primary"
164
+ };
165
+ const _hoisted_10 = { class: "slider-hint" };
166
+ const _sfc_main = /* @__PURE__ */ defineComponent({
167
+ ...{ name: "SliderCaptcha" },
168
+ __name: "SliderCaptcha",
169
+ props: {
170
+ blockLength: { default: 42 },
171
+ blockRadius: { default: 10 },
172
+ canvasWidth: { default: 320 },
173
+ canvasHeight: { default: 155 },
174
+ sliderHint: { default: "向右滑动" },
175
+ accuracy: { default: 3 },
176
+ imageList: { default: [] }
177
+ },
178
+ emits: ["success", "fail", "close"],
179
+ setup(__props, { emit: __emit }) {
180
+ const props = __props;
181
+ const emit = __emit;
182
+ const canvas = ref(null);
183
+ const block = ref(null);
184
+ const isFrontCheck = ref(false);
185
+ const verifyActive = ref(false);
186
+ const verifySuccess = ref(false);
187
+ const verifyFail = ref(false);
188
+ const canvasCtx = ref(null);
189
+ const blockCtx = ref(null);
190
+ const blockWidth = ref(props.blockLength * 2);
191
+ const blockX = ref(void 0);
192
+ const blockY = ref(void 0);
193
+ const image = ref(void 0);
194
+ const originX = ref(void 0);
195
+ const originY = ref(void 0);
196
+ const dragDistanceList = ref([]);
197
+ const sliderBoxWidth = ref(0);
198
+ const sliderButtonLeft = ref(0);
199
+ const isMouseDown = ref(false);
200
+ const isLoading = ref(true);
201
+ const timestamp = ref(null);
202
+ const successHint = ref("");
203
+ const key = ref(void 0);
204
+ const isSliderSlide = ref(false);
205
+ onMounted(() => {
206
+ init();
207
+ });
208
+ const init = () => {
209
+ initDom();
210
+ bindEvents();
211
+ };
212
+ const initDom = () => {
213
+ if (isFrontCheck.value) {
214
+ canvasCtx.value = canvas.value.getContext("2d");
215
+ blockCtx.value = block.value.getContext("2d");
216
+ initImage();
217
+ } else {
218
+ getCaptcha();
219
+ }
220
+ };
221
+ const getCaptcha = () => {
222
+ http.get("/framework-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
223
+ key.value = res.data.data.key;
224
+ block.value.src = res.data.data.blockSrc;
225
+ block.value.style.top = res.data.data.blockY + "px";
226
+ canvas.value.src = res.data.data.canvasSrc;
227
+ setTimeout(() => {
228
+ isLoading.value = false;
229
+ }, 200);
230
+ });
231
+ };
232
+ const initImage = () => {
233
+ const imageObject = createImage(() => {
234
+ drawBlock();
235
+ let { canvasWidth, canvasHeight, blockX: blockX2, blockY: blockY2, blockRadius, blockWidth: blockWidth2 } = this;
236
+ canvasCtx.value.drawImage(image, 0, 0, canvasWidth, canvasHeight);
237
+ blockCtx.value.drawImage(image, 0, 0, canvasWidth, canvasHeight);
238
+ let yAxle = blockY2 - blockRadius * 2;
239
+ let ImageData = blockCtx.value.getImageData(blockX2, yAxle, blockWidth2, blockWidth2);
240
+ block.value.width = blockWidth2;
241
+ blockCtx.value.putImageData(ImageData, 0, yAxle);
242
+ isLoading.value = false;
243
+ key.value = "loyer";
244
+ });
245
+ image.value = imageObject;
246
+ };
247
+ const createImage = (onload) => {
248
+ const image2 = document.createElement("img");
249
+ image2.crossOrigin = "Anonymous";
250
+ image2.onload = onload;
251
+ image2.onerror = () => {
252
+ image2.src = `${getBaseUrl()}/img/slider-captcha/pic-0.jpeg`;
253
+ };
254
+ image2.src = getImageSrc();
255
+ return image2;
256
+ };
257
+ const getImageSrc = () => {
258
+ const len = props.imageList.length;
259
+ return len > 0 ? props.imageList[getNonceByRange(0, len)] : `https://loyer.wang/view/ftp/wallpaper/${getNonceByRange(1, 1e3)}.jpg`;
260
+ };
261
+ const getNonceByRange = (start, end) => {
262
+ return Math.round(Math.random() * (end - start) + start);
263
+ };
264
+ const drawBlock = () => {
265
+ blockX.value = getNonceByRange(blockWidth.value + 10, props.canvasWidth - (blockWidth.value + 10));
266
+ blockY.value = getNonceByRange(10 + props.blockRadius * 2, props.canvasHeight - (blockWidth.value + 10));
267
+ draw(canvasCtx.value, "fill");
268
+ draw(blockCtx.value, "clip");
269
+ };
270
+ const draw = (ctx, operation) => {
271
+ const PI = Math.PI;
272
+ let { blockX: x, blockY: y, blockLength: l, blockRadius: r } = this;
273
+ ctx.beginPath();
274
+ ctx.moveTo(x, y);
275
+ ctx.arc(x + l / 2, y - r + 2, r, 0.72 * PI, 2.26 * PI);
276
+ ctx.lineTo(x + l, y);
277
+ ctx.arc(x + l + r - 2, y + l / 2, r, 1.21 * PI, 2.78 * PI);
278
+ ctx.lineTo(x + l, y + l);
279
+ ctx.lineTo(x, y + l);
280
+ ctx.arc(x + r - 2, y + l / 2, r + 0.4, 2.76 * PI, 1.24 * PI, true);
281
+ ctx.lineTo(x, y);
282
+ ctx.lineWidth = 2;
283
+ ctx.fillStyle = "rgba(255, 255, 255, 0.9)";
284
+ ctx.strokeStyle = "rgba(255, 255, 255, 0.9)";
285
+ ctx.stroke();
286
+ ctx[operation]();
287
+ ctx.globalCompositeOperation = "destination-over";
288
+ };
289
+ const bindEvents = () => {
290
+ var _a, _b, _c;
291
+ (_a = document.getElementById("slider-button")) == null ? void 0 : _a.addEventListener("mousedown", (event) => {
292
+ startEvent(event.clientX, event.clientY);
293
+ updateSliderButtonImage("slide");
294
+ });
295
+ document.addEventListener("mousemove", (event) => {
296
+ moveEvent(event.clientX, event.clientY);
297
+ });
298
+ document.addEventListener("mouseup", (event) => {
299
+ endEvent(event.clientX);
300
+ });
301
+ (_b = document.getElementById("slider-button")) == null ? void 0 : _b.addEventListener("click", (event) => {
302
+ updateSliderButtonImage("init");
303
+ });
304
+ (_c = document.getElementById("slider-button")) == null ? void 0 : _c.addEventListener("touchstart", (event) => {
305
+ startEvent(event.changedTouches[0].pageX, event.changedTouches[0].pageY);
306
+ });
307
+ document.addEventListener("touchmove", (event) => {
308
+ moveEvent(event.changedTouches[0].pageX, event.changedTouches[0].pageY);
309
+ });
310
+ document.addEventListener("touchend", (event) => {
311
+ endEvent(event.changedTouches[0].pageX);
312
+ });
313
+ };
314
+ const updateSliderButtonImage = (type) => {
315
+ if (type == "init") {
316
+ isSliderSlide.value = false;
317
+ } else if (type == "slide") {
318
+ isSliderSlide.value = true;
319
+ }
320
+ };
321
+ const checkImgSrc = () => {
322
+ if (isFrontCheck.value) {
323
+ return true;
324
+ }
325
+ return !!canvas.value.src;
326
+ };
327
+ const startEvent = (clientX, clientY) => {
328
+ if (!checkImgSrc() || isLoading.value || verifySuccess.value) {
329
+ return;
330
+ }
331
+ originX.value = clientX;
332
+ originY.value = clientY;
333
+ isMouseDown.value = true;
334
+ timestamp.value = +/* @__PURE__ */ new Date();
335
+ updateSliderButtonImage("slide");
336
+ };
337
+ const moveEvent = (clientX, clientY) => {
338
+ if (!isMouseDown.value) {
339
+ return false;
340
+ }
341
+ const moveX = clientX - originX.value;
342
+ const moveY = clientY - originY.value;
343
+ if (moveX < 0 || moveX + 40 >= props.canvasWidth) {
344
+ return false;
345
+ }
346
+ sliderButtonLeft.value = moveX > props.canvasWidth - 56 ? props.canvasWidth - 56 : moveX;
347
+ let blockLeft = (props.canvasWidth - 40 - 20) / (props.canvasWidth - 40) * moveX;
348
+ block.value.style.left = (blockLeft > props.canvasWidth - 56 - 18 - 7 ? props.canvasWidth - 56 - 18 - 7 : blockLeft) + "px";
349
+ verifyActive.value = true;
350
+ sliderBoxWidth.value = moveX + 28;
351
+ dragDistanceList.value.push(moveY);
352
+ };
353
+ const endEvent = (clientX) => {
354
+ if (!isMouseDown.value) {
355
+ return false;
356
+ }
357
+ isMouseDown.value = false;
358
+ if (clientX === originX.value) {
359
+ return false;
360
+ }
361
+ isLoading.value = true;
362
+ verifyActive.value = false;
363
+ timestamp.value = +/* @__PURE__ */ new Date() - timestamp.value;
364
+ const moveLength = parseInt(block.value.style.left);
365
+ if (timestamp.value > 1e4) {
366
+ verifyFailEvent();
367
+ } else {
368
+ if (!turingTest()) {
369
+ verifyFailEvent();
370
+ } else {
371
+ if (isFrontCheck.value) {
372
+ const accuracyValue = props.accuracy <= 1 ? 1 : props.accuracy > 10 ? 10 : props.accuracy;
373
+ const spliced = Math.abs(moveLength - blockX.value) <= accuracyValue;
374
+ if (!spliced) {
375
+ verifyFailEvent();
376
+ } else {
377
+ emit("success", { key: key.value, value: moveLength });
378
+ }
379
+ return;
380
+ }
381
+ let params = {
382
+ key: key.value,
383
+ captcha: moveLength
384
+ };
385
+ http.get("/framework-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
386
+ emit("success", { key: key.value, value: moveLength });
387
+ }).catch(() => {
388
+ verifyFailEvent();
389
+ });
390
+ }
391
+ }
392
+ updateSliderButtonImage("init");
393
+ };
394
+ const turingTest = () => {
395
+ const arr = dragDistanceList.value;
396
+ const average = arr.reduce(calcSum) / arr.length;
397
+ const deviations = arr.map((x) => x - average);
398
+ const stdDev = Math.sqrt(deviations.map(calcSquare).reduce(calcSum) / arr.length);
399
+ return average !== stdDev;
400
+ };
401
+ const verifyFailEvent = () => {
402
+ verifyFail.value = true;
403
+ emit("fail", {});
404
+ refresh();
405
+ };
406
+ const refresh = () => {
407
+ setTimeout(() => {
408
+ verifyFail.value = false;
409
+ }, 300);
410
+ isLoading.value = true;
411
+ verifyActive.value = false;
412
+ verifySuccess.value = false;
413
+ block.value.style.left = 0;
414
+ sliderBoxWidth.value = 0;
415
+ sliderButtonLeft.value = 0;
416
+ nextTick(() => {
417
+ if (isFrontCheck.value) {
418
+ let { canvasWidth, canvasHeight } = this;
419
+ canvasCtx.value.clearRect(0, 0, canvasWidth, canvasHeight);
420
+ blockCtx.value.clearRect(0, 0, canvasWidth, canvasHeight);
421
+ block.value.width = canvasWidth;
422
+ image.value.src = getImageSrc();
423
+ } else {
424
+ getCaptcha();
425
+ }
426
+ });
427
+ };
428
+ const close = () => {
429
+ emit("close");
430
+ };
431
+ const calcSum = (x, y) => {
432
+ return x + y;
433
+ };
434
+ const calcSquare = (x) => {
435
+ return x * x;
436
+ };
437
+ return (_ctx, _cache) => {
438
+ return openBlock(), createElementBlock("div", _hoisted_1, [
439
+ createElementVNode("div", _hoisted_2, [
440
+ createTextVNode(" 完成拼图验证 "),
441
+ createElementVNode("div", {
442
+ onClick: refresh,
443
+ class: "slider-captcha-refresh-icon"
444
+ }, _hoisted_4),
445
+ createElementVNode("div", {
446
+ onClick: close,
447
+ class: "slider-captcha-close-icon"
448
+ }, [
449
+ createVNode(unref(CircleClose))
450
+ ])
451
+ ]),
452
+ createElementVNode("div", {
453
+ class: "slider-captcha",
454
+ style: normalizeStyle({ width: _ctx.canvasWidth + "px" }),
455
+ onselectstart: "return false;"
456
+ }, [
457
+ isLoading.value ? (openBlock(), createElementBlock("div", {
458
+ key: 0,
459
+ class: normalizeClass({ "img-loading": isLoading.value }),
460
+ style: normalizeStyle({ height: _ctx.canvasHeight + "px" })
461
+ }, null, 6)) : createCommentVNode("", true),
462
+ verifySuccess.value ? (openBlock(), createElementBlock("div", {
463
+ key: 1,
464
+ class: "success-hint",
465
+ style: normalizeStyle({ height: _ctx.canvasHeight + "px" })
466
+ }, toDisplayString(successHint.value), 5)) : createCommentVNode("", true),
467
+ isFrontCheck.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
468
+ createElementVNode("canvas", {
469
+ ref_key: "canvas",
470
+ ref: canvas,
471
+ class: "slide-canvas",
472
+ width: _ctx.canvasWidth,
473
+ height: _ctx.canvasHeight
474
+ }, null, 8, _hoisted_5),
475
+ createElementVNode("canvas", {
476
+ ref_key: "block",
477
+ ref: block,
478
+ class: "slide-block",
479
+ width: _ctx.canvasWidth,
480
+ height: _ctx.canvasHeight
481
+ }, null, 8, _hoisted_6)
482
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
483
+ createElementVNode("img", {
484
+ ref_key: "canvas",
485
+ ref: canvas,
486
+ class: "slide-canvas",
487
+ width: _ctx.canvasWidth,
488
+ height: _ctx.canvasHeight
489
+ }, null, 8, _hoisted_7),
490
+ createElementVNode("img", {
491
+ ref_key: "block",
492
+ ref: block,
493
+ class: normalizeClass(["slide-block", { "verify-fail": verifyFail.value }])
494
+ }, null, 2)
495
+ ], 64)),
496
+ createElementVNode("div", {
497
+ class: normalizeClass(["slider", { "verify-active": verifyActive.value, "verify-success": verifySuccess.value, "verify-fail": verifyFail.value }])
498
+ }, [
499
+ createElementVNode("div", {
500
+ class: "slider-box background-primary",
501
+ style: normalizeStyle({ width: sliderBoxWidth.value + "px" })
502
+ }, [
503
+ createElementVNode("div", {
504
+ class: "slider-button",
505
+ id: "slider-button",
506
+ style: normalizeStyle({ left: sliderButtonLeft.value + "px" })
507
+ }, [
508
+ !isSliderSlide.value ? (openBlock(), createElementBlock("div", _hoisted_8)) : (openBlock(), createElementBlock("div", _hoisted_9))
509
+ ], 4)
510
+ ], 4),
511
+ createElementVNode("span", _hoisted_10, toDisplayString(_ctx.sliderHint), 1)
512
+ ], 2)
513
+ ], 4)
514
+ ]);
515
+ };
516
+ }
517
+ });
518
+ const _export_sfc = (sfc, props) => {
519
+ const target = sfc.__vccOpts || sfc;
520
+ for (const [key, val] of props) {
521
+ target[key] = val;
522
+ }
523
+ return target;
524
+ };
525
+ const SliderCaptcha = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-894ffd06"]]);
526
+ export {
527
+ SliderCaptcha as default
528
+ };
@@ -0,0 +1,14 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {
2
+ showSliderCaptcha: () => void;
3
+ hideSliderCaptcha: () => void;
4
+ validateResult: import('vue').Ref<boolean>;
5
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ success: (data: Object) => void;
7
+ fail: (data: Object) => void;
8
+ close: () => void;
9
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>> & {
10
+ onClose?: (() => any) | undefined;
11
+ onSuccess?: ((data: Object) => any) | undefined;
12
+ onFail?: ((data: Object) => any) | undefined;
13
+ }, {}, {}>;
14
+ export default _default;