<template>
  <div></div>
</template>

<script>
import store from "@/store";
import router from "@/router";
export default {
  name: "home",
  beforeCreate() {
    const getFirstPageName = (list) => {
      const [first] = list || [];
      if (first.children?.length > 0) {
        return getFirstPageName(first.children);
      }
      return first?.name || null;
    };
    const firstPage = getFirstPageName(store.getters.sidebarRouters);
    if (firstPage) {
      router.replace({ name: firstPage });
    } else {
      router.replace("/401");
    }
  },
};
</script>

<style scoped lang="scss"></style>
