Browse Source

展示项目名称

master
修宁 6 months ago
parent
commit
ff820ba58c
  1. 6
      src/core/manager/WorldModel.ts
  2. 42
      src/editor/ModelMain.vue

6
src/core/manager/WorldModel.ts

@ -49,6 +49,7 @@ export default class WorldModel {
catalog: [] as Catalog, // 世界模型目录 catalog: [] as Catalog, // 世界模型目录
server: '', server: '',
project_uuid: '', // 项目ID project_uuid: '', // 项目ID
project_label: '', // 项目名称
catalogCode: '', // 当前楼层的目录代码 catalogCode: '', // 当前楼层的目录代码
stateManagerId: '', // 当前楼层的状态管理器id, 一般是 项目ID+目录项ID stateManagerId: '', // 当前楼层的状态管理器id, 一般是 项目ID+目录项ID
@ -59,7 +60,8 @@ export default class WorldModel {
isLoading: false, isLoading: false,
isRunning: false, isRunning: false,
isVirtual: false, isVirtual: false,
timeRate: 1 timeRate: 1,
currentEnv: null
} }
}) })
@ -177,6 +179,7 @@ export default class WorldModel {
this.state.catalog = catalog this.state.catalog = catalog
this.state.server = lccModelWorld.server this.state.server = lccModelWorld.server
this.state.project_uuid = lccModelWorld.projectUuid this.state.project_uuid = lccModelWorld.projectUuid
this.state.project_label = lccModelWorld.projectLabel
// 没有打开楼层,不加载 this.state.catalogCode // 没有打开楼层,不加载 this.state.catalogCode
this.state.isDraft = false this.state.isDraft = false
@ -216,4 +219,5 @@ export default class WorldModel {
} }
const worldModel = new WorldModel() const worldModel = new WorldModel()
window['worldModel'] = worldModel
export { worldModel } export { worldModel }

42
src/editor/ModelMain.vue

@ -8,11 +8,13 @@
>{{ rootMenu.label }} >{{ rootMenu.label }}
<component :is="renderIcon('element ArrowDown')"></component> <component :is="renderIcon('element ArrowDown')"></component>
</div> </div>
<div style="flex-grow: 1;"></div> <div style="flex-grow: 1;">
<span>{{ worldModelState.project_label }}</span>
</div>
<div v-if="isModelOpen" style="display: flex; flex-direction: row; align-items: center; margin-right: 10px;"> <div v-if="isModelOpen" style="display: flex; flex-direction: row; align-items: center; margin-right: 10px;">
<div class="field-block" style="margin-right: 5px;"> <div class="field-block" style="margin-right: 5px;">
<el-select style="width:180px;" placeholder="运行环境" <el-select style="width:180px;" placeholder="运行环境" :disabled="worldModelState.runState.currentEnvId && worldModelState.runState.isRunning"
v-model="worldModelState.runState.currentEnvId"> v-model="currentEnvId">
<el-option v-for="env in envList" :key="env.envId" :label="env.envName" :value="env.envId"></el-option> <el-option v-for="env in envList" :key="env.envId" :label="env.envName" :value="env.envId"></el-option>
<template #footer> <template #footer>
<el-button size="small" type="primary" @click="createEnv" plain>创建虚拟环境</el-button> <el-button size="small" type="primary" @click="createEnv" plain>创建虚拟环境</el-button>
@ -29,13 +31,13 @@
</el-select> </el-select>
</div> </div>
<el-button :icon="renderIcon('Play')" type="primary" <el-button :icon="renderIcon('Play')" type="primary"
v-if="!worldModelState.runState.isRunning" v-if="!worldModelState.runState.currentEnvId || !worldModelState.runState.isRunning"
:disabled="!worldModelState.runState.currentEnvId" :disabled="!worldModelState.runState.currentEnvId"
:loading="worldModelState.runState.isLoading" :loading="worldModelState.runState.isLoading"
@click="startEnv">启动服务 @click="startEnv">启动服务
</el-button> </el-button>
<el-button :icon="renderIcon('Stop')" type="danger" plain <el-button :icon="renderIcon('Stop')" type="danger" plain
v-if="worldModelState.runState.isRunning" v-if="worldModelState.runState.currentEnvId && worldModelState.runState.isRunning"
:loading="worldModelState.runState.isLoading" :loading="worldModelState.runState.isLoading"
@click="stopEnv">停止服务 @click="stopEnv">停止服务
</el-button> </el-button>
@ -229,7 +231,8 @@ export default {
sectionRightName: 'property', sectionRightName: 'property',
sectionBottomName: '', sectionBottomName: '',
sectionLeftSearch: '', sectionLeftSearch: '',
centerActiveName: 'ModelEditor' centerActiveName: 'ModelEditor',
currentEnvId: worldModel.state.runState.currentEnvId
} }
}, },
computed: { computed: {
@ -284,6 +287,33 @@ export default {
} }
} }
}, },
'currentEnvId': {
handler(newVal, originalVal) {
if (this.worldModelState.runState.currentEnvId && this.worldModelState.runState.isRunning) {
throw new Error('cannot change env when running')
this.currentEnvId = originalVal
} else {
// ID
const env = _.find(this.envList, env => env.envId === newVal)
if (!env) {
this.worldModelState.runState.currentEnvId = newVal
this.worldModelState.runState.isLoading = false
this.worldModelState.runState.isRunning = false
this.worldModelState.runState.isVirtual = false
this.worldModelState.runState.timeRate = 0
this.worldModelState.runState.currentEnv = null
} else {
this.worldModelState.runState.currentEnvId = newVal
this.worldModelState.runState.isLoading = false
this.worldModelState.runState.isRunning = false
this.worldModelState.runState.isVirtual = env.isVirtual
this.worldModelState.runState.timeRate = 1
this.worldModelState.runState.currentEnv = env
}
}
}
},
hideBottom(value) { hideBottom(value) {
if (value) { if (value) {
this.$refs.mainSplit.refreshSize([100, 0]) this.$refs.mainSplit.refreshSize([100, 0])

Loading…
Cancel
Save