Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11d4e2ea
authored
Mar 15, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补全 fileSizeFormatter 的注释
parent
07d79e32
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
src/utils/index.ts
+11
-2
No files found.
src/utils/index.ts
View file @
11d4e2ea
...
@@ -138,9 +138,18 @@ export const generateUUID = () => {
...
@@ -138,9 +138,18 @@ export const generateUUID = () => {
})
})
}
}
export
const
fileSizeFormatter
=
(
row
)
=>
{
/**
* element plus 的文件大小 Formatter 实现
*
* @param row 行数据
* @param column 字段
* @param cellValue 字段值
*/
// @ts-ignore
export
const
fileSizeFormatter
=
(
row
,
column
,
cellValue
)
=>
{
const
fileSize
=
cellValue
const
unitArr
=
[
'Bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
,
'PB'
,
'EB'
,
'ZB'
,
'YB'
]
const
unitArr
=
[
'Bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
,
'PB'
,
'EB'
,
'ZB'
,
'YB'
]
const
srcSize
=
parseFloat
(
row
.
s
ize
)
const
srcSize
=
parseFloat
(
fileS
ize
)
const
index
=
Math
.
floor
(
Math
.
log
(
srcSize
)
/
Math
.
log
(
1024
))
const
index
=
Math
.
floor
(
Math
.
log
(
srcSize
)
/
Math
.
log
(
1024
))
const
size
=
srcSize
/
Math
.
pow
(
1024
,
index
)
const
size
=
srcSize
/
Math
.
pow
(
1024
,
index
)
const
sizeStr
=
size
.
toFixed
(
2
)
//保留的小数位数
const
sizeStr
=
size
.
toFixed
(
2
)
//保留的小数位数
...
...
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