<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="main animate__animated animate__backInRight">
          <home1 v-if="user.role_type == '0' || user.role_type == '1'"></home1>
          <home2 v-else-if="user.role_type == '2'" :is_role="is_role"></home2>
          <home3 v-else-if="user.role_type == '3'" :is_role="is_role"></home3>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import type { Ref } from 'vue';
import store from '@/stores/counter';
import { ref, onMounted } from 'vue';
import home1 from './parts/home-1.vue';
import home2 from './parts/home-2.vue';
import home3 from './parts/home-3.vue';
let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string; role_type: string }> = ref({
  _id: '',
  name: '',
  unit_name: '',
  nick_name: '',
  role_type: '',
});
let is_role: Ref<boolean> = ref(true);
onMounted(async () => {
  user.value = store.state.user as { _id: string; name: string; unit_name: string; nick_name: string; role_type: string };
  await searchRole();
});
// 查询
const searchRole = async () => {
  let role = localStorage.getItem('is_role');
  if (role) is_role.value = JSON.parse(role);
};
</script>

<style scoped></style>
