mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
code: uploader
This commit is contained in:
parent
1bf998beea
commit
0cba15dd48
@ -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,
|
||||
})
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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 {
|
||||
|
@ -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',
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Date: 2022-01-10 14:57:53
|
||||
* @Description: Psd文件解析
|
||||
* @LastEditors: ShawnPhang <site: book.palxp.com>
|
||||
* @LastEditTime: 2023-07-25 17:03:02
|
||||
* @LastEditTime: 2023-07-25 15:56:22
|
||||
-->
|
||||
<template>
|
||||
<div id="page-design-index" ref="pageDesignIndex">
|
||||
|
@ -64,7 +64,7 @@ export default defineComponent({
|
||||
const cover = hasCover ? await proxy?.draw() : undefined
|
||||
const widgets = proxy.dWidgets // reviseData()
|
||||
const { id: newId, stat, msg } = await api.home.saveWorks({ cover, id, title: proxy.title || '未命名设计', data: JSON.stringify({ page: proxy.dPage, widgets }), temp_id: tempid, width: proxy.dPage.width, height: proxy.dPage.height })
|
||||
stat !== 0 ? useNotification('保存成功', '可在"我的作品"中查看') : useNotification('保存失败', msg, 'error')
|
||||
stat !== 0 ? useNotification('保存成功', '可在"我的作品"中查看') : useNotification('保存失败', msg, { type: 'error' })
|
||||
!id && router.push({ path: '/home', query: { id: newId }, replace: true })
|
||||
store.commit('setShowMoveable', true)
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ export default defineComponent({
|
||||
context.emit('change', { downloadPercent: 95, downloadText: '正在处理封面', downloadMsg: '即将结束...' })
|
||||
const cover = await draw()
|
||||
const { id, stat, msg } = await api.home.saveWorks({ cover, title: '自设计模板', data: JSON.stringify({ page, widgets }), width: page.width, height: page.height })
|
||||
stat !== 0 ? useNotification('保存成功', '可在"我的模板"中查看') : useNotification('保存失败', msg, 'error')
|
||||
stat !== 0 ? useNotification('保存成功', '可在"我的模板"中查看') : useNotification('保存失败', msg, { type: 'error' })
|
||||
router.push({ path: '/psd', query: { id }, replace: true })
|
||||
context.emit('change', { downloadPercent: 99.99, downloadText: '上传完成', cancelText: '查看我的作品' }) // 关闭弹窗
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user