| | |
| | | }, |
| | | |
| | | computed: { |
| | | |
| | | poster() { |
| | | return "/images/player/player_poster.gif?t=" + Math.random() |
| | | } |
| | |
| | | ctx: null, |
| | | canvasWidth: 0, |
| | | canvasHeight: 0, |
| | | algoDataSocket: null |
| | | }; |
| | | }, |
| | | watch: { |
| | |
| | | if (newVal !== oldVal) { |
| | | if (this.wfs.config) { |
| | | this.wfs.destroy(); |
| | | !!this.algoDataSocket && this.algoDataSocket.close() |
| | | } |
| | | this.$nextTick(() => { |
| | | this.clickStart(); |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.clickStart(); |
| | | this.$nextTick(() => { |
| | | this.canvas = this.$refs.areaCanvas; |
| | | this.ctx = this.canvas.getContext("2d"); |
| | | this.ctx.lineWidth = 1; |
| | | this.initArea(); |
| | | |
| | | }) |
| | | }, |
| | | beforeDestroy() { |
| | | this.wfs.destroy(); |
| | | this.wfsId = ""; |
| | | |
| | | !!this.algoDataSocket && this.algoDataSocket.close() |
| | | }, |
| | | methods: { |
| | | checkConnect(id) { |
| | |
| | | this.canvasData.polygon = res.data.polygon; |
| | | console.log(this.canvasData) |
| | | this.clickSelect(this.canvasData); |
| | | }, |
| | | initAlgoDataWebScoket() { |
| | | if (typeof (WebSocket) === "undefined") { |
| | | console.log("error,您的浏览器不支持socket") |
| | | } else { |
| | | this.algoDataSocket = new WebSocket() |
| | | this.algoDataSocket.onopen = () => { |
| | | console.log("socket连接成功") |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.clickStart(); |
| | | this.$nextTick(()=>{ |
| | | this.canvas = this.$refs.areaCanvas; |
| | | this.ctx = this.canvas.getContext("2d"); |
| | | this.ctx.lineWidth = 1; |
| | | this.initArea(); |
| | | |
| | | }) |
| | | }, |
| | | beforeDestroy() { |
| | | this.wfs.destroy(); |
| | | this.wfsId = ""; |
| | | this.algoDataSocket.onerror = () => { |
| | | console.log("连接错误") |
| | | } |
| | | this.algoDataSocket.onmessage = msg => { |
| | | console.log(msg) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | </script> |