|
|
@@ -0,0 +1,86 @@
|
|
|
+<template>
|
|
|
+ <div :style="styleMap?.mainStyle" class="flex overflow-hidden box-border">
|
|
|
+ <div
|
|
|
+ class="shrink-0 box-border"
|
|
|
+ :class="expand ? 'flex-1! border-r-none!' : 'basis-1/3'"
|
|
|
+ style="border-right: solid 1px #ededed"
|
|
|
+ >
|
|
|
+ <div :style="styleMap?.menuTitleStyle">{{ title }}</div>
|
|
|
+ <div :style="styleMap?.buttonBoxStyle" class="box-border overflow-hidden">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in children || []"
|
|
|
+ :key="index"
|
|
|
+ :style="activeIndex === index ? activeStyle : styleMap?.itemsStyle"
|
|
|
+ class="min-h-30px grid place-items-center overflow-hidden"
|
|
|
+ >
|
|
|
+ {{ item.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="!expand" class="basis-2/3"></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { computed, type CSSProperties } from 'vue'
|
|
|
+import { useWidgetStyle, getStyle } from '../hooks/useWidgetStyle'
|
|
|
+import { useProjectStore } from '@/store/modules/project'
|
|
|
+import defaultStyle from './style.json'
|
|
|
+
|
|
|
+const props = defineProps<{
|
|
|
+ width: number
|
|
|
+ height: number
|
|
|
+ styles: any
|
|
|
+ state: string
|
|
|
+ part: string
|
|
|
+ scrollbar: string
|
|
|
+ title: string
|
|
|
+ // 折叠展开
|
|
|
+ expand: boolean
|
|
|
+ // 子项
|
|
|
+ children?: any[]
|
|
|
+ // 当前激活index
|
|
|
+ activeIndex: number
|
|
|
+}>()
|
|
|
+
|
|
|
+const styleMap = useWidgetStyle({
|
|
|
+ widget: 'lv_menu',
|
|
|
+ props
|
|
|
+})
|
|
|
+
|
|
|
+const projectStore = useProjectStore()
|
|
|
+
|
|
|
+// 激活样式
|
|
|
+const activeStyle = computed(() => {
|
|
|
+ const styles = props.styles
|
|
|
+
|
|
|
+ const itemStyle = styles.find(
|
|
|
+ (item) => item?.part?.name === 'items' && item.part?.state === 'checked'
|
|
|
+ )
|
|
|
+
|
|
|
+ const globalItemStyle = projectStore.globalStyle
|
|
|
+ ?.find((item) => item.widget === 'lv_menu')
|
|
|
+ ?.part?.find((item) => item.partName === 'items')
|
|
|
+ ?.state?.find((item) => item.state === 'checked')?.style
|
|
|
+
|
|
|
+ const defaultItemStyle = defaultStyle.part
|
|
|
+ .find((item) => item.partName === 'items')
|
|
|
+ ?.state.find((item) => item.state === 'checked')?.style
|
|
|
+
|
|
|
+ const style = itemStyle || globalItemStyle || defaultItemStyle
|
|
|
+
|
|
|
+ let styleMap: CSSProperties = {}
|
|
|
+
|
|
|
+ Object.keys(style || {}).forEach((key) => {
|
|
|
+ // 合并样式
|
|
|
+ styleMap = {
|
|
|
+ ...styleMap,
|
|
|
+ ...getStyle(key, style?.[key])
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return styleMap
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped></style>
|