<script lang="ts" setup>
import { computed } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { ConfigGlobal } from '@/components/ConfigGlobal'
import { useDesign } from '@/hooks/web/useDesign'
import { useCache } from '@/hooks/web/useCache'
import { setCssVar } from '@/utils'

const { getPrefixCls } = useDesign()

const prefixCls = getPrefixCls('app')

const appStore = useAppStore()

const currentSize = computed(() => appStore.getCurrentSize)

const greyMode = computed(() => appStore.getGreyMode)

const { wsCache } = useCache()

// 根据浏览器当前主题设置系统主题色
const setDefaultTheme = () => {
  // if (wsCache.get('isDark')) {
  //   appStore.setIsDark(wsCache.get('isDark'))
  //   return
  // }
  const isDarkTheme = false // isDark()
  appStore.setIsDark(isDarkTheme)

  // 切换标签栏显示时，同步切换标签栏的高度
  setCssVar('--tags-view-height', '0px')
  appStore.setTagsView(false)

  // 菜单置顶
  appStore.setLayout('top')
}

setDefaultTheme()
</script>

<template>
  <ConfigGlobal :size="currentSize">
    <RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
  </ConfigGlobal>
</template>

<style lang="less">
@prefix-cls: ~'@{namespace}-app';

.size {
  width: 100%;
  height: 100%;
}

html,
body {
  padding: 0 !important;
  margin: 0;
  overflow: hidden;
  .size;

  #app {
    .size;
  }
}

.@{prefix-cls}-grey-mode {
  filter: grayscale(100%);
}

.el-transfer {
  --el-transfer-panel-width: 300px;
}
.el-transfer-panel__body {
  padding-right: 30px;
}
</style>
