export default {
  methods: {
    hasAuth(permission) {
      if (permission === "") {
        return true;
      }
      const { state } = this.$store;
      // TODO: 当前模块下- store.state.activatedModule 用户权限 当前系统process.env.SYSTEM_CODE
      const userPermission = state.auth.user?.permissions || [];
      if (!userPermission.length) {
        return false;
      }

      let _permission = [state.adminAuthorityMark];
      if (typeof permission === "string" && permission !== "") {
        _permission.push(permission);
      } else if (Array.isArray(permission)) {
        _permission = [...permission, ..._permission];
      }

      return _permission.some((auth) => userPermission.includes(auth));
    },
  },
};
