auto-save 2026-05-27 15:26 (~3)
This commit is contained in:
@@ -36,6 +36,32 @@ let isRestoring = false
|
||||
// Position change threshold for history | 位置变化阈值
|
||||
const POSITION_THRESHOLD = 10
|
||||
|
||||
const DEFAULT_NODE_DIMENSIONS = {
|
||||
text: { width: 320, height: 220 },
|
||||
image: { width: 320, height: 260 },
|
||||
imageConfig: { width: 320, height: 280 },
|
||||
video: { width: 320, height: 220 },
|
||||
videoConfig: { width: 320, height: 260 },
|
||||
llmConfig: { width: 360, height: 360 },
|
||||
default: { width: 320, height: 240 }
|
||||
}
|
||||
|
||||
const normalizeDimensions = (type, dimensions = {}) => {
|
||||
const fallback = DEFAULT_NODE_DIMENSIONS[type] || DEFAULT_NODE_DIMENSIONS.default
|
||||
const width = Number(dimensions.width)
|
||||
const height = Number(dimensions.height)
|
||||
|
||||
return {
|
||||
width: Number.isFinite(width) && width > 0 ? width : fallback.width,
|
||||
height: Number.isFinite(height) && height > 0 ? height : fallback.height
|
||||
}
|
||||
}
|
||||
|
||||
const normalizeNodeForCanvas = (node) => ({
|
||||
...node,
|
||||
dimensions: normalizeDimensions(node.type, node.dimensions)
|
||||
})
|
||||
|
||||
// Batch operation tracking | 批量操作跟踪
|
||||
let isBatchOperation = false
|
||||
let batchStartState = null
|
||||
@@ -167,12 +193,14 @@ const checkSignificantChanges = (oldState, newState) => {
|
||||
|
||||
const createNode = (type, position, data = {}, rootProps = {}, now = Date.now()) => {
|
||||
const id = getNodeId()
|
||||
const { dimensions, ...nodeRootProps } = rootProps
|
||||
|
||||
return {
|
||||
id,
|
||||
type,
|
||||
position,
|
||||
...rootProps,
|
||||
...nodeRootProps,
|
||||
dimensions: normalizeDimensions(type, dimensions),
|
||||
data: {
|
||||
...getDefaultNodeData(type),
|
||||
...data,
|
||||
@@ -416,7 +444,7 @@ export const loadProject = (projectId) => {
|
||||
|
||||
if (canvasData) {
|
||||
// Restore nodes | 恢复节点
|
||||
nodes.value = canvasData.nodes || []
|
||||
nodes.value = (canvasData.nodes || []).map(normalizeNodeForCanvas)
|
||||
edges.value = canvasData.edges || []
|
||||
canvasViewport.value = canvasData.viewport || { x: 100, y: 50, zoom: 0.8 }
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
:max-zoom="2"
|
||||
:snap-to-grid="true"
|
||||
:snap-grid="[20, 20]"
|
||||
:only-render-visible-elements="true"
|
||||
@connect="onConnect"
|
||||
@node-click="onNodeClick"
|
||||
@pane-click="onPaneClick"
|
||||
@@ -61,7 +62,7 @@
|
||||
>
|
||||
<Background v-if="showGrid" :gap="20" :size="1" />
|
||||
<MiniMap
|
||||
v-if="!isMobile"
|
||||
v-if="showMiniMap"
|
||||
position="bottom-right"
|
||||
:pannable="true"
|
||||
:zoomable="true"
|
||||
@@ -473,6 +474,7 @@ const inputPlaceholder = '你可以试着说"帮我生成一个二次元的卡
|
||||
// Quick suggestions | 快捷建议
|
||||
const suggestionPage = ref(0)
|
||||
const suggestions = computed(() => QUICK_SUGGESTION_GROUPS[suggestionPage.value % QUICK_SUGGESTION_GROUPS.length])
|
||||
const showMiniMap = computed(() => !isMobile.value && nodes.value.length <= 120)
|
||||
|
||||
const refreshSuggestions = () => {
|
||||
suggestionPage.value = (suggestionPage.value + 1) % QUICK_SUGGESTION_GROUPS.length
|
||||
|
||||
Reference in New Issue
Block a user