base.js 3.38 KB
/*
 * @Descripttion:
 * @version:
 * @Author: limin
 * @Date: 2021-03-31 00:05:24
 * @LastEditors: limin
 * @LastEditTime: 2021-03-31 00:38:50
 */
// 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 Vue from 'vue'
import GlsxVueComponents from 'glsx-vue-components'
import 'glsx-vue-components/dist/glsx-vue-components.css'
import './styles/index.css'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
//引用富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
//引入富文本css
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

// import zh_CN from 'vee-validate/dist/locale/zh_CN'
// const {
//   Validator
// } = VeeValidate
// import VueI18n from 'vue-i18n'
// Vue.use(VueI18n)
// const i18n = new VueI18n({
//   locale: 'zh_CN'
// })
import '@/components'
import './utils/util.js'
Vue.use(GlsxVueComponents)
var mixin = {
  data() {
    return {
      eventBus: new Vue()
    }
  },
  mounted() {
    const _this = this
    const theme = new this.$Theme()
    const connection = this.$Penpal.connectToParent({
      methods: {
        setTheme(color) {
          theme.change(color)
        },
        height() {
          return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight //
        },
        translate(params) {
          _this.eventBus.$emit('params', params)
        }
      }
    })
    connection.promise.then(parent => {
      // const cfg = _this.$get_session_config()
      _this.$$parent = parent
        // if (cfg) return
      parent.getResources().then(config => {
        _this.$set_session_config(config)
        _this.init()
      })
    })
  },
  methods: {
    init() {
      this.$children[0].flag = true
      this.$children[0].init && this.$children[0].init()
    },
    /**
     * 页面跳转方法 用法 :
     * this.$root.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
     * 或:
     * this.$parent.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
     *
     * @param {*} path  如:  ['一级菜单名称','二级菜单名称','三级菜单名称','四级菜单名称','五级菜单名称']
     * @param {*} params 传给下一个页面的参数
     */
    to(path, params) {
      if (this.$$parent) {
        this.$$parent.to(path, params)
      } else {
        this.$$connection.promise.then(parent => {
          parent.to(path, params)
        })
      }
    }
  },

}
const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/oss_dj_equity_config') => {
    return new Promise(resolve => {
      const xhr = new XMLHttpRequest()
      xhr.onreadystatechange = () => {
        if (xhr.readyState === 4 && xhr.status === 200) {
          let config = JSON.parse(xhr.responseText)
          window.$config = config
          resolve({
            'vue': Vue,
            'config': config
          })
        }
      }
      xhr.open('GET', url)
      xhr.send()

    })
  }
  /* eslint-disable no-new */
const render = App => {
  window.vm = new Vue({
    el: '#app',
    mixins: [mixin],
    render: h => h(App)
  })
}
export default {
  render,
  getConfig,
}