test

作者: 蓝色海洋_1982 | 来源:发表于2017-05-30 21:24 被阅读0次

如何写main.js

// 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 Vuefrom 'vue'

import Appfrom './App'

import routerfrom './router'

import VueResourcefrom 'vue-resource'

import hwGlobal from './assets/js/hwGolbal'

import axios from 'axios'

import storefrom './store'

import apifrom './config/api'

import ElementUIfrom 'element-ui'

import Echartsfrom 'echarts'

import base64from 'js-base64'

import base64Urlfrom 'base64-url'

import 'element-ui/lib/theme-default/index.css'

import './assets/css/index.css'

import '@/assets/css/JensenCSS.css'

import '@/assets/css/JaneCSS.css'

import utilsfrom './assets/js/utils.js'

import csbValidator from './assets/js/CSBValidator'

import csbDrag from './assets/js/CSBDrag'

import VueI18nfrom 'vue-i18n'

import speechSDKfrom '@/assets/js/speech.browser.sdk.js'

import recorderfrom '@/assets/js/recorder.js'

import jsPlumbfrom 'jsplumb'

import 'jsplumb/css/jsplumbtoolkit-defaults.css'

Vue.use(VueI18n)

Vue.use(VueResource)

Vue.use(ElementUI)

Vue.use(hwGlobal)

Vue.use(csbValidator.install)

Vue.use(csbDrag.install)

//

const i18n =new VueI18n({

locale:'zh',//

  messages: {

'zh':require('@/i18n/lang/zh'),

'en':require('@/i18n/lang/en')

}

})

// document.cookie = `_CSB_LANG=zh`;

Object.defineProperty(Vue.prototype,'$echarts', {

value: Echarts

})

Object.defineProperty(Vue.prototype,'$api', {

value: api

})

Object.defineProperty(Vue.prototype,'$base64', {

value: base64

})

Object.defineProperty(Vue.prototype,'$base64Url', {

value: base64Url

})

Object.defineProperty(Vue.prototype,'$axios', {

value: axios

})

Object.defineProperty(Vue.prototype,'$utils', {

value: utils

})

Object.defineProperty(Vue.prototype,'$recorder', {

value: recorder

})

Object.defineProperty(Vue.prototype,'$busEvent', {

value:new Vue({})

})

Object.defineProperty(Vue.prototype,'$speechSDK', {

value:new speechSDK.msSDK.msSDK_install()

})

Object.defineProperty(Vue.prototype,'$jsPlumb', {

value: jsPlumb.jsPlumb

})

Vue.http.interceptors.push((request, next) => {

next((response) => {

var url =window.location.href

    if(response.data.auth&&response.data.auth==="false"&&response.data.msg==="Need login CSB or valid token"){

var xhr =null;

if(window.XMLHttpRequest){

xhr =new XMLHttpRequest();

}else {

xhr =new ActiveXObject('Microsoft.XMLHTTP');

}

xhr.open('GET','rest/sys/env',true)

xhr.send()

//begin ajax

      xhr.onreadystatechange =function(){

if(xhr.readyState ==4){

if(xhr.status ==200){

if(JSON.parse(xhr.response).params[0].value ==='test'){

window.location.href ="https://login-beta.huawei.com/login/?redirect="+encodeURIComponent(url)

}else if (JSON.parse(xhr.response).params[0].value ==='produce'){

window.location.href ="https://login.huawei.com/login/?redirect="+encodeURIComponent(url)

}

}

}

}

//end ajax

    }

if(response.status ===401){

if (url.endsWith('/mark'))

{

}

else

      {

var xhr =null;

if(window.XMLHttpRequest){

xhr =new XMLHttpRequest();

}else {

xhr =new ActiveXObject('Microsoft.XMLHTTP');

}

xhr.open('GET','rest/sys/env',true)

xhr.send()

xhr.onreadystatechange =function(){

if(xhr.readyState ==4){

if(xhr.status ==200){

if(JSON.parse(xhr.response).params[0].value ==='test'){

window.location.href ="https://login-beta.huawei.com/login/?redirect="+encodeURIComponent(url)

}else if (JSON.parse(xhr.response).params[0].value ==='produce'){

window.location.href ="https://login.huawei.com/login/?redirect="+encodeURIComponent(url)

}

}

}

}

// window.location.href = "https://login-beta.huawei.com/login/?redirect="+url

      }

}

})

})

/* eslint-disable no-new */

new Vue({

el:'#app',

router,

store,

i18n,

template:'',

components: { App }

})

相关文章

  • 泰斯拓

    TEST test Test TEST test test test test test test test

  • makedown test

    test test test test test test test ####### test test test...

  • 无标题文章

    test test test test test test test test

  • 2019-01-14

    test test test test test test test test

  • test2

    test test test test test test

  • 简书

    简书 test test test test test test

  • Test

    Test test Test Test Test

  • 无标题文章

    test test test test test

  • 此处为标题?

    测试test测试test测试test测试test测试test测试test测试test测试test测试test测试t...

  • Mardown

    Mardown test+test+test+test+test

网友评论

      本文标题:test

      本文链接:https://www.haomeiwen.com/subject/ovnrfxtx.html