import { createApp } from 'vue'
import { createPinia } from 'pinia'

// 这三个能力通过函数或指令使用，无法由模板组件扫描自动补充样式。
import 'element-plus/es/components/message/style/css'
import 'element-plus/es/components/message-box/style/css'
import 'element-plus/es/components/loading/style/css'

import App from './App.vue'
import service from '@/api/request'
import router from './router'
import './styles/index.scss'

const app = createApp(App)

app.use(createPinia())
app.use(router)

async function bootstrap() {
  // Mock 仅允许显式开启。开发环境默认联调真实后端契约。
  const shouldEnableMock = import.meta.env.VITE_ENABLE_MOCK === 'true'

  if (shouldEnableMock) {
    const { installMockAdapter } = await import('@/mock/adapter')
    installMockAdapter(service)
  }

  app.mount('#app')
}

void bootstrap()
