<template>
	<a-config-provider :locale="getAntdLocale">
		<AppDebugActions />
		<RouterView />
	</a-config-provider>
</template>

<script lang="ts" setup>
import { IParam, IProjectSetting } from './core';
import { useLocale } from './locales';
import { toggleTheme } from '@zougt/vite-plugin-theme-preprocessor/dist/browser-utils';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
App.setUIAppInstance(getCurrentInstance() as IParam);
const { getAntdLocale } = useLocale();
dayjs.locale(getAntdLocale.value.locale);

onMounted(() => {
	const codeName = localStorage.getItem('theme-class');
	if (codeName) {
		toggleTheme({ scopeName: codeName });
	} else {
		localStorage.setItem('theme-class', 'theme-default');
		toggleTheme({ scopeName: 'theme-default' });
	}
	const projectSetting: IProjectSetting = App.getProjectSetting();
	const body = document.querySelector('body');
	if (projectSetting.grayMode) {
		if (body) {
			body.style.filter = 'grayscale(1)';
		}
	}
	if (projectSetting.colorWeak) {
		if (body) {
			body.style.filter = 'invert(80%)';
		}
	}
});
</script>
<style lang="less">
#app {
	width: 100%;
	height: 100%;
}
</style>
