Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·100 lines (84 loc) · 1.89 KB
/
Copy pathmain.js
File metadata and controls
executable file
·100 lines (84 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import App from './App'
import en from './locale/en.json'
import zhHans from './locale/zh-Hans.json'
const messages = {
en,
'zh-Hans': zhHans
}
function getDefaultLocale() {
try {
const storedLocale = uni.getStorageSync('locale')
console.log('[Language] Stored locale from storage:', storedLocale)
if (storedLocale) {
console.log('[Language] Using stored locale:', storedLocale)
return storedLocale
}
} catch (error) {
console.log('[Language] Failed to get stored locale:', error)
}
// Get system language
var locale = uni.getLocale()
let result
if (locale == 'zh-Hans') {
result = 'zh-Hans'
} else {
result = 'en'
}
console.log('[Language] Final selected locale:', result)
return result
}
let i18nConfig = {
locale: getDefaultLocale(),
messages
}
// #ifndef VUE3
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18nVue2 = new VueI18n(i18nConfig)
Vue.config.productionTip = false
App.mpType = 'app'
import tabBar from "components/tabBar.vue"
Vue.component('tabBar',tabBar)
try {
function isPromise(obj) {
return (
!!obj &&
(typeof obj === "object" || typeof obj === "function") &&
typeof obj.then === "function"
);
}
uni.addInterceptor({
returnValue(res) {
if (!isPromise(res)) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => {
if (res[0]) {
reject(res[0]);
} else {
resolve(res[1]);
}
});
});
},
});
} catch (error) { }
const app = new Vue({
i18n: i18nVue2,
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import { createI18n } from 'vue-i18n'// v9.x
const i18nVue3 = createI18n(i18nConfig)
export function createApp() {
const app = createSSRApp(App)
app.use(i18nVue3)
return {
app
}
}// #endif