mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-28 04:10:31 +08:00
code: uploader
This commit is contained in:
parent
1bf998beea
commit
0cba15dd48
@ -1,15 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: ShawnPhang
|
* @Author: ShawnPhang
|
||||||
* @Date: 2021-09-30 16:28:40
|
* @Date: 2021-09-30 16:28:40
|
||||||
* @Description: 加载遮罩 / 弹窗
|
* @Description: 弹出提示
|
||||||
* @LastEditors: ShawnPhang
|
* @LastEditors: ShawnPhang
|
||||||
* @LastEditTime: 2022-01-20 18:19:20
|
* @LastEditTime: 2022-01-20 18:19:20
|
||||||
*/
|
*/
|
||||||
import { ElNotification } from 'element-plus'
|
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({
|
ElNotification({
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
type,
|
...extra,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ export default defineComponent({
|
|||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
html2canvas(document.getElementById('page-design-canvas'), opts).then((canvas: any) => {
|
html2canvas(document.getElementById('page-design-canvas'), opts).then((canvas: any) => {
|
||||||
canvas.toBlob(
|
canvas.toBlob(
|
||||||
async function (blobObj: Blob) {
|
async (blobObj: Blob) => {
|
||||||
const result: any = await Qiniu.upload(blobObj, { bucket: 'cloud-design', prePath: 'cover/user' })
|
const result: any = await Qiniu.upload(blobObj, { bucket: 'xp-design', prePath: 'cover/user' })
|
||||||
cb(result)
|
cb(result)
|
||||||
},
|
},
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
|
@ -19,6 +19,7 @@ import { ElUpload } from 'element-plus'
|
|||||||
import Qiniu from '@/common/methods/QiNiu'
|
import Qiniu from '@/common/methods/QiNiu'
|
||||||
import { getImage } from '@/common/methods/getImgDetail'
|
import { getImage } from '@/common/methods/getImgDetail'
|
||||||
import _config from '@/config'
|
import _config from '@/config'
|
||||||
|
import useNotification from '@/common/methods/notification'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { ElUpload },
|
components: { ElUpload },
|
||||||
@ -26,7 +27,7 @@ export default defineComponent({
|
|||||||
modelValue: {},
|
modelValue: {},
|
||||||
options: {
|
options: {
|
||||||
default: () => {
|
default: () => {
|
||||||
return { bucket: 'cloud-design', prePath: 'user' }
|
return { bucket: 'xp-design', prePath: 'user' }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hold: {
|
hold: {
|
||||||
@ -69,10 +70,14 @@ export default defineComponent({
|
|||||||
const uploadQueue = async () => {
|
const uploadQueue = async () => {
|
||||||
if (!uploading) {
|
if (!uploading) {
|
||||||
uploading = true
|
uploading = true
|
||||||
if (uploadList[0]) {
|
const file = uploadList[0]
|
||||||
tempSimpleRes = await qiNiuUpload(uploadList[0]) // 队列有文件,执行上传
|
if (file) {
|
||||||
const { width, height }: any = await getImage(uploadList[0])
|
if (file.size <= 1024 * 1024) {
|
||||||
context.emit('done', { width, height, url: _config.IMG_URL + tempSimpleRes.key }) // 单个文件进行响应
|
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
|
uploading = false
|
||||||
handleRemove() // 移除已上传文件
|
handleRemove() // 移除已上传文件
|
||||||
index++
|
index++
|
||||||
@ -110,10 +115,7 @@ export default defineComponent({
|
|||||||
context.emit('update:modelValue', percent)
|
context.emit('update:modelValue', percent)
|
||||||
}
|
}
|
||||||
const handleRemove = () => {
|
const handleRemove = () => {
|
||||||
if (uploadList.length <= 0) {
|
uploadList.length > 0 && uploadList.splice(0, 1)
|
||||||
return
|
|
||||||
}
|
|
||||||
uploadList.splice(0, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -70,10 +70,10 @@ export default {
|
|||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
zoom: 1,
|
zoom: 1,
|
||||||
fontClass: {
|
fontClass: {
|
||||||
alias: '思源黑体 常规',
|
alias: '素材集市酷方体',
|
||||||
id: 206607,
|
id: 33925853,
|
||||||
value: 'SourceHanSansSC-Regular',
|
value: 'sucaijishikufangti',
|
||||||
url: 'https://font.palxp.com/SourceHanSansSC-Regular.woff',
|
url: 'https://res.palxp.com/static/fonts/20200809-152508-8654.woff',
|
||||||
},
|
},
|
||||||
fontFamily: 'SourceHanSansSC-Regular',
|
fontFamily: 'SourceHanSansSC-Regular',
|
||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @Date: 2022-01-10 14:57:53
|
* @Date: 2022-01-10 14:57:53
|
||||||
* @Description: Psd文件解析
|
* @Description: Psd文件解析
|
||||||
* @LastEditors: ShawnPhang <site: book.palxp.com>
|
* @LastEditors: ShawnPhang <site: book.palxp.com>
|
||||||
* @LastEditTime: 2023-07-25 17:03:02
|
* @LastEditTime: 2023-07-25 15:56:22
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div id="page-design-index" ref="pageDesignIndex">
|
<div id="page-design-index" ref="pageDesignIndex">
|
||||||
|
@ -64,7 +64,7 @@ export default defineComponent({
|
|||||||
const cover = hasCover ? await proxy?.draw() : undefined
|
const cover = hasCover ? await proxy?.draw() : undefined
|
||||||
const widgets = proxy.dWidgets // reviseData()
|
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 })
|
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 })
|
!id && router.push({ path: '/home', query: { id: newId }, replace: true })
|
||||||
store.commit('setShowMoveable', true)
|
store.commit('setShowMoveable', true)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ export default defineComponent({
|
|||||||
context.emit('change', { downloadPercent: 95, downloadText: '正在处理封面', downloadMsg: '即将结束...' })
|
context.emit('change', { downloadPercent: 95, downloadText: '正在处理封面', downloadMsg: '即将结束...' })
|
||||||
const cover = await draw()
|
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 })
|
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 })
|
router.push({ path: '/psd', query: { id }, replace: true })
|
||||||
context.emit('change', { downloadPercent: 99.99, downloadText: '上传完成', cancelText: '查看我的作品' }) // 关闭弹窗
|
context.emit('change', { downloadPercent: 99.99, downloadText: '上传完成', cancelText: '查看我的作品' }) // 关闭弹窗
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user