From d91340062866ccadd88a01af131006690a465181 Mon Sep 17 00:00:00 2001
From: STATICHIT <2394412110@qq.com>
Date: Sat, 31 Aug 2024 00:55:57 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9ADrag=20Handle=20Check?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/common/component/PluginPanel.vue | 15 +++++++++++----
packages/controller/src/useLayout.js | 7 ++++++-
packages/design-core/config/addons.js | 12 ------------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/packages/common/component/PluginPanel.vue b/packages/common/component/PluginPanel.vue
index c1793be131..871f29dd8d 100644
--- a/packages/common/component/PluginPanel.vue
+++ b/packages/common/component/PluginPanel.vue
@@ -21,8 +21,8 @@
-
-
+
+
@@ -70,7 +70,7 @@ export default {
},
emits: ['close'],
setup(props, { emit }) {
- const { getPluginWidth, changePluginWidth } = useLayout()
+ const { getPluginWidth, changePluginWidth, getPluginByLayout } = useLayout()
const panelState = inject('panelState')
const closePanel = () => {
useLayout().closePlugin()
@@ -108,6 +108,11 @@ export default {
let startX = 0
let startWidth = 0
+ //滚动条位置
+ const align = ref(getPluginByLayout(props.fixedName))
+ const isLeftResizer = ref(align.value.includes('left'))
+ const isRightResizer = ref(align.value.includes('right'))
+
const onMouseMoveRight = (event) => {
const newWidth = startWidth + (event.clientX - startX)
panelWidth.value = Math.max(MIN_WIDTH, Math.min(newWidth, MAX_WIDTH))
@@ -153,7 +158,9 @@ export default {
panel,
panelWidth,
onMouseDownRight,
- onMouseDownLeft
+ onMouseDownLeft,
+ isLeftResizer,
+ isRightResizer
}
}
}
diff --git a/packages/controller/src/useLayout.js b/packages/controller/src/useLayout.js
index 0c0e47cfd7..fa08c375f5 100644
--- a/packages/controller/src/useLayout.js
+++ b/packages/controller/src/useLayout.js
@@ -170,13 +170,17 @@ export default () => {
}
const pluginStorageReactive = useStorage('plugin', plugin)
+ //获取插件宽度
const getPluginWidth = (name) => pluginStorageReactive.value[name]?.width || 300
+ //修改插件宽度
const changePluginWidth = (name, width) => {
if (Object.prototype.hasOwnProperty.call(pluginStorageReactive.value, name)) {
pluginStorageReactive.value[name].width = width
}
}
+ //获取插件布局
+ const getPluginByLayout = (name) => pluginStorageReactive.value[name]?.align || 'leftTop'
//获取某个布局(左上/左下/右上)的插件名称列表
const getPluginsByLayout = (layout = 'all') => {
@@ -217,6 +221,7 @@ export default () => {
changeLeftFixedPanels,
changeRightFixedPanels,
getPluginsByLayout,
- changePluginLayout
+ changePluginLayout,
+ getPluginByLayout
}
}
diff --git a/packages/design-core/config/addons.js b/packages/design-core/config/addons.js
index aa37eedcdd..f659b40737 100644
--- a/packages/design-core/config/addons.js
+++ b/packages/design-core/config/addons.js
@@ -65,16 +65,4 @@ const addons = {
settings: [Props, Styles, Events]
}
-const plugin = {}
-addons.plugins.forEach((item) => {
- plugin[item.id] = item
-})
-addons.settings.forEach((item) => {
- plugin[item.id] = item
-})
-
-export const getPlugin = (pluginName) => {
- return plugin[pluginName] || null
-}
-
export default addons