<script setup lang="ts">
import { computed, onMounted } from "vue";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { ReDialog } from "@/components/ReDialog";
import { useBtnPermissionStore } from "@/store/modules/btnPermission";
import { useSysConfigStoreHook } from "./store/modules/sysConfig";
import { getConfig } from "./api/common/login";

const currentLocale = computed(() => zhCn);
const btnPermissionStore = useBtnPermissionStore();
const sysConfigStore = useSysConfigStoreHook();

onMounted(async () => {
  await btnPermissionStore.fetchPermissions();
  const config : any = await getConfig();
  sysConfigStore.setServerHost(config.serverHost ? config.serverHost : config.data.serverHost);
})
</script>

<template>
  <ElConfigProvider :locale="currentLocale">
    <router-view />
    <ReDialog />
  </ElConfigProvider>
</template>

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