Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
corporateCulture-qd
Overview
Overview
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
王立鹏
corporateCulture-qd
Commits
cc7f2a1c
Commit
cc7f2a1c
authored
Jan 23, 2026
by
lijiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【需求 17679】 perf: 继续优化上传文件组件,加入loading,百分比等
parent
d7d59a8a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
3 deletions
+18
-3
index.vue
src/components/common/PublishBox/index.vue
+4
-1
index.vue
src/components/common/UploadFile/index.vue
+8
-0
useUploadImg.ts
src/hooks/useUploadImg.ts
+5
-1
index.vue
src/views/publishLongArticle/index.vue
+1
-1
No files found.
src/components/common/PublishBox/index.vue
View file @
cc7f2a1c
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
v-if=
"form.imgUrl.length"
v-if=
"form.imgUrl.length"
class=
"flex flex-wrap gap-2 w-fit"
class=
"flex flex-wrap gap-2 w-fit"
v-loading=
"uploadPercent > 0"
v-loading=
"uploadPercent > 0"
:element-loading-text=
"uploadPercent + '%'"
>
>
<!-- 删除图片 -->
<!-- 删除图片 -->
<div
<div
...
@@ -118,9 +119,11 @@
...
@@ -118,9 +119,11 @@
text
text
class=
"w-10 h-10 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg"
class=
"w-10 h-10 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg"
@
click=
"fileInputRef?.click()"
@
click=
"fileInputRef?.click()"
:disabled=
"uploadPercent > 0"
>
>
<el-icon
size=
"18"
>
<el-icon
size=
"18"
>
<IEpPicture
/>
<span
v-if=
"!form.imgUrl.length && uploadPercent > 0"
>
<IEpLoading
/></span>
<span
v-else
>
<IEpPicture
/></span>
</el-icon>
</el-icon>
</el-button>
</el-button>
</el-tooltip>
</el-tooltip>
...
...
src/components/common/UploadFile/index.vue
View file @
cc7f2a1c
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
:multiple=
"multiple"
:multiple=
"multiple"
:limit=
"limit"
:limit=
"limit"
class=
"custom-upload"
class=
"custom-upload"
v-loading=
"uploadPercent > 0"
:element-loading-text=
"uploadPercent + '%'"
>
>
<el-icon><Plus
/></el-icon>
<el-icon><Plus
/></el-icon>
<el-dialog
:append-to-body=
"true"
v-model=
"dialogVisible"
>
<el-dialog
:append-to-body=
"true"
v-model=
"dialogVisible"
>
...
@@ -40,6 +42,7 @@ const fileList = ref<UploadUserFile[]>([])
...
@@ -40,6 +42,7 @@ const fileList = ref<UploadUserFile[]>([])
const
uploadRef
=
useTemplateRef
(
'uploadRef'
)
const
uploadRef
=
useTemplateRef
(
'uploadRef'
)
const
dialogImageUrl
=
ref
(
''
)
const
dialogImageUrl
=
ref
(
''
)
const
dialogVisible
=
ref
(
false
)
const
dialogVisible
=
ref
(
false
)
const
uploadPercent
=
ref
(
0
)
const
isArrayType
=
computed
(()
=>
Array
.
isArray
(
modelValue
.
value
))
const
isArrayType
=
computed
(()
=>
Array
.
isArray
(
modelValue
.
value
))
const
hasReachedLimit
=
computed
(()
=>
fileList
.
value
.
length
>=
props
.
limit
)
const
hasReachedLimit
=
computed
(()
=>
fileList
.
value
.
length
>=
props
.
limit
)
...
@@ -129,9 +132,12 @@ const handleChange: UploadProps['onChange'] = async (uploadFile, uploadFiles) =>
...
@@ -129,9 +132,12 @@ const handleChange: UploadProps['onChange'] = async (uploadFile, uploadFiles) =>
const
{
promise
}
=
uploadFileApi
(
uploadFile
.
raw
,
{
const
{
promise
}
=
uploadFileApi
(
uploadFile
.
raw
,
{
onProgress
:
(
progress
)
=>
{
onProgress
:
(
progress
)
=>
{
console
.
log
(
'progress'
,
progress
)
console
.
log
(
'progress'
,
progress
)
uploadPercent
.
value
=
progress
},
},
})
})
const
data
=
await
promise
const
data
=
await
promise
console
.
log
(
'data'
,
data
)
console
.
log
(
'data'
,
data
)
const
url
=
data
.
filePath
||
''
const
url
=
data
.
filePath
||
''
const
name
=
data
.
finalName
||
''
const
name
=
data
.
finalName
||
''
...
@@ -157,6 +163,8 @@ const handleChange: UploadProps['onChange'] = async (uploadFile, uploadFiles) =>
...
@@ -157,6 +163,8 @@ const handleChange: UploadProps['onChange'] = async (uploadFile, uploadFiles) =>
if
(
fileIndex
!==
-
1
)
{
if
(
fileIndex
!==
-
1
)
{
fileList
.
value
.
splice
(
fileIndex
,
1
)
fileList
.
value
.
splice
(
fileIndex
,
1
)
}
}
}
finally
{
uploadPercent
.
value
=
0
}
}
}
}
}
}
...
...
src/hooks/useUploadImg.ts
View file @
cc7f2a1c
...
@@ -8,6 +8,7 @@ export const useUploadImg = (imgList: Ref<string[]> = ref([])) => {
...
@@ -8,6 +8,7 @@ export const useUploadImg = (imgList: Ref<string[]> = ref([])) => {
// 上传图片的change事件
// 上传图片的change事件
const
handleFileChange
=
async
(
e
:
Event
)
=>
{
const
handleFileChange
=
async
(
e
:
Event
)
=>
{
try
{
const
file
=
(
e
.
target
as
HTMLInputElement
).
files
?.[
0
]
const
file
=
(
e
.
target
as
HTMLInputElement
).
files
?.[
0
]
if
(
!
file
)
return
if
(
!
file
)
return
...
@@ -18,11 +19,14 @@ export const useUploadImg = (imgList: Ref<string[]> = ref([])) => {
...
@@ -18,11 +19,14 @@ export const useUploadImg = (imgList: Ref<string[]> = ref([])) => {
})
})
const
data
=
await
promise
const
data
=
await
promise
imgList
.
value
.
push
(
data
.
filePath
)
imgList
.
value
.
push
(
data
.
filePath
)
}
catch
(
error
)
{
console
.
error
(
'上传失败:'
,
error
)
}
finally
{
uploadPercent
.
value
=
0
uploadPercent
.
value
=
0
// 重置input的value
// 重置input的value
;(
e
.
target
as
HTMLInputElement
).
value
=
''
;(
e
.
target
as
HTMLInputElement
).
value
=
''
}
}
}
// 删除图片
// 删除图片
const
handleDeleteImg
=
(
urlStr
:
string
)
=>
{
const
handleDeleteImg
=
(
urlStr
:
string
)
=>
{
...
...
src/views/publishLongArticle/index.vue
View file @
cc7f2a1c
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
<!-- 帖子 专栏专访 是富文本 需要上传封面图 封面图 -->
<!-- 帖子 专栏专访 是富文本 需要上传封面图 封面图 -->
<
template
v-else
>
<
template
v-else
>
<el-form-item
label=
"封面图"
prop=
"faceUrl"
>
<el-form-item
label=
"封面图"
prop=
"faceUrl"
>
<UploadFile
v-model=
"form.faceUrl"
:limit=
"1"
class=
"w-full
"
/>
<UploadFile
class=
"w-fit"
v-model=
"form.faceUrl"
:limit=
"1
"
/>
</el-form-item>
</el-form-item>
</
template
>
</
template
>
...
...
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