<template>
  <div class="error-page">
    <div class="content-wrap">
      <h1 v-if="error.statusCode === 404">找不到您要访问的资源！</h1>
      <h1 v-else>{{ error.message }}</h1>
      <p>{{ error.url }} - {{ error.statusCode }}</p>
      <pre v-if="error.statusCode !== 404">错误详情：<br/>{{ errorDetail }}</pre>
      <div class="opera">
        <nuxt-link to="/" class="button">返回首页</nuxt-link>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: {
    error: {}
  },
  computed: {
    errorDetail () {
      return JSON.stringify(this.error, null, 2)
    }
  }
}
</script>

<style scoped lang="scss">
.error-page {
  width: 100%;
  height: 100vh;
  background-color: var(--background-color);
  padding-top: 200px;
  box-sizing: border-box;
  .content-wrap {
    width: 800px;
    margin: 0 auto;
    padding: 50px 100px;
    background-color: var(--color-white);
    text-align: center;
    h1 {
      margin: 0;
    }
    p {
      color: var(--color-gray);
    }
    pre {
      font-size: var(--font-size-small);
      text-align: left;
      white-space: pre-wrap;
      word-break: break-all;
      color: var(--color-gray);
      line-height: 1.5;
    }
    .opera {
      margin-top: 50px;
      display: flex;
      justify-content: center;
      border-top: 1px solid var(--border-color);
      padding-top: 20px;
    }
    .button {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 120px;
      height: 40px;
      background-color: var(--primary-color);
      color: var(--color-white);
    }
  }
}
</style>
