Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 11 additions & 4 deletions packages/common/component/PluginPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<slot name="content"></slot>
</div>

<div class="resizer-right" @mousedown="onMouseDownRight"></div>
<div class="resizer-left" @mousedown="onMouseDownLeft"></div>
<div class="resizer-right" v-if="isLeftResizer" @mousedown="onMouseDownRight"></div>
<div class="resizer-left" v-if="isRightResizer" @mousedown="onMouseDownLeft"></div>
</div>
</template>

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -153,7 +158,9 @@ export default {
panel,
panelWidth,
onMouseDownRight,
onMouseDownLeft
onMouseDownLeft,
isLeftResizer,
isRightResizer
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/controller/src/useLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ export default () => {
}
const pluginStorageReactive = useStorage('plugin', plugin)

//获取插件宽度
Comment thread
STATICHIT marked this conversation as resolved.
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') => {
Expand Down Expand Up @@ -217,6 +221,7 @@ export default () => {
changeLeftFixedPanels,
changeRightFixedPanels,
getPluginsByLayout,
changePluginLayout
changePluginLayout,
getPluginByLayout
}
}
12 changes: 0 additions & 12 deletions packages/design-core/config/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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