创建小程序
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import App from './App'
|
||||
import store from './store'
|
||||
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import uView from './uni_modules/uview-ui';
|
||||
Vue.use(uView);
|
||||
Vue.config.productionTip = false
|
||||
Vue.prototype.$store = store
|
||||
Vue.prototype.$adpid = "1111111111"
|
||||
Vue.prototype.$backgroundAudioData = {
|
||||
playing: false,
|
||||
playTime: 0,
|
||||
formatedPlayTime: '00:00:00'
|
||||
}
|
||||
|
||||
// i18n部分的配置
|
||||
// 引入语言包,注意路径
|
||||
import Chinese from '@/common/locales/zh.js';
|
||||
import English from '@/common/locales/en.js';
|
||||
import Eyu from '@/common/locales/ru.js';
|
||||
|
||||
// 引入并使用vue-i18n
|
||||
import VueI18n from 'vue-i18n'
|
||||
Vue.use(VueI18n)
|
||||
console.log(uni.getLocale())
|
||||
let i18nConfig = {
|
||||
locale: uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):'zh',// 获取已设置的语言
|
||||
messages: {
|
||||
// 这里的属性名是任意的,您也可以把zh设置为cn等,只是后续切换语言时
|
||||
// 要标识这里的语言属性,如:this.$i18n.locale = zh|en|cn|xxx
|
||||
'zh': Chinese,
|
||||
'en': English,
|
||||
'ru': Eyu,
|
||||
}
|
||||
}
|
||||
// 构造i18n对象
|
||||
const i18n = new VueI18n({
|
||||
// 默认语言,这里的local属性,对应message中的cn、en属性
|
||||
locale:uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):'zh',
|
||||
// 引入语言文件
|
||||
messages: {
|
||||
// 这里的属性名是任意的,您也可以把zh设置为cn等,只是后续切换语言时
|
||||
// 要标识这里的语言属性,如:this.$i18n.locale = zh|en|cn|xxx
|
||||
'zh': Chinese,
|
||||
'en': English,
|
||||
'ru': Eyu,
|
||||
}
|
||||
})
|
||||
|
||||
App.mpType = 'app'
|
||||
Vue.prototype._i18n = i18n
|
||||
const app = new Vue({
|
||||
store,
|
||||
i18n,
|
||||
...App
|
||||
})
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
// #ifdef VUE3
|
||||
import {
|
||||
createSSRApp
|
||||
} from 'vue'
|
||||
import * as Pinia from 'pinia';
|
||||
import Vuex from "vuex";
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
app.use(store)
|
||||
app.use(Pinia.createPinia());
|
||||
app.config.globalProperties.$adpid = "1111111111"
|
||||
app.config.globalProperties.$backgroundAudioData = {
|
||||
playing: false,
|
||||
playTime: 0,
|
||||
formatedPlayTime: '00:00:00'
|
||||
}
|
||||
return {
|
||||
app,
|
||||
Vuex, // 如果 nvue 使用 vuex 的各种map工具方法时,必须 return Vuex
|
||||
Pinia // 此处必须将 Pinia 返回
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
Reference in New Issue
Block a user