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
Unverified
Commit
07d79e32
authored
Mar 15, 2023
by
芋道源码
Committed by
Gitee
Mar 15, 2023
Browse files
Options
Browse Files
Download
Plain Diff
!29 Vue3 重构:基础设施 -> 文件管理功能 优化部分代码
Merge pull request !29 from xiaowuye/dev
parents
d4681248
b6e3a583
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
30 deletions
+23
-30
src/utils/index.ts
+9
-0
src/views/infra/file/index.vue
+2
-11
src/views/infra/fileConfig/index.vue
+12
-19
No files found.
src/utils/index.ts
View file @
07d79e32
...
@@ -137,3 +137,12 @@ export const generateUUID = () => {
...
@@ -137,3 +137,12 @@ export const generateUUID = () => {
return
(
c
===
'x'
?
random
:
(
random
&
0x3
)
|
0x8
).
toString
(
16
)
return
(
c
===
'x'
?
random
:
(
random
&
0x3
)
|
0x8
).
toString
(
16
)
})
})
}
}
export
const
fileSizeFormatter
=
(
row
)
=>
{
const
unitArr
=
[
'Bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
,
'PB'
,
'EB'
,
'ZB'
,
'YB'
]
const
srcSize
=
parseFloat
(
row
.
size
)
const
index
=
Math
.
floor
(
Math
.
log
(
srcSize
)
/
Math
.
log
(
1024
))
const
size
=
srcSize
/
Math
.
pow
(
1024
,
index
)
const
sizeStr
=
size
.
toFixed
(
2
)
//保留的小数位数
return
sizeStr
+
' '
+
unitArr
[
index
]
}
src/views/infra/file/index.vue
View file @
07d79e32
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
align=
"center"
align=
"center"
prop=
"size"
prop=
"size"
width=
"120"
width=
"120"
:formatter=
"
sizeFormat
"
:formatter=
"
fileSizeFormatter
"
/>
/>
<el-table-column
label=
"文件类型"
align=
"center"
prop=
"type"
width=
"180px"
/>
<el-table-column
label=
"文件类型"
align=
"center"
prop=
"type"
width=
"180px"
/>
<el-table-column
<el-table-column
...
@@ -86,6 +86,7 @@
...
@@ -86,6 +86,7 @@
<file-upload-form
ref=
"modalRef"
@
success=
"getList"
/>
<file-upload-form
ref=
"modalRef"
@
success=
"getList"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"Config"
>
<
script
setup
lang=
"ts"
name=
"Config"
>
import
{
fileSizeFormatter
}
from
'@/utils'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
*
as
FileApi
from
'@/api/infra/file'
import
*
as
FileApi
from
'@/api/infra/file'
import
FileUploadForm
from
'./form.vue'
import
FileUploadForm
from
'./form.vue'
...
@@ -147,16 +148,6 @@ const handleDelete = async (id: number) => {
...
@@ -147,16 +148,6 @@ const handleDelete = async (id: number) => {
}
catch
{}
}
catch
{}
}
}
// TODO 写到 utils/index.ts 中
const
sizeFormat
=
(
row
)
=>
{
const
unitArr
=
[
'Bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
,
'PB'
,
'EB'
,
'ZB'
,
'YB'
]
const
srcSize
=
parseFloat
(
row
.
size
)
const
index
=
Math
.
floor
(
Math
.
log
(
srcSize
)
/
Math
.
log
(
1024
))
const
size
=
srcSize
/
Math
.
pow
(
1024
,
index
)
const
sizeStr
=
size
.
toFixed
(
2
)
//保留的小数位数
return
sizeStr
+
' '
+
unitArr
[
index
]
}
/** 初始化 **/
/** 初始化 **/
onMounted
(()
=>
{
onMounted
(()
=>
{
getList
()
getList
()
...
...
src/views/infra/fileConfig/index.vue
View file @
07d79e32
...
@@ -175,28 +175,21 @@ const handleDelete = async (id: number) => {
...
@@ -175,28 +175,21 @@ const handleDelete = async (id: number) => {
}
}
/** 主配置按钮操作 */
/** 主配置按钮操作 */
const
handleMaster
=
(
id
)
=>
{
const
handleMaster
=
async
(
id
)
=>
{
// TODO 改成 await 的形式
try
{
message
await
message
.
confirm
(
'是否确认修改配置编号为"'
+
id
+
'"的数据项为主配置?'
)
.
confirm
(
'是否确认修改配置编号为"'
+
id
+
'"的数据项为主配置?'
)
await
FileConfigApi
.
updateFileConfigMaster
(
id
)
.
then
(
function
()
{
message
.
success
(
t
(
'common.updateSuccess'
))
return
FileConfigApi
.
updateFileConfigMaster
(
id
)
await
getList
()
})
}
catch
{}
.
then
(()
=>
{
getList
()
message
.
success
(
t
(
'common.updateSuccess'
))
})
.
catch
(()
=>
{})
}
}
/** 测试按钮操作 */
/** 测试按钮操作 */
const
handleTest
=
(
id
)
=>
{
const
handleTest
=
async
(
id
)
=>
{
// TODO 改成 await 的形式
try
{
FileConfigApi
.
testFileConfig
(
id
)
const
response
=
await
FileConfigApi
.
testFileConfig
(
id
)
.
then
((
response
)
=>
{
message
.
alert
(
'测试通过,上传文件成功!访问地址:'
+
response
)
message
.
alert
(
'测试通过,上传文件成功!访问地址:'
+
response
)
}
catch
{}
})
.
catch
(()
=>
{})
}
}
/** 初始化 **/
/** 初始化 **/
...
...
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