<template>
  <div class="errPage-container">
    <div class="pan-back-btn" @click="back">
      <el-icon style="margin-right: 5px" class="no-inherit">
        <arrow-left />
      </el-icon>
      返回
    </div>
    <!-- <el-button icon="arrow-left" class="pan-back-btn">
      
    </el-button> -->
    <el-row>
      <el-col :span="12">
        <h1 class="text-jumbo text-ginormous">401错误!</h1>
        <h2>您没有访问权限！</h2>
        <h6 v-if="getAuthority()">
          对不起，您没有访问权限，请不要进行非法操作！您可以返回主页面
        </h6>
        <ul v-if="getAuthority()" class="list-unstyled">
          <li class="link-type">
            <router-link to="/"> 回首页 </router-link>
          </li>
        </ul>
      </el-col>
      <el-col :span="12">
        <img
          :src="errGif"
          width="313"
          height="428"
          alt="Girl has dropped her ice cream."
        />
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import errImage from "@/assets/401_images/401.gif";
import usePermissionStore from "@/store/modules/permission";
import useUserStore from "@/store/modules/user";
let { proxy } = getCurrentInstance();

const errGif = ref(errImage + "?" + +new Date());
function getAuthority() {
  return usePermissionStore().cacheRouters.length;
}
function back() {
  if (!getAuthority()) {
    useUserStore()
      .logOut()
      .then(() => {
        proxy.$router.push({ path: "/login" });
      });
  } else {
    proxy.$router.go(-1);
  }
}
</script>

<style lang="scss" scoped>
.errPage-container {
  width: 800px;
  max-width: 100%;
  margin: 100px auto;
  .pan-back-btn {
    background: #008489;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    border: none !important;
    border-radius: 4px;
    width: 80px;
    cursor: pointer;
  }
  .pan-gif {
    margin: 0 auto;
    display: block;
  }
  .pan-img {
    display: block;
    margin: 0 auto;
    width: 100%;
  }
  .text-jumbo {
    font-size: 60px;
    font-weight: 700;
    color: #484848;
  }
  .list-unstyled {
    font-size: 14px;
    li {
      padding-bottom: 5px;
    }
    a {
      color: #008489;
      text-decoration: none;
      &:hover {
        text-decoration: underline;
      }
    }
  }
}
</style>
