| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import "./public-path.js"
- import Vue from 'vue'
- import Router from 'vue-router'
- import App from './App'
- import VueI18n from 'vue-i18n'
- import routes from './router/index.js'
- import PcClientComponent from 'pc-client-component';
- // bug fixed by jack
- // 在加载 css 的时候 font 不能被正确的加载
- import './assets/summernote.css';
- Vue.config.productionTip = false
- Vue.use(Router)
- // 国际化
- Vue.use(VueI18n);
- moment.locale('zh');
- let router = null;
- let instance = null;
- let i18n = null;
- function render(props = {}) {
- const { container } = props;
- router = new Router({
- base: window.__POWERED_BY_QIANKUN__ ? ((process.env.NODE_ENV === 'production') ? '/' : '/pcapp/') : '/',
- mode: 'hash',
- routes: routes,
- });
- i18n = new VueI18n({
- locale: 'zh-CN',
- messages: {
- 'zh-CN': require('./lang/zh-CN.js'),
- 'en-US': require('./lang/en-US.js'),
- }
- })
- // PC Client 组件
- Vue.use(PcClientComponent);
- instance = new Vue({
- router,
- i18n,
- render: (h) => h(App),
- }).$mount(container ? container.querySelector('#app-client-trace') : '#app-client-trace');
- }
- // 独立运行时
- if (!window.__POWERED_BY_QIANKUN__) {
- render();
- }
- /**
- * bootstrap 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap。
- * 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
- */
- export async function bootstrap() {
- console.log('[client-trace] bootstraped');
- }
- /**
- * 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
- */
- export async function mount(props) {
- console.log('[client-trace] props from main framework', props);
- render(props);
- }
- /**
- * 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
- */
- export async function unmount() {
- instance.$destroy();
- instance.$el.innerHTML = '';
- instance = null;
- router = null;
- }
|