Skip to content

Commit

Permalink
optimize: 捕获页面加载过程中的异常,并打印在控制台中。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Jan 22, 2025
1 parent 6d57101 commit bd1b5b2
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions packages/gui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,36 @@ import 'ant-design-vue/dist/antd.css'
import './view/style/index.scss'
import './view/style/theme/dark.scss' // 暗色主题

Vue.config.productionTip = false
Vue.use(antd)
Vue.use(VueRouter)
Vue.component(DsContainer)
// 3. 创建 router 实例,然后传 `routes` 配置
// 你还可以传别的配置参数, 不过先这么简单着吧。
const router = new VueRouter({
routes, // (缩写) 相当于 routes: routes
})
const app = new Vue({
router,
render: h => h(App),
})
view.initApi(app).then(async (api) => {
// 初始化status
await view.initPre(Vue, api)
app.$mount('#app')
view.initModules(app, router)
})
try {
Vue.config.productionTip = false
Vue.use(antd)
Vue.use(VueRouter)
Vue.component(DsContainer)
// 3. 创建 router 实例,然后传 `routes` 配置
// 你还可以传别的配置参数, 不过先这么简单着吧。
const router = new VueRouter({
routes, // (缩写) 相当于 routes: routes
})
const app = new Vue({
router,
render: h => h(App),
})
view.initApi(app).then(async (api) => {
// 初始化status
await view.initPre(Vue, api)
app.$mount('#app')
view.initModules(app, router)
})

// fix vue-router NavigationDuplicated
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return VueRouterPush.call(this, location).catch(err => err)
}
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return VueRouterReplace.call(this, location).catch(err => err)
// fix vue-router NavigationDuplicated
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return VueRouterPush.call(this, location).catch(err => err)
}
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return VueRouterReplace.call(this, location).catch(err => err)
}
} catch (e) {
console.error('页面加载出现未知异常:', e)
}

0 comments on commit bd1b5b2

Please sign in to comment.