diff --git a/package-lock.json b/package-lock.json index 2c03361..0386d30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "echarts": "^5.6.0", "element-plus": "^2.9.7", "pinia": "^3.0.1", + "qwebchannel": "^6.2.0", "vue": "^3.2.13", "vue-router": "^4.0.3", "vuex": "^4.0.0" @@ -9271,6 +9272,12 @@ ], "license": "MIT" }, + "node_modules/qwebchannel": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/qwebchannel/-/qwebchannel-6.2.0.tgz", + "integrity": "sha512-DfJMFZutES2w/v2L3q6id+RoqG92PxnWIkW6dBQh1Be3mo6y2BEckvNfymXlIyCxks5dz0UbmzKZ2jT1qjOCzw==", + "license": "LGPL-3.0" + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", diff --git a/package.json b/package.json index f1d84b1..1c88b40 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "echarts": "^5.6.0", "element-plus": "^2.9.7", "pinia": "^3.0.1", + "qwebchannel": "^6.2.0", "vue": "^3.2.13", "vue-router": "^4.0.3", "vuex": "^4.0.0" diff --git a/public/index.html b/public/index.html index d4ec971..0b595c3 100644 --- a/public/index.html +++ b/public/index.html @@ -9,7 +9,7 @@ <%= webpackConfig.name %> - + diff --git a/src/router/index.js b/src/router/index.js index aeccb57..50ef926 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -11,6 +11,7 @@ const routes = [ { path: '/nav', name: 'nav', + redirect: '/workBenches', // 默认跳转 component: () => import(/* webpackChunkName: "hostsList" */ '../views/nav.vue'), children: [ { diff --git a/src/utils/pythonBridge.js b/src/utils/pythonBridge.js index 9d4bb67..3e8aef5 100644 --- a/src/utils/pythonBridge.js +++ b/src/utils/pythonBridge.js @@ -12,18 +12,25 @@ export function usePythonBridge() { }; // 调用 Python 方法 - const callPython = (data) => { - if (bridge.value) { - bridge.value.stringFromJs(data); - } + const fetchDataConfig = (data) => { + return new Promise((resolve, reject) => { + if (!bridge.value) { + reject(new Error('返回出错,请检查是否已连接到 Python')); + return; + } + + bridge.value.fetchDataConfig(data, function (result) { + resolve(result); + }); + }); }; // 从 Python 获取数据 - const getPythonData = () => { + const getPythonData = (data) => { if (bridge.value) { - bridge.value.stringToJs(function (result) { - alert(result); - }); + bridge.value.stringToJs(data, function (result) { + alert(result); + }); } }; @@ -31,7 +38,7 @@ export function usePythonBridge() { onMounted(initBridge); return { - callPython, + fetchDataConfig, getPythonData }; } \ No newline at end of file diff --git a/src/utils/storage.js b/src/utils/storage.js index 8d9eb78..972cb5a 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -17,4 +17,11 @@ export function setUser(user) { export function getUser() { return JSON.parse(localStorage.getItem('user')); +} + +export function setNumData(numData) { + localStorage.setItem('num', JSON.stringify(numData)); +} +export function getNumData() { + return JSON.parse(localStorage.getItem('num')); } \ No newline at end of file diff --git a/src/views/hosts/hostsList.vue b/src/views/hosts/hostsList.vue index f00e665..7119deb 100644 --- a/src/views/hosts/hostsList.vue +++ b/src/views/hosts/hostsList.vue @@ -12,65 +12,57 @@ 查询 +
+ + + - - -
- - -
- - - - - - + + +
+
+ +
-
- -
- - - diff --git a/src/views/hosts/workbenches.vue b/src/views/hosts/workbenches.vue index 682dec3..c791b33 100644 --- a/src/views/hosts/workbenches.vue +++ b/src/views/hosts/workbenches.vue @@ -3,31 +3,31 @@
- + - +
- + - +
@@ -35,19 +35,20 @@
- + - +
- 开始获取数据 + 开始获取数据 + 停止获取 重置数据
@@ -55,21 +56,61 @@