From e14358f85a7d32a753225f253ff223d17cf36c25 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 02 Apr 2025 19:10:00 +0800
Subject: [PATCH] style: 风格处理
---
src/utils/websocket/drone-ws-control.js | 249 ++++++++++++++++++++++---------------------------
1 files changed, 111 insertions(+), 138 deletions(-)
diff --git a/src/utils/websocket/drone-ws-control.js b/src/utils/websocket/drone-ws-control.js
index f4e56fd..9e5be0f 100644
--- a/src/utils/websocket/drone-ws-control.js
+++ b/src/utils/websocket/drone-ws-control.js
@@ -1,145 +1,118 @@
// import { EventBus } from '@/eventBus/event-bus';
-import { EBizCode, EBizCodeMessage } from '@/utils/staticData/enums';
-import { ControlSource } from '@/utils/staticData/device';
+import { EBizCode, EBizCodeMessage } from '@/utils/staticData/enums'
+import { ControlSource } from '@/utils/staticData/device'
export default {
- data() {
- return {
- droneControlSource: '',
- payloadControlSource: '',
- ControlSource: ControlSource,
- };
- },
- methods: {
- useDroneControlWsEvent(sn, payloadSn, funcs) {
- const _this = this;
- this.droneControlSource = this.ControlSource.A;
- this.payloadControlSource = this.ControlSource.B;
+ data() {
+ return {
+ droneControlSource: '',
+ payloadControlSource: '',
+ ControlSource: ControlSource,
+ }
+ },
+ methods: {
+ useDroneControlWsEvent(sn, payloadSn, funcs) {
+ const _this = this
+ this.droneControlSource = this.ControlSource.A
+ this.payloadControlSource = this.ControlSource.B
- function onControlSourceChange(data) {
- if (
- data.type === 1 &&
- data.sn === sn
- ) {
- _this.droneControlSource = data.control_source;
- _this.$store.commit(
- 'SET_DRONE_CONTROL_SOURCE',
- _this.droneControlSource,
- );
- // _this.$message.info(`飞行控制改为 ${_this.droneControlSource}`)
- // _this._showMessage.info(`飞行控制改为 ${_this.droneControlSource}`)
- return;
- }
- if (
- data.type === 2 &&
- data.sn === payloadSn
- ) {
- _this.payloadControlSource = data.control_source;
- // _this.$message.info(`负载控制改为 ${_this.payloadControlSource}.`)
- // _this._showMessage.info(`负载控制改为 ${_this.payloadControlSource}.`)
- }
- }
+ function onControlSourceChange(data) {
+ if (data.type === 1 && data.sn === sn) {
+ _this.droneControlSource = data.control_source
+ _this.$store.commit('SET_DRONE_CONTROL_SOURCE', _this.droneControlSource)
+ // _this.$message.info(`飞行控制改为 ${_this.droneControlSource}`)
+ // _this._showMessage.info(`飞行控制改为 ${_this.droneControlSource}`)
+ return
+ }
+ if (data.type === 2 && data.sn === payloadSn) {
+ _this.payloadControlSource = data.control_source
+ // _this.$message.info(`负载控制改为 ${_this.payloadControlSource}.`)
+ // _this._showMessage.info(`负载控制改为 ${_this.payloadControlSource}.`)
+ }
+ }
- function handleProgress(key, message, error) {
- if (error !== 0) {
- // _this.$notify.closeAll()
- // _this.$notify.error({
- // title: key + '错误码:' + error,
- // message: message,
- // duration: 30
- // })
- // _this._showMessage.warning(key + '错误码:' + error)
- _this._showMessage.warning(key);
- } else {
- // _this.$notify.closeAll()
- // _this.$notify.info({
- // title: key,
- // message: message,
- // duration: 30
- // })
- _this._showMessage.info(message);
- }
- }
+ function handleProgress(key, message, error) {
+ if (error !== 0) {
+ // _this.$notify.closeAll()
+ // _this.$notify.error({
+ // title: key + '错误码:' + error,
+ // message: message,
+ // duration: 30
+ // })
+ // _this._showMessage.warning(key + '错误码:' + error)
+ _this._showMessage.warning(key)
+ } else {
+ // _this.$notify.closeAll()
+ // _this.$notify.info({
+ // title: key,
+ // message: message,
+ // duration: 30
+ // })
+ _this._showMessage.info(message)
+ }
+ }
- function handleDroneControlWsEvent(payload) {
- if (!payload) {
- return;
- }
- switch (payload.biz_code) {
- case EBizCode.ControlSourceChange: {
- onControlSourceChange(payload.data);
- break;
- }
- case EBizCode.FlyToPointProgress: {
- const {
- sn: deviceSn,
- result,
- message: msg,
- } = payload.data;
- if (deviceSn !== sn) return;
- handleProgress(
- EBizCodeMessage[EBizCode.FlyToPointProgress],
- `设备(编码: ${deviceSn}) ${msg}`,
- result,
- );
- break;
- }
- case EBizCode.TakeoffToPointProgress: {
- const {
- sn: deviceSn,
- result,
- message: msg,
- } = payload.data;
- if (deviceSn !== sn) return;
- handleProgress(
- EBizCodeMessage[EBizCode.TakeoffToPointProgress],
- `设备(编码: ${deviceSn}) ${msg}`,
- result,
- );
- break;
- }
- case EBizCode.JoystickInvalidNotify: {
- const {
- sn: deviceSn,
- result,
- message: msg,
- } = payload.data;
- if (deviceSn !== sn) return;
- handleProgress(
- EBizCodeMessage[EBizCode.JoystickInvalidNotify],
- `设备(编码: ${deviceSn}) ${msg}`,
- result,
- );
- break;
- }
- case EBizCode.DrcStatusNotify: {
- const {
- sn: deviceSn,
- result,
- message: msg,
- } = payload.data;
- break;
- }
- }
- }
+ function handleDroneControlWsEvent(payload) {
+ if (!payload) {
+ return
+ }
+ switch (payload.biz_code) {
+ case EBizCode.ControlSourceChange: {
+ onControlSourceChange(payload.data)
+ break
+ }
+ case EBizCode.FlyToPointProgress: {
+ const { sn: deviceSn, result, message: msg } = payload.data
+ if (deviceSn !== sn) return
+ handleProgress(
+ EBizCodeMessage[EBizCode.FlyToPointProgress],
+ `设备(编码: ${deviceSn}) ${msg}`,
+ result
+ )
+ break
+ }
+ case EBizCode.TakeoffToPointProgress: {
+ const { sn: deviceSn, result, message: msg } = payload.data
+ if (deviceSn !== sn) return
+ handleProgress(
+ EBizCodeMessage[EBizCode.TakeoffToPointProgress],
+ `设备(编码: ${deviceSn}) ${msg}`,
+ result
+ )
+ break
+ }
+ case EBizCode.JoystickInvalidNotify: {
+ const { sn: deviceSn, result, message: msg } = payload.data
+ if (deviceSn !== sn) return
+ handleProgress(
+ EBizCodeMessage[EBizCode.JoystickInvalidNotify],
+ `设备(编码: ${deviceSn}) ${msg}`,
+ result
+ )
+ break
+ }
+ case EBizCode.DrcStatusNotify: {
+ const { sn: deviceSn, result, message: msg } = payload.data
+ break
+ }
+ }
+ }
- return {
- handleDroneControlWsEvent,
- };
- },
- },
- mounted() {
- this.$EventBus.$on(
- 'droneControlWs',
- this.useDroneControlWsEvent(this.sn, this.payloadSelectInfo.value)
- .handleDroneControlWsEvent,
- );
- },
- beforeDestroy() {
- this.$EventBus.$off(
- 'droneControlWs',
- this.useDroneControlWsEvent(this.sn, this.payloadSelectInfo.value)
- .handleDroneControlWsEvent,
- );
- },
-};
+ return {
+ handleDroneControlWsEvent,
+ }
+ },
+ },
+ mounted() {
+ this.$EventBus.$on(
+ 'droneControlWs',
+ this.useDroneControlWsEvent(this.sn, this.payloadSelectInfo.value).handleDroneControlWsEvent
+ )
+ },
+ beforeDestroy() {
+ this.$EventBus.$off(
+ 'droneControlWs',
+ this.useDroneControlWsEvent(this.sn, this.payloadSelectInfo.value).handleDroneControlWsEvent
+ )
+ },
+}
--
Gitblit v1.9.3