Browse Source

菜单定义,widgetview 挂件视图定义

master
修宁 7 months ago
parent
commit
c1bfcea362
  1. 8
      src/runtime/DefineWidget.ts
  2. 86
      src/views/ModelMain.vue

8
src/runtime/DefineWidget.ts

@ -1,4 +1,4 @@
import type { Component } from 'vue' import { type Component, markRaw } from 'vue'
export type WidgetSide = 'left' | 'right' | 'bottom' export type WidgetSide = 'left' | 'right' | 'bottom'
@ -31,7 +31,7 @@ export class WidgetInfo {
console.log(`Widget ${this.option.name} already exists`) console.log(`Widget ${this.option.name} already exists`)
return return
} }
_widgetMap.set(this.option.name, this.option) _widgetMap.set(this.option.name, markRaw(this.option))
} }
} }
@ -44,6 +44,10 @@ export function getWidgetBySide(side: WidgetSide): WidgetOption[] {
.sort((a, b) => (a.order || 0) - (b.order || 0)) .sort((a, b) => (a.order || 0) - (b.order || 0))
} }
export function getWidgetByName(name: string): WidgetOption | undefined {
return _widgetMap.get(name)
}
/** /**
* Widget * Widget
*/ */

86
src/views/ModelMain.vue

@ -5,7 +5,8 @@
<div class="app-header-menu-wrap"> <div class="app-header-menu-wrap">
<div class="app-header-menu" v-for="rootMenu in calcRootMenu" @click="clickRootMenu" <div class="app-header-menu" v-for="rootMenu in calcRootMenu" @click="clickRootMenu"
v-menus:left="rootMenu.children" v-menus:left="rootMenu.children"
>{{ rootMenu.label }} <component :is="renderIcon('element ArrowDown')"></component> >{{ rootMenu.label }}
<component :is="renderIcon('element ArrowDown')"></component>
</div> </div>
</div> </div>
<div class="user"> <div class="user">
@ -17,14 +18,28 @@
<div class="app-section"> <div class="app-section">
<div class="btns-toolbar btns-toolbar-left"> <div class="btns-toolbar btns-toolbar-left">
<div class="btns btns-top"> <div class="btns btns-top">
<template v-for="panel in getWidgetBySide('left')">
<div class="item" :class="{selected:sectionLeftTitle===panel.name}" @click="btnLeftMe(panel)">
{{ panel.title }}
</div>
</template>
<!--
<div :class="['item',sectionLeftTitle==='模型'?'selected':'']" @click="btnLeftMe('模型')">模型</div> <div :class="['item',sectionLeftTitle==='模型'?'selected':'']" @click="btnLeftMe('模型')">模型</div>
<div :class="['item',sectionLeftTitle==='监控'?'selected':'']" @click="btnLeftMe('监控')">监控</div> <div :class="['item',sectionLeftTitle==='监控'?'selected':'']" @click="btnLeftMe('监控')">监控</div>
<div :class="['item',sectionLeftTitle==='对象'?'selected':'']" @click="btnLeftMe('对象')">对象</div> <div :class="['item',sectionLeftTitle==='对象'?'selected':'']" @click="btnLeftMe('对象')">对象</div>
-->
</div> </div>
<div class="btns btns-bottom"> <div class="btns btns-bottom">
<template v-for="panel in getWidgetBySide('bottom')">
<div class="item" :class="{selected:sectionBottomTitle===panel.name}" @click="btnBottomMe(panel)">
{{ panel.title }}
</div>
</template>
<!--
<div :class="['item',sectionBottomTitle==='任务'?'selected':'']" @click="btnBottomMe('任务')">任务</div> <div :class="['item',sectionBottomTitle==='任务'?'selected':'']" @click="btnBottomMe('任务')">任务</div>
<div :class="['item',sectionBottomTitle==='日志'?'selected':'']" @click="btnBottomMe('日志')">日志</div> <div :class="['item',sectionBottomTitle==='日志'?'selected':'']" @click="btnBottomMe('日志')">日志</div>
<div :class="['item',sectionBottomTitle==='脚本'?'selected':'']" @click="btnBottomMe('脚本')">脚本</div> <div :class="['item',sectionBottomTitle==='脚本'?'selected':'']" @click="btnBottomMe('脚本')">脚本</div>
-->
</div> </div>
</div> </div>
<Split class="section" :direction="'vertical'" style="flex-shrink: 0;flex-grow:1;" ref="mainSplit"> <Split class="section" :direction="'vertical'" style="flex-shrink: 0;flex-grow:1;" ref="mainSplit">
@ -34,8 +49,9 @@
<SplitArea v-show="!hideLeft" class="section-left" :class="{'hidden-split':hideLeft}" <SplitArea v-show="!hideLeft" class="section-left" :class="{'hidden-split':hideLeft}"
:size="hideLeft ? 0 : sectionLeftSize"> :size="hideLeft ? 0 : sectionLeftSize">
<div class="section-item-wrap"> <div class="section-item-wrap">
<div class="title">{{ sectionLeftTitle }}</div> <div class="title">{{ calcLeftPanel?.title }}</div>
</div> </div>
<component :is="calcLeftPanel.component" />
</SplitArea> </SplitArea>
<SplitArea class="section-center" :class="{'hidden-split':hideRight}" :size="calcCenterSize"> <SplitArea class="section-center" :class="{'hidden-split':hideRight}" :size="calcCenterSize">
<el-tabs type="card" class="section-tabs"> <el-tabs type="card" class="section-tabs">
@ -85,44 +101,51 @@
</SplitArea> </SplitArea>
<SplitArea v-show="!hideRight" class="section-right" :size="hideRight ? 0 : sectionRightSize"> <SplitArea v-show="!hideRight" class="section-right" :size="hideRight ? 0 : sectionRightSize">
<div class="section-item-wrap"> <div class="section-item-wrap">
<div class="title">{{ sectionRightTitle }}</div> <div class="title">{{ calcRightPanel?.title }}</div>
</div> </div>
<component :is="calcRightPanel.component" />
</SplitArea> </SplitArea>
</Split> </Split>
</SplitArea> </SplitArea>
<SplitArea v-show="!hideBottom" :class="['section-bottom']" :size="hideBottom ? 0 : bottomSize" :min-size="0"> <SplitArea v-show="!hideBottom" :class="['section-bottom']" :size="hideBottom ? 0 : bottomSize" :min-size="0">
<div class="section-item-wrap"> <div class="section-item-wrap">
<div class="title">{{ sectionBottomTitle }}</div> <div class="title">{{ calcBottomPanel?.title }}</div>
</div> </div>
<component :is="calcBottomPanel.component" />
</SplitArea> </SplitArea>
</Split> </Split>
<div class="btns-toolbar btns-toolbar-right"> <div class="btns-toolbar btns-toolbar-right">
<div class="btns btns-top"> <div class="btns btns-top">
<template v-for="panel in getWidgetBySide('right')">
<div class="item" :class="{selected:sectionRightTitle===panel.name}" @click="btnRightMe(panel)">
{{ panel.title }}
</div>
</template>
<!--
<div :class="['item',sectionRightTitle==='属性'?'selected':'']" @click="btnRightMe('属性')">属性</div> <div :class="['item',sectionRightTitle==='属性'?'selected':'']" @click="btnRightMe('属性')">属性</div>
<div :class="['item',sectionRightTitle==='数据'?'selected':'']" @click="btnRightMe('数据')">数据</div> <div :class="['item',sectionRightTitle==='数据'?'selected':'']" @click="btnRightMe('数据')">数据</div>
<div :class="['item',sectionRightTitle==='警告'?'selected':'']" @click="btnRightMe('警告')">警告</div> <div :class="['item',sectionRightTitle==='警告'?'selected':'']" @click="btnRightMe('警告')">警告</div>
-->
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { renderIcon } from '@/utils/webutils.js'
import Split from '@/components/split/split.vue' import Split from '@/components/split/split.vue'
import SplitArea from '@/components/split/split-area.vue' import SplitArea from '@/components/split/split-area.vue'
import { renderIcon } from '@/utils/webutils.js'
import Logo from '@/assets/images/logo.png' import Logo from '@/assets/images/logo.png'
import './ModelMain.less' import './ModelMain.less'
import ModelMainInit from '@/views/ModelMainInit.js' import ModelMainInit from '@/views/ModelMainInit.js'
import { getRootMenu } from '@/runtime/DefineMenu.js' import { getRootMenu } from '@/runtime/DefineMenu.js'
import { getWidgetByName, getWidgetBySide } from '@/runtime/DefineWidget.js'
ModelMainInit() ModelMainInit()
export default { export default {
components: { components: { Split, SplitArea },
Split,
SplitArea
},
mounted() { mounted() {
}, },
data() { data() {
@ -131,17 +154,35 @@ export default {
calcRootMenu: getRootMenu(), calcRootMenu: getRootMenu(),
activeIndex: '', activeIndex: '',
bottomSize: 30, bottomSize: 30,
hideBottom: false, hideBottom: true,
hideLeft: false, hideLeft: false,
hideRight: false, hideRight: false,
sectionLeftSize: 20, sectionLeftSize: 20,
sectionRightSize: 20, sectionRightSize: 20,
sectionLeftTitle: '模型', sectionLeftTitle: 'modeltree',
sectionRightTitle: '属性', sectionRightTitle: 'property',
sectionBottomTitle: '任务' sectionBottomTitle: ''
} }
}, },
computed: { computed: {
calcLeftPanel() {
if (!this.sectionLeftTitle || this.hideLeft) {
return undefined
}
return getWidgetByName(this.sectionLeftTitle)
},
calcRightPanel() {
if (!this.sectionRightTitle || this.hideRight) {
return undefined
}
return getWidgetByName(this.sectionRightTitle)
},
calcBottomPanel() {
if (!this.sectionBottomTitle || this.hideBottom) {
return undefined
}
return getWidgetByName(this.sectionBottomTitle)
},
calcCenterSize() { calcCenterSize() {
if (this.hideLeft && this.hideRight) { if (this.hideLeft && this.hideRight) {
return 100 return 100
@ -170,6 +211,7 @@ export default {
}, },
methods: { methods: {
renderIcon, renderIcon,
getWidgetBySide,
recalcCenterSize() { recalcCenterSize() {
if (this.hideLeft && this.hideRight) { if (this.hideLeft && this.hideRight) {
this.$refs.centerSplit.refreshSize([0, 100, 0]) this.$refs.centerSplit.refreshSize([0, 100, 0])
@ -190,34 +232,34 @@ export default {
handleSelect() { handleSelect() {
}, },
btnLeftMe(name) { btnLeftMe(panel) {
if (this.sectionLeftTitle === name) { if (this.sectionLeftTitle === panel.name) {
this.hideLeft = true this.hideLeft = true
this.sectionLeftTitle = '' this.sectionLeftTitle = ''
} else { } else {
this.hideLeft = false this.hideLeft = false
this.sectionLeftTitle = name this.sectionLeftTitle = panel.name
} }
}, },
btnRightMe(name) { btnRightMe(panel) {
if (this.sectionRightTitle === name) { if (this.sectionRightTitle === panel.name) {
this.hideRight = true this.hideRight = true
this.sectionRightTitle = '' this.sectionRightTitle = ''
} else { } else {
this.hideRight = false this.hideRight = false
this.sectionRightTitle = name this.sectionRightTitle = panel.name
} }
}, },
btnBottomMe(name) { btnBottomMe(panel) {
if (this.sectionBottomTitle === name) { if (this.sectionBottomTitle === panel.name) {
this.hideBottom = true this.hideBottom = true
this.sectionBottomTitle = '' this.sectionBottomTitle = ''
} else { } else {
this.hideBottom = false this.hideBottom = false
this.sectionBottomTitle = name this.sectionBottomTitle = panel.name
} }
} }
} }

Loading…
Cancel
Save