base.js
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import GlsxVueComponents from 'glsx-vue-components'
// import 'glsx-vue-components/dist/glsx-vue-components.css'
import { Request as request } from 'glsx-vue-common'
import '@/styles/index.css'
// 组件
import '@/components'
import { Util } from './common/util'
// import _ from 'lodash'
// import axios from 'axios'
Vue.prototype.btn_size = 'mini'
Vue.prototype.$Utils = Util
Vue.use(ElementUI)
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)
})
})
},
methods: {
/**
* 页面跳转方法 用法 :
* 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) {
console.log(path, params, '000')
if (this.$$parent) {
this.$$parent.to(path, params)
} else {
this.$$connection.promise.then((parent) => {
parent.to(path, params)
})
}
},
close(title) {
this.$$parent.close(title)
},
},
}
const URL =
'https://oss-config.dev.glsx.com.cn/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/task-config') => {
return new Promise((resolve, reject) => {
request({ url }).then((res) => {
if (res.status === 'success') {
resolve({ vue: Vue, config: JSON.parse(res.data) })
} else {
reject('ERROR.')
}
})
})
}
/* eslint-disable no-new */
const render = (App) => {
window.vm = new Vue({
el: '#app',
mixins: [mixin],
render: (h) => h(App),
})
}
export default { render, getConfig }