@truenewx/tnxvue3 2.6.0

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.
Files changed (60) hide show
  1. package/README.md +3 -0
  2. package/package.json +76 -0
  3. package/sample/App.vue +19 -0
  4. package/sample/main.js +11 -0
  5. package/sample/pages/index.vue +79 -0
  6. package/sample/pages/info.vue +28 -0
  7. package/sample/tnx.js +31 -0
  8. package/src/aj-captcha/Verify/VerifyPoints.vue +258 -0
  9. package/src/aj-captcha/Verify/VerifySlide.vue +379 -0
  10. package/src/aj-captcha/Verify.vue +375 -0
  11. package/src/aj-captcha/api/index.js +19 -0
  12. package/src/aj-captcha/utils/ase.js +11 -0
  13. package/src/aj-captcha/utils/util.js +35 -0
  14. package/src/ant-design/tnxad-theme.css +5 -0
  15. package/src/ant-design/tnxad.css +8 -0
  16. package/src/ant-design/tnxad.js +23 -0
  17. package/src/element-plus/alert/Alert.vue +112 -0
  18. package/src/element-plus/avatar/Avatar.vue +124 -0
  19. package/src/element-plus/button/Button.vue +184 -0
  20. package/src/element-plus/check-icon/CheckIcon.vue +61 -0
  21. package/src/element-plus/close-error-button/CloseErrorButton.vue +45 -0
  22. package/src/element-plus/curd/Curd.vue +224 -0
  23. package/src/element-plus/date-picker/DatePicker.vue +206 -0
  24. package/src/element-plus/date-range/DateRange.vue +78 -0
  25. package/src/element-plus/datetime-picker/DateTimePicker.vue +129 -0
  26. package/src/element-plus/detail-form/DetailForm.vue +88 -0
  27. package/src/element-plus/dialog/Dialog.vue +259 -0
  28. package/src/element-plus/dialog/DialogContent.vue +13 -0
  29. package/src/element-plus/drawer/Drawer.vue +175 -0
  30. package/src/element-plus/dropdown-item/DropdownItem.vue +30 -0
  31. package/src/element-plus/enum-select/EnumSelect.vue +125 -0
  32. package/src/element-plus/fetch-cascader/FetchCascader.vue +138 -0
  33. package/src/element-plus/fetch-select/FetchSelect.vue +166 -0
  34. package/src/element-plus/fetch-tags/FetchTags.vue +122 -0
  35. package/src/element-plus/fss-upload/FssUpload.vue +306 -0
  36. package/src/element-plus/fss-view/FssView.vue +163 -0
  37. package/src/element-plus/icon/Icon.vue +221 -0
  38. package/src/element-plus/input-number/InputNumber.vue +150 -0
  39. package/src/element-plus/paged/Paged.vue +76 -0
  40. package/src/element-plus/permission-tree/PermissionTree.vue +184 -0
  41. package/src/element-plus/query-form/QueryForm.vue +138 -0
  42. package/src/element-plus/query-table/QueryTable.vue +402 -0
  43. package/src/element-plus/region-cascader/RegionCascader.vue +108 -0
  44. package/src/element-plus/select/Select.vue +446 -0
  45. package/src/element-plus/slider/Slider.vue +88 -0
  46. package/src/element-plus/steps-nav/StepsNav.vue +57 -0
  47. package/src/element-plus/submit-form/SubmitForm.vue +236 -0
  48. package/src/element-plus/table-column/TableColumn.vue +32 -0
  49. package/src/element-plus/tabs/Tabs.vue +93 -0
  50. package/src/element-plus/tnxel.css +890 -0
  51. package/src/element-plus/tnxel.js +528 -0
  52. package/src/element-plus/transfer/Transfer.vue +117 -0
  53. package/src/element-plus/upload/Upload.vue +856 -0
  54. package/src/percent/Percent.vue +12 -0
  55. package/src/text/Text.vue +33 -0
  56. package/src/tnxvue-cli.js +64 -0
  57. package/src/tnxvue-router.js +161 -0
  58. package/src/tnxvue-validator.js +365 -0
  59. package/src/tnxvue.css +12 -0
  60. package/src/tnxvue.js +343 -0
@@ -0,0 +1,379 @@
1
+ <template>
2
+ <div style="position: relative;">
3
+ <div v-if="type === '2'" class="verify-img-out"
4
+ :style="{height: (parseInt(setSize.imgHeight) + vSpace) + 'px'}"
5
+ >
6
+ <div class="verify-img-panel" :style="{height: setSize.imgHeight}">
7
+ <img :src="'data:image/png;base64,'+backImgBase" alt="" style="width:100%;height:100%;display:block">
8
+ <div class="verify-refresh" @click="refresh" v-show="showRefresh">
9
+ <el-icon :size="16">
10
+ <icon-refresh/>
11
+ </el-icon>
12
+ </div>
13
+ <transition name="tips">
14
+ <span class="verify-tips" v-if="tipWords" :class="passFlag ?'suc-bg':'err-bg'">{{ tipWords }}</span>
15
+ </transition>
16
+ </div>
17
+ </div>
18
+ <!-- 公共部分 -->
19
+ <div class="verify-bar-area" :style="{height: barSize.height, 'line-height':barSize.height}">
20
+ <span class="verify-msg" v-text="text"></span>
21
+ <div class="verify-left-bar" :class="leftBarClass"
22
+ :style="{width: (leftBarWidth!==undefined)?leftBarWidth: barSize.height, height: barSize.height, transaction: transitionWidth}">
23
+ <span class="verify-msg" v-text="finishText"></span>
24
+ <div class="verify-move-block" :class="moveBlockClass"
25
+ @touchstart="start"
26
+ @mousedown="start"
27
+ :style="{width: barSize.height, height: barSize.height, left: moveBlockLeft, transition: transitionLeft}">
28
+ <el-icon class="verify-icon" :size="18">
29
+ <component :is="moveBlockIcon"/>
30
+ </el-icon>
31
+ <div v-if="type === '2'" class="verify-sub-block"
32
+ :style="{'width':Math.floor(parseInt(setSize.imgWidth)*47/310)+ 'px',
33
+ 'height': setSize.imgHeight,
34
+ 'top':'-' + (parseInt(setSize.imgHeight) + vSpace) + 'px',
35
+ 'background-size': setSize.imgWidth + ' ' + setSize.imgHeight,
36
+ }">
37
+ <img :src="'data:image/png;base64,'+blockBackImgBase" alt=""
38
+ style="width:100%;height:100%;display:block;-webkit-user-drag:none;">
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </template>
45
+ <script type="text/babel">
46
+ /**
47
+ * VerifySlide
48
+ * @description 滑块
49
+ * */
50
+ import {aesEncrypt} from "../utils/ase"
51
+ import {resetSize} from '../utils/util'
52
+ import {reqCheck, reqGet} from "../api"
53
+ import {computed, getCurrentInstance, nextTick, onMounted, reactive, ref, toRefs, watch} from 'vue';
54
+ import {ArrowRightBold, Check, Close, Refresh} from '@element-plus/icons-vue';
55
+ // "captchaType":"blockPuzzle",
56
+ export default {
57
+ name: 'VerifySlide',
58
+ components: {
59
+ 'icon-right': ArrowRightBold,
60
+ 'icon-check': Check,
61
+ 'icon-close': Close,
62
+ 'icon-refresh': Refresh,
63
+ },
64
+ props: {
65
+ captchaType: {
66
+ type: String,
67
+ },
68
+ type: {
69
+ type: String,
70
+ default: '1'
71
+ },
72
+ //弹出式pop,固定fixed
73
+ mode: {
74
+ type: String,
75
+ default: 'fixed'
76
+ },
77
+ vSpace: {
78
+ type: Number,
79
+ default: 5
80
+ },
81
+ explain: {
82
+ type: String,
83
+ default: '向右滑动完成验证'
84
+ },
85
+ imgSize: {
86
+ type: Object,
87
+ default() {
88
+ return {
89
+ width: '310px',
90
+ height: '155px'
91
+ }
92
+ }
93
+ },
94
+ blockSize: {
95
+ type: Object,
96
+ default() {
97
+ return {
98
+ width: '50px',
99
+ height: '50px'
100
+ }
101
+ }
102
+ },
103
+ barSize: {
104
+ type: Object,
105
+ default() {
106
+ return {
107
+ width: '310px',
108
+ height: '40px'
109
+ }
110
+ }
111
+ }
112
+ },
113
+ setup(props, context) {
114
+ const {mode, captchaType, vSpace, imgSize, barSize, type, blockSize, explain} = toRefs(props)
115
+ const {proxy} = getCurrentInstance();
116
+ let secretKey = ref(''), //后端返回的ase加密秘钥
117
+ passFlag = ref(''), //是否通过的标识
118
+ backImgBase = ref(''), //验证码背景图片
119
+ blockBackImgBase = ref(''), //验证滑块的背景图片
120
+ backToken = ref(''), //后端返回的唯一token值
121
+ startMoveTime = ref(''), //移动开始的时间
122
+ endMovetime = ref(''), //移动结束的时间
123
+ tipsBackColor = ref(''), //提示词的背景颜色
124
+ tipWords = ref(''),
125
+ text = ref(''),
126
+ finishText = ref(''),
127
+ setSize = reactive({
128
+ imgHeight: 0,
129
+ imgWidth: 0,
130
+ barHeight: 0,
131
+ barWidth: 0
132
+ }),
133
+ top = ref(0),
134
+ left = ref(0),
135
+ moveBlockLeft = ref(undefined),
136
+ leftBarWidth = ref(undefined),
137
+ // 移动中样式
138
+ moveBlockClass = ref(undefined),
139
+ leftBarClass = ref(undefined),
140
+ moveBlockIcon = ref('icon-right'),
141
+ status = ref(false), //鼠标状态
142
+ isEnd = ref(false), //是够验证完成
143
+ showRefresh = ref(true),
144
+ transitionLeft = ref(''),
145
+ transitionWidth = ref(''),
146
+ startLeft = ref(0)
147
+
148
+ const barArea = computed(() => {
149
+ return proxy.$el.querySelector('.verify-bar-area')
150
+ })
151
+
152
+ function init() {
153
+ text.value = explain.value
154
+ getPictrue();
155
+ nextTick(() => {
156
+ let {imgHeight, imgWidth, barHeight, barWidth} = resetSize(proxy)
157
+ setSize.imgHeight = imgHeight
158
+ setSize.imgWidth = imgWidth
159
+ setSize.barHeight = barHeight
160
+ setSize.barWidth = barWidth
161
+ proxy.$parent.$emit('ready', proxy)
162
+ })
163
+
164
+ window.removeEventListener("touchmove", function (e) {
165
+ move(e);
166
+ });
167
+ window.removeEventListener("mousemove", function (e) {
168
+ move(e);
169
+ });
170
+
171
+ //鼠标松开
172
+ window.removeEventListener("touchend", function () {
173
+ end();
174
+ });
175
+ window.removeEventListener("mouseup", function () {
176
+ end();
177
+ });
178
+
179
+ window.addEventListener("touchmove", function (e) {
180
+ move(e);
181
+ });
182
+ window.addEventListener("mousemove", function (e) {
183
+ move(e);
184
+ });
185
+
186
+ //鼠标松开
187
+ window.addEventListener("touchend", function () {
188
+ end();
189
+ });
190
+ window.addEventListener("mouseup", function () {
191
+ end();
192
+ });
193
+ }
194
+
195
+ watch(type, () => {
196
+ init()
197
+ })
198
+ onMounted(() => {
199
+ // 禁止拖拽
200
+ init()
201
+ proxy.$el.onselectstart = function () {
202
+ return false
203
+ }
204
+ })
205
+
206
+ //鼠标按下
207
+ function start(e) {
208
+ e = e || window.event
209
+ let x;
210
+ if (!e.touches) { //兼容PC端
211
+ x = e.clientX;
212
+ } else { //兼容移动端
213
+ x = e.touches[0].pageX;
214
+ }
215
+ console.log(barArea);
216
+ startLeft.value = Math.floor(x - barArea.value.getBoundingClientRect().left);
217
+ startMoveTime.value = +new Date(); //开始滑动的时间
218
+ if (isEnd.value === false) {
219
+ text.value = ''
220
+ moveBlockClass.value = 'bg-primary text-white';
221
+ leftBarClass.value = 'border-primary';
222
+ e.stopPropagation();
223
+ status.value = true;
224
+ }
225
+ }
226
+
227
+ //鼠标移动
228
+ function move(e) {
229
+ e = e || window.event
230
+ if (status.value && isEnd.value === false) {
231
+ let x;
232
+ if (!e.touches) { //兼容PC端
233
+ x = e.clientX;
234
+ } else { //兼容移动端
235
+ x = e.touches[0].pageX;
236
+ }
237
+ let bar_area_left = barArea.value.getBoundingClientRect().left;
238
+ let move_block_left = x - bar_area_left //小方块相对于父元素的left值
239
+ if (move_block_left >= barArea.value.offsetWidth - parseInt(parseInt(blockSize.value.width) / 2) - 2) {
240
+ move_block_left = barArea.value.offsetWidth - parseInt(parseInt(blockSize.value.width) / 2) - 2;
241
+ }
242
+ if (move_block_left <= 0) {
243
+ move_block_left = parseInt(parseInt(blockSize.value.width) / 2);
244
+ }
245
+ //拖动后小方块的left值
246
+ moveBlockLeft.value = (move_block_left - startLeft.value) + "px"
247
+ leftBarWidth.value = (move_block_left - startLeft.value) + "px"
248
+ }
249
+ }
250
+
251
+ //鼠标松开
252
+ function end() {
253
+ endMovetime.value = +new Date();
254
+ //判断是否重合
255
+ if (status.value && isEnd.value === false) {
256
+ let moveLeftDistance = parseInt((moveBlockLeft.value || '').replace('px', ''));
257
+ moveLeftDistance = moveLeftDistance * 310 / parseInt(setSize.imgWidth)
258
+ let data = {
259
+ captchaType: captchaType.value,
260
+ "pointJson": secretKey.value ? aesEncrypt(JSON.stringify({x: moveLeftDistance, y: 5.0}),
261
+ secretKey.value) : JSON.stringify({x: moveLeftDistance, y: 5.0}),
262
+ "token": backToken.value
263
+ }
264
+ reqCheck(data).then(res => {
265
+ if (res.repCode === "0000") {
266
+ moveBlockClass.value = 'bg-success';
267
+ leftBarClass.value = 'border-success';
268
+ moveBlockIcon.value = 'icon-check';
269
+ showRefresh.value = false
270
+ isEnd.value = true;
271
+ if (mode.value === 'pop') {
272
+ setTimeout(() => {
273
+ proxy.$parent.clickShow = false;
274
+ refresh();
275
+ }, 1500)
276
+ }
277
+ passFlag.value = true
278
+ tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(2)}s验证成功`
279
+ let captchaVerification = secretKey.value ? aesEncrypt(
280
+ backToken.value + '---' + JSON.stringify({x: moveLeftDistance, y: 5.0}),
281
+ secretKey.value) : backToken.value + '---' + JSON.stringify({x: moveLeftDistance, y: 5.0})
282
+ setTimeout(() => {
283
+ tipWords.value = ""
284
+ proxy.$parent.closeBox();
285
+ proxy.$parent.$emit('success', {captchaVerification})
286
+ }, 1000)
287
+ } else {
288
+ moveBlockClass.value = 'bg-danger';
289
+ leftBarClass.value = 'border-danger';
290
+ moveBlockIcon.value = 'icon-close';
291
+ passFlag.value = false
292
+ setTimeout(function () {
293
+ refresh();
294
+ }, 1000);
295
+ proxy.$parent.$emit('error', proxy)
296
+ tipWords.value = "验证失败"
297
+ setTimeout(() => {
298
+ tipWords.value = ""
299
+ }, 1000)
300
+ }
301
+ })
302
+ status.value = false;
303
+ }
304
+ }
305
+
306
+ const refresh = () => {
307
+ showRefresh.value = true
308
+ finishText.value = ''
309
+
310
+ transitionLeft.value = 'left .3s'
311
+ moveBlockLeft.value = 0
312
+
313
+ leftBarWidth.value = undefined
314
+ transitionWidth.value = 'width .3s'
315
+
316
+ leftBarClass.value = '';
317
+ moveBlockClass.value = '';
318
+ moveBlockIcon.value = 'icon-right';
319
+ isEnd.value = false
320
+
321
+ getPictrue()
322
+ setTimeout(() => {
323
+ transitionWidth.value = ''
324
+ transitionLeft.value = ''
325
+ text.value = explain.value
326
+ }, 300)
327
+ }
328
+
329
+ // 请求背景图片和验证图片
330
+ function getPictrue() {
331
+ let data = {
332
+ captchaType: captchaType.value
333
+ }
334
+ reqGet(data).then(res => {
335
+ if (res.repCode === "0000") {
336
+ backImgBase.value = res.repData.originalImageBase64
337
+ blockBackImgBase.value = res.repData.jigsawImageBase64
338
+ backToken.value = res.repData.token
339
+ secretKey.value = res.repData.secretKey
340
+ } else {
341
+ tipWords.value = res.repMsg;
342
+ }
343
+ })
344
+ }
345
+
346
+ return {
347
+ secretKey, //后端返回的ase加密秘钥
348
+ passFlag, //是否通过的标识
349
+ backImgBase, //验证码背景图片
350
+ blockBackImgBase, //验证滑块的背景图片
351
+ backToken, //后端返回的唯一token值
352
+ startMoveTime, //移动开始的时间
353
+ endMovetime, //移动结束的时间
354
+ tipsBackColor, //提示词的背景颜色
355
+ tipWords,
356
+ text,
357
+ finishText,
358
+ setSize,
359
+ top,
360
+ left,
361
+ moveBlockLeft,
362
+ leftBarWidth,
363
+ // 移动中样式
364
+ moveBlockClass,
365
+ leftBarClass,
366
+ moveBlockIcon,
367
+ status, //鼠标状态
368
+ isEnd, //是够验证完成
369
+ showRefresh,
370
+ transitionLeft,
371
+ transitionWidth,
372
+ barArea,
373
+ refresh,
374
+ start
375
+ }
376
+ },
377
+ }
378
+ </script>
379
+