diff --git a/.env.cloud b/.env.cloud index c1d9094..10d7727 100644 --- a/.env.cloud +++ b/.env.cloud @@ -1,2 +1,3 @@ VITE_APP_ENV = cloud -VITE_BASE_URL = 'http://192.168.1.99:8080' \ No newline at end of file +VITE_BASE_URL = 'http://192.168.1.99:8080' +VITE_ZMQ_BASE_URL = '192.168.1.99' \ No newline at end of file diff --git a/.env.local b/.env.local index e890e1e..11a68f9 100644 --- a/.env.local +++ b/.env.local @@ -1 +1,3 @@ VITE_APP_ENV = local +VITE_BASE_URL = 'http://192.168.1.99:8080' +VITE_ZMQ_BASE_URL = '192.168.1.99' \ No newline at end of file diff --git a/package.json b/package.json index 421b83b..c2137f5 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "preview": "vite preview", "build-only": "vite build", "build:dev": "vite build --mode development", - "build:prod": "vite build --mode prod", + "build:cloud": "vite build --mode cloud", "type-check": "vue-tsc --build" }, "dependencies": { diff --git a/src/api/module/taks/index.ts b/src/api/module/taks/index.ts index dba2a06..76ff2d6 100644 --- a/src/api/module/taks/index.ts +++ b/src/api/module/taks/index.ts @@ -12,8 +12,7 @@ export const getTaskList = (params: Param) => }>({ url: 'api/task/summary', method: 'get', - data: params, - + params, }) diff --git a/src/composables/useZMQJsonWorker.ts b/src/composables/useZMQJsonWorker.ts index 845a493..064b23d 100644 --- a/src/composables/useZMQJsonWorker.ts +++ b/src/composables/useZMQJsonWorker.ts @@ -1,15 +1,26 @@ import { WorkerCMD, ZmqCMD, } from '@/utils/zmq' -import type { ManualAction, PublishMsg, PubMsgData, SubMsgData, TimeoutMsg, ZmqMessage } from '@/utils/zmq' +import type { + ManualAction, + PublishMsg, + PubMsgData, + SubMsgData, + TimeoutMsg, + ZmqMessage +} from '@/utils/zmq' import webWorker from '@/utils/zmqJsonWorker?worker' + const env = import.meta.env -const defaultHost = import.meta.env.PROD ? window.location.hostname : '192.168.1.199' +let defaultHost = env.VITE_ZMQ_BASE_URL +if (env.VITE_APP_ENV === 'local') { + defaultHost = window.location.hostname === 'localhost' ? env.VITE_ZMQ_BASE_URL : window.location.hostname +} class ZMQJsonWorker { private static instance: ZMQJsonWorker | null = null; // ➤ 单例实例 private worker: Worker; private scribeHandlers: Map void> = new Map(); private pubTimeoutHandlers: Map void> = new Map(); - private host: string; + private readonly host: string; private statusCallback: ((status: string) => void) | null = null; private isAlwaysListenMsgMap: Map> = new Map(); @@ -64,7 +75,13 @@ class ZMQJsonWorker { if (isAlwaysListen) { this.isAlwaysListenMsgMap.set(`${msg.id}`, msg) } - this.worker.postMessage({ cmd: WorkerCMD.PUBLISH, topic, msg: JSON.stringify(msg), isTimeout, isAlwaysListen }); + this.worker.postMessage({ + cmd: WorkerCMD.PUBLISH, + topic, + msg: JSON.stringify(msg), + isTimeout, + isAlwaysListen + }); } setStatusCallback(callback: (status: string) => void) { @@ -104,7 +121,7 @@ class ZMQJsonWorker { private handleMessage(e: MessageEvent) { const { cmd, msg, topic, community } = e.data; - + console.log(e.data) if (cmd === ZmqCMD.STATUS) { const status = community ? 'disconnected' : 'connected'; if (this.statusCallback) { diff --git a/src/router/index.ts b/src/router/index.ts index ad2c875..e7f6eb0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -53,16 +53,16 @@ export const defaultRouter = [ icon: 'i-mingcute:task-line', } }, - { - path: '/testG6', - name: 'testG6', - component: () => import('@/views/testG6/index.vue'), - meta: { - title: '测试G6', - isShow: true, - icon: 'i-mingcute:task-line', - } - } + // { + // path: '/testG6', + // name: 'testG6', + // component: () => import('@/views/testG6/index.vue'), + // meta: { + // title: '测试G6', + // isShow: true, + // icon: 'i-mingcute:task-line', + // } + // } ], }, ] diff --git a/src/views/firmwareUpload/index.vue b/src/views/firmwareUpload/index.vue index 18826c4..badb7a1 100644 --- a/src/views/firmwareUpload/index.vue +++ b/src/views/firmwareUpload/index.vue @@ -1,17 +1,23 @@