开放云服务设置,增加加载完后通知主应用功能

This commit is contained in:
fangxiang 2023-01-19 15:52:43 +08:00
parent 9ad2665b0d
commit b2aff3720c
3 changed files with 51 additions and 48 deletions

View File

@ -36,6 +36,9 @@ export class WuJieInitializer {
$wujie.bus.$on("initialize_app", (device_sn: string) => { $wujie.bus.$on("initialize_app", (device_sn: string) => {
WuJieInitializer.onInitializeApp(device_sn, $wujie, $store, $q, $t); WuJieInitializer.onInitializeApp(device_sn, $wujie, $store, $q, $t);
}); });
setTimeout(() => {
$wujie.bus.$emit("client_mounted");
}, 500);
} }
} }
@ -79,6 +82,9 @@ export class WuJieInitializer {
.initialize() .initialize()
.then(() => { .then(() => {
$store.commit("setInitialized"); $store.commit("setInitialized");
if ($wujie) {
$wujie.bus.$emit("client_initialize_end");
}
}); });
EventBus.getInstance().emit(EventNamesDefine.WebSocketConnected, this); EventBus.getInstance().emit(EventNamesDefine.WebSocketConnected, this);
}, 0); }, 0);

View File

@ -1,61 +1,59 @@
import { IWuJieInterface } from './../store/index'; import { IWuJieInterface } from "./../store/index";
import { store } from 'quasar/wrappers'; import { store } from "quasar/wrappers";
export default class WuJieReconnectingWebSocket { export default class WuJieReconnectingWebSocket {
readyState: number ; readyState: number;
$wujie : IWuJieInterface; $wujie: IWuJieInterface;
constructor() { constructor() {
this.readyState=WebSocket.OPEN; this.readyState = WebSocket.OPEN;
this.onclose=(ev:any)=>{} this.onclose = (ev: any) => {};
this.onerror=(ev:any)=>{} this.onerror = (ev: any) => {};
this.onmessage=(ev:any)=>{} this.onmessage = (ev: any) => {};
this.onopen=(ev:any)=>{} this.onopen = (ev: any) => {};
this.$wujie = (window as any).$wujie; this.$wujie = (window as any).$wujie;
if(this.$wujie){ if (this.$wujie) {
this.$wujie.bus.$on("onclose",this.onclose) this.$wujie.bus.$on("onclose", this.onclose);
this.$wujie.bus.$on("onerror",this.onerror) this.$wujie.bus.$on("onerror", this.onerror);
this.$wujie.bus.$on("onmessage", (ev:any)=>{ this.$wujie.bus.$on("onmessage", (ev: any) => {
if(this.onmessage) { if (this.onmessage) {
this.onmessage(ev) this.onmessage(ev);
} }
}) });
this.$wujie.bus.$on("onopen",this.onopen) this.$wujie.bus.$on("onopen", this.onopen);
setTimeout(() => { setTimeout(() => {
if(this.onopen){ if (this.onopen) {
this.onopen(null); this.onopen(null);
} }
},1000); }, 500);
} }
} }
onclose: ((event: any) => void) | null; onclose: ((event: any) => void) | null;
/** /**
* An event listener to be called when an error occurs * An event listener to be called when an error occurs
*/ */
onerror: ((event: any) => void) | null; onerror: ((event: any) => void) | null;
/** /**
* An event listener to be called when a message is received from the server * An event listener to be called when a message is received from the server
*/ */
onmessage: ((event: MessageEvent) => void) | null; onmessage: ((event: MessageEvent) => void) | null;
/** /**
* An event listener to be called when the WebSocket connection's readyState changes to OPEN; * An event listener to be called when the WebSocket connection's readyState changes to OPEN;
* this indicates that the connection is ready to send and receive data * this indicates that the connection is ready to send and receive data
*/ */
onopen: ((event: any) => void) | null; onopen: ((event: any) => void) | null;
/** /**
* Closes the WebSocket connection or connection attempt, if any. If the connection is already * Closes the WebSocket connection or connection attempt, if any. If the connection is already
* CLOSED, this method does nothing * CLOSED, this method does nothing
*/ */
close(code?: number, reason?: string){ close(code?: number, reason?: string) {}
} /**
/** * Enqueue specified data to be transmitted to the server over the WebSocket connection
* Enqueue specified data to be transmitted to the server over the WebSocket connection */
*/ send(data: string) {
send(data: string) { if (this.$wujie) {
if(this.$wujie){ this.$wujie.bus.$emit("send_to", data);
this.$wujie.bus.$emit("send_to",data)
}
} }
}
} }

View File

@ -104,7 +104,6 @@
:disable="loading" :disable="loading"
/> />
<q-tab <q-tab
v-if="$store.state.advanced_debug"
name="cloud_server" name="cloud_server"
no-caps no-caps
icon="cloud" icon="cloud"