Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
兵
兵役_吉林工业
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
麦嘉得
兵役_吉林工业
提交
00941628
提交
00941628
编写于
2月 01, 2019
作者:
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: delete unused code
上级
c1719929
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
4 行增加
和
103 行删除
+4
-103
index.js
src/utils/index.js
+0
-79
validate.js
src/utils/validate.js
+2
-22
Link.vue
src/views/layout/components/Sidebar/Link.vue
+1
-1
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+1
-1
未找到文件。
src/utils/index.js
已删除
100644 → 0
浏览文件 @
c1719929
/**
* Created by jiachenpan on 16/11/18.
*/
export
function
parseTime
(
time
,
cFormat
)
{
if
(
arguments
.
length
===
0
)
{
return
null
}
const
format
=
cFormat
||
'
{y}-{m}-{d} {h}:{i}:{s}
'
let
date
if
(
typeof
time
===
'
object
'
)
{
date
=
time
}
else
{
if
((
typeof
time
===
'
string
'
)
&&
(
/^
[
0-9
]
+$/
.
test
(
time
)))
{
time
=
parseInt
(
time
)
}
if
((
typeof
time
===
'
number
'
)
&&
(
time
.
toString
().
length
===
10
))
{
time
=
time
*
1000
}
date
=
new
Date
(
time
)
}
const
formatObj
=
{
y
:
date
.
getFullYear
(),
m
:
date
.
getMonth
()
+
1
,
d
:
date
.
getDate
(),
h
:
date
.
getHours
(),
i
:
date
.
getMinutes
(),
s
:
date
.
getSeconds
(),
a
:
date
.
getDay
()
}
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
let
value
=
formatObj
[
key
]
// Note: getDay() returns 0 on Sunday
if
(
key
===
'
a
'
)
{
return
[
'
日
'
,
'
一
'
,
'
二
'
,
'
三
'
,
'
四
'
,
'
五
'
,
'
六
'
][
value
]
}
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
'
0
'
+
value
}
return
value
||
0
})
return
time_str
}
export
function
formatTime
(
time
,
option
)
{
time
=
+
time
*
1000
const
d
=
new
Date
(
time
)
const
now
=
Date
.
now
()
const
diff
=
(
now
-
d
)
/
1000
if
(
diff
<
30
)
{
return
'
刚刚
'
}
else
if
(
diff
<
3600
)
{
// less 1 hour
return
Math
.
ceil
(
diff
/
60
)
+
'
分钟前
'
}
else
if
(
diff
<
3600
*
24
)
{
return
Math
.
ceil
(
diff
/
3600
)
+
'
小时前
'
}
else
if
(
diff
<
3600
*
24
*
2
)
{
return
'
1天前
'
}
if
(
option
)
{
return
parseTime
(
time
,
option
)
}
else
{
return
(
d
.
getMonth
()
+
1
+
'
月
'
+
d
.
getDate
()
+
'
日
'
+
d
.
getHours
()
+
'
时
'
+
d
.
getMinutes
()
+
'
分
'
)
}
}
export
function
isExternal
(
path
)
{
return
/^
(
https
?
:|mailto:|tel:
)
/
.
test
(
path
)
}
src/utils/validate.js
浏览文件 @
00941628
...
@@ -7,26 +7,6 @@ export function isvalidUsername(str) {
...
@@ -7,26 +7,6 @@ export function isvalidUsername(str) {
return
valid_map
.
indexOf
(
str
.
trim
())
>=
0
return
valid_map
.
indexOf
(
str
.
trim
())
>=
0
}
}
/* 合法uri*/
export
function
isExternal
(
path
)
{
export
function
validateURL
(
textval
)
{
return
/^
(
https
?
:|mailto:|tel:
)
/
.
test
(
path
)
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.,?'
\\
+&%$#=~_-
]
+
))
*$/
return
urlregex
.
test
(
textval
)
}
/* 小写字母*/
export
function
validateLowerCase
(
str
)
{
const
reg
=
/^
[
a-z
]
+$/
return
reg
.
test
(
str
)
}
/* 大写字母*/
export
function
validateUpperCase
(
str
)
{
const
reg
=
/^
[
A-Z
]
+$/
return
reg
.
test
(
str
)
}
/* 大小写字母*/
export
function
validatAlphabets
(
str
)
{
const
reg
=
/^
[
A-Za-z
]
+$/
return
reg
.
test
(
str
)
}
}
src/views/layout/components/Sidebar/Link.vue
浏览文件 @
00941628
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
isExternal
}
from
'
@/utils
'
import
{
isExternal
}
from
'
@/utils
/validate
'
export
default
{
export
default
{
props
:
{
props
:
{
...
...
src/views/layout/components/Sidebar/SidebarItem.vue
浏览文件 @
00941628
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<
script
>
<
script
>
import
path
from
'
path
'
import
path
from
'
path
'
import
{
isExternal
}
from
'
@/utils
'
import
{
isExternal
}
from
'
@/utils
/validate
'
import
Item
from
'
./Item
'
import
Item
from
'
./Item
'
import
AppLink
from
'
./Link
'
import
AppLink
from
'
./Link
'
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录