import { delFile, getTransport } from '@/api/common'
import { TransportEnum } from '@/enum/common'
export class CommonController {
  static dataTypeByKeyMap = new Map([
    ['LONG', 'value'],
    ['STRING', 'value'],
    ['JSON', 'value'],
    ['DOUBLE', 'value'],
    ['BOOLEAN', 'value']
  ])

  static async getTransport () {
    const { data } = await getTransport()
    return Object.keys(data).map(key => {
      return {
        port: key,
        address: data[key as TransportEnum]
      }
    })
  }

  static async delOtaPkg (filePath: string, fileName: string) {
    await delFile(filePath, fileName)
  }
}
