This commit is contained in:
fan 2023-08-25 09:44:40 +08:00
commit 622200a090
4 changed files with 34 additions and 17 deletions

View File

@ -206,6 +206,12 @@ export class TrainState extends GraphicStateBase implements ITrainState {
set runDirection(v: boolean) {
this.states.runDirection = v;
}
get headDirection(): boolean {
return this.states.headDirection;
}
set headDirection(v: boolean) {
this.states.headDirection = v;
}
clone(): TrainState {
return new TrainState(this.states.cloneMessage());
}

View File

@ -80,6 +80,8 @@ export interface ITrainState extends GraphicState {
set pointTo(v: boolean);
get runDirection(): boolean;
set runDirection(v: boolean);
get headDirection(): boolean;
set headDirection(v: boolean);
}
interface bodyWH {
@ -136,8 +138,8 @@ export const trainConsts = {
};
export class TrainHead extends Container {
arrow: Graphics; // 箭头
pause: Graphics; // 停止
arrow: Graphics; // 运行方向
pause: Graphics; // 车头
train: Train;
constructor(train: Train) {
super();
@ -152,15 +154,8 @@ export class TrainHead extends Container {
this.pause.clear();
}
doRepaint() {
let direction = 'left'; // 箭头在左边(方向向右)
const states = this.train.states;
if (states.runDirection) {
direction = 'right';
}
this.clear();
if (!direction) {
return;
}
const bodyWH = this.train.trainbody.getBodyWH();
const marginX = trainConsts.marginX;
const pauseW = trainConsts.pauseW;
@ -180,7 +175,7 @@ export class TrainHead extends Container {
-marginX - pauseW / 2 - codeWidth / 2,
codeHeight / 2,
];
if (direction != 'left') {
if (states.runDirection) {
const aP: Array<number> = [];
arrowPoint.forEach((item, index) => {
if (index % 2 == 1) {
@ -190,6 +185,8 @@ export class TrainHead extends Container {
}
});
arrowPoint = aP;
}
if (states.headDirection) {
const pP: Array<number> = [];
pausePoint.forEach((item, index) => {
if (index % 2 == 1) {

View File

@ -3,6 +3,12 @@
<q-header reveal class="bg-primary text-white">
<q-toolbar>
<q-toolbar-title> {{ mapName }} </q-toolbar-title>
<q-btn
color="info"
label="销毁仿真"
class="q-mr-md"
@click="destroySimAndBack"
/>
<q-btn color="info" label="返回" @click="backConfirm" />
</q-toolbar>
<q-resize-observer @resize="onHeaderResize" />
@ -90,11 +96,8 @@ onUnmounted(() => {
if (dialogInstance.value && lineStore.showLayerDialog) {
dialogInstance.value.hide();
}
if (simulationId) {
lineStore.setSimulationId(null);
lineStore.destroy();
destroySimulation({ simulationId });
}
});
watch(
[() => lineStore.stateProCount, () => lineStore.selectedGraphics],
@ -129,4 +132,10 @@ watch(
});
}
);
function destroySimAndBack() {
if (simulationId) {
destroySimulation({ simulationId });
}
backConfirm();
}
</script>

View File

@ -3,9 +3,14 @@ import { RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'home',
component: () => import('layouts/MainLayout.vue'),
children: [{ path: '', component: () => import('pages/IndexPage.vue') }],
children: [
{
path: '',
name: 'home',
component: () => import('pages/IndexPage.vue'),
},
],
},
{