import { createSSRApp } from "vue";
import App from "./App";
import store from "./store"; // store
import plugins from "./plugins"; // plugins
import "./permission"; // permission

// 引入json导出组件
import JsonExcel from "vue-json-excel";

// 引入UI组件
import uviewPlus from "@/uni_modules/uview-plus";
import oaCalendar from "@/components/oa-calendar/uni-calendar";
import oaTabbar from "@/components/oa-tabbar/index";
import oaTimeLine from "@/components/oa-timeLine/index"
import oaTimeLineItem from "@/components/oa-timeLine-item/index"
import oaUpload from "@/components/oa-upload/index"
import oaScroll from "@/components/oa-scroll/index"
import oaTouch from "@/components/oa-touch/index"
import oaDropdown from "@/components/oa-dropdown/index"
import oaUpgrade from "@/components/oa-upgrade/index"
import oaTransForm from "@/components/oa-transForm/index"
import oaTtsAudio from "@/components/oa-ttsAudio/index"
import oaWeather from "@/components/oa-weather/index"

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

  //挂载全局组件
  app.component('oa-calendar', oaCalendar)
  app.component('oa-tabbar', oaTabbar)
  app.component('oa-timeLine', oaTimeLine)
  app.component('oa-timeLine-item', oaTimeLineItem)
  app.component('oa-upload', oaUpload)
  app.component('oa-scroll', oaScroll)
  app.component('oa-touch', oaTouch)
  app.component('oa-dropdown', oaDropdown)
  app.component('oa-upgrade', oaUpgrade)
  app.component('oa-transForm', oaTransForm)
  app.component('oa-ttsAudio', oaTtsAudio)
  app.component('oa-weather', oaWeather)
  

  // 挂载全局json导出
  app.component("downloadExcel", JsonExcel);
  // 添加全局变量
  app.provide("$store", store);
  app.config.globalProperties.$store = store;

  app
    .use(uviewPlus)
    .use(store)
    .use(plugins);

  return {
    app,
  };
}
