Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangqinghua
smart
Commits
636c4984
Commit
636c4984
authored
Jan 07, 2019
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构 jtopo
parent
03decbd7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
util.service.ts
src/main/webapp/app/shared/common/util.service.ts
+60
-0
No files found.
src/main/webapp/app/shared/common/util.service.ts
0 → 100644
View file @
636c4984
import
{
Injectable
}
from
'@angular/core'
;
@
Injectable
()
export
class
UtilService
{
startTime
;
stoppedStatus
=
true
;
constructor
()
{
}
/*
* 生成uuid算法,碰撞率低于1/2^^122
* @param x 0-9或a-f范围内的一个32位十六进制数
*/
generateUUID
()
{
let
d
=
new
Date
().
getTime
();
let
uuid
=
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
(
c
)
=>
{
let
r
=
(
d
+
Math
.
random
()
*
16
)
%
16
|
0
;
d
=
Math
.
floor
(
d
/
16
);
return
(
c
===
'x'
?
r
:
(
r
&
0x3
|
0x8
)).
toString
(
16
);
});
return
uuid
;
}
/**
* 计算程序执行时间
* @type {{startTime: {}, timeSpan: number, start: Timer.start, stop: Timer.stop, getTimeSpan: Timer.getTimeSpan}}
*/
start
()
{
if
(
this
.
stoppedStatus
)
{
this
.
startTime
=
new
Date
().
getTime
();
this
.
stoppedStatus
=
false
;
}
}
pause
()
{
let
startTime
=
this
.
startTime
;
if
(
startTime
)
{
let
t
=
new
Date
().
getTime
()
-
startTime
;
return
t
;
}
else
{
return
-
1
;
}
};
stop
()
{
let
startTime
=
this
.
startTime
;
if
(
startTime
)
{
this
.
stoppedStatus
=
true
;
let
t
=
new
Date
().
getTime
()
-
startTime
;
return
t
;
}
else
{
this
.
stoppedStatus
=
true
;
return
-
1
;
}
}
}
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