123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <script setup lang="ts">
- import { computed, watch } from 'vue'
- import { useAppStore } from './store/modules/app'
- import { ConfigGlobal } from './components/ConfigGlobal'
- import { useDesign } from './hooks/web/useDesign'
- import { getCodeList, getDeptTree, getDistrictTree } from './api'
- import { useUserStore } from './store/modules/user'
- const { getPrefixCls } = useDesign()
- const prefixCls = getPrefixCls('app')
- const appStore = useAppStore()
- const currentSize = computed(() => appStore.getCurrentSize)
- const greyMode = computed(() => appStore.getGreyMode)
- const userStore = useUserStore()
- appStore.initTheme()
- // 全局存一下字典数据
- const getGlobalCodeList = async () => {
- const {
- success,
- data: { list }
- } = await getCodeList({
- current: 1,
- size: 10000000
- })
- if (success) {
- const formatter = list.map((i) => {
- return {
- codeName: i.codeName,
- codeType: i.codeType,
- codeValue: i.codeValue
- }
- })
- sessionStorage.setItem('CODE_ENUM', JSON.stringify(formatter))
- }
- }
- // 存一下公共部门树
- const getDeptTreeFunc = async () => {
- const { data, success } = await getDeptTree()
- if (success) {
- sessionStorage.setItem('DEPT_TREE', JSON.stringify(data))
- }
- }
- // 存一下行政区划
- const getDistrictFunc = async () => {
- const { data, success } = await getDistrictTree()
- if (success) {
- sessionStorage.setItem('DISTRICT_TREE', JSON.stringify(data))
- }
- }
- // watch(
- // () => userStore.getToken,
- // (val) => {
- // if (val) {
- // getGlobalCodeList()
- // getDeptTreeFunc()
- // getDistrictFunc()
- // }
- // },
- // {
- // immediate: true
- // }
- // )
- </script>
- <template>
- <ConfigGlobal :size="currentSize">
- <RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
- </ConfigGlobal>
- </template>
- <style lang="less">
- @prefix-cls: ~'@{adminNamespace}-app';
- .size {
- width: 100%;
- height: 100%;
- }
- html,
- body {
- padding: 0 !important;
- margin: 0 !important;
- overflow: hidden;
- .size;
- #app {
- .size;
- }
- }
- .@{prefix-cls}-grey-mode {
- filter: grayscale(100%);
- }
- </style>
|