import { useAppStore } from "@/store/appStore";

export const useEnv = () => {
  const { sysInfo } = useAppStore();
  const { uniPlatform } = sysInfo;
  const platform = computed(() => {
    if (uniPlatform === 'mp-weixin') {
      return 'mp';
    } else if (uniPlatform === 'web') {
      return window?.platform || 'h5';
    }
  });
  const isH5 = computed(() => platform.value === "h5");
  const isWap2App = computed(() => platform.value === "wap2app");
  const isMP = computed(() => platform.value === "mp");
  const isAndroid = computed(() => sysInfo.platform.toLowerCase() == 'android')
  const isIOS = computed(() => sysInfo.platform.toLowerCase() == 'ios')

  return {
    platform,
    isH5,
    isWap2App,
    isMP,
    isAndroid,
    isIOS
  }
}