feat: 手机端访问二维码受websocket连接状态控制

This commit is contained in:
log1997
2026-01-09 17:34:13 +08:00
parent 3eac4e1aac
commit 8471fb104f
3 changed files with 31 additions and 2 deletions

View File

@@ -9,7 +9,10 @@ import { IndexDb } from '@/utils/dexie'
export function useViewModel() {
const serverConfig = useStore().serverConfig
const { getServerList: serverList, getCurrentServer: currentServer } = storeToRefs(serverConfig)
const {
getServerList: serverList,
getCurrentServer: currentServer,
} = storeToRefs(serverConfig)
const currentServerValue = ref<ServerType>(cloneDeep(currentServer.value))
const wsUrl = ref<string>('ws://localhost:8080/echo')
const msgList = ref<WsMsgData[]>([])
@@ -41,6 +44,16 @@ export function useViewModel() {
currentServerValue.value.host = newValue
serverConfig.updateServerList(currentServerValue.value)
})
watch(
() => wsStatus.value,
(newValue) => {
if (newValue && (newValue.connected === true || newValue.connected === false)) {
serverConfig.setServerStatus(newValue.connected)
}
},
)
onMounted(() => {
getAllMsg()
})