import { createApp } from 'vue'
import App from './App.vue'
import directive from './directive'
import router from './router'
import { createPinia } from 'pinia'
import PiniaPluginPersist from './plugins/pinia-plugin-persist'

import '@/utils/mathjax' // 必须在引入mathjax前引入mathjax的配置文件
// import "mathjax/es5/tex-mml-chtml"; // 使用 tex-mml-chtml
import 'mathjax/es5/tex-mml-svg'

import './styles/element-plus.scss'
import './styles/global.scss'
import './styles/vxe.scss'
import './styles/homeWorkCSS/style.css'
import './styles/homeWorkCSS/style.scss'
// import './styles/qml-preview.css'

import 'vxe-pc-ui/lib/style.css'
import 'vxe-table/lib/style.css'
import sass from './utils/sass'

// 初始化图标
const favicon = document.getElementById('sass-favicon') as HTMLLinkElement
favicon.href = sass.getLogo()
// 初始化标题
const title = document.getElementById('sass-title') as HTMLTitleElement
title.innerHTML = sass.platform.appName

const pinia = createPinia()
pinia.use(PiniaPluginPersist)

createApp(App).use(router).use(directive).use(pinia).mount('#app')

export function resetAllStores() {
  if (!pinia) {
    console.error('Pinia is not installed')
    return
  }
  const allStores = (pinia as any)._s
  for (const [_key, store] of allStores) {
    store.$reset?.()
  }
}
