菜单报错调整

This commit is contained in:
fan 2023-07-21 10:51:15 +08:00
parent 7cb9548aaa
commit 8fffd57b5b

View File

@ -138,12 +138,8 @@ const DefaultCanvasMenu = new ContextMenu({
{
items: [SelectAllOptions],
},
{
items: [JumpStaitonOptions],
},
],
});
let drawApp: JlDrawApp | null = null;
export function getDrawApp(): JlDrawApp | null {
@ -161,7 +157,6 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
drawApp = new JlDrawApp(dom);
const app = drawApp;
//根据草稿图类型加载绘图工具
const draftType = useDrawStore().$state.draftType;
let drawAssistants: (
| PlatformDraw
| StationDraw
@ -180,6 +175,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
| AxleCountingDraw
| SeparatorDraw
)[] = [];
const draftType = useDrawStore().$state.draftType;
if (draftType === 'Line') {
drawAssistants = [
new PlatformDraw(
@ -228,9 +224,26 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
}
app.setOptions({ drawAssistants: drawAssistants });
if (draftType === 'Line') {
const menuOptionsNew = {
name: '绘制-画布菜单',
groups: [
{
items: [UndoOptions, RedoOptions],
},
{
items: [SelectAllOptions],
},
{
items: [JumpStaitonOptions],
},
],
};
DefaultCanvasMenu.setOptions(menuOptionsNew);
}
// 画布右键菜单
app.registerMenu(DefaultCanvasMenu);
app.canvas.on('_rightclick', (e) => {
if (app._drawing) return;
UndoOptions.disabled = !app.opRecord.hasUndo;
@ -244,27 +257,30 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
SelectAllOptions.handler = () => {
app.selectAllGraphics();
};
const stations = app.queryStore.queryByType<Station>(Station.Type);
const jumpStaitonItems: MenuItemOptions[] = [];
stations.forEach((station) => {
const item: MenuItemOptions = {
name: station.datas.code,
handler: () => {
app.makeGraphicCenterShow(station);
},
if (draftType === 'Line') {
const stations = app.queryStore.queryByType<Station>(Station.Type);
const jumpStaitonItems: MenuItemOptions[] = [];
stations.forEach((station) => {
const item: MenuItemOptions = {
name: station.datas.code,
handler: () => {
app.makeGraphicCenterShow(station);
},
};
jumpStaitonItems.push(item);
});
JumpStaitonOptions.subMenu = {
name: '车站列表',
groups: [
{
name: '车站列表',
items: jumpStaitonItems,
},
],
};
jumpStaitonItems.push(item);
});
JumpStaitonOptions.subMenu = {
name: '车站列表',
groups: [
{
name: '车站列表',
items: jumpStaitonItems,
},
],
};
DefaultCanvasMenu.update();
DefaultCanvasMenu.update();
}
DefaultCanvasMenu.open(e.global);
});
app.addKeyboardListener(