封装了一个element ui多图上传组件,支持v-model
<template>
<div
class="uploader"
:exceed="
$props.value.length >= $props.limit ||
(pending && $props.value.length === $props.limit - 1)
"
>
<el-upload
action=""
list-type="picture-card"
:on-success="handleOnUploadSuccess"
:on-error="handleOnUploadError"
:on-exceed="handleOnUploadExceed"
:on-remove="handleOnRemove"
:before-upload="handleBeforeUpload"
:http-request="handleUploadHttpRequest"
:file-list="$props.value"
:on-preview="handlePreview"
:show-file-list="true"
:limit="$props.limit"
accept="image/png,image/gif,image/jpg,image/jpeg"
>
<i class="el-icon-plus"></i>
</el-upload>
<ElImageViewer
v-if="showViewer"
:on-close="() => (showViewer = false)"
:url-list="[viewerUrl]"
></ElImageViewer>
</div>
</template>
<script>
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
export default {
components: { ElImageViewer },
props: {
value: { type: Array, default: () => [] },
api: Function,
fileName: { type: String, default: "file" },
limit: { type: Number, default: 3 },
size: { type: Number, default: 5 }
},
model: {
prop: "value",
event: "change"
},
data() {
return {
pending: false,
viewerUrl: "",
showViewer: false,
attachmentFetching: true,
attachmentUploading: false,
attachmentTooLarge: false,
attachmentUploadFormData: new FormData()
};
},
methods: {
handleOnUploadSuccess(response, file, fileList) {
this.attachmentUploadFormData.delete(this.$props.fileName);
this.attachmentUploading = false;
this.$message.success("上传成功");
fileList[fileList.length - 1].url = response.data;
fileList[fileList.length - 1].isDefault = 1;
this.$emit("change", fileList);
this.pending = false;
},
handleOnUploadError(error) {
this.attachmentUploadFormData.delete(this.$props.fileName);
this.attachmentUploading = false;
this.$message.error(error.msg || error);
this.pending = false;
},
handleBeforeUpload(file) {
const isLt2M = file.size / 1024 / 1024 < this.$props.size;
if (!isLt2M) {
this.attachmentTooLarge = true;
this.$message.error(`上传图片大小不能超过 ${this.$props.size}MB!`);
return false;
}
this.attachmentUploadFormData.append(this.$props.fileName, file);
this.pending = true;
return true;
},
handleOnUploadExceed() {
this.$message.error(`最多只能上传 ${this.$props.limit} 个附件~`);
},
async handleUploadHttpRequest() {
this.attachmentUploading = true;
return this.$props
.api(this.attachmentUploadFormData)
.then(response => Promise.resolve(response))
.catch(error => Promise.reject(error));
},
handlePreview(file) {
this.viewerUrl = file.url;
this.showViewer = true;
},
handleOnRemove(file, fileList) {
if (this.attachmentTooLarge) {
this.attachmentTooLarge = false;
return;
}
this.$emit("change", fileList);
}
}
};
</script>
<style lang="scss" scoped>
.uploader {
display: inline-block;
width: 100%;
&[exceed="true"] {
::v-deep {
.el-upload.el-upload--picture-card {
display: none;
}
}
}
::v-deep {
.el-list-enter-active,
.el-list-leave-active {
transition: unset;
}
.el-list-enter,
.el-list-leave-active {
opacity: 0;
transform: unset;
}
}
}
</style>
苹果 M1 pro 的显卡性能,据说达到了 RTX 3050Ti 的水平。这是不是说,苹果的游戏短板终于补起了,以后可以在 MacBook Pro 玩大型游戏了。
https://www.anandtech.com/show/17019/apple-announced-m1-pro-m1-max-giant-new-socs-with-allout-performance
Mastodon终于解决了kt-paperclip的compatible S3兼容问题
https://github.com/mastodon/mastodon/pull/16866
PS. 前天给kt-paperclip提issue,发现其实这个分支提交也没多少,issue基本没人回复啊。似乎是几个印度人在维护 😪
搭了一个gitea👇
https://git.moezx.cc/mashiro/mastodon
分享动态
//转发自: @KKOMDA: 【原神1周年】感谢你们出现在我的生命中!
感谢大家对我视频的支持和喜爱!~
一路走来有你们的陪伴真的非常开心!也感谢原神这款游戏给我带来的快乐!
原神一周年生日快乐!
https://api.2heng.xin/bilibili/og.php?av=848357187&high_quality=1&danmaku=0
https://t.bilibili.com/582573001874250657
꒰⑅•ᴗ•⑅꒱走进秘密的小森林,和2233一起开橘红色的派对吧!
白天效果 06:00am——16:00pm;
傍晚效果 16:00pm——19:00pm;
夜晚效果 19:00pm——06:00am;
https://api.2heng.xin/bilibili/og.php?av=293514912&high_quality=1&danmaku=0
https://t.bilibili.com/581775104319158975
Chinese 🇨🇳 / Dictatorial Admin / Mastodon Code Contributor / 摸鱼技术布道师
Steam: https://steamcommunity.com/id/MashiroBest
Epic: https://store.epicgames.com/en-US/u/d211c824cbd94aaeba898db6bb823ff7
原批交流群:966322309