<script setup lang="ts">
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { useThemeStore } from '@/stores/theme'
import { isMicro } from '@/config/mainMicro'
import { microName } from '@/config/subMicro'

const locale = zhCn

const themeStore = useThemeStore()
themeStore.initTheme()

if (isMicro) {
  const router = useRouter()
  const route = useRoute()
  watch(
    () => route.path,
    () => {
      window.$wujie?.bus.$emit('sub-route-change', microName, route.path)
    },
    {
      immediate: true
    }
  )

  window.$wujie?.bus.$on(`${microName}-router-change`, (route: string) => {
    router.push(route)
  })
}
</script>

<template>
  <el-config-provider :locale="locale">
    <router-view></router-view>
  </el-config-provider>
</template>

<style scoped></style>
