main.js
3.02 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
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-08-22 15:11:57
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-08-22 15:19:05
* @FilePath: \scrm-base\src\main.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import * as Sentry from '@sentry/vue'
import webSee from '@websee/core'
import performance from '@websee/performance'
import recordscreen from '@websee/recordscreen'
import { BrowserTracing } from '@sentry/tracing'
import { Http } from 'glsx-common'
import '@/common/reg-prototype.js'
import '@/common/error-handler.js'
import { fetchConfig, config } from '@/config/index'
import '@/assets/style/index.scss'
// import '@/assets/images/sprite/sprite.css'
import './components'
import './filters'
import { Message } from './plugins/element.js'
Vue.config.productionTip = false
Vue.prototype.$event = new Vue()
if (process.env.NODE_ENV === 'production') {
Sentry.init({
Vue,
dsn: 'https://c4344b1745b14d839d6683e2b7aa5a44@sentry.glsx.com.cn/22',
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ['localhost', 'http://192.168.3.172', 'scrm.glsx.com.cn', 'scrm.test.glsx.com.cn', 'scrm.beta.glsx.com.cn', 'scrm.cgacar.com', 'scrm.beta.cgacar.com', /^\//]
})
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0
})
}
Vue.use(webSee, {
dsn: 'http://192.168.1.127:8083/reportData', // 上报的地址
apikey: 'scrm', // 项目唯一的id
userId: 'scrm', // 用户id
repeatCodeError: true, // 开启错误上报去重,重复的代码错误只上报一次
silentWhiteScreen: true, // 开启白屏检测
skeletonProject: true, // 项目是否有骨架屏
handleHttpStatus(data) {
// 自定义hook, 根据接口返回的 response 判断请求是否正确
let { url, response } = data
let { code } = typeof response === 'string' ? JSON.parse(response) : response
if (url.includes('/getErrorList')) {
return code === 200 ? true : false
} else {
return true
}
}
})
// 注册性能检测插件
webSee.use(performance)
// 注册页面录屏插件,设置单次录屏时长为20s,默认是10s
webSee.use(recordscreen, { recordScreentime: 10 })
var instance = null
async function render() {
const cfg = await fetchConfig(false)
const { response, request, sign, secret } = cfg
Vue.use(config, cfg)
const http = new Http({ response, request, sign, secret, alert: Message.error })
Vue.prototype.$http = http
instance = new Vue({
router,
store,
render: h => h(App)
}).$mount('#main')
}
export const http = params => Vue.prototype.$http(params)
export const This = key => instance[key]
render()