U:调整数据监听位置,增加切换后取消监听
This commit is contained in:
1 parent
0f66f7bffd
commit
46fea9a788
3 files changed
+31
-6
No files matched your search
@@ -41,11 +41,6 @@ httpConfig.setConfig({
|
|||||||
|
|
||||||
// http 注册
|
// http 注册
|
||||||
import httpPlugin from './plugins/http'
|
import httpPlugin from './plugins/http'
|
||||||
import { useApplicationStore } from '@/stores/application'
|
|
||||||
|
|
||||||
// 注册消息监听
|
|
||||||
const useApplicationStore1 = useApplicationStore()
|
|
||||||
useApplicationStore1.subscribe()
|
|
||||||
|
|
||||||
// httpPlugin.install(app)
|
// httpPlugin.install(app)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { defineStore, storeToRefs } from 'pinia'
|
|||||||
import { useWebSocketStore } from '@/stores/websocketStore'
|
import { useWebSocketStore } from '@/stores/websocketStore'
|
||||||
import { WebSocketResponse } from '@/types/websocket'
|
import { WebSocketResponse } from '@/types/websocket'
|
||||||
import { ApplicationType } from '@/types/infoModel'
|
import { ApplicationType } from '@/types/infoModel'
|
||||||
|
import { httpClient } from '@/utils/http'
|
||||||
|
import { ResponseModel, SubscriptionInfo } from '@/types/response'
|
||||||
|
|
||||||
export const useApplicationStore = defineStore('applicationInfoSub', () => {
|
export const useApplicationStore = defineStore('applicationInfoSub', () => {
|
||||||
const appInfos: Ref<ApplicationType[]> = ref([])
|
const appInfos: Ref<ApplicationType[]> = ref([])
|
||||||
@@ -140,12 +142,27 @@ export const useApplicationStore = defineStore('applicationInfoSub', () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unsubscribe() {
|
||||||
|
const subAppInfo: SubscriptionInfo = {
|
||||||
|
subscriptionType: 'AppDetailInfo',
|
||||||
|
interval: 1,
|
||||||
|
}
|
||||||
|
httpClient
|
||||||
|
.post(`/unsubscribe`, JSON.stringify(subAppInfo))
|
||||||
|
.then((res: ResponseModel) => {
|
||||||
|
console.log('取消订阅应用详细信息成功:', res)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('取消订阅应用详细信息失败:', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe, // 状态
|
subscribe, // 状态
|
||||||
appInfos,
|
appInfos,
|
||||||
selectedApp,
|
selectedApp,
|
||||||
inspectingAppDetails,
|
inspectingAppDetails,
|
||||||
|
unsubscribe,
|
||||||
// 计算属性
|
// 计算属性
|
||||||
activeApps,
|
activeApps,
|
||||||
inactiveApps,
|
inactiveApps,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MonitorView',
|
name: 'MonitorView',
|
||||||
})
|
})
|
||||||
|
import { useApplicationStore } from '@/stores/application'
|
||||||
|
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||||
import MonitorSidebar from './MonitorSidebar.vue'
|
import MonitorSidebar from './MonitorSidebar.vue'
|
||||||
@@ -118,8 +119,15 @@ const resetLayout = () => {
|
|||||||
inspectorWidth.value = 350
|
inspectorWidth.value = 350
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册消息监听
|
||||||
|
const useApplicationStore1 = useApplicationStore()
|
||||||
|
|
||||||
// 键盘快捷键
|
// 键盘快捷键
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
// 创建事件绑定
|
||||||
|
useApplicationStore1.subscribe()
|
||||||
|
|
||||||
|
|
||||||
const handleKeydown = (event: KeyboardEvent) => {
|
const handleKeydown = (event: KeyboardEvent) => {
|
||||||
if (event.ctrlKey && event.key === 'r') {
|
if (event.ctrlKey && event.key === 'r') {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@@ -135,6 +143,11 @@ onMounted(() => {
|
|||||||
document.removeEventListener('mouseup', stopResize)
|
document.removeEventListener('mouseup', stopResize)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
useApplicationStore1.unsubscribe()
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in new issue
Block a user