// export const runTimeEnv = () => {
//   if (plus) {
//     const currentWebView = plus.webview.getWebviewById("wv");
//     return currentWebView.RunTime === "app";
//   } else {
//     return false;
//   }
// };\

export const closeWebview = () => {
  try {
    const currentWebView = plus.webview.getWebviewById("wv");
    currentWebView.close();
  } catch (e) {
    return () => {};
  }
};

// 判断是oa还是墨册
export const OAorMc = () => {
  if (window.plus) {
    const currentWebView = plus.webview.getWebviewById("wv");
    console.log("currentWebView.type", currentWebView.type);
    return currentWebView.type;
  } else {
    return "MC";
  }
};
export const hasPermission = (userPermission) => {
  let userPermissionList = Array.isArray(userPermission)
    ? userPermission
    : [userPermission];
  // 当前用户的权限列表
  let permissionList = uni.getStorageSync("ruleBtn")
    ? uni.getStorageSync("ruleBtn")
    : [];
  return userPermissionList.some((e) => permissionList.includes(e));
};