viviandjava 5 місяців тому
батько
коміт
4d28d05d0c
3 змінених файлів з 15 додано та 5 видалено
  1. 2 1
      package.json
  2. 7 4
      src/layout/index.vue
  3. 6 0
      vite.config.ts

+ 2 - 1
package.json

@@ -35,7 +35,8 @@
     "vue": "^3.5.12",
     "vue-router": "^4.4.5",
     "vue3-cookies": "^1.0.6",
-    "vue3-marquee": "^4.2.2"
+    "vue3-marquee": "^4.2.2",
+    "x2js": "^3.4.4"
   },
   "devDependencies": {
     "@tsconfig/node20": "^20.1.4",

+ 7 - 4
src/layout/index.vue

@@ -12,7 +12,7 @@ import { getAlarmData } from '@/api/rolldata'
 import { jumpPage } from '@/utils'
 import CrossSection from '@/components/CrossSection.vue'
 import { Vue3Marquee } from 'vue3-marquee'
-
+import X2js from 'x2js';
 const appStore = useAppStore()
 const stationStore = useStationStore()
 const route = useRoute()
@@ -72,10 +72,13 @@ bus.on('handle_ue_response', (data) => {
 
 async function getAlarmInfo() {
   alarmInfo.value = await getAlarmData().then(res => {
-    debugger
-    res.data
+    // 实例化
+    let x2js = new X2js();
+    let xml = res;
+// 将xml解析为我们需要的json对象
+    let json = x2js.xml2js(xml);
+    return json.DataTable.diffgram.DocumentElement.Table.things
   })
-  debugger
 }
 
 onMounted(() => {

+ 6 - 0
vite.config.ts

@@ -32,6 +32,12 @@ export default defineConfig({
         changeOrigin: true,
         rewrite: path => path.replace(/^\/gx_api/, '')
       },
+      '/gx_gj_api': {
+        // 共享平台
+        target: 'http://10.8.4.136:8881/api/sq_zh/',
+        changeOrigin: true,
+        rewrite: path => path.replace(/^\/gx_gj_api/, '')
+      },
       '/nmc_api': {
         // 共享平台
         target: 'http://www.nmc.cn/',