import { createApp } from 'vue'
import './style.css'

import { isElectron } from '@/utils/electron'

if (isElectron()) {
  import('./electron.css')
}

import ArcoVue from '@arco-design/web-vue'
import '@arco-themes/vue-mengtu/index.less'
import '@/styles/store-theme.less'

import ArcoVueIcon from '@arco-design/web-vue/es/icon'

import App from './App.vue'
import { router } from './router/'
import { createPinia } from 'pinia'
import globalComponents from '@/components'
import trimInput from '@/plugins/trimInput'
import { setupResponsiveModal } from '@/plugins/responsiveModal'

setupResponsiveModal()

const app = createApp(App)
app
  .use(ArcoVue)
  .use(trimInput)
  .use(ArcoVueIcon)
  .use(router)
  .use(createPinia())
  .use(globalComponents)
  .mount('#app')

if ('serviceWorker' in navigator && import.meta.env.PROD) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js').catch((error) => {
      console.warn('Service Worker 注册失败：', error)
    })
  })
}
