import '@/assets/css/define/theme.less'
import '@/assets/css/define/global.less'
import '@/assets/css/dropsize.less'
import '@/assets/css/naive-ui-adjust.less'
import 'uno.css'
import { createApp } from 'vue'
import router from './router'
import App from './App.vue'
import * as plugins from './plugins'
import request from "@/api/index.js";
import { brandConfig } from '@brand-config'

if (window.__POWERED_BY_WUJIE__) {
  // eslint-disable-next-line
  window.__webpack_public_path__ = window.__WUJIE_PUBLIC_PATH__;
}

// 从品牌配置中设置 CSS 变量
function setBrandCSSVariables() {
  const root = document.documentElement
  // 设置主色，统一使用品牌配置的颜色
  root.style.setProperty('--im-primary-color', brandConfig.primaryColor)
  // 设置辅色，统一使用品牌配置的颜色
  root.style.setProperty('--im-secondary-color', brandConfig.secondaryColor)
  // 设置渐变起始色，统一使用品牌配置的颜色
  root.style.setProperty('--im-gradient-start-color', brandConfig.gradientStartColor)
  // 消息气泡背景色也使用品牌主色
  root.style.setProperty('--im-message-right-bg-color', brandConfig.primaryColor)
}

async function bootstrap() {
  // 在应用启动前设置品牌 CSS 变量
  setBrandCSSVariables()

  const app = createApp(App)

  app.use(router)
  
  app.config.globalProperties.$request = request;

  plugins.setPinia(app)
  plugins.setHljsVuePlugin(app)
  plugins.setupNaive(app)
  plugins.setMdEditor(app)
  plugins.setComponents(app)
  plugins.setupDirective(app)

  app.mount('#app')
}

bootstrap()