Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-lab
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-lab
Commits
466a9d89
提交
466a9d89
authored
8月 27, 2026
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixes
上级
d128e96a
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
36 行删除
+6
-36
AppUpload.vue
src/components/base/AppUpload.vue
+6
-36
没有找到文件。
src/components/base/AppUpload.vue
浏览文件 @
466a9d89
...
...
@@ -2,28 +2,19 @@
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
md5
from
'blueimp-md5'
import
{
getSignature
}
from
'@/api/base'
import
{
upload
as
localUpload
}
from
'@/utils/upload'
const
isSchool
=
import
.
meta
.
env
.
MODE
===
'school'
import
{
upload
}
from
'@/utils/upload'
interface
Props
{
modelValue
:
string
|
{
name
:
string
;
url
:
string
}[]
prefix
?:
string
size
?:
number
limit
?:
number
beforeUpload
?:
(
file
:
any
)
=>
void
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
prefix
:
'upload/saas-lab/'
})
const
props
=
defineProps
<
Props
>
()
const
emit
=
defineEmits
([
'update:modelValue'
,
'success'
])
const
uploadData
=
ref
()
const
fileList
=
ref
<
UploadUserFile
[]
>
([])
watchEffect
(()
=>
{
...
...
@@ -44,21 +35,6 @@ const handleBeforeUpload = async (file: any) => {
ElMessage
.
error
(
`文件大小不能超过
${
props
.
size
/
1024
/
1024
}
M`
)
return
false
}
if
(
!
isSchool
)
{
const
fileName
=
file
.
name
const
key
=
props
.
prefix
+
md5
(
fileName
+
new
Date
().
getTime
())
+
'/'
+
fileName
const
response
:
Record
<
string
,
any
>
=
await
getSignature
()
uploadData
.
value
=
{
key
,
host
:
response
.
host
,
OSSAccessKeyId
:
response
.
accessid
,
policy
:
response
.
policy
,
signature
:
response
.
signature
,
success_action_status
:
'200'
,
url
:
`
${
response
.
host
}
/
${
key
}
`
,
}
file
.
url
=
`
${
response
.
host
}
/
${
key
}
`
}
if
(
props
.
beforeUpload
)
{
return
props
.
beforeUpload
(
file
)
}
...
...
@@ -118,15 +94,11 @@ const handleRemove: UploadProps['onRemove'] = (file, files) => {
}
}
//
学校模式 — 本地服务器上传
//
统一使用上传工具,由上传工具根据当前环境选择上传方式
const
customRequest
=
async
(
options
:
any
)
=>
{
try
{
const
url
=
await
localUpload
(
options
.
file
)
fileList
.
value
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
uid
===
options
.
file
.
uid
)
{
item
.
url
=
url
}
})
const
url
=
await
upload
(
options
.
file
)
options
.
file
.
url
=
url
options
.
onSuccess
({
url
},
options
.
file
)
}
catch
(
err
)
{
options
.
onError
(
err
)
...
...
@@ -141,9 +113,7 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
<
template
>
<el-upload
:action=
"isSchool ? '#' : uploadData?.host"
:data=
"uploadData"
:http-request=
"isSchool ? customRequest : undefined"
:http-request=
"customRequest"
:show-file-list=
"showFileList"
:before-upload=
"handleBeforeUpload"
:on-exceed=
"handleExceed"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论