<template>
  <div class="l-flex c-error-page">
    <div class="c-error-page__img" />
    <div class="l-flex__auto l-flex--col jcenter center c-error-page__main">
      <div class="l-flex--row c-sibling-item--v">
        <img
          class="l-flex__none c-sibling-item"
          src="/logo.png"
        >
        <div class="c-sibling-item far c-error-page__name">{{ title }}</div>
      </div>
      <div class="c-sibling-item--v c-error-page__title">鉴权失败，请稍后重试</div>
      <div
        class="c-error-page__retry u-pointer"
        @click="retry"
      >
        重 试
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'ErrorPage',
  data () {
    return {
      title: process.env.VUE_APP_NAME
    }
  },
  computed: {
    ...mapGetters(['token', 'tenant']),
    message () {
      if (!this.token) {
        return '鉴权失败，请稍后重试'
      }
      if (!this.tenant) {
        return '未知用户，请联系管理员'
      }
      return '未登录'
    }
  },
  methods: {
    retry () {
      window.location.reload()
    }
  }
}
</script>

<style lang="scss" scoped>
.c-error-page {
  width: 100%;
  height: 100%;

  &__img {
    flex: 1 0 400px;
    display: inline-block;
    max-width: 800px;
    background: url("~@/assets/illustration.png") 50% 50% / 757px 613px
      no-repeat;
  }

  @media screen and (max-width: 900px) {
    .c-error-page__img {
      display: none;
    }
  }

  &__main {
    padding: 40px $spacing 180px;
    background-color: #fff;
  }

  &__header {
    margin-bottom: 60px;
  }

  &__name {
    color: $blue;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
  }

  &__title {
    color: $error;
    font-size: 18px;
    font-weight: bold;
  }

  &__retry {
    position: relative;
    margin-top: 40px;
    color: $warning;
    font-size: 16px;

    &:hover {
      color: $warning--light;

      &::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        height: 0;
        bottom: 0;
        border-bottom: 1px solid $warning;
      }
    }
  }
}
</style>
