import { createSSRApp } from 'vue'
import App from './App'
import { i18n } from './locale'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { useImg, systemInfo, format } from './utils';
import Theme from "@/components/theme"
import trans from "@/components/trans"
import uviewPlus from '@/uni_modules/uview-plus'

const systemInfoName = systemInfo();
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

export function createApp() {
  const app = createSSRApp(App);
  app.config.globalProperties.$adjustPosition = systemInfoName.osName == 'ios' ? true : false;
  app.config.globalProperties.$useImg = useImg;
  app.config.globalProperties.$format = format;

  app.component('Theme', Theme);
  app.component('trans', trans)
  app.use(i18n);
  app.use(pinia);
  app.use(uviewPlus);
  return {
    app
  }
}