perf: auto import vue element-plus

This commit is contained in:
xingyu
2023-01-18 12:34:52 +08:00
parent 85c4d1fb03
commit 8e03c57bf4
58 changed files with 50 additions and 142 deletions

View File

@@ -33,11 +33,10 @@
</div>
</template>
<script setup lang="ts" name="UploadFile">
import { PropType, ref } from 'vue'
import { PropType } from 'vue'
import { useMessage } from '@/hooks/web/useMessage'
import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { ElUpload, UploadInstance, UploadProps, UploadRawFile, UploadUserFile } from 'element-plus'
const message = useMessage() // 消息弹窗
const emit = defineEmits(['update:modelValue'])

View File

@@ -51,9 +51,7 @@
</template>
<script setup lang="ts" name="UploadImg">
import { ref } from 'vue'
import type { UploadProps } from 'element-plus'
import { ElUpload, ElNotification, ElImageViewer } from 'element-plus'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { generateUUID } from '@/utils'
@@ -111,17 +109,8 @@ const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
const imgSize = rawFile.size / 1024 / 1024 < props.fileSize
const imgType = props.fileType
if (!imgType.includes(rawFile.type as FileTypes))
ElNotification({
title: '温馨提示',
message: '上传图片不符合所需的格式!',
type: 'warning'
})
if (!imgSize)
ElNotification({
title: '温馨提示',
message: `上传图片大小不能超过 ${props.fileSize}M`,
type: 'warning'
})
message.notifyWarning('上传图片不符合所需的格式!')
if (!imgSize) message.notifyWarning(`上传图片大小不能超过 ${props.fileSize}M`)
return imgType.includes(rawFile.type as FileTypes) && imgSize
}
@@ -133,11 +122,7 @@ const uploadSuccess: UploadProps['onSuccess'] = (res: any): void => {
// 图片上传错误提示
const uploadError = () => {
ElNotification({
title: '温馨提示',
message: '图片上传失败,请您重新上传!',
type: 'error'
})
message.notifyError('图片上传失败,请您重新上传!')
}
</script>
<style scoped lang="scss">