Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
vue3-element-admin
提交
c2cf46bd
V
vue3-element-admin
项目概览
有来技术
/
vue3-element-admin
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue3-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c2cf46bd
编写于
1月 12, 2022
作者:
郝
郝先瑞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(MiniCardUpload.vue): 删除mini卡片上传组件
上级
e2158940
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
121 deletion
+0
-121
src/components/Upload/MiniCardUpload.vue
src/components/Upload/MiniCardUpload.vue
+0
-121
未找到文件。
src/components/Upload/MiniCardUpload.vue
已删除
100644 → 0
浏览文件 @
e2158940
<
template
>
<div>
<el-upload
class=
"mini-card-uploader"
:headers=
"headers"
:action=
"uploadAction"
:multiple=
"false"
:show-file-list=
"false"
:file-list=
"fileList"
:before-upload=
"handleBeforeUpload"
:on-success=
"handleUploadSuccess"
:on-preview=
"handlePreview"
:auto-upload=
"true"
>
<img
v-if=
"fileList[0].url"
:src=
"fileList[0].url"
class=
"mini-card"
>
<i
v-else
class=
"el-icon-plus mini-card-uploader-icon"
></i>
<i
v-if=
"fileList[0].url"
class=
"el-icon-close mini-card-remove-icon"
@
click.stop=
"handleRemove(fileList[0].url)"
></i>
</el-upload>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
Local
}
from
"
@/utils/storage
"
;
import
{
deleteFile
}
from
'
@/api/system/file
'
import
{
computed
,
reactive
,
toRefs
}
from
"
vue
"
;
const
emit
=
defineEmits
([
'
update:modelValue
'
]);
const
props
=
defineProps
({
modelValue
:
{
type
:
String
,
default
:
''
},
maxCount
:
{
type
:
Number
,
default
:
1
}
})
const
state
=
reactive
({
uploadAction
:
import
.
meta
.
env
.
VITE_APP_BASE_API
+
'
/youlai-admin/api/v1/files
'
,
headers
:
{
authorization
:
Local
.
get
(
'
token
'
)},
fileList
:
[{
url
:
''
}]
})
const
imgUrl
=
computed
({
get
()
{
return
props
.
modelValue
},
set
(
val
)
{
state
.
fileList
=
[{
url
:
val
as
string
}]
emit
(
'
update:modelValue
'
,
val
)
}
})
const
{
uploadAction
,
headers
,
fileList
}
=
toRefs
(
state
)
function
handleBeforeUpload
(
file
:
any
)
{
const
isJPG
=
file
.
type
===
'
image/jpeg
'
const
isLt2M
=
file
.
size
/
1024
/
1024
<
2
if
(
!
isJPG
)
{
}
if
(
!
isLt2M
)
{
}
return
true
}
function
handleUploadSuccess
(
response
:
any
)
{
state
.
fileList
.
pop
();
const
fileUrl
=
response
.
data
state
.
fileList
.
push
({
url
:
fileUrl
})
emit
(
'
update:modelValue
'
,
fileUrl
)
}
function
handleRemove
(
file
:
any
)
{
deleteFile
(
file
.
url
)
emit
(
'
update:modelValue
'
,
''
)
}
</
script
>
<
style
>
.mini-card-uploader
.el-upload
{
border
:
1px
dashed
#d9d9d9
;
border-radius
:
6px
;
cursor
:
pointer
;
position
:
relative
;
overflow
:
hidden
;
}
.mini-card-uploader
.el-upload
:hover
{
border-color
:
#409EFF
;
}
.mini-card-uploader-icon
{
font-size
:
28px
;
color
:
#8c939d
;
width
:
60px
;
height
:
50px
;
line-height
:
50px
;
text-align
:
center
;
}
.mini-card
{
width
:
60px
;
height
:
50px
;
display
:
block
;
}
.mini-card-remove-icon
{
position
:
absolute
;
right
:
0
;
top
:
0
;
color
:
#409eff
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录