main.js
5.78 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Vue
import Vue from 'vue'
// import axios from 'axios'
// import i18n from './i18n'
import App from './App'
// 核心插件
import d2Admin from '@/plugin/d2admin'
// store
import store from '@/store/index'
// 针对template模板中使用可选链操作符
import chaining from '@/plugin/chaining'
// 接入sentry
import * as Sentry from '@sentry/vue'
import { BrowserTracing } from '@sentry/tracing'
// import D2Crud from '@d2-projects/d2-crud'
// 菜单和路由设置
import router from './router'
import 'default-passive-events'
import notice from '@/common/notice'
import 'element-ui/lib/theme-chalk/index.css'
// d2Admin 已导入
// import ElementUI from 'element-ui'
// Vue.use(ElementUI)
// import menuHeader from '@/menu/header'
// import menuAside from '@/menu/aside'
// import { frameInRoutes } from '@/router/routes'
// 核心插件
Vue.use(d2Admin)
Vue.use(chaining)
Vue.prototype.notice = notice
const isProd = process.env.NODE_ENV === 'production'
// console.log(isProd)
if (!isProd) {
Vue.config.devtools = true
}
// 实例化
process.env.NODE_ENV === 'production' &&
Sentry.init({
Vue,
dsn: 'https://39bc80d3bb0a419a8d7d9bf5a39678e3@sentry.glsx.com.cn/24',
// dsn: 'http://6225fb8e73fb453a8455a9371f3517da@192.168.3.115:9000/4',
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ['localhost', 'my-site-url.com', /^\//]
})
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
logErrors: true
})
// console.log(test)
// Vue.use(D2Crud)
var baseConfig = {
axios: {
appkey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
}
}
// 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取
fetch(
'http://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config'
)
.then(
response => {
// 处理http响应
return response.json()
},
error => {
// 处理错误
console.log(error)
}
)
.then(response => {
// console.log(response)
const { code, data } = response
code == '200' && (baseConfig = data)
// console.log('data', data)
new Vue({
router,
store,
// i18n,
render: h => {
// data.axios.baseURL =
// 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
Vue.prototype.baseConfig = data
return h(App)
},
// created () {
// 处理路由 得到每一级的路由设置
// this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 (暂时不需要)
// this.$store.commit('d2admin/menu/headerSet', menuHeader)
// 设置侧边栏菜单 (TODO 进行过滤)
// this.$store.commit('d2admin/menu/asideSet', menuAside)
// 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader)
// },
created() {
// 系统配置
Vue.config.devtools = true
// 展示系统信息
this.$store.commit('d2admin/releases/versionShow')
// 用户登录后从数据库加载一系列的设置
this.$store.dispatch('d2admin/account/load')
// 获取并记录用户 UA
this.$store.commit('d2admin/ua/get')
// 初始化全屏监听
this.$store.dispatch('d2admin/fullscreen/listen')
},
mounted() {}
}).$mount('#app')
})
// axios({
// // baseURL: process.env.VUE_APP_REPO + '/dj-car-life-system-config-test',
// // baseURL: process.env.VUE_APP_REPO + '/dj-car-life-system-config',
// baseURL:
// 'http://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config',
// method: 'get'
// // }).then(({ data }) => {
// }).then(({ data }) => {
// // console.log(data)
// // let {data} = res
// console.log(data)
// baseConfig = data
// // 新配置中心写法
// const { data: config, code } = data
// code == '200' && (baseConfig = config)
// // console.log(data)
// // // debugger
// console.log(baseConfig)
// // baseConfig = data.data
// // 先本地切换到测试环境接口
// // data.axios.baseURL = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// new Vue({
// router,
// store,
// // i18n,
// render: h => {
// // data.axios.baseURL =
// // 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// Vue.prototype.baseConfig = data
// return h(App)
// },
// // created () {
// // 处理路由 得到每一级的路由设置
// // this.$store.commit('d2admin/page/init', frameInRoutes)
// // 设置顶栏菜单 (暂时不需要)
// // this.$store.commit('d2admin/menu/headerSet', menuHeader)
// // 设置侧边栏菜单 (TODO 进行过滤)
// // this.$store.commit('d2admin/menu/asideSet', menuAside)
// // 初始化菜单搜索功能
// // this.$store.commit('d2admin/search/init', menuHeader)
// // },
// created() {
// // 系统配置
// Vue.config.devtools = true
// // 展示系统信息
// this.$store.commit('d2admin/releases/versionShow')
// // 用户登录后从数据库加载一系列的设置
// this.$store.dispatch('d2admin/account/load')
// // 获取并记录用户 UA
// this.$store.commit('d2admin/ua/get')
// // 初始化全屏监听
// this.$store.dispatch('d2admin/fullscreen/listen')
// },
// mounted() {}
// }).$mount('#app')
// })
export { baseConfig }