mirror of
https://github.com/palxiao/poster-design
synced 2024-11-23 08:38:40 +00:00
fix: paste history lost bug
This commit is contained in:
parent
dcacc3e5e4
commit
3bf285085d
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -9,5 +9,8 @@
|
||||
},
|
||||
"css.validate": false,
|
||||
"less.validate": false,
|
||||
"scss.validate": false
|
||||
"scss.validate": false,
|
||||
"i18n-ally.localesPaths": [
|
||||
"src/languages"
|
||||
]
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 差分补丁目前已知的问题是,对于预期以外的影响状态树的修改,现在都会写进历史记录,看起来就像多了一段毫无变化的历史栈一样
|
||||
* 例如图层的 left 在修改后可能为 12.6262638 但为了输入框中显示友好,在 input 组件中将自动格式化为 12.63,这个逻辑以前不会有问题,现在则不能这么做了
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-05-18 01:51:34
|
||||
* @LastEditTime: 2024-05-22 19:33:04
|
||||
*/
|
||||
import { onMounted } from 'vue'
|
||||
// import WebWorker from '@/utils/plugins/webWorker'
|
||||
@ -14,7 +14,7 @@ import historyFactory from '@/utils/widgets/diffLayouts'
|
||||
import { useHistoryStore, useWidgetStore } from '@/store'
|
||||
|
||||
const blackClass: string[] = ['operation-item', 'icon-undo', 'icon-redo']
|
||||
const whiteKey: string[] = ['ArrowLeft', 'ArrowDown', 'ArrowRight', 'ArrowUp', 'Backspace', 'Delete']
|
||||
const whiteKey: string[] = ['ArrowLeft', 'ArrowDown', 'ArrowRight', 'ArrowUp', 'Backspace', 'Delete', 'v']
|
||||
|
||||
const historyStore = useHistoryStore()
|
||||
const widgetStore = useWidgetStore()
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Date: 2024-04-10 23:02:46
|
||||
* @Description: 主画布
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-04-16 11:34:08
|
||||
* @LastEditTime: 2024-05-22 19:29:51
|
||||
-->
|
||||
<template>
|
||||
<div id="main">
|
||||
@ -273,8 +273,6 @@ async function drop(e: MouseEvent) {
|
||||
const widget = dWidgets.value.find((item: { uuid: string }) => item.uuid == dropIn)
|
||||
if (!widget) return
|
||||
widget.imgUrl = item.value.url
|
||||
console.log('加入+', widget)
|
||||
|
||||
// store.commit('setShowMoveable', true) // 恢复选择
|
||||
controlStore.setShowMoveable(true) // 恢复选择
|
||||
} else {
|
||||
@ -285,7 +283,6 @@ async function drop(e: MouseEvent) {
|
||||
} else if (type === 'bg') {
|
||||
console.log('背景图片放置')
|
||||
} else if (type !== 'group') {
|
||||
console.log(setting)
|
||||
widgetStore.addWidget(setting as Required<TPageState>)
|
||||
// store.dispatch('addWidget', setting) // 正常加入面板
|
||||
}
|
||||
|
@ -2,12 +2,13 @@
|
||||
* @Author: Jeremy Yu
|
||||
* @Date: 2024-03-28 14:00:00
|
||||
* @Description:
|
||||
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
|
||||
* @LastEditTime: 2024-03-28 14:00:00
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-05-22 19:32:24
|
||||
*/
|
||||
|
||||
import { useCanvasStore, useHistoryStore } from "@/store"
|
||||
import { TWidgetStore, TdWidgetData } from ".."
|
||||
import { useWidgetStore } from "@/store"
|
||||
import { customAlphabet } from 'nanoid/non-secure'
|
||||
const nanoid = customAlphabet('1234567890abcdef', 12)
|
||||
|
||||
@ -50,8 +51,7 @@ export function copyWidget(store: TWidgetStore) {
|
||||
|
||||
/** 粘贴组件 */
|
||||
export function pasteWidget(store: TWidgetStore) {
|
||||
const historyStore = useHistoryStore()
|
||||
const canvasStore = useCanvasStore()
|
||||
const widgetStore = useWidgetStore()
|
||||
const copyElement: TdWidgetData[] = JSON.parse(JSON.stringify(store.dCopyElement))
|
||||
const container = copyElement.find((item) => item.isContainer)
|
||||
for (let i = 0; i < copyElement.length; ++i) {
|
||||
@ -63,19 +63,15 @@ export function pasteWidget(store: TWidgetStore) {
|
||||
}
|
||||
copyElement[i].top += 30
|
||||
copyElement[i].left += 30
|
||||
widgetStore.addWidget(copyElement[i])
|
||||
}
|
||||
store.dWidgets = store.dWidgets.concat(copyElement)
|
||||
// store.dWidgets = store.dWidgets.concat(copyElement)
|
||||
store.dActiveElement = copyElement[0]
|
||||
store.dSelectWidgets = copyElement
|
||||
if (container) {
|
||||
store.dActiveElement = container
|
||||
store.dSelectWidgets = []
|
||||
}
|
||||
|
||||
historyStore.pushHistory("pasteWidget")
|
||||
// store.dispatch('pushHistory', 'pasteWidget')
|
||||
// 复制以调整下次粘贴的位置
|
||||
store.copyWidget()
|
||||
// store.dispatch('copyWidget')
|
||||
canvasStore.reChangeCanvas()
|
||||
// store.dispatch('reChangeCanvas')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user