mirror of
https://github.com/palxiao/poster-design
synced 2024-11-22 07:39:41 +00:00
fix: copy&paste
This commit is contained in:
parent
ba34a9ee94
commit
125d52f863
6
package-lock.json
generated
6
package-lock.json
generated
@ -21,6 +21,7 @@
|
||||
"element-plus": "^2.3.7",
|
||||
"fontfaceobserver": "^2.1.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"mitt": "^3.0.1",
|
||||
"moveable": "^0.26.0",
|
||||
"moveable-helper": "^0.4.0",
|
||||
"nanoid": "^3.1.23",
|
||||
@ -3013,6 +3014,11 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/mitt": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
|
||||
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw=="
|
||||
},
|
||||
"node_modules/moveable": {
|
||||
"version": "0.26.0",
|
||||
"resolved": "https://registry.npmjs.org/moveable/-/moveable-0.26.0.tgz",
|
||||
|
@ -24,6 +24,7 @@
|
||||
"element-plus": "^2.3.7",
|
||||
"fontfaceobserver": "^2.1.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"mitt": "^3.0.1",
|
||||
"moveable": "^0.26.0",
|
||||
"moveable-helper": "^0.4.0",
|
||||
"nanoid": "^3.1.23",
|
||||
|
@ -8,14 +8,15 @@
|
||||
// import store from '@/store'
|
||||
// import { getImage } from '../getImgDetail'
|
||||
import setImageData from '@/common/methods/DesignFeatures/setImage'
|
||||
import wText from '@/components/modules/widgets/wText/wText.vue'
|
||||
// import wText from '@/components/modules/widgets/wText/wText.vue'
|
||||
import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting'
|
||||
import wImage from '@/components/modules/widgets/wImage/wImage.vue'
|
||||
import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue'
|
||||
|
||||
export default async function(type: string, item: TCommonItemData, data: Record<string, any>) {
|
||||
let setting = data
|
||||
if (type === 'text') {
|
||||
!item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wText.setting))) : (setting = item)
|
||||
!item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wTextSetting))) : (setting = item)
|
||||
!setting.text ? (setting.text = '双击编辑文字') : (setting.text = decodeURIComponent(setting.text)) // item.text
|
||||
setting.fontSize = item.fontSize
|
||||
setting.width = item.width || item.fontSize * setting.text.length
|
||||
|
@ -50,6 +50,7 @@ import photoList from './components/photoList.vue'
|
||||
import imgWaterFall from './components/imgWaterFall.vue'
|
||||
import { TUploadDoneData } from '@/components/common/Uploader/index.vue'
|
||||
import { IGetTempListData } from '@/api/home'
|
||||
import eventBus from '@/utils/plugins/eventBus'
|
||||
|
||||
type TProps = {
|
||||
active?: number
|
||||
@ -238,6 +239,11 @@ const openPSD = () => {
|
||||
window.open(router.resolve('/psd').href, '_blank')
|
||||
}
|
||||
|
||||
eventBus.on('refreshUserImages', () => {
|
||||
state.imgList = []
|
||||
load(true)
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
selectDesign,
|
||||
loadDesign,
|
||||
|
@ -17,7 +17,8 @@ import Qiniu from '@/common/methods/QiNiu'
|
||||
import _config from '@/config'
|
||||
import { getImage } from '@/common/methods/getImgDetail'
|
||||
import wImage from '@/components/modules/widgets/wImage/wImage.vue'
|
||||
import wText from '@/components/modules/widgets/wText/wText.vue'
|
||||
import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting'
|
||||
import eventBus from '@/utils/plugins/eventBus'
|
||||
|
||||
export default () => {
|
||||
return new Promise<void>((resolve) => {
|
||||
@ -38,6 +39,8 @@ export default () => {
|
||||
const { width, height }: any = await getImage(file)
|
||||
const url = _config.IMG_URL + result.key
|
||||
await api.material.addMyPhoto({ width, height, url })
|
||||
// 刷新用户列表
|
||||
eventBus.emit('refreshUserImages')
|
||||
// 添加图片到画布中
|
||||
store.commit('setShowMoveable', false) // 清理掉上一次的选择
|
||||
const setting = JSON.parse(JSON.stringify(wImage.setting))
|
||||
@ -54,10 +57,14 @@ export default () => {
|
||||
'text/plain': new Blob([''], {type: 'text/plain'})
|
||||
})
|
||||
])
|
||||
// 最后尝试复制,将图片替换为图片组件
|
||||
setTimeout(() => {
|
||||
store.dispatch('copyWidget')
|
||||
}, 100)
|
||||
break
|
||||
} else if (item.types.toString().indexOf('text') !== -1) {
|
||||
store.commit('setShowMoveable', false) // 清理掉上一次的选择
|
||||
const setting = JSON.parse(JSON.stringify(wText.setting))
|
||||
const setting = JSON.parse(JSON.stringify(wTextSetting))
|
||||
setting.text = await navigator.clipboard.readText()
|
||||
store.dispatch('addWidget', setting)
|
||||
break
|
||||
|
@ -38,6 +38,9 @@ const all = {
|
||||
fonts: (state: Type.Object) => {
|
||||
return state.fonts
|
||||
},
|
||||
app: (state: Type.Object) => {
|
||||
return state.app
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
...mutations,
|
||||
|
@ -38,5 +38,5 @@ export default {
|
||||
},
|
||||
managerEdit(state: Type.Object, status: string) {
|
||||
state.tempEditing = status
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -291,6 +291,7 @@ export default {
|
||||
}
|
||||
|
||||
store.dispatch('pushHistory', 'pasteWidget')
|
||||
store.dispatch('copyWidget')
|
||||
store.dispatch('reChangeCanvas')
|
||||
},
|
||||
// TODO: 选中元件与取消选中
|
||||
|
9
src/utils/plugins/eventBus.ts
Normal file
9
src/utils/plugins/eventBus.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import mitt from 'mitt';
|
||||
|
||||
type Events = {
|
||||
refreshUserImages: any;
|
||||
};
|
||||
|
||||
const emitter = mitt<Events>();
|
||||
|
||||
export default emitter;
|
@ -12,7 +12,7 @@
|
||||
import { StyleValue, onMounted, reactive, nextTick } from 'vue'
|
||||
import { useStore } from 'vuex'
|
||||
import api from '@/api'
|
||||
import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
// import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
import Preload from '@/utils/plugins/preload'
|
||||
import FontFaceObserver from 'fontfaceobserver'
|
||||
import { fontWithDraw, font2style } from '@/utils/widgets/loadFontRule'
|
||||
|
@ -67,7 +67,7 @@ import zoomControl from '@/components/modules/layout/zoomControl/index.vue'
|
||||
import lineGuides from '@/components/modules/layout/lineGuides.vue'
|
||||
|
||||
import shortcuts from '@/mixins/shortcuts'
|
||||
import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
// import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
import HeaderOptions from './components/HeaderOptions.vue'
|
||||
import ProgressLoading from '@/components/common/ProgressLoading/index.vue'
|
||||
import { useSetupMapGetters } from '@/common/hooks/mapGetters'
|
||||
|
@ -37,7 +37,7 @@ import { useFontStore } from '@/common/methods/fonts'
|
||||
import copyRight from './CopyRight.vue'
|
||||
import _config from '@/config'
|
||||
import useConfirm from '@/common/methods/confirm'
|
||||
import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
// import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
|
||||
import { useSetupMapGetters } from '@/common/hooks/mapGetters'
|
||||
|
||||
type TProps = {
|
||||
|
Loading…
Reference in New Issue
Block a user