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

42
src/editor/ModelMain.vue

@ -8,11 +8,13 @@
>{{ rootMenu.label }}
<component :is="renderIcon('element ArrowDown')"></component>
</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 class="field-block" style="margin-right: 5px;">
<el-select style="width:180px;" placeholder="运行环境"
v-model="worldModelState.runState.currentEnvId">
<el-select style="width:180px;" placeholder="运行环境" :disabled="worldModelState.runState.currentEnvId && worldModelState.runState.isRunning"
v-model="currentEnvId">
<el-option v-for="env in envList" :key="env.envId" :label="env.envName" :value="env.envId"></el-option>
<template #footer>
<el-button size="small" type="primary" @click="createEnv" plain>创建虚拟环境</el-button>
@ -29,13 +31,13 @@
</el-select>
</div>
<el-button :icon="renderIcon('Play')" type="primary"
v-if="!worldModelState.runState.isRunning"
v-if="!worldModelState.runState.currentEnvId || !worldModelState.runState.isRunning"
:disabled="!worldModelState.runState.currentEnvId"
:loading="worldModelState.runState.isLoading"
@click="startEnv">启动服务
</el-button>
<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"
@click="stopEnv">停止服务
</el-button>
@ -229,7 +231,8 @@ export default {
sectionRightName: 'property',
sectionBottomName: '',
sectionLeftSearch: '',
centerActiveName: 'ModelEditor'
centerActiveName: 'ModelEditor',
currentEnvId: worldModel.state.runState.currentEnvId
}
},
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) {
if (value) {
this.$refs.mainSplit.refreshSize([100, 0])

Loading…
Cancel
Save