mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 多选工具栏显示逻辑优化
This commit is contained in:
parent
db4a16f50e
commit
3c8e7759e8
@ -5,5 +5,6 @@ export const enum ToolbarStates {
|
||||
EL_POSITION = 'elPosition',
|
||||
SLIDE_DESIGN = 'slideDesign',
|
||||
SLIDE_ANIMATION = 'slideAnimation',
|
||||
MULTI_STYLE = 'multiStyle',
|
||||
MULTI_POSITION = 'multiPosition',
|
||||
}
|
@ -19,7 +19,6 @@ import TableStylePanel from './TableStylePanel.vue'
|
||||
import LatexStylePanel from './LatexStylePanel.vue'
|
||||
import VideoStylePanel from './VideoStylePanel.vue'
|
||||
import AudioStylePanel from './AudioStylePanel.vue'
|
||||
import MultiStylePanel from './MultiStylePanel.vue'
|
||||
|
||||
const panelMap = {
|
||||
[ElementTypes.TEXT]: TextStylePanel,
|
||||
@ -33,16 +32,9 @@ const panelMap = {
|
||||
[ElementTypes.AUDIO]: AudioStylePanel,
|
||||
}
|
||||
|
||||
const { activeElementIdList, activeElementList, handleElement, activeGroupElementId } = storeToRefs(useMainStore())
|
||||
const { handleElement } = storeToRefs(useMainStore())
|
||||
|
||||
const currentPanelComponent = computed<unknown>(() => {
|
||||
if (activeElementIdList.value.length > 1) {
|
||||
if (!activeGroupElementId.value) return MultiStylePanel
|
||||
|
||||
const activeGroupElement = activeElementList.value.find(item => item.id === activeGroupElementId.value)
|
||||
return activeGroupElement ? (panelMap[activeGroupElement.type] || null) : null
|
||||
}
|
||||
|
||||
return handleElement.value ? (panelMap[handleElement.value.type] || null) : null
|
||||
})
|
||||
</script>
|
@ -139,7 +139,7 @@ import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||
import { FONTS } from '@/configs/font'
|
||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||
|
||||
import SVGLine from '../common/SVGLine.vue'
|
||||
import SVGLine from './common/SVGLine.vue'
|
||||
import ColorButton from '@/components/ColorButton.vue'
|
||||
import TextColorButton from '@/components/TextColorButton.vue'
|
||||
import ColorPicker from '@/components/ColorPicker/index.vue'
|
@ -24,6 +24,7 @@ import ElementAnimationPanel from './ElementAnimationPanel.vue'
|
||||
import SlideDesignPanel from './SlideDesignPanel.vue'
|
||||
import SlideAnimationPanel from './SlideAnimationPanel.vue'
|
||||
import MultiPositionPanel from './MultiPositionPanel.vue'
|
||||
import MultiStylePanel from './MultiStylePanel.vue'
|
||||
import SymbolPanel from './SymbolPanel.vue'
|
||||
import Tabs from '@/components/Tabs.vue'
|
||||
|
||||
@ -33,7 +34,7 @@ interface ElementTabs {
|
||||
}
|
||||
|
||||
const mainStore = useMainStore()
|
||||
const { activeElementIdList, handleElement, toolbarState } = storeToRefs(mainStore)
|
||||
const { activeElementIdList, activeElementList, activeGroupElementId, handleElement, toolbarState } = storeToRefs(mainStore)
|
||||
|
||||
const elementTabs = computed<ElementTabs[]>(() => {
|
||||
if (handleElement.value?.type === 'text') {
|
||||
@ -56,8 +57,8 @@ const slideTabs = [
|
||||
{ label: '动画', key: ToolbarStates.EL_ANIMATION },
|
||||
]
|
||||
const multiSelectTabs = [
|
||||
{ label: '样式', key: ToolbarStates.EL_STYLE },
|
||||
{ label: '位置', key: ToolbarStates.MULTI_POSITION },
|
||||
{ label: '样式(多选)', key: ToolbarStates.MULTI_STYLE },
|
||||
{ label: '位置(多选)', key: ToolbarStates.MULTI_POSITION },
|
||||
]
|
||||
|
||||
const setToolbarState = (value: ToolbarStates) => {
|
||||
@ -66,7 +67,13 @@ const setToolbarState = (value: ToolbarStates) => {
|
||||
|
||||
const currentTabs = computed(() => {
|
||||
if (!activeElementIdList.value.length) return slideTabs
|
||||
else if (activeElementIdList.value.length > 1) return multiSelectTabs
|
||||
else if (activeElementIdList.value.length > 1) {
|
||||
if (!activeGroupElementId.value) return multiSelectTabs
|
||||
|
||||
const activeGroupElement = activeElementList.value.find(item => item.id === activeGroupElementId.value)
|
||||
if (activeGroupElement) return elementTabs.value
|
||||
return multiSelectTabs
|
||||
}
|
||||
return elementTabs.value
|
||||
})
|
||||
|
||||
@ -84,6 +91,7 @@ const currentPanelComponent = computed(() => {
|
||||
[ToolbarStates.EL_ANIMATION]: ElementAnimationPanel,
|
||||
[ToolbarStates.SLIDE_DESIGN]: SlideDesignPanel,
|
||||
[ToolbarStates.SLIDE_ANIMATION]: SlideAnimationPanel,
|
||||
[ToolbarStates.MULTI_STYLE]: MultiStylePanel,
|
||||
[ToolbarStates.MULTI_POSITION]: MultiPositionPanel,
|
||||
[ToolbarStates.SYMBOL]: SymbolPanel,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user