import App from '@/App'
import messages from '@/locale/'
import * as nav from '@/utils/navigate.js'
import storage from "@/utils/storage.js"
import {
	setupI18n,
	i18nConfig
} from '@/locale'

import * as Pinia from 'pinia';

// let i18nConfig = {
// 	locale: uni.getLocale() || "zh-Hans",
// 	messages
// }
console.log('main')
console.log(uni.getLocale())
// #ifndef VUE3
import Vue from 'vue'
import VueI18n from 'vue-i18n' // v8.x
import './uni.promisify.adaptor'

import '@/uni.scss'

Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	i18n,
	...App
})
Vue.prototype.$nav = nav;
Vue.prototype.$i18n = i18n;
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import {
	createI18n
} from 'vue-i18n' // v9.x
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
const store = Pinia.createPinia();
store.use(piniaPluginPersistedstate); // 使用持久化插件
const i18n = createI18n(i18nConfig)
export function createApp() {
	const app = createSSRApp(App)
	app.config.globalProperties.$nav = nav;
	app.use(store)
	setupI18n(app)
	return {
		app,
		Pinia
	}
}
// #endif