Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize:Cj subsequent optimization #842

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/common/component/PluginPanel.vue
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
},
emits: ['close'],
setup(props, { emit }) {
const { getPluginWidth, changePluginWidth, getPluginByLayout } = useLayout()
const { getPluginWidth, changePluginWidth, getPluginByLayout, changeMoveDragBarState } = useLayout()
const panelState = inject('panelState')
const closePanel = () => {
useLayout().closePlugin()
Expand Down Expand Up @@ -129,23 +129,27 @@ export default {
const throttledMouseMoveLeft = throttle(onMouseMoveLeft, 50)
const onMouseUpRight = () => {
changeMoveDragBarState(false)
document.removeEventListener('mousemove', throttledMouseMoveRight)
document.removeEventListener('mouseup', onMouseUpRight)
}
const onMouseUpLeft = () => {
changeMoveDragBarState(false)
document.removeEventListener('mousemove', throttledMouseMoveLeft)
document.removeEventListener('mouseup', onMouseUpLeft)
}
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
const onMouseDownRight = (event) => {
changeMoveDragBarState(true)
startX = event.clientX
startWidth = panel.value.offsetWidth
document.addEventListener('mousemove', throttledMouseMoveRight)
document.addEventListener('mouseup', onMouseUpRight)
}
const onMouseDownLeft = (event) => {
changeMoveDragBarState(true)
startX = event.clientX
startWidth = panel.value.offsetWidth
document.addEventListener('mousemove', throttledMouseMoveLeft)
Expand Down
11 changes: 10 additions & 1 deletion packages/controller/src/useLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const pluginState = reactive({
})

const layoutState = reactive({
isMoveDragBar: false,
deviceType: 'desktop',
iframeWidth: '1200px',
dimension: {
Expand Down Expand Up @@ -82,6 +83,12 @@ const layoutState = reactive({
},
pageStatus: ''
})
const getMoveDragBarState = () => {
return layoutState.isMoveDragBar
}
const changeMoveDragBarState = (state) => {
layoutState.isMoveDragBar = state
}
const leftMenuShownStorage = useStorage('leftMenuShown', layoutState.plugins.isShow)
const rightMenuShownStorage = useStorage('rightMenuShown', layoutState.settings.isShow)
const changeMenuShown = (menuName) => {
Expand Down Expand Up @@ -312,6 +319,8 @@ export default () => {
isSameSide,
getPluginShown,
changePluginShown,
changeMenuShown
changeMenuShown,
getMoveDragBarState,
changeMoveDragBarState
}
}
27 changes: 21 additions & 6 deletions packages/design-core/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<div id="canvas-wrap" ref="canvasRef">
<div ref="siteCanvas" class="site-canvas" :style="siteCanvasStyle">
<div
ref="siteCanvas"
class="site-canvas"
:style="siteCanvasStyle"
:class="{ 'not-selected': getMoveDragBarState() }"
>
<canvas-container
:controller="controller"
:materials-panel="materialsPanel"
Expand Down Expand Up @@ -52,6 +57,7 @@ export default {
const showMask = ref(true)
const canvasRef = ref(null)
let showModal = false // 弹窗标识
const { getMoveDragBarState } = useLayout()

const removeNode = (node) => {
const { pageState } = useCanvas()
Expand Down Expand Up @@ -129,11 +135,15 @@ export default {
)

const nodeSelected = (node, parent, type) => {
const { toolbars } = useLayout().layoutState
if (type !== 'clickTree') {
useLayout().closePlugin()
const { toolbars, plugins, settings } = useLayout().layoutState
const leftPanels = localStorage.getItem('leftPanels')
const rightPanels = localStorage.getItem('rightPanels')
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
if (type !== 'clickTree' && plugins.render && !leftPanels.includes(plugins.render)) {
useLayout().closePlugin(true)
}
if (settings.render && !rightPanels.includes(settings.render)) {
useLayout().closeSetting(true)
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
}

const { getSchema, getNodePath } = useCanvas().canvasApi.value

const schema = getSchema()
Expand Down Expand Up @@ -189,7 +199,8 @@ export default {
ast
},
siteCanvasStyle,
canvasRef
canvasRef,
getMoveDragBarState
}
}
}
Expand All @@ -212,4 +223,8 @@ export default {
transform-origin: top;
}
}
.not-selected {
pointer-events: none;
user-select: none;
}
</style>
12 changes: 9 additions & 3 deletions packages/design-core/src/DesignPlugins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</div>
</div>

<div>
<div :class="{ 'not-selected': getMoveDragBarState() }">
<!-- 插件面板 -->
<div
v-show="renderPanel && components[renderPanel]"
Expand Down Expand Up @@ -166,6 +166,7 @@ export default {
},
emits: ['click', 'node-click', 'changeLeftAlign'],
setup(props, { emit }) {
// TODO:后续优化
const components = {}
const iconComponents = {}
const pluginRef = ref(null)
Expand All @@ -184,7 +185,8 @@ export default {
dragPluginLayout,
isSameSide,
getPluginShown,
closePlugin
closePlugin,
getMoveDragBarState
} = useLayout()

const rightMenu = ref(null)
Expand Down Expand Up @@ -310,7 +312,8 @@ export default {
PLUGIN_POSITION,
getPluginShown,
switchAlign,
rightMenu
rightMenu,
getMoveDragBarState
}
}
}
Expand Down Expand Up @@ -453,4 +456,7 @@ export default {
:deep(.svg-icon.icon-plugin-icon-plugin-help) {
font-size: 22px;
}
.not-selected {
user-select: none;
}
STATICHIT marked this conversation as resolved.
Show resolved Hide resolved
</style>
6 changes: 4 additions & 2 deletions packages/design-core/src/DesignSettings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- 右侧插件栏-->
<template>
<!-- 插件面板 -->
<div>
<div :class="{ 'not-selected': getMoveDragBarState() }">
<div
v-show="renderPanel && components[renderPanel]"
id="tiny-engine-right-panel"
Expand Down Expand Up @@ -83,6 +83,7 @@ export default {
dragPluginLayout,
isSameSide,
getPluginShown,
getMoveDragBarState,
layoutState: { settings: settingsState }
} = useLayout()

Expand Down Expand Up @@ -172,7 +173,8 @@ export default {
PLUGIN_POSITION,
getPluginShown,
switchAlign,
rightMenu
rightMenu,
getMoveDragBarState
}
}
}
Expand Down