Преглед на файлове

perf: delete unused code

Pan преди 6 години
родител
ревизия
009416282b
променени са 4 файла, в които са добавени 4 реда и са изтрити 103 реда
  1. 0 79
      src/utils/index.js
  2. 2 22
      src/utils/validate.js
  3. 1 1
      src/views/layout/components/Sidebar/Link.vue
  4. 1 1
      src/views/layout/components/Sidebar/SidebarItem.vue

+ 0 - 79
src/utils/index.js

@@ -1,79 +0,0 @@
1
-/**
2
- * Created by jiachenpan on 16/11/18.
3
- */
4
-
5
-export function parseTime(time, cFormat) {
6
-  if (arguments.length === 0) {
7
-    return null
8
-  }
9
-  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
10
-  let date
11
-  if (typeof time === 'object') {
12
-    date = time
13
-  } else {
14
-    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
15
-      time = parseInt(time)
16
-    }
17
-    if ((typeof time === 'number') && (time.toString().length === 10)) {
18
-      time = time * 1000
19
-    }
20
-    date = new Date(time)
21
-  }
22
-  const formatObj = {
23
-    y: date.getFullYear(),
24
-    m: date.getMonth() + 1,
25
-    d: date.getDate(),
26
-    h: date.getHours(),
27
-    i: date.getMinutes(),
28
-    s: date.getSeconds(),
29
-    a: date.getDay()
30
-  }
31
-  const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
32
-    let value = formatObj[key]
33
-    // Note: getDay() returns 0 on Sunday
34
-    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
35
-    if (result.length > 0 && value < 10) {
36
-      value = '0' + value
37
-    }
38
-    return value || 0
39
-  })
40
-  return time_str
41
-}
42
-
43
-export function formatTime(time, option) {
44
-  time = +time * 1000
45
-  const d = new Date(time)
46
-  const now = Date.now()
47
-
48
-  const diff = (now - d) / 1000
49
-
50
-  if (diff < 30) {
51
-    return '刚刚'
52
-  } else if (diff < 3600) {
53
-    // less 1 hour
54
-    return Math.ceil(diff / 60) + '分钟前'
55
-  } else if (diff < 3600 * 24) {
56
-    return Math.ceil(diff / 3600) + '小时前'
57
-  } else if (diff < 3600 * 24 * 2) {
58
-    return '1天前'
59
-  }
60
-  if (option) {
61
-    return parseTime(time, option)
62
-  } else {
63
-    return (
64
-      d.getMonth() +
65
-      1 +
66
-      '月' +
67
-      d.getDate() +
68
-      '日' +
69
-      d.getHours() +
70
-      '时' +
71
-      d.getMinutes() +
72
-      '分'
73
-    )
74
-  }
75
-}
76
-
77
-export function isExternal(path) {
78
-  return /^(https?:|mailto:|tel:)/.test(path)
79
-}

+ 2 - 22
src/utils/validate.js

@@ -7,26 +7,6 @@ export function isvalidUsername(str) {
7 7
   return valid_map.indexOf(str.trim()) >= 0
8 8
 }
9 9
 
10
-/* 合法uri*/
11
-export function validateURL(textval) {
12
-  const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
13
-  return urlregex.test(textval)
14
-}
15
-
16
-/* 小写字母*/
17
-export function validateLowerCase(str) {
18
-  const reg = /^[a-z]+$/
19
-  return reg.test(str)
20
-}
21
-
22
-/* 大写字母*/
23
-export function validateUpperCase(str) {
24
-  const reg = /^[A-Z]+$/
25
-  return reg.test(str)
26
-}
27
-
28
-/* 大小写字母*/
29
-export function validatAlphabets(str) {
30
-  const reg = /^[A-Za-z]+$/
31
-  return reg.test(str)
10
+export function isExternal(path) {
11
+  return /^(https?:|mailto:|tel:)/.test(path)
32 12
 }

+ 1 - 1
src/views/layout/components/Sidebar/Link.vue

@@ -7,7 +7,7 @@
7 7
 </template>
8 8
 
9 9
 <script>
10
-import { isExternal } from '@/utils'
10
+import { isExternal } from '@/utils/validate'
11 11
 
12 12
 export default {
13 13
   props: {

+ 1 - 1
src/views/layout/components/Sidebar/SidebarItem.vue

@@ -35,7 +35,7 @@
35 35
 
36 36
 <script>
37 37
 import path from 'path'
38
-import { isExternal } from '@/utils'
38
+import { isExternal } from '@/utils/validate'
39 39
 import Item from './Item'
40 40
 import AppLink from './Link'
41 41