Commit f37b538e by chenwq

配置服务切换

1 parent 80bf9c29
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"glsx-vue-common": "^1.1.20", "glsx-vue-common": "^1.1.20",
"glsx-vue-components": "^1.0.15", "glsx-vue-components": "^1.0.15",
"glsx-common": "^2.10.1",
"node-sass": "^4.9.3", "node-sass": "^4.9.3",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"vee-validate": "^2.1.0-beta.11", "vee-validate": "^2.1.0-beta.11",
......
...@@ -7,6 +7,7 @@ import 'glsx-vue-components/dist/glsx-vue-components.css' ...@@ -7,6 +7,7 @@ import 'glsx-vue-components/dist/glsx-vue-components.css'
import './styles/role-user-common.scss' import './styles/role-user-common.scss'
import './styles/index.scss' import './styles/index.scss'
import './date.js' import './date.js'
import { utils } from 'glsx-common'
import zh_CN from 'vee-validate/dist/locale/zh_CN' import zh_CN from 'vee-validate/dist/locale/zh_CN'
import VeeValidate, { Validator } from 'vee-validate' import VeeValidate, { Validator } from 'vee-validate'
// import VeeValidate from 'vee-validate' // import VeeValidate from 'vee-validate'
...@@ -17,7 +18,7 @@ Vue.component('tree', Tree) ...@@ -17,7 +18,7 @@ Vue.component('tree', Tree)
const config = { const config = {
errorBagName: 'errorBags', errorBagName: 'errorBags',
fieldsBagName: 'fieldBags' fieldsBagName: 'fieldBags',
} }
Vue.use(VeeValidate, config) Vue.use(VeeValidate, config)
Validator.localize('zh_CN', zh_CN) Validator.localize('zh_CN', zh_CN)
...@@ -26,7 +27,7 @@ var mixin = { ...@@ -26,7 +27,7 @@ var mixin = {
data() { data() {
return { return {
connection: null, connection: null,
eventBus: null eventBus: null,
} }
}, },
beforeMount() { beforeMount() {
...@@ -45,36 +46,52 @@ var mixin = { ...@@ -45,36 +46,52 @@ var mixin = {
}, },
$$on(e) { $$on(e) {
_this.eventBus.$emit('event', e) _this.eventBus.$emit('event', e)
} },
} },
}) })
this.connection.promise.then(parent => { this.connection.promise.then((parent) => {
const cfg = _this.$get_session_config() const cfg = _this.$get_session_config()
if (cfg) return if (cfg) return
parent.getResources().then(config => { parent.getResources().then((config) => {
_this.$set_session_config(config) _this.$set_session_config(config)
}) })
}) })
}, },
methods: { methods: {
C2P(_event) { C2P(_event) {
this.connection.promise.then(parent => { this.connection.promise.then((parent) => {
parent.$$emit(_event) parent.$$emit(_event)
}) })
} },
} },
} }
const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config' // const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/authority_common') => { // const getConfig = (url = URL + '/authority_common') => {
return new Promise(resolve => { // return new Promise(resolve => {
const xhr = new XMLHttpRequest() // const xhr = new XMLHttpRequest()
xhr.onreadystatechange = () => { // xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) { // if (xhr.readyState === 4 && xhr.status === 200) {
resolve({ 'vue': Vue, 'config': JSON.parse(xhr.responseText) }) // resolve({ 'vue': Vue, 'config': JSON.parse(xhr.responseText) })
} // }
// }
// xhr.open('GET', url)
// xhr.send()
// })
// }
const getConfig = () => {
let params = {
moduleName: 'glsx-oss-authority',
mockUrl:
'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/authority_common',
httpOptions: {
Headers: { refererurl: location.href },
request: { timeout: 30000 },
},
} }
xhr.open('GET', url) return new Promise((resolve, reject) => {
xhr.send() utils.getConfig(params).then((res) => {
resolve({ vue: Vue, config: res })
})
}) })
} }
/* eslint-disable no-new */ /* eslint-disable no-new */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!