// 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 = () => {
  try {
    return plus.webview.currentWebview().type;
  } catch (e) {
    return "";
  }
};
export const hasPermission = (userPermission) => {
  let userPermissionList = Array.isArray(userPermission)
    ? userPermission
    : [userPermission];
  // 当前用户的权限列表
  let permissionList = uni.getStorageSync("ruleBtn")
    ? uni.getStorageSync("ruleBtn")
    : [];
  console.log(
    "jjajaj",
    userPermissionList.some((e) => permissionList.includes(e), userPermission)
  );
  return userPermissionList.some((e) => permissionList.includes(e));
};