Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
InJoyU
vue-element-admin
提交
fe950801
V
vue-element-admin
项目概览
InJoyU
/
vue-element-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fe950801
编写于
2月 19, 2019
作者:
P
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf[utils]: optimizate variable name
上级
070a3343
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
25 deletion
+23
-25
src/utils/createUniqueString.js
src/utils/createUniqueString.js
+0
-8
src/utils/index.js
src/utils/index.js
+7
-1
src/utils/validate.js
src/utils/validate.js
+12
-12
src/views/example/components/ArticleDetail.vue
src/views/example/components/ArticleDetail.vue
+2
-2
src/views/login/index.vue
src/views/login/index.vue
+2
-2
未找到文件。
src/utils/createUniqueString.js
已删除
100644 → 0
浏览文件 @
070a3343
/**
* Created by jiachenpan on 17/3/8.
*/
export
default
function
createUniqueString
()
{
const
timestamp
=
+
new
Date
()
+
''
const
randomNum
=
parseInt
((
1
+
Math
.
random
())
*
65536
)
+
''
return
(
+
(
randomNum
+
timestamp
)).
toString
(
32
)
}
src/utils/index.js
浏览文件 @
fe950801
...
...
@@ -239,7 +239,7 @@ export function debounce(func, wait, immediate) {
// 据上一次触发时间间隔
const
last
=
+
new
Date
()
-
timestamp
// 上次被包装函数被调用时间间隔
last小于设定时间间隔
wait
// 上次被包装函数被调用时间间隔
last 小于设定时间间隔
wait
if
(
last
<
wait
&&
last
>
0
)
{
timeout
=
setTimeout
(
later
,
wait
-
last
)
}
else
{
...
...
@@ -290,3 +290,9 @@ export function deepClone(source) {
export
function
uniqueArr
(
arr
)
{
return
Array
.
from
(
new
Set
(
arr
))
}
export
function
createUniqueString
()
{
const
timestamp
=
+
new
Date
()
+
''
const
randomNum
=
parseInt
((
1
+
Math
.
random
())
*
65536
)
+
''
return
(
+
(
randomNum
+
timestamp
)).
toString
(
32
)
}
src/utils/validate.js
浏览文件 @
fe950801
...
...
@@ -2,35 +2,35 @@
* Created by jiachenpan on 16/11/18.
*/
export
function
isvalidUsername
(
str
)
{
const
valid_map
=
[
'
admin
'
,
'
editor
'
]
return
valid_map
.
indexOf
(
str
.
trim
())
>=
0
}
export
function
isExternal
(
path
)
{
return
/^
(
https
?
:|mailto:|tel:
)
/
.
test
(
path
)
}
export
function
validUsername
(
str
)
{
const
valid_map
=
[
'
admin
'
,
'
editor
'
]
return
valid_map
.
indexOf
(
str
.
trim
())
>=
0
}
/* 合法uri*/
export
function
valid
ateURL
(
textva
l
)
{
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
(
textva
l
)
export
function
valid
URL
(
ur
l
)
{
const
reg
=
/^
(
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
reg
.
test
(
ur
l
)
}
/* 小写字母*/
export
function
valid
ate
LowerCase
(
str
)
{
export
function
validLowerCase
(
str
)
{
const
reg
=
/^
[
a-z
]
+$/
return
reg
.
test
(
str
)
}
/* 大写字母*/
export
function
valid
ate
UpperCase
(
str
)
{
export
function
validUpperCase
(
str
)
{
const
reg
=
/^
[
A-Z
]
+$/
return
reg
.
test
(
str
)
}
/* 大小写字母*/
export
function
valid
ate
Alphabets
(
str
)
{
export
function
validAlphabets
(
str
)
{
const
reg
=
/^
[
A-Za-z
]
+$/
return
reg
.
test
(
str
)
}
...
...
@@ -40,7 +40,7 @@ export function validateAlphabets(str) {
* @param email
* @returns {boolean}
*/
export
function
valid
ate
Email
(
email
)
{
export
function
validEmail
(
email
)
{
const
re
=
/^
(([^
<>()
\[\]\\
.,;:
\s
@"
]
+
(\.[^
<>()
\[\]\\
.,;:
\s
@"
]
+
)
*
)
|
(
".+"
))
@
((\[[
0-9
]{1,3}\.[
0-9
]{1,3}\.[
0-9
]{1,3}\.[
0-9
]{1,3}\])
|
(([
a-zA-Z
\-
0-9
]
+
\.)
+
[
a-zA-Z
]{2,}))
$/
return
re
.
test
(
email
)
}
src/views/example/components/ArticleDetail.vue
浏览文件 @
fe950801
...
...
@@ -78,7 +78,7 @@ import Tinymce from '@/components/Tinymce'
import
Upload
from
'
@/components/Upload/singleImage3
'
import
MDinput
from
'
@/components/MDinput
'
import
Sticky
from
'
@/components/Sticky
'
// 粘性header组件
import
{
valid
ate
URL
}
from
'
@/utils/validate
'
import
{
validURL
}
from
'
@/utils/validate
'
import
{
fetchArticle
}
from
'
@/api/article
'
import
{
userSearch
}
from
'
@/api/remoteSearch
'
import
Warning
from
'
./Warning
'
...
...
@@ -121,7 +121,7 @@ export default {
}
const
validateSourceUri
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
)
{
if
(
valid
ate
URL
(
value
))
{
if
(
validURL
(
value
))
{
callback
()
}
else
{
this
.
$message
({
...
...
src/views/login/index.vue
浏览文件 @
fe950801
...
...
@@ -71,7 +71,7 @@
</
template
>
<
script
>
import
{
is
validUsername
}
from
'
@/utils/validate
'
import
{
validUsername
}
from
'
@/utils/validate
'
import
LangSelect
from
'
@/components/LangSelect
'
import
SocialSign
from
'
./socialsignin
'
...
...
@@ -80,7 +80,7 @@ export default {
components
:
{
LangSelect
,
SocialSign
},
data
()
{
const
validateUsername
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
is
validUsername
(
value
))
{
if
(
!
validUsername
(
value
))
{
callback
(
new
Error
(
'
Please enter the correct user name
'
))
}
else
{
callback
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录