import { createSSRApp } from 'vue'
import App from './App.vue'

// 1. 引入主题核心方法
import {
  THEME_PRESETS,
  switchTheme,
  getThemeConfigFromStorage,
  initTheme
} from './utils/theme.js'

// 2. 导入主题混入文件
import themeMixin from './mixins/themeMixin.js'


export function createApp() {
  const app = createSSRApp(App)

  // 注册全局混入
  app.mixin(themeMixin)


  // 挂载的全局主题方法
  app.config.globalProperties.$theme = {
    presets: THEME_PRESETS,
    switchTheme: switchTheme,
    getConfig: getThemeConfigFromStorage,
    initTheme: initTheme
  }

  return { app }
}