wangzhonglu преди 9 месеца
родител
ревизия
cf78bc76dd
променени са 5 файла, в които са добавени 566 реда и са изтрити 34 реда
  1. 0
    26
      src/App.vue
  2. 13
    4
      src/assets/less/common.less
  3. 4
    4
      src/assets/less/customModal.less
  4. 33
    0
      src/utils/dom.js
  5. 516
    0
      src/utils/keyCode.js

+ 0
- 26
src/App.vue Целия файл

@@ -1,9 +1,5 @@
1 1
 <template>
2 2
   <div id="app">
3
-    <div class="btn">新建</div>
4
-    <Button type="primary" class="my_btn">Primary</Button>
5
-
6
-    1212
7 3
     <router-view></router-view>
8 4
   </div>
9 5
 </template>
@@ -53,26 +49,4 @@ export default {
53 49
     }
54 50
   }
55 51
 }
56
-.btn {
57
-  margin: 20px;
58
-  width: 80px;
59
-  height: 32px;
60
-  text-align: center;
61
-  line-height: 32px;
62
-  color: #fff;
63
-  border-radius: 8px;
64
-  opacity: 1;
65
-  background: linear-gradient(180deg, #30e5fc 0%, #34a4ff 100%);
66
-  box-shadow: inset 0 1px 2px 0 #ffffffb3, inset 0 -2px 3px 0 #ffffff4d,
67
-    0 3px 5px 0 #339dff80, inset 0 -2px 0 0 #2b89e0;
68
-}
69
-.primary_btn.ivu-btn.ivu-btn-primary {
70
-  margin: 20px;
71
-  border: none;
72
-  border-radius: 8px;
73
-  opacity: 1;
74
-  background: linear-gradient(180deg, #30e5fc 0%, #34a4ff 100%);
75
-  box-shadow: inset 0 1px 2px 0 #ffffffb3, inset 0 -2px 3px 0 #ffffff4d,
76
-    0 3px 5px 0 #339dff80, inset 0 -2px 0 0 #2b89e0;
77
-}
78 52
 </style>

+ 13
- 4
src/assets/less/common.less Целия файл

@@ -16,10 +16,10 @@ body,
16 16
   box-sizing: border-box;
17 17
   overflow: hidden;
18 18
   // 设置弥散渐变
19
-  background-image: url("~@/assets/img/dispersion_gradient.png");
20
-  background-size: cover;
21
-  background-repeat: no-repeat;
22
-  background-position: center;
19
+  // background-image: url("~@/assets/img/dispersion_gradient.png");
20
+  // background-size: cover;
21
+  // background-repeat: no-repeat;
22
+  // background-position: center;
23 23
   /* 第一个方块颜色,第二个轨道颜色(用于更改火狐浏览器样式) */
24 24
   // scrollbar-color: #7c8db5 #f3f4fc;
25 25
   /* 火狐滚动条无法自定义宽度,只能通过此属性使滚动条宽度变细 */
@@ -330,4 +330,13 @@ fieldset[disabled] .ivu-input,
330 330
 // 可关闭的错误消息可复制消息
331 331
 .ivu-message-custom-content.ivu-message-error {
332 332
   user-select: text;
333
+}
334
+// 按钮样式
335
+.primary_btn.ivu-btn.ivu-btn-primary {
336
+  border: none;
337
+  border-radius: 8px;
338
+  opacity: 1;
339
+  background: linear-gradient(180deg, #30e5fc 0%, #34a4ff 100%);
340
+  box-shadow: inset 0 1px 2px 0 #ffffffb3, inset 0 -2px 3px 0 #ffffff4d,
341
+    0 3px 5px 0 #339dff80, inset 0 -2px 0 0 #2b89e0;
333 342
 }

+ 4
- 4
src/assets/less/customModal.less Целия файл

@@ -39,10 +39,10 @@
39 39
     padding: 13px 16px !important;
40 40
     border-bottom: none;
41 41
     // 设置弥散渐变
42
-    background-image: url("~@/assets/img/dispersion_gradient1.png");
43
-    background-size: cover;
44
-    background-repeat: no-repeat;
45
-    background-position: center;
42
+    // background-image: url("~@/assets/img/dispersion_gradient1.png");
43
+    // background-size: cover;
44
+    // background-repeat: no-repeat;
45
+    // background-position: center;
46 46
     .ivu-modal-header-inner {
47 47
       font-size: 16px !important;
48 48
       color: #253A70;

+ 33
- 0
src/utils/dom.js Целия файл

@@ -0,0 +1,33 @@
1
+const isClient = typeof window !== "undefined";
2
+
3
+export const on = (function () {
4
+  if (isClient && document.addEventListener) {
5
+    return function (element, event, handler, useCapture = false) {
6
+      if (element && event && handler) {
7
+        element.addEventListener(event, handler, useCapture);
8
+      }
9
+    };
10
+  } else {
11
+    return function (element, event, handler) {
12
+      if (element && event && handler) {
13
+        element.attachEvent("on" + event, handler);
14
+      }
15
+    };
16
+  }
17
+})();
18
+
19
+export const off = (function () {
20
+  if (isClient && document.removeEventListener) {
21
+    return function (element, event, handler, useCapture = false) {
22
+      if (element && event) {
23
+        element.removeEventListener(event, handler, useCapture);
24
+      }
25
+    };
26
+  } else {
27
+    return function (element, event, handler) {
28
+      if (element && event) {
29
+        element.detachEvent("on" + event, handler);
30
+      }
31
+    };
32
+  }
33
+})();

+ 516
- 0
src/utils/keyCode.js Целия файл

@@ -0,0 +1,516 @@
1
+const KeyCode = {
2
+  /**
3
+   * MAC_ENTER
4
+   */
5
+  MAC_ENTER: 3,
6
+  /**
7
+   * BACKSPACE
8
+   */
9
+  BACKSPACE: 8,
10
+  /**
11
+   * TAB
12
+   */
13
+  TAB: 9,
14
+  /**
15
+   * NUMLOCK on FF/Safari Mac
16
+   */
17
+  NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac
18
+  /**
19
+   * ENTER
20
+   */
21
+  ENTER: 13,
22
+  /**
23
+   * SHIFT
24
+   */
25
+  SHIFT: 16,
26
+  /**
27
+   * CTRL
28
+   */
29
+  CTRL: 17,
30
+  /**
31
+   * ALT
32
+   */
33
+  ALT: 18,
34
+  /**
35
+   * PAUSE
36
+   */
37
+  PAUSE: 19,
38
+  /**
39
+   * CAPS_LOCK
40
+   */
41
+  CAPS_LOCK: 20,
42
+  /**
43
+   * ESC
44
+   */
45
+  ESC: 27,
46
+  /**
47
+   * SPACE
48
+   */
49
+  SPACE: 32,
50
+  /**
51
+   * PAGE_UP
52
+   */
53
+  PAGE_UP: 33, // also NUM_NORTH_EAST
54
+  /**
55
+   * PAGE_DOWN
56
+   */
57
+  PAGE_DOWN: 34, // also NUM_SOUTH_EAST
58
+  /**
59
+   * END
60
+   */
61
+  END: 35, // also NUM_SOUTH_WEST
62
+  /**
63
+   * HOME
64
+   */
65
+  HOME: 36, // also NUM_NORTH_WEST
66
+  /**
67
+   * LEFT
68
+   */
69
+  LEFT: 37, // also NUM_WEST
70
+  /**
71
+   * UP
72
+   */
73
+  UP: 38, // also NUM_NORTH
74
+  /**
75
+   * RIGHT
76
+   */
77
+  RIGHT: 39, // also NUM_EAST
78
+  /**
79
+   * DOWN
80
+   */
81
+  DOWN: 40, // also NUM_SOUTH
82
+  /**
83
+   * PRINT_SCREEN
84
+   */
85
+  PRINT_SCREEN: 44,
86
+  /**
87
+   * INSERT
88
+   */
89
+  INSERT: 45, // also NUM_INSERT
90
+  /**
91
+   * DELETE
92
+   */
93
+  DELETE: 46, // also NUM_DELETE
94
+  /**
95
+   * ZERO
96
+   */
97
+  ZERO: 48,
98
+  /**
99
+   * ONE
100
+   */
101
+  ONE: 49,
102
+  /**
103
+   * TWO
104
+   */
105
+  TWO: 50,
106
+  /**
107
+   * THREE
108
+   */
109
+  THREE: 51,
110
+  /**
111
+   * FOUR
112
+   */
113
+  FOUR: 52,
114
+  /**
115
+   * FIVE
116
+   */
117
+  FIVE: 53,
118
+  /**
119
+   * SIX
120
+   */
121
+  SIX: 54,
122
+  /**
123
+   * SEVEN
124
+   */
125
+  SEVEN: 55,
126
+  /**
127
+   * EIGHT
128
+   */
129
+  EIGHT: 56,
130
+  /**
131
+   * NINE
132
+   */
133
+  NINE: 57,
134
+  /**
135
+   * QUESTION_MARK
136
+   */
137
+  QUESTION_MARK: 63, // needs localization
138
+  /**
139
+   * A
140
+   */
141
+  A: 65,
142
+  /**
143
+   * B
144
+   */
145
+  B: 66,
146
+  /**
147
+   * C
148
+   */
149
+  C: 67,
150
+  /**
151
+   * D
152
+   */
153
+  D: 68,
154
+  /**
155
+   * E
156
+   */
157
+  E: 69,
158
+  /**
159
+   * F
160
+   */
161
+  F: 70,
162
+  /**
163
+   * G
164
+   */
165
+  G: 71,
166
+  /**
167
+   * H
168
+   */
169
+  H: 72,
170
+  /**
171
+   * I
172
+   */
173
+  I: 73,
174
+  /**
175
+   * J
176
+   */
177
+  J: 74,
178
+  /**
179
+   * K
180
+   */
181
+  K: 75,
182
+  /**
183
+   * L
184
+   */
185
+  L: 76,
186
+  /**
187
+   * M
188
+   */
189
+  M: 77,
190
+  /**
191
+   * N
192
+   */
193
+  N: 78,
194
+  /**
195
+   * O
196
+   */
197
+  O: 79,
198
+  /**
199
+   * P
200
+   */
201
+  P: 80,
202
+  /**
203
+   * Q
204
+   */
205
+  Q: 81,
206
+  /**
207
+   * R
208
+   */
209
+  R: 82,
210
+  /**
211
+   * S
212
+   */
213
+  S: 83,
214
+  /**
215
+   * T
216
+   */
217
+  T: 84,
218
+  /**
219
+   * U
220
+   */
221
+  U: 85,
222
+  /**
223
+   * V
224
+   */
225
+  V: 86,
226
+  /**
227
+   * W
228
+   */
229
+  W: 87,
230
+  /**
231
+   * X
232
+   */
233
+  X: 88,
234
+  /**
235
+   * Y
236
+   */
237
+  Y: 89,
238
+  /**
239
+   * Z
240
+   */
241
+  Z: 90,
242
+  /**
243
+   * META
244
+   */
245
+  META: 91, // WIN_KEY_LEFT
246
+  /**
247
+   * WIN_KEY_RIGHT
248
+   */
249
+  WIN_KEY_RIGHT: 92,
250
+  /**
251
+   * CONTEXT_MENU
252
+   */
253
+  CONTEXT_MENU: 93,
254
+  /**
255
+   * NUM_ZERO
256
+   */
257
+  NUM_ZERO: 96,
258
+  /**
259
+   * NUM_ONE
260
+   */
261
+  NUM_ONE: 97,
262
+  /**
263
+   * NUM_TWO
264
+   */
265
+  NUM_TWO: 98,
266
+  /**
267
+   * NUM_THREE
268
+   */
269
+  NUM_THREE: 99,
270
+  /**
271
+   * NUM_FOUR
272
+   */
273
+  NUM_FOUR: 100,
274
+  /**
275
+   * NUM_FIVE
276
+   */
277
+  NUM_FIVE: 101,
278
+  /**
279
+   * NUM_SIX
280
+   */
281
+  NUM_SIX: 102,
282
+  /**
283
+   * NUM_SEVEN
284
+   */
285
+  NUM_SEVEN: 103,
286
+  /**
287
+   * NUM_EIGHT
288
+   */
289
+  NUM_EIGHT: 104,
290
+  /**
291
+   * NUM_NINE
292
+   */
293
+  NUM_NINE: 105,
294
+  /**
295
+   * NUM_MULTIPLY
296
+   */
297
+  NUM_MULTIPLY: 106,
298
+  /**
299
+   * NUM_PLUS
300
+   */
301
+  NUM_PLUS: 107,
302
+  /**
303
+   * NUM_MINUS
304
+   */
305
+  NUM_MINUS: 109,
306
+  /**
307
+   * NUM_PERIOD
308
+   */
309
+  NUM_PERIOD: 110,
310
+  /**
311
+   * NUM_DIVISION
312
+   */
313
+  NUM_DIVISION: 111,
314
+  /**
315
+   * F1
316
+   */
317
+  F1: 112,
318
+  /**
319
+   * F2
320
+   */
321
+  F2: 113,
322
+  /**
323
+   * F3
324
+   */
325
+  F3: 114,
326
+  /**
327
+   * F4
328
+   */
329
+  F4: 115,
330
+  /**
331
+   * F5
332
+   */
333
+  F5: 116,
334
+  /**
335
+   * F6
336
+   */
337
+  F6: 117,
338
+  /**
339
+   * F7
340
+   */
341
+  F7: 118,
342
+  /**
343
+   * F8
344
+   */
345
+  F8: 119,
346
+  /**
347
+   * F9
348
+   */
349
+  F9: 120,
350
+  /**
351
+   * F10
352
+   */
353
+  F10: 121,
354
+  /**
355
+   * F11
356
+   */
357
+  F11: 122,
358
+  /**
359
+   * F12
360
+   */
361
+  F12: 123,
362
+  /**
363
+   * NUMLOCK
364
+   */
365
+  NUMLOCK: 144,
366
+  /**
367
+   * SEMICOLON
368
+   */
369
+  SEMICOLON: 186, // needs localization
370
+  /**
371
+   * DASH
372
+   */
373
+  DASH: 189, // needs localization
374
+  /**
375
+   * EQUALS
376
+   */
377
+  EQUALS: 187, // needs localization
378
+  /**
379
+   * COMMA
380
+   */
381
+  COMMA: 188, // needs localization
382
+  /**
383
+   * PERIOD
384
+   */
385
+  PERIOD: 190, // needs localization
386
+  /**
387
+   * SLASH
388
+   */
389
+  SLASH: 191, // needs localization
390
+  /**
391
+   * APOSTROPHE
392
+   */
393
+  APOSTROPHE: 192, // needs localization
394
+  /**
395
+   * SINGLE_QUOTE
396
+   */
397
+  SINGLE_QUOTE: 222, // needs localization
398
+  /**
399
+   * OPEN_SQUARE_BRACKET
400
+   */
401
+  OPEN_SQUARE_BRACKET: 219, // needs localization
402
+  /**
403
+   * BACKSLASH
404
+   */
405
+  BACKSLASH: 220, // needs localization
406
+  /**
407
+   * CLOSE_SQUARE_BRACKET
408
+   */
409
+  CLOSE_SQUARE_BRACKET: 221, // needs localization
410
+  /**
411
+   * WIN_KEY
412
+   */
413
+  WIN_KEY: 224,
414
+  /**
415
+   * MAC_FF_META
416
+   */
417
+  MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91
418
+  /**
419
+   * WIN_IME
420
+   */
421
+  WIN_IME: 229,
422
+
423
+  // ======================== Function ========================
424
+  /**
425
+   * whether text and modified key is entered at the same time.
426
+   */
427
+  isTextModifyingKeyEvent(e) {
428
+    const { keyCode } = e;
429
+    if (
430
+      (e.altKey && !e.ctrlKey) ||
431
+      e.metaKey ||
432
+      // Function keys don't generate text
433
+      (keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12)
434
+    ) {
435
+      return false;
436
+    }
437
+
438
+    // The following keys are quite harmless, even in combination with
439
+    // CTRL, ALT or SHIFT.
440
+    switch (keyCode) {
441
+      case KeyCode.ALT:
442
+      case KeyCode.CAPS_LOCK:
443
+      case KeyCode.CONTEXT_MENU:
444
+      case KeyCode.CTRL:
445
+      case KeyCode.DOWN:
446
+      case KeyCode.END:
447
+      case KeyCode.ESC:
448
+      case KeyCode.HOME:
449
+      case KeyCode.INSERT:
450
+      case KeyCode.LEFT:
451
+      case KeyCode.MAC_FF_META:
452
+      case KeyCode.META:
453
+      case KeyCode.NUMLOCK:
454
+      case KeyCode.NUM_CENTER:
455
+      case KeyCode.PAGE_DOWN:
456
+      case KeyCode.PAGE_UP:
457
+      case KeyCode.PAUSE:
458
+      case KeyCode.PRINT_SCREEN:
459
+      case KeyCode.RIGHT:
460
+      case KeyCode.SHIFT:
461
+      case KeyCode.UP:
462
+      case KeyCode.WIN_KEY:
463
+      case KeyCode.WIN_KEY_RIGHT:
464
+        return false;
465
+      default:
466
+        return true;
467
+    }
468
+  },
469
+
470
+  /**
471
+   * whether character is entered.
472
+   */
473
+  isCharacterKey(keyCode) {
474
+    if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
475
+      return true;
476
+    }
477
+
478
+    if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
479
+      return true;
480
+    }
481
+
482
+    if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
483
+      return true;
484
+    }
485
+
486
+    // Safari sends zero key code for non-latin characters.
487
+    if (window.navigator.userAgent.indexOf("WebKit") !== -1 && keyCode === 0) {
488
+      return true;
489
+    }
490
+
491
+    switch (keyCode) {
492
+      case KeyCode.SPACE:
493
+      case KeyCode.QUESTION_MARK:
494
+      case KeyCode.NUM_PLUS:
495
+      case KeyCode.NUM_MINUS:
496
+      case KeyCode.NUM_PERIOD:
497
+      case KeyCode.NUM_DIVISION:
498
+      case KeyCode.SEMICOLON:
499
+      case KeyCode.DASH:
500
+      case KeyCode.EQUALS:
501
+      case KeyCode.COMMA:
502
+      case KeyCode.PERIOD:
503
+      case KeyCode.SLASH:
504
+      case KeyCode.APOSTROPHE:
505
+      case KeyCode.SINGLE_QUOTE:
506
+      case KeyCode.OPEN_SQUARE_BRACKET:
507
+      case KeyCode.BACKSLASH:
508
+      case KeyCode.CLOSE_SQUARE_BRACKET:
509
+        return true;
510
+      default:
511
+        return false;
512
+    }
513
+  }
514
+};
515
+
516
+export default KeyCode;

Loading…
Отказ
Запис