Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-dml
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-dml
Commits
4d2829a1
提交
4d2829a1
authored
4月 10, 2023
作者:
陈志磊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
f7ac5f7c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
7 行增加
和
166 行删除
+7
-166
.eslintrc-auto-import.json
.eslintrc-auto-import.json
+1
-0
auto-imports.d.ts
auto-imports.d.ts
+6
-2
AppUpload copy.vue
src/components/base/AppUpload copy.vue
+0
-164
没有找到文件。
.eslintrc-auto-import.json
浏览文件 @
4d2829a1
...
...
@@ -115,6 +115,7 @@
"useArrayFilter"
:
true
,
"useArrayFind"
:
true
,
"useArrayFindIndex"
:
true
,
"useArrayFindLast"
:
true
,
"useArrayJoin"
:
true
,
"useArrayMap"
:
true
,
"useArrayReduce"
:
true
,
...
...
auto-imports.d.ts
浏览文件 @
4d2829a1
// Generated by 'unplugin-auto-import'
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-auto-import
export
{}
declare
global
{
const
$$
:
typeof
import
(
'vue/macros'
)[
'$$'
]
...
...
@@ -109,6 +112,7 @@ declare global {
const
useArrayFilter
:
typeof
import
(
'@vueuse/core'
)[
'useArrayFilter'
]
const
useArrayFind
:
typeof
import
(
'@vueuse/core'
)[
'useArrayFind'
]
const
useArrayFindIndex
:
typeof
import
(
'@vueuse/core'
)[
'useArrayFindIndex'
]
const
useArrayFindLast
:
typeof
import
(
'@vueuse/core'
)[
'useArrayFindLast'
]
const
useArrayJoin
:
typeof
import
(
'@vueuse/core'
)[
'useArrayJoin'
]
const
useArrayMap
:
typeof
import
(
'@vueuse/core'
)[
'useArrayMap'
]
const
useArrayReduce
:
typeof
import
(
'@vueuse/core'
)[
'useArrayReduce'
]
...
...
@@ -276,5 +280,5 @@ declare global {
// for type re-export
declare
global
{
// @ts-ignore
export
type
{
Component
,
ComponentPublicInstance
,
ComputedRef
,
InjectionKey
,
PropType
,
Ref
,
VNode
}
from
'vue'
export
type
{
Component
,
ComponentPublicInstance
,
ComputedRef
,
InjectionKey
,
PropType
,
Ref
,
VNode
}
from
'vue'
}
src/components/base/AppUpload copy.vue
deleted
100644 → 0
浏览文件 @
f7ac5f7c
<
script
lang=
"ts"
setup
>
import
{
ElMessage
}
from
'element-plus'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
md5
from
'blueimp-md5'
import
{
getSignature
}
from
'@/api/base'
const
props
=
withDefaults
(
defineProps
<
{
modelValue
:
string
|
[]
prefix
?:
string
size
?:
number
beforeUploadFiles
?:
(
file
:
any
)
=>
boolean
|
void
onChange
?:
(
file
:
any
,
files
:
any
)
=>
void
}
>
(),
{
prefix
:
'upload/admin/'
}
)
const
emit
=
defineEmits
([
'update:modelValue'
])
const
uploadData
=
ref
()
const
fileList
=
ref
<
UploadUserFile
[]
>
([])
watch
(
()
=>
props
.
modelValue
,
value
=>
{
fileList
.
value
=
Array
.
isArray
(
value
)
?
[...
value
]
:
[]
}
)
const
showFileList
=
computed
(()
=>
{
return
Array
.
isArray
(
props
.
modelValue
)
})
// 上传之前
const
handleBeforeUpload
=
async
(
file
:
any
)
=>
{
const
fileName
=
file
.
name
const
key
=
props
.
prefix
+
md5
(
fileName
+
new
Date
().
getTime
())
+
'/'
+
fileName
const
response
:
Record
<
string
,
any
>
=
await
getSignature
()
uploadData
.
value
=
{
key
,
OSSAccessKeyId
:
response
.
accessid
,
policy
:
response
.
policy
,
signature
:
response
.
signature
,
success_action_status
:
'200'
,
url
:
`
${
response
.
host
}
/
${
key
}
`
}
file
.
url
=
`
${
response
.
host
}
/
${
key
}
`
if
(
props
.
beforeUploadFiles
)
{
return
props
.
beforeUploadFiles
(
file
)
}
}
// 上传成功
const
handleSuccess
:
UploadProps
[
'onSuccess'
]
=
(
response
,
file
:
any
,
files
:
any
)
=>
{
if
(
!
files
.
every
((
item
:
any
)
=>
item
.
status
===
'success'
))
return
if
(
showFileList
.
value
)
{
emit
(
'update:modelValue'
,
files
.
map
((
item
:
any
)
=>
{
return
{
name
:
item
.
name
,
url
:
item
.
url
||
item
.
raw
.
url
,
size
:
item
.
size
||
item
.
raw
.
size
,
type
:
item
.
type
||
item
.
raw
.
type
}
})
)
}
else
{
emit
(
'update:modelValue'
,
file
.
raw
.
url
)
}
}
// 上传限制
const
handleExceed
:
UploadProps
[
'onExceed'
]
=
()
=>
{
ElMessage
.
warning
(
'文件超出个数限制'
)
}
// 删除
const
handleRemove
:
UploadProps
[
'onRemove'
]
=
(
uploadFile
,
uploadFiles
)
=>
{
if
(
showFileList
.
value
)
{
emit
(
'update:modelValue'
,
uploadFiles
.
map
((
item
:
any
)
=>
{
return
{
name
:
item
.
name
,
url
:
item
.
url
||
item
.
raw
.
url
,
size
:
item
.
size
,
type
:
item
.
type
}
})
)
}
else
{
emit
(
'update:modelValue'
,
''
)
}
}
// 预览
const
handlePreview
:
UploadProps
[
'onPreview'
]
=
uploadFile
=>
{
console
.
log
(
uploadFile
)
}
</
script
>
<
template
>
<el-upload
action=
"https://webapp-pub.oss-cn-beijing.aliyuncs.com"
:data=
"uploadData"
:show-file-list=
"showFileList"
:before-upload=
"handleBeforeUpload"
:on-exceed=
"handleExceed"
:on-remove=
"handleRemove"
:on-preview=
"handlePreview"
:on-success=
"handleSuccess"
:file-list=
"fileList"
class=
"uploader"
>
<template
v-if=
"showFileList"
>
<template
v-if=
"$attrs['list-type'] === 'picture-card'"
>
<el-icon><Plus
/></el-icon>
</
template
>
<
template
v-else-if=
"props.beforeUploadFiles"
>
<el-button
type=
"primary"
size=
"default"
round
>
上传图片/视频附件
</el-button>
</
template
>
<
template
v-else
>
<el-button
type=
"primary"
class=
"app-upload-btn"
>
点击上传
</el-button>
</
template
>
</template>
<div
class=
"avatar-uploader"
v-else
>
<el-image
:src=
"(modelValue as string)"
fit=
"contain"
v-if=
"modelValue"
/>
<el-icon
v-else
class=
"avatar-uploader-icon"
><Plus
/></el-icon>
</div>
<
template
#
tip
>
<div
class=
"el-upload__tip"
><slot
name=
"tip"
></slot></div>
</
template
>
</el-upload>
</template>
<
style
lang=
"scss"
>
.uploader
{
flex
:
1
;
}
.avatar-uploader
{
width
:
178px
;
height
:
178px
;
border
:
1px
dashed
var
(
--
el-border-color
);
border-radius
:
6px
;
cursor
:
pointer
;
position
:
relative
;
overflow
:
hidden
;
transition
:
var
(
--
el-transition-duration-fast
);
.el-image
{
width
:
100%
;
height
:
100%
;
}
}
.avatar-uploader
:hover
{
border-color
:
var
(
--
el-color-primary
);
}
.avatar-uploader-icon
{
font-size
:
28px
;
color
:
#8c939d
;
width
:
100%
;
height
:
100%
;
text-align
:
center
;
}
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论