Files
lucky_shop/main.js
ZF sun 071db2d70c feat(i18n): add remote translation override and hot update support
1. add remote translation override feature with multi-tenant isolation
2. implement hot reload for i18n texts via componentRefresh mechanism
3. add boot timeout fallback and local cache support
4. add events for translation update and fallback state
2026-06-10 14:12:49 +08:00

62 lines
1.5 KiB
JavaScript

// #ifdef H5
import './common/js/pc'
// #endif
import Vue from 'vue'
import App from './App'
import store from './store'
import Util from './common/js/util.js'
import Http from './common/js/http.js'
import Lang from './common/js/lang.js'
import Config from './common/js/config.js'
import EventBus from './common/js/event-bus.js'
import DomEventBridge from './common/js/dom-event-bridge.js'
import globalConfig from './common/js/golbalConfig.js';
import {
uniStorage
} from './common/js/storage.js'
Vue.prototype.$store = store //挂在vue
Vue.config.productionTip = false
Vue.prototype.$util = Util;
Vue.prototype.$api = Http;
Vue.prototype.$langConfig = Lang; //语言包对象
Vue.prototype.$lang = Lang.lang; //解析语言包
Vue.prototype.$config = Config;
// #ifdef H5
EventBus.setDomBridge(DomEventBridge)
// #endif
Vue.prototype.$eventBus = EventBus;
Vue.mixin(globalConfig);
// 远端 i18n 翻译热更新:复用项目原有"componentRefresh"机制(同 diy.js 下拉刷新)
// lang.js 在翻译覆写更新时 commit('setComponentRefresh'),
// golbalConfig.js 已把 componentRefresh 注册为全局 computed,
// 在此 watch 它并 $forceUpdate,触发所有页面内 {{$lang('xxx')}} 重新求值
Vue.mixin({
watch: {
componentRefresh() {
this.$forceUpdate();
}
}
});
App.mpType = 'app';
// 重写存储,增加前缀
uniStorage();
// 组件已改为按需引入,不再全局注册
const app = new Vue({
...App,
store
})
app.$mount()