import { createApp } from 'vue' import { createPinia } from 'pinia' import { PiniaLogger } from 'pinia-logger' import App from './App.vue' import router from './router' import { get } from '@/http/http' import { i18n } from '@/i18n' import { useStore } from '@/store' import directives from '@/directives' import { switchLanguage } from '@/plugins/switchLanguage' import '@/assets/scss/index.scss' import 'animate.css/animate.min.css' get('/static/offline/JSON/config.json').then(res => { const app = createApp(App) //全局自定义指令 for (const key in directives) { if (Object.hasOwnProperty.call(directives, key)) { //当key不等于index时注册 因为index是指令出口文件 if (key !== 'index.ts') { const directiveName = key.split('.') app.directive(directiveName[0], directives[key].default) } } } const pinia = createPinia() pinia.use( PiniaLogger({ disabled: process.env.NODE_ENV === 'production', expanded: false, showDuration: true, showStoreName: true, logErrors: true }) ) app.use(pinia) const store = useStore() store.SET_CONFIG(res.data as Record) app.use(router).use(i18n).use(switchLanguage).mount('#app') })