<template>
  <div :class="classes">
    <ul v-if="type === 'rect' && current % 2" class="page-number-rect-list">
      <li
        v-for="n in total"
        :key="n"
        :class="{ 'rect-li-act': n === current }"
      ></li>
    </ul>
    <div v-if="type === 'text'" class="page-number-text-cont">
      第{{ current }}页（共{{ total }}页）
    </div>
  </div>
</template>

<script>
export default {
  name: "PageNumber",
  props: {
    type: {
      type: String,
      default: "text",
      validator(val) {
        return ["text", "rect"].indexOf(val) !== -1;
      },
    },
    total: {
      type: Number,
      default: 1,
    },
    current: {
      type: Number,
      default: 1,
    },
  },
  computed: {
    classes() {
      return ["page-number", `page-number-${this.type}`];
    },
  },
};
</script>
