线路订阅调整
This commit is contained in:
parent
ea363b44cd
commit
ea54841d8a
@ -87,7 +87,7 @@ export function destroyLineApp(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function initLineApp(lineId: number): IGraphicApp {
|
||||
export function initLineApp(): IGraphicApp {
|
||||
if (lineApp) return lineApp;
|
||||
const lineAppDataLoader: IGraphicAppConfig['dataLoader'] = async () => {
|
||||
const lineStore = useLineStore();
|
||||
@ -186,6 +186,65 @@ export function initLineApp(lineId: number): IGraphicApp {
|
||||
token: getJwtToken() as string,
|
||||
});
|
||||
|
||||
let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) =
|
||||
null;
|
||||
lineApp.on('websocket-connect-state-change', (connected) => {
|
||||
if (!connected && !msgNotify) {
|
||||
msgNotify = Notify.create({
|
||||
type: 'negative',
|
||||
timeout: 0,
|
||||
position: 'top-right',
|
||||
message: '通信链接已断开!',
|
||||
});
|
||||
} else if (msgNotify && connected) {
|
||||
msgNotify();
|
||||
msgNotify = null;
|
||||
}
|
||||
});
|
||||
|
||||
lineApp.reload().then(() => {
|
||||
if (!lineApp) return;
|
||||
const quickJumpMenu = new ContextMenu({
|
||||
name: '快捷跳转',
|
||||
groups: [
|
||||
{
|
||||
items: lineApp.queryStore
|
||||
.queryByType<Station>(Station.Type)
|
||||
.map<MenuItemOptions>((station) => ({
|
||||
name: station.datas.name ?? '',
|
||||
handler: () => {
|
||||
lineApp?.makeGraphicCenterShow(station);
|
||||
},
|
||||
})),
|
||||
},
|
||||
],
|
||||
});
|
||||
lineApp.registerMenu(quickJumpMenu);
|
||||
lineApp.canvas.on('_rightclick', (e) => {
|
||||
quickJumpMenu.open(e.global);
|
||||
});
|
||||
|
||||
const axleCountings = lineApp.queryStore.queryByType<AxleCounting>(
|
||||
AxleCounting.Type
|
||||
);
|
||||
axleCountings.forEach((axleCounting) => {
|
||||
axleCounting.visible = false;
|
||||
});
|
||||
const trainWindows = lineApp.queryStore.queryByType<TrainWindow>(
|
||||
TrainWindow.Type
|
||||
);
|
||||
trainWindows.forEach((trainWindow) => {
|
||||
trainWindow.visible = false;
|
||||
});
|
||||
handleSubscribe(lineApp);
|
||||
});
|
||||
|
||||
return lineApp;
|
||||
}
|
||||
|
||||
function handleSubscribe(lineApp: IGraphicApp) {
|
||||
const lineStore = useLineStore();
|
||||
const lineId = lineStore.lineId;
|
||||
lineApp.subscribe({
|
||||
destination: `/queue/line/${lineId}/device`,
|
||||
messageConverter: (message: Uint8Array) => {
|
||||
@ -235,21 +294,6 @@ export function initLineApp(lineId: number): IGraphicApp {
|
||||
return states;
|
||||
},
|
||||
});
|
||||
let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) =
|
||||
null;
|
||||
lineApp.on('websocket-connect-state-change', (connected) => {
|
||||
if (!connected && !msgNotify) {
|
||||
msgNotify = Notify.create({
|
||||
type: 'negative',
|
||||
timeout: 0,
|
||||
position: 'top-right',
|
||||
message: '通信链接已断开!',
|
||||
});
|
||||
} else if (msgNotify && connected) {
|
||||
msgNotify();
|
||||
msgNotify = null;
|
||||
}
|
||||
});
|
||||
const lineNetStore = useLineNetStore();
|
||||
lineApp.subscribe({
|
||||
destination: '/queue/xian/ncc/alert',
|
||||
@ -258,42 +302,4 @@ export function initLineApp(lineId: number): IGraphicApp {
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
});
|
||||
|
||||
lineApp.reload().then(() => {
|
||||
if (!lineApp) return;
|
||||
const quickJumpMenu = new ContextMenu({
|
||||
name: '快捷跳转',
|
||||
groups: [
|
||||
{
|
||||
items: lineApp.queryStore
|
||||
.queryByType<Station>(Station.Type)
|
||||
.map<MenuItemOptions>((station) => ({
|
||||
name: station.datas.name ?? '',
|
||||
handler: () => {
|
||||
lineApp?.makeGraphicCenterShow(station);
|
||||
},
|
||||
})),
|
||||
},
|
||||
],
|
||||
});
|
||||
lineApp.registerMenu(quickJumpMenu);
|
||||
lineApp.canvas.on('_rightclick', (e) => {
|
||||
quickJumpMenu.open(e.global);
|
||||
});
|
||||
|
||||
const axleCountings = lineApp.queryStore.queryByType<AxleCounting>(
|
||||
AxleCounting.Type
|
||||
);
|
||||
axleCountings.forEach((axleCounting) => {
|
||||
axleCounting.visible = false;
|
||||
});
|
||||
const trainWindows = lineApp.queryStore.queryByType<TrainWindow>(
|
||||
TrainWindow.Type
|
||||
);
|
||||
trainWindows.forEach((trainWindow) => {
|
||||
trainWindow.visible = false;
|
||||
});
|
||||
});
|
||||
|
||||
return lineApp;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export const useLineStore = defineStore('line', {
|
||||
},
|
||||
initLineApp(lineId: number) {
|
||||
this.setLineId(lineId);
|
||||
const app = initLineApp(lineId);
|
||||
const app = initLineApp();
|
||||
app.on('graphicselected', (graphics) => {
|
||||
this.selectedGraphics = markRaw(graphics);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user