main.js
5.72 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
183
184
185
186
187
188
189
190
191
192
193
/* eslint-disable eqeqeq */
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-29 15:35:47
*/
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import api from './api'
// import { fetchConfig, cfg } from '@/config'
import '@/assets/css/index.scss'
import { bus, tools, store as local, util } from './utils'
import './utils/util'
import 'components'
import { components } from '@/plugins/vant'
components.forEach(component => {
// console.log(component)
Vue.use(component)
})
Vue.prototype.api = api
Vue.prototype.bus = bus
Vue.prototype.tools = tools
Vue.prototype.local = local
Vue.prototype.to = function (name, params) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params })
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'
import VConsole from 'vconsole'
// var baseConfig = {
// axios: {
// appkey: 'd7ffc3346fc9a45bccaaa35300d59022',
// secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
// }
// }
import * as Sentry from '@sentry/vue'
import { BrowserTracing } from '@sentry/tracing'
// 实例化
process.env.NODE_ENV === 'production' &&
Sentry.init({
Vue,
dsn: 'https://f0db411905b541eebe6d591707f561a4@sentry.glsx.com.cn/26',
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
})
let baseConfig = {
// 系统名字
sysName: '嘀加支付宝h5系统',
// // 系统说明
// "subName": '让你的生意慧简单',
// 是否需要注册-true;false
hasReg: false,
// 是否需要配置账号权限;true-有权限,从后台获取权限信息;false-无需权限
hasAuth: false,
vconsole: false,
env: 'production',
appId: '2021003142677540',
// "appId": "2016081500252788",
// "css_url": 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/index.css',
axios: {
// "baseURL": "http://192.168.3.226:9203/rop-dj-smartcarlife/router",
// "baseURL": "https://dj.dev.glsx.com.cn",
// "baseURL": "http://192.168.3.226:9711",
baseURL: 'https://dj.glsx.com.cn',
appkey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353',
timeout: 50000,
result: {
data_key: 'data',
message_key: 'message',
code_key: 'code',
code_success_value: 0,
code_message_map: {}
}
}
}
window.$fetchConfig = baseConfig
// const isMock = ['prod', 'production'].includes(process.env.NODE_ENV)
// 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取
fetch('https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-alipay-config')
.then(
response => {
// 处理http响应
return response.json()
},
error => {
// 处理错误
console.log(error)
}
)
.then(response => {
console.log(response)
const { code, data } = response
if (code == '200') {
console.log(data)
baseConfig = data
console.log('baseConfig', baseConfig)
window.$fetchConfig = data
} else {
baseConfig = response
window.$fetchConfig = response
}
// && ((baseConfig = data), (window.$fetchConfig = data))
})
.catch(el => {
// console.log(el)
// baseConfig = {
// sysName: '嘀加支付宝h5系统',
// hasReg: false,
// hasAuth: false,
// vconsole: true,
// env: 'develop',
// axios: {
// baseURL: 'http://192.168.3.226:9711',
// appkey: '48e5e13229b82c1b4e6e8c96151f0637',
// secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b',
// timeout: 50000,
// result: {
// data_key: 'data',
// message_key: 'message',
// code_key: 'code',
// code_success_value: 0,
// code_message_map: {}
// }
// }
// }
})
.finally(() => {
init()
})
function init() {
console.log(baseConfig, 'baseConfig')
baseConfig.vconsole && new VConsole()
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 }