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,
|
"css.validate": false,
|
||||||
"less.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,这个逻辑以前不会有问题,现在则不能这么做了
|
* 例如图层的 left 在修改后可能为 12.6262638 但为了输入框中显示友好,在 input 组件中将自动格式化为 12.63,这个逻辑以前不会有问题,现在则不能这么做了
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @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 { onMounted } from 'vue'
|
||||||
// import WebWorker from '@/utils/plugins/webWorker'
|
// import WebWorker from '@/utils/plugins/webWorker'
|
||||||
@ -14,7 +14,7 @@ import historyFactory from '@/utils/widgets/diffLayouts'
|
|||||||
import { useHistoryStore, useWidgetStore } from '@/store'
|
import { useHistoryStore, useWidgetStore } from '@/store'
|
||||||
|
|
||||||
const blackClass: string[] = ['operation-item', 'icon-undo', 'icon-redo']
|
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 historyStore = useHistoryStore()
|
||||||
const widgetStore = useWidgetStore()
|
const widgetStore = useWidgetStore()
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @Date: 2024-04-10 23:02:46
|
* @Date: 2024-04-10 23:02:46
|
||||||
* @Description: 主画布
|
* @Description: 主画布
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-04-16 11:34:08
|
* @LastEditTime: 2024-05-22 19:29:51
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -273,8 +273,6 @@ async function drop(e: MouseEvent) {
|
|||||||
const widget = dWidgets.value.find((item: { uuid: string }) => item.uuid == dropIn)
|
const widget = dWidgets.value.find((item: { uuid: string }) => item.uuid == dropIn)
|
||||||
if (!widget) return
|
if (!widget) return
|
||||||
widget.imgUrl = item.value.url
|
widget.imgUrl = item.value.url
|
||||||
console.log('加入+', widget)
|
|
||||||
|
|
||||||
// store.commit('setShowMoveable', true) // 恢复选择
|
// store.commit('setShowMoveable', true) // 恢复选择
|
||||||
controlStore.setShowMoveable(true) // 恢复选择
|
controlStore.setShowMoveable(true) // 恢复选择
|
||||||
} else {
|
} else {
|
||||||
@ -285,7 +283,6 @@ async function drop(e: MouseEvent) {
|
|||||||
} else if (type === 'bg') {
|
} else if (type === 'bg') {
|
||||||
console.log('背景图片放置')
|
console.log('背景图片放置')
|
||||||
} else if (type !== 'group') {
|
} else if (type !== 'group') {
|
||||||
console.log(setting)
|
|
||||||
widgetStore.addWidget(setting as Required<TPageState>)
|
widgetStore.addWidget(setting as Required<TPageState>)
|
||||||
// store.dispatch('addWidget', setting) // 正常加入面板
|
// store.dispatch('addWidget', setting) // 正常加入面板
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
* @Author: Jeremy Yu
|
* @Author: Jeremy Yu
|
||||||
* @Date: 2024-03-28 14:00:00
|
* @Date: 2024-03-28 14:00:00
|
||||||
* @Description:
|
* @Description:
|
||||||
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-03-28 14:00:00
|
* @LastEditTime: 2024-05-22 19:32:24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useCanvasStore, useHistoryStore } from "@/store"
|
import { useCanvasStore, useHistoryStore } from "@/store"
|
||||||
import { TWidgetStore, TdWidgetData } from ".."
|
import { TWidgetStore, TdWidgetData } from ".."
|
||||||
|
import { useWidgetStore } from "@/store"
|
||||||
import { customAlphabet } from 'nanoid/non-secure'
|
import { customAlphabet } from 'nanoid/non-secure'
|
||||||
const nanoid = customAlphabet('1234567890abcdef', 12)
|
const nanoid = customAlphabet('1234567890abcdef', 12)
|
||||||
|
|
||||||
@ -50,8 +51,7 @@ export function copyWidget(store: TWidgetStore) {
|
|||||||
|
|
||||||
/** 粘贴组件 */
|
/** 粘贴组件 */
|
||||||
export function pasteWidget(store: TWidgetStore) {
|
export function pasteWidget(store: TWidgetStore) {
|
||||||
const historyStore = useHistoryStore()
|
const widgetStore = useWidgetStore()
|
||||||
const canvasStore = useCanvasStore()
|
|
||||||
const copyElement: TdWidgetData[] = JSON.parse(JSON.stringify(store.dCopyElement))
|
const copyElement: TdWidgetData[] = JSON.parse(JSON.stringify(store.dCopyElement))
|
||||||
const container = copyElement.find((item) => item.isContainer)
|
const container = copyElement.find((item) => item.isContainer)
|
||||||
for (let i = 0; i < copyElement.length; ++i) {
|
for (let i = 0; i < copyElement.length; ++i) {
|
||||||
@ -63,19 +63,15 @@ export function pasteWidget(store: TWidgetStore) {
|
|||||||
}
|
}
|
||||||
copyElement[i].top += 30
|
copyElement[i].top += 30
|
||||||
copyElement[i].left += 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.dActiveElement = copyElement[0]
|
||||||
store.dSelectWidgets = copyElement
|
store.dSelectWidgets = copyElement
|
||||||
if (container) {
|
if (container) {
|
||||||
store.dActiveElement = container
|
store.dActiveElement = container
|
||||||
store.dSelectWidgets = []
|
store.dSelectWidgets = []
|
||||||
}
|
}
|
||||||
|
// 复制以调整下次粘贴的位置
|
||||||
historyStore.pushHistory("pasteWidget")
|
|
||||||
// store.dispatch('pushHistory', 'pasteWidget')
|
|
||||||
store.copyWidget()
|
store.copyWidget()
|
||||||
// store.dispatch('copyWidget')
|
|
||||||
canvasStore.reChangeCanvas()
|
|
||||||
// store.dispatch('reChangeCanvas')
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user