Squashed commit of the following:
All checks were successful
local-test分支构建发布 / Docker-Build (push) Successful in 1m53s

commit 33292ca9b8
Author: joylink_fanyuhong <18706759286@163.com>
Date:   Tue Nov 12 09:17:32 2024 +0800

    订阅处理

commit cdcad825f7
Author: joylink_fanyuhong <18706759286@163.com>
Date:   Tue Nov 12 09:13:54 2024 +0800

    取消订阅调整

commit 44f7389132
Merge: 425d8e9 a2ae992
Author: joylink_fanyuhong <18706759286@163.com>
Date:   Mon Nov 11 18:18:43 2024 +0800

    Merge remote-tracking branch 'origin/develop' into develop

commit 425d8e986b
Author: joylink_fanyuhong <18706759286@163.com>
Date:   Mon Nov 11 18:16:10 2024 +0800

    处理订阅

commit a2ae99209f
Author: joylink_zhaoerwei <Bob_Engineer@163.com>
Date:   Mon Nov 11 17:48:52 2024 +0800

    订阅调整
This commit is contained in:
joylink_zhaoerwei 2024-11-12 09:49:53 +08:00
parent 40e11e0d67
commit 158aed62e6
6 changed files with 56 additions and 14 deletions

View File

@ -95,7 +95,10 @@ export function destroyLineApp(): void {
export function initLineApp(lineId: number): IGraphicApp {
lineApp = lineAppMap.get(lineId) || null;
if (lineApp) return lineApp;
if (lineApp) {
handleSubscribe(lineApp);
return lineApp;
}
lineApp = newGraphicApp({
interactiveGraphicTypeIncludes: [
Signal.Type,
@ -258,6 +261,18 @@ export async function loadLineDatas(): Promise<IGraphicStorage> {
}
}
export function cancelSubscribe(lineApp: IGraphicApp) {
const lineStore = useLineStore();
const lineId = lineStore.lineId;
if (lineId) {
lineApp.unsubscribe(`/queue/line/${lineId}/device`);
lineApp.unsubscribe(`/queue/line/${lineId}/train`);
monitorDestinations.forEach((destination) => {
lineApp.unsubscribe(destination);
});
}
}
let monitorDestinations: string[] = [];
function handleSubscribe(lineApp: IGraphicApp) {
const lineStore = useLineStore();
const lineId = lineStore.lineId;
@ -312,7 +327,8 @@ function handleSubscribe(lineApp: IGraphicApp) {
});
const lineNetStore = useLineNetStore();
const userStore = useUserStore();
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
monitorDestinations = getMonitorPath(userStore.roles).destinations;
monitorDestinations.forEach((destination) => {
lineApp.subscribe({
destination,
messageHandle: (message: Uint8Array) => {

View File

@ -52,7 +52,10 @@ export function destroyLineNetApp(): void {
}
export function initLineNetApp(): IGraphicApp {
if (lineNetApp) return lineNetApp;
if (lineNetApp) {
handleSubscribe(lineNetApp);
return lineNetApp;
}
lineNetApp = newGraphicApp({
interactiveGraphicTypeIncludes: [
RunLine.Type,
@ -146,7 +149,15 @@ export async function loadLineNetDatas(): Promise<IGraphicStorage> {
}
}
function handleSubscribe(lineNetApp: IGraphicApp) {
export function cancelSubscribe(lineNetApp: IGraphicApp) {
lineNetApp.unsubscribe('/queue/lineNet');
monitorDestinations.forEach((destination) => {
lineNetApp.unsubscribe(destination);
});
}
let monitorDestinations: string[] = [];
export function handleSubscribe(lineNetApp: IGraphicApp) {
const lineNetStore = useLineNetStore();
lineNetApp.enableWsMassaging({
wsUrl: `${getWebsocketUrl()}`,
@ -165,7 +176,8 @@ function handleSubscribe(lineNetApp: IGraphicApp) {
},
});
const userStore = useUserStore();
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
monitorDestinations = getMonitorPath(userStore.roles).destinations;
monitorDestinations.forEach((destination) => {
lineNetApp.subscribe({
destination,
messageHandle: (message: Uint8Array) => {

View File

@ -7,7 +7,7 @@
</template>
<script setup lang="ts">
import { onMounted, watch } from 'vue';
import { onMounted, onUnmounted, watch } from 'vue';
import { useLineStore } from 'src/stores/line-store';
import { useRoute } from 'vue-router';
import { useLineNetStore } from 'src/stores/line-net-store';
@ -80,7 +80,7 @@ function centerFaultDevice() {
}
}
// onUnmounted(() => {
// lineStore.destroy();
// });
onUnmounted(() => {
lineStore.cancelSubscribe();
});
</script>

View File

@ -7,7 +7,7 @@
</template>
<script setup lang="ts">
import { onMounted, watch } from 'vue';
import { onMounted, onUnmounted, watch } from 'vue';
import { useLineNetStore } from 'src/stores/line-net-store';
import { RunLine } from 'src/graphics/runLine/RunLine';
import { useRouter } from 'vue-router';
@ -73,7 +73,7 @@ onMounted(() => {
}
});
// onUnmounted(() => {
// lineNetStore.destroy();
// });
onUnmounted(() => {
lineNetStore.cancelSubscribe();
});
</script>

View File

@ -4,6 +4,7 @@ import {
initLineNetApp,
getLineNetApp,
destroyLineNetApp,
cancelSubscribe,
} from 'src/drawApp/lineNetApp';
import { markRaw } from 'vue';
import { QTable } from 'quasar';
@ -72,6 +73,10 @@ export const useLineNetStore = defineStore('lineNet', {
this.selectedGraphics = [];
return app;
},
cancelSubscribe() {
const app = this.getLineNetApp();
cancelSubscribe(app);
},
destroy() {
this.selectedGraphics = null;
destroyLineNetApp();

View File

@ -1,6 +1,11 @@
import { defineStore } from 'pinia';
import { IJlCanvas, JlGraphic, IGraphicApp } from 'jl-graphic';
import { initLineApp, getLineApp, destroyLineApp } from 'src/drawApp/lineApp';
import {
initLineApp,
getLineApp,
destroyLineApp,
cancelSubscribe,
} from 'src/drawApp/lineApp';
import { markRaw } from 'vue';
export const useLineStore = defineStore('line', {
@ -50,6 +55,10 @@ export const useLineStore = defineStore('line', {
this.selectedGraphics = null;
destroyLineApp();
},
cancelSubscribe() {
const app = this.getLineApp();
cancelSubscribe(app);
},
setLineId(id: number | null) {
this.lineId = id;
},