From 0cba15dd48b891d0f155974737da486740df17a9 Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Tue, 25 Jul 2023 23:19:30 +0800 Subject: [PATCH 1/2] code: uploader --- src/common/methods/notification.ts | 12 ++++++++--- .../business/save-download/CreateCover.vue | 4 ++-- src/components/common/Uploader/index.vue | 20 ++++++++++--------- .../modules/widgets/wText/wText.vue | 8 ++++---- src/views/Psd.vue | 2 +- src/views/components/HeaderOptions.vue | 2 +- src/views/components/UploadTemplate.vue | 2 +- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/common/methods/notification.ts b/src/common/methods/notification.ts index f26f78d..93fe227 100644 --- a/src/common/methods/notification.ts +++ b/src/common/methods/notification.ts @@ -1,15 +1,21 @@ /* * @Author: ShawnPhang * @Date: 2021-09-30 16:28:40 - * @Description: 加载遮罩 / 弹窗 + * @Description: 弹出提示 * @LastEditors: ShawnPhang * @LastEditTime: 2022-01-20 18:19:20 */ import { ElNotification } from 'element-plus' -export default (title: string, message: string = '', type: any = 'success') => { + +interface ElNotifi { + type?: 'success' | 'warning' | 'info' | 'error' | '' + position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' +} + +export default (title: string, message: string = '', extra?: ElNotifi) => { ElNotification({ title, message, - type, + ...extra, }) } diff --git a/src/components/business/save-download/CreateCover.vue b/src/components/business/save-download/CreateCover.vue index b4f383d..52aa55b 100644 --- a/src/components/business/save-download/CreateCover.vue +++ b/src/components/business/save-download/CreateCover.vue @@ -57,8 +57,8 @@ export default defineComponent({ setTimeout(async () => { html2canvas(document.getElementById('page-design-canvas'), opts).then((canvas: any) => { canvas.toBlob( - async function (blobObj: Blob) { - const result: any = await Qiniu.upload(blobObj, { bucket: 'cloud-design', prePath: 'cover/user' }) + async (blobObj: Blob) => { + const result: any = await Qiniu.upload(blobObj, { bucket: 'xp-design', prePath: 'cover/user' }) cb(result) }, 'image/jpeg', diff --git a/src/components/common/Uploader/index.vue b/src/components/common/Uploader/index.vue index e7f8e17..e2e3dd1 100644 --- a/src/components/common/Uploader/index.vue +++ b/src/components/common/Uploader/index.vue @@ -19,6 +19,7 @@ import { ElUpload } from 'element-plus' import Qiniu from '@/common/methods/QiNiu' import { getImage } from '@/common/methods/getImgDetail' import _config from '@/config' +import useNotification from '@/common/methods/notification' export default defineComponent({ components: { ElUpload }, @@ -26,7 +27,7 @@ export default defineComponent({ modelValue: {}, options: { default: () => { - return { bucket: 'cloud-design', prePath: 'user' } + return { bucket: 'xp-design', prePath: 'user' } }, }, hold: { @@ -69,10 +70,14 @@ export default defineComponent({ const uploadQueue = async () => { if (!uploading) { uploading = true - if (uploadList[0]) { - tempSimpleRes = await qiNiuUpload(uploadList[0]) // 队列有文件,执行上传 - const { width, height }: any = await getImage(uploadList[0]) - context.emit('done', { width, height, url: _config.IMG_URL + tempSimpleRes.key }) // 单个文件进行响应 + const file = uploadList[0] + if (file) { + if (file.size <= 1024 * 1024) { + tempSimpleRes = await qiNiuUpload(file) // 队列有文件,执行上传 + const { width, height }: any = await getImage(file) + useNotification('上传成功', '目前没有用户系统,请注意别上传隐私照片哦!', { position: 'bottom-left' }) + context.emit('done', { width, height, url: _config.IMG_URL + tempSimpleRes.key }) // 单个文件进行响应 + } else useNotification('爱护小水管', '请上传小于 1M 的图片哦!', { type: 'error', position: 'bottom-left' }) uploading = false handleRemove() // 移除已上传文件 index++ @@ -110,10 +115,7 @@ export default defineComponent({ context.emit('update:modelValue', percent) } const handleRemove = () => { - if (uploadList.length <= 0) { - return - } - uploadList.splice(0, 1) + uploadList.length > 0 && uploadList.splice(0, 1) } return { diff --git a/src/components/modules/widgets/wText/wText.vue b/src/components/modules/widgets/wText/wText.vue index 17842ea..6266888 100644 --- a/src/components/modules/widgets/wText/wText.vue +++ b/src/components/modules/widgets/wText/wText.vue @@ -70,10 +70,10 @@ export default { fontSize: 24, zoom: 1, fontClass: { - alias: '思源黑体 常规', - id: 206607, - value: 'SourceHanSansSC-Regular', - url: 'https://font.palxp.com/SourceHanSansSC-Regular.woff', + alias: '素材集市酷方体', + id: 33925853, + value: 'sucaijishikufangti', + url: 'https://res.palxp.com/static/fonts/20200809-152508-8654.woff', }, fontFamily: 'SourceHanSansSC-Regular', fontWeight: 'normal', diff --git a/src/views/Psd.vue b/src/views/Psd.vue index 43d4715..2649252 100644 --- a/src/views/Psd.vue +++ b/src/views/Psd.vue @@ -3,7 +3,7 @@ * @Date: 2022-01-10 14:57:53 * @Description: Psd文件解析 * @LastEditors: ShawnPhang - * @LastEditTime: 2023-07-25 17:03:02 + * @LastEditTime: 2023-07-25 15:56:22 -->