import { createApp } from "vue";
import { globalComponentRegister } from "./global";
import store from "./store";
import api from "@/api";
import { ElMessage } from "element-plus";
import variables from "@/utils/variables";
import App from "./App.vue";
import router from "./router";

const app = createApp(App).use(store).use(router).use(globalComponentRegister);
app.directive("teacher-permission", {
  mounted(el, binding) {
    if (binding.value.role !== "TEACHER") {
      el.parentNode.removeChild(el);
    }
  },
});
app.directive("student-permission", {
  mounted(el, binding) {
    if (binding.value.role !== "STUDENT") {
      el.parentNode.removeChild(el);
    }
  },
});

app.config.productionTip = false;
app.config.globalProperties.$apis = api;
app.config.globalProperties.$message = ElMessage;
app.config.globalProperties.$variables = variables;
app.mount("#app");
