import { list as classList } from "@/api/device/class";

// 设备分类
export function useDeviceClass() {
  const deviceClassOptions = ref([]);
  const getDevClass = () => {
    classList().then((res) => {
      if (res.code === 0) {
        deviceClassOptions.value = res.data;
      }
    });
  };

  onMounted(() => getDevClass());
  onUnmounted(() => getDevClass());

  return { deviceClassOptions };
}

// 设备类型
export function useDeviceType() {
  const deviceTypeOptions = ref([
    {
      value: 0,
      label: "音响",
    },
    {
      value: 1,
      label: "耳机",
    },
    {
      value: 2,
      label: "穿戴",
    },
  ]);

  return { deviceTypeOptions };
}

// 热门设备
export function useHot() {
  const hotOptions = ref([
    {
      value: 0,
      label: "否",
    },
    {
      value: 1,
      label: "是",
    },
  ]);

  return { hotOptions };
}

// 功能权限
import { list as functionList } from "@/api/device/function";
export function useDeviceFun() {
  const deviceFunOptions = ref([]);

  const getDevFun = () => {
    functionList({ isDelete: 0 }).then((res) => {
      if (res.code === 0) {
        deviceFunOptions.value = res.data;
      }
    });
  };

  onMounted(() => getDevFun());
  onUnmounted(() => getDevFun());

  return { deviceFunOptions };
}

// 设备模式
export function useDeviceMode () {
  const devModeOptions = [{
    value: 1,
    label: '蓝牙',
    disabled: false
  }, {
    value: 2,
    label: 'WIFI',
    disabled: false
  }, {
    value: 3,
    label: '传统蓝牙',
    disabled: false
  }, {
    value: 4,
    label: '4G',
    disabled: false
  }]

  return { devModeOptions }
}