Commit 56507c13 authored by Damon's avatar Damon

feat: 增加路由拦截

parent cdf251ba
......@@ -15256,6 +15256,16 @@
"which-boxed-primitive": "^1.0.2"
}
},
"uni-read-pages": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz",
"integrity": "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA=="
},
"uni-simple-router": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.6.tgz",
"integrity": "sha512-n5gepoT3QcBrvVLeTCY/DjUjC4m1hNzwFlOa1VlCsww/4/34MGfvegpN9OWR8jOxxtUPKGHLAG0yODL/ITCwbw=="
},
"unicode-canonical-property-names-ecmascript": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
......
......@@ -2,7 +2,8 @@ import Vue from 'vue'
import App from './App'
import store from '@/store'
import vuexStore from "@/store/$u.mixin.js"
import {router,RouterMount} from './router.js'
Vue.use(router)
Vue.config.productionTip = false
App.mpType = 'app'
......@@ -24,4 +25,10 @@ Vue.use(httpInterceptor, app)
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
// #ifdef H5
RouterMount(app,router,'#app')
// #endif
// #ifndef H5
app.$mount()
// #endif
......@@ -5,6 +5,7 @@
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"name": "index",
"style": {
"navigationBarTitleText": "题库",
"navigationStyle": "custom",
......@@ -13,6 +14,7 @@
},
{
"path": "pages/index/cert",
"name": "cert",
"style": {
"navigationBarTitleText": "证书",
"navigationStyle": "custom",
......@@ -21,6 +23,7 @@
},
{
"path": "pages/index/mine",
"name": "mine",
"style": {
"navigationBarTitleText": "个人中心",
"disableScroll": true
......@@ -33,6 +36,7 @@
"pages": [
{
"path": "index",
"name": "login",
"style": {
"navigationBarTitleText": "授权登录",
"enablePullDownRefresh": false,
......@@ -46,6 +50,7 @@
"pages": [
{
"path": "detail",
"name": "learnDetail",
"style": {
"navigationBarTitleText": "题库详情"
}
......@@ -57,6 +62,7 @@
"pages": [
{
"path": "detail",
"name": "certDetail",
"style": {
"navigationBarTitleText": "证书详情"
}
......@@ -68,6 +74,7 @@
"pages": [
{
"path": "customer",
"name": "mineCustomer",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "联系客服",
......
import { RouterMount, createRouter } from 'uni-simple-router'
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
routes: [...ROUTES],
})
//全局路由前置守卫
router.beforeEach((to, from, next) => {
next()
})
// 全局路由后置守卫
router.afterEach((to, from) => {
console.log('跳转结束')
})
export { router, RouterMount }
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true )
})
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment