<template>
  <el-config-provider size="default" :z-index="1000" :locale="locale">
    <RouterView />
  </el-config-provider>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn.mjs'
import en from 'element-plus/es/locale/lang/en.mjs'
import { setKeyCode } from '@/store/product'
const language = ref('zh-cn')
const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en))
// 在组件挂载时清空 localStorage
onMounted(() => {
  localStorage.removeItem('socket_connect')
  document.addEventListener('keydown', (e: any) => {
    setKeyCode(e.key)
  })
  document.addEventListener('keyup', () => {
    setKeyCode(null)
  })
})
onUnmounted(() => {
  document.removeEventListener('keydown', (e) => {
    setKeyCode(e.key)
  })
  document.removeEventListener('keyup', () => {
    setKeyCode(null)
  })
})
</script>
<style lang="scss">
body {
  margin: 0;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
}

div {
  box-sizing: border-box;
}
li {
  list-style: none;
}
ul,
li {
  margin: 0;
  padding: 0;
}
</style>
