<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
  import fs from 'fs'
  import path from 'path'
  import {reqBigScreen, reqDevice, reqImportConfigFiles, reqPreviewSourceList} from "./api"

  export default {
    name: 'vedio_app',

    async mounted() {
      // 将配置文件传给服务器
      const formData = new FormData()
      let device = fs.readFileSync(path.join(__static, '/EnityDevice.json'), 'utf8')
      let bigscreen = fs.readFileSync(path.join(__static, '/EnityBigScreen.json'), 'utf8')

      formData.append('device',device)
      formData.append('bigscreen',bigscreen)

      // 发送请求将配置文件传给服务器
      const res = await reqImportConfigFiles(formData)
      if(!res){
        console.log('上传配置文件成功!')
      }

      // 获取大屏,信号源，设备数据并保存到vuex中
      const bigScreenJson = await reqBigScreen()
      const signalListJson = await reqPreviewSourceList()
      const deviceJson = await reqDevice()
      this.$store.dispatch('saveBigscreen',bigScreenJson.filter(item => item.IsVisibility === true))
      this.$store.dispatch('saveSignalList',signalListJson)
      this.$store.dispatch('saveDevice',deviceJson)
    }
  }
</script>

<style>

</style>








