import { reactive } from 'vue';
type status = 'init' | 'login' | 'logout' | 'error';

// 是否允许点击空白位置关闭弹窗
export const modalClickMask = false;

export const state = reactive({
  user: {
    status: 'init' as status,
    data: {} as any
  },
  application: window.matchMedia('(display-mode: standalone)').matches, // 是否在应用里面
  navBarHeight: 0, // 状态栏高度
  ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/'
});

// 预览上传到oss的地址
export const getOssUploadUrl = (bucket: string) => {
  const tmpBucket = bucket || 'gym';
  return `https://${tmpBucket}.ks3-cn-beijing.ksyuncs.com/`;
};

export const setLoginInit = () => {
  state.user.status = 'init';
  state.user.data = null;
};

export const setLogin = (data: any) => {
  state.user.status = 'login';
  state.user.data = data;
};

export const setLogout = () => {
  state.user.status = 'logout';
  state.user.data = null;
};

export const setLoginError = () => {
  state.user.status = 'error';
  state.user.data = null;
};
