<template>
  <router-view />
  <el-container style="height: 100%">
    <el-aside width="200px" style="overflow-x: hidden">
      <el-menu>
        <el-submenu index="1">
          <template #title
            ><i class="el-icon-message"> </i><span> 大分类A</span></template
          >
          <el-menu-item index="1-1">A.小分类a</el-menu-item>
          <el-menu-item index="1-2">A.小分类b</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-aside
      style="
        width: 200px;
        height: 100%;
        border: 1px solid #eee;
        background-color: #ffe;
        text-align: center;
        vertical-align: middle;
      "
    >
      模型列表 图片+名称
    </el-aside>

    <el-container>
      <el-header style="text-align: center; font-size: 40px">
        <el-button
          @click="ondrawerbuttonclick"
          type="primary"
          style="margin-left: 16px"
        >
          可以添加属性,可以添加到项目,可以添加到打包集合
        </el-button>
      </el-header>

      <el-main>
        <el-button @click="onclickaxios"> login_post</el-button>
        <el-button @click="havelogin"> login_get</el-button>
        <el-button @click="logout"> logout</el-button>
        <br />
        <br />
        <el-button @click="gotologin11"> gotologin</el-button>
        <router-link to="/Login">gotologin</router-link>
      </el-main>
    </el-container>
  </el-container>

  <el-drawer
    v-model="drawer"
    size="70%"
    destroy-on-close
    show-close="true"
    :with-header="false"
  >
    <LoadFBX ref="myfbx" :fbxfilepath="curefbxname"> </LoadFBX>
  </el-drawer>
</template>

<script>
import { isLogin } from "@/api/api.js";
import LoadFBX from "@/components/LoadFBX.vue";
import qs from "qs";
//import { useRouter } from "vue-router";

export default {
  name: "Home",
  components: {
    LoadFBX,
  },
  methods: {
    gotologin11() {
      console.log("goto login");
      this.$router.push("Login");
    },
    ondrawerbuttonclick() {
      this.curefbxname =
        this.fbxnamelist[this.count++ % this.fbxnamelist.length]; //索引自加1  取余fbx列表数量
      console.log("click : " + this.curefbxname); // ! 打印信息  审查自己name是否正确
      this.drawer = true; // 打开`抽屉`控件
    },
    onclickaxios() {
      console.log("nihao");
      var fdata = qs.stringify({
        name: "123",
        email: "2@qq.com",
        password: "123456789",
        remember: "on",
      });
      this.axios
        .post("/login", fdata, { withCredentials: true })
        .then((response) => {
          console.log(response.data);
        });
    },
    havelogin() {
      isLogin().then((response) => {
        console.log(response.data);
      });
    },
    logout() {
      this.axios
        .post("http://localhost:8070/logout", {}, { withCredentials: true })
        .then((response) => {
          console.log(response.data);
        });
    },
  },
  data() {
    return {
      drawer: false, // 设置为true的时候drawer打开
      fbxnamelist: ["a.fbx", "b.fbx", "Samba Dancing.fbx"], // ! fbx列表,用于测试,后续会删掉
      curefbxname: "a.fbx", // 当前的fbx名称,用于传参用
      count: 0, // ! 一个索引,所随着点击次数增加,使用的时候要取余,在正式代码中会删掉
    };
  },
};
</script>

<style lang="scss" scoped>
.el-main {
  padding: 0px;
}
</style>
