Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
9e862bee
Commit
9e862bee
authored
Dec 25, 2018
by
愚道
Committed by
Yu
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless util and move e2e outside
parent
39181808
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
8 additions
and
238 deletions
+8
-238
e2e/baseLayout.e2e.js
e2e/baseLayout.e2e.js
+3
-1
e2e/home.e2e.js
e2e/home.e2e.js
+0
-0
e2e/login.e2e.js
e2e/login.e2e.js
+0
-0
e2e/topMenu.e2e.js
e2e/topMenu.e2e.js
+0
-0
e2e/userLayout.e2e.js
e2e/userLayout.e2e.js
+3
-1
src/utils/Yuan.js
src/utils/Yuan.js
+0
-33
src/utils/utils.js
src/utils/utils.js
+1
-178
src/utils/utils.test.js
src/utils/utils.test.js
+1
-25
No files found.
src/
e2e/baseLayout.e2e.js
→
e2e/baseLayout.e2e.js
View file @
9e862bee
import
RouterConfig
from
'
../../config/router.config
'
;
import
config
from
'
../config/config
'
;
const
RouterConfig
=
config
.
routes
;
const
BASE_URL
=
`http://localhost:
${
process
.
env
.
PORT
||
8000
}
`
;
const
BASE_URL
=
`http://localhost:
${
process
.
env
.
PORT
||
8000
}
`
;
...
...
src/
e2e/home.e2e.js
→
e2e/home.e2e.js
View file @
9e862bee
File moved
src/
e2e/login.e2e.js
→
e2e/login.e2e.js
View file @
9e862bee
File moved
src/
e2e/topMenu.e2e.js
→
e2e/topMenu.e2e.js
View file @
9e862bee
File moved
src/
e2e/userLayout.e2e.js
→
e2e/userLayout.e2e.js
View file @
9e862bee
import
RouterConfig
from
'
../../config/router.config
'
;
import
config
from
'
../config/config
'
;
const
RouterConfig
=
config
.
routes
;
const
BASE_URL
=
`http://localhost:
${
process
.
env
.
PORT
||
8000
}
`
;
const
BASE_URL
=
`http://localhost:
${
process
.
env
.
PORT
||
8000
}
`
;
...
...
src/utils/Yuan.js
deleted
100644 → 0
View file @
39181808
import
React
from
'
react
'
;
import
{
Charts
}
from
'
ant-design-pro
'
;
const
{
yuan
}
=
Charts
;
/**
* 减少使用 dangerouslySetInnerHTML
*/
export
default
class
Yuan
extends
React
.
PureComponent
{
componentDidMount
()
{
this
.
rendertoHtml
();
}
componentDidUpdate
()
{
this
.
rendertoHtml
();
}
rendertoHtml
=
()
=>
{
const
{
children
}
=
this
.
props
;
if
(
this
.
main
)
{
this
.
main
.
innerHTML
=
yuan
(
children
);
}
};
render
()
{
return
(
<
span
ref
=
{
ref
=>
{
this
.
main
=
ref
;
}}
/
>
);
}
}
src/utils/utils.js
View file @
9e862bee
import
moment
from
'
moment
'
;
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
import
React
from
'
react
'
;
import
nzh
from
'
nzh/cn
'
;
import
{
parse
,
stringify
}
from
'
qs
'
;
export
function
fixedZero
(
val
)
{
return
val
*
1
<
10
?
`0
${
val
}
`
:
val
;
}
export
function
getTimeDistance
(
type
)
{
const
now
=
new
Date
();
const
oneDay
=
1000
*
60
*
60
*
24
;
if
(
type
===
'
today
'
)
{
now
.
setHours
(
0
);
now
.
setMinutes
(
0
);
now
.
setSeconds
(
0
);
return
[
moment
(
now
),
moment
(
now
.
getTime
()
+
(
oneDay
-
1000
))];
}
if
(
type
===
'
week
'
)
{
let
day
=
now
.
getDay
();
now
.
setHours
(
0
);
now
.
setMinutes
(
0
);
now
.
setSeconds
(
0
);
if
(
day
===
0
)
{
day
=
6
;
}
else
{
day
-=
1
;
}
const
beginTime
=
now
.
getTime
()
-
day
*
oneDay
;
return
[
moment
(
beginTime
),
moment
(
beginTime
+
(
7
*
oneDay
-
1000
))];
}
if
(
type
===
'
month
'
)
{
const
year
=
now
.
getFullYear
();
const
month
=
now
.
getMonth
();
const
nextDate
=
moment
(
now
).
add
(
1
,
'
months
'
);
const
nextYear
=
nextDate
.
year
();
const
nextMonth
=
nextDate
.
month
();
return
[
moment
(
`
${
year
}
-
${
fixedZero
(
month
+
1
)}
-01 00:00:00`
),
moment
(
moment
(
`
${
nextYear
}
-
${
fixedZero
(
nextMonth
+
1
)}
-01 00:00:00`
).
valueOf
()
-
1000
),
];
}
const
year
=
now
.
getFullYear
();
return
[
moment
(
`
${
year
}
-01-01 00:00:00`
),
moment
(
`
${
year
}
-12-31 23:59:59`
)];
}
export
function
getPlainNode
(
nodeList
,
parentPath
=
''
)
{
const
arr
=
[];
nodeList
.
forEach
(
node
=>
{
const
item
=
node
;
item
.
path
=
`
${
parentPath
}
/
${
item
.
path
||
''
}
`
.
replace
(
/
\/
+/g
,
'
/
'
);
item
.
exact
=
true
;
if
(
item
.
children
&&
!
item
.
component
)
{
arr
.
push
(...
getPlainNode
(
item
.
children
,
item
.
path
));
}
else
{
if
(
item
.
children
&&
item
.
component
)
{
item
.
exact
=
false
;
}
arr
.
push
(
item
);
}
});
return
arr
;
}
export
function
digitUppercase
(
n
)
{
return
nzh
.
toMoney
(
n
);
}
function
getRelation
(
str1
,
str2
)
{
if
(
str1
===
str2
)
{
console
.
warn
(
'
Two path are equal!
'
);
// eslint-disable-line
}
const
arr1
=
str1
.
split
(
'
/
'
);
const
arr2
=
str2
.
split
(
'
/
'
);
if
(
arr2
.
every
((
item
,
index
)
=>
item
===
arr1
[
index
]))
{
return
1
;
}
if
(
arr1
.
every
((
item
,
index
)
=>
item
===
arr2
[
index
]))
{
return
2
;
}
return
3
;
}
function
getRenderArr
(
routes
)
{
let
renderArr
=
[];
renderArr
.
push
(
routes
[
0
]);
for
(
let
i
=
1
;
i
<
routes
.
length
;
i
+=
1
)
{
// 去重
renderArr
=
renderArr
.
filter
(
item
=>
getRelation
(
item
,
routes
[
i
])
!==
1
);
// 是否包含
const
isAdd
=
renderArr
.
every
(
item
=>
getRelation
(
item
,
routes
[
i
])
===
3
);
if
(
isAdd
)
{
renderArr
.
push
(
routes
[
i
]);
}
}
return
renderArr
;
}
/**
* Get router routing configuration
* { path:{name,...param}}=>Array<{name,path ...param}>
* @param {string} path
* @param {routerData} routerData
*/
export
function
getRoutes
(
path
,
routerData
)
{
let
routes
=
Object
.
keys
(
routerData
).
filter
(
routePath
=>
routePath
.
indexOf
(
path
)
===
0
&&
routePath
!==
path
);
// Replace path to '' eg. path='user' /user/name => name
routes
=
routes
.
map
(
item
=>
item
.
replace
(
path
,
''
));
// Get the route to be rendered to remove the deep rendering
const
renderArr
=
getRenderArr
(
routes
);
// Conversion and stitching parameters
const
renderRoutes
=
renderArr
.
map
(
item
=>
{
const
exact
=
!
routes
.
some
(
route
=>
route
!==
item
&&
getRelation
(
route
,
item
)
===
1
);
return
{
exact
,
...
routerData
[
`
${
path
}${
item
}
`
],
key
:
`
${
path
}${
item
}
`
,
path
:
`
${
path
}${
item
}
`
,
};
});
return
renderRoutes
;
}
export
function
getPageQuery
()
{
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
}
export
function
getQueryPath
(
path
=
''
,
query
=
{})
{
const
search
=
stringify
(
query
);
if
(
search
.
length
)
{
return
`
${
path
}
?
${
search
}
`
;
}
return
path
;
}
/* eslint no-useless-escape:0 */
const
reg
=
/
(((
^https
?
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+
(?:
:
\d
+
)?
|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w]
*
))?)
$/
;
const
reg
=
/
(((
^https
?
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+
(?:
:
\d
+
)?
|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w]
*
))?)
$/
;
export
function
isUrl
(
path
)
{
export
function
isUrl
(
path
)
{
return
reg
.
test
(
path
);
return
reg
.
test
(
path
);
}
}
export
function
formatWan
(
val
)
{
const
v
=
val
*
1
;
if
(
!
v
||
Number
.
isNaN
(
v
))
return
''
;
let
result
=
val
;
if
(
val
>
10000
)
{
result
=
Math
.
floor
(
val
/
10000
);
result
=
(
<
span
>
{
result
}
<
span
style
=
{{
position
:
'
relative
'
,
top
:
-
2
,
fontSize
:
14
,
fontStyle
:
'
normal
'
,
marginLeft
:
2
,
}}
>
万
<
/span
>
<
/span
>
);
}
return
result
;
}
// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
export
function
isAntdPro
()
{
return
window
.
location
.
hostname
===
'
preview.pro.ant.design
'
;
}
src/utils/utils.test.js
View file @
9e862bee
import
{
fixedZero
,
isUrl
}
from
'
./utils
'
;
import
{
isUrl
}
from
'
./utils
'
;
describe
(
'
fixedZero tests
'
,
()
=>
{
it
(
'
should not pad large numbers
'
,
()
=>
{
expect
(
fixedZero
(
10
)).
toEqual
(
10
);
expect
(
fixedZero
(
11
)).
toEqual
(
11
);
expect
(
fixedZero
(
15
)).
toEqual
(
15
);
expect
(
fixedZero
(
20
)).
toEqual
(
20
);
expect
(
fixedZero
(
100
)).
toEqual
(
100
);
expect
(
fixedZero
(
1000
)).
toEqual
(
1000
);
});
it
(
'
should pad single digit numbers and return them as string
'
,
()
=>
{
expect
(
fixedZero
(
0
)).
toEqual
(
'
00
'
);
expect
(
fixedZero
(
1
)).
toEqual
(
'
01
'
);
expect
(
fixedZero
(
2
)).
toEqual
(
'
02
'
);
expect
(
fixedZero
(
3
)).
toEqual
(
'
03
'
);
expect
(
fixedZero
(
4
)).
toEqual
(
'
04
'
);
expect
(
fixedZero
(
5
)).
toEqual
(
'
05
'
);
expect
(
fixedZero
(
6
)).
toEqual
(
'
06
'
);
expect
(
fixedZero
(
7
)).
toEqual
(
'
07
'
);
expect
(
fixedZero
(
8
)).
toEqual
(
'
08
'
);
expect
(
fixedZero
(
9
)).
toEqual
(
'
09
'
);
});
});
describe
(
'
isUrl tests
'
,
()
=>
{
describe
(
'
isUrl tests
'
,
()
=>
{
it
(
'
should return false for invalid and corner case inputs
'
,
()
=>
{
it
(
'
should return false for invalid and corner case inputs
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment