Commit 56507c13 authored by Damon's avatar Damon

feat: 增加路由拦截

parent cdf251ba
...@@ -15256,6 +15256,16 @@ ...@@ -15256,6 +15256,16 @@
"which-boxed-primitive": "^1.0.2" "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": { "unicode-canonical-property-names-ecmascript": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"flyio": "^0.6.2", "flyio": "^0.6.2",
"regenerator-runtime": "^0.12.1", "regenerator-runtime": "^0.12.1",
"uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.6",
"vue": "^2.6.11", "vue": "^2.6.11",
"vuex": "^3.2.0" "vuex": "^3.2.0"
}, },
......
...@@ -2,7 +2,8 @@ import Vue from 'vue' ...@@ -2,7 +2,8 @@ import Vue from 'vue'
import App from './App' import App from './App'
import store from '@/store' import store from '@/store'
import vuexStore from "@/store/$u.mixin.js" import vuexStore from "@/store/$u.mixin.js"
import {router,RouterMount} from './router.js'
Vue.use(router)
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
...@@ -24,4 +25,10 @@ Vue.use(httpInterceptor, app) ...@@ -24,4 +25,10 @@ Vue.use(httpInterceptor, app)
import httpApi from '@/common/http.api.js' import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app) Vue.use(httpApi, app)
// #ifdef H5
RouterMount(app,router,'#app')
// #endif
// #ifndef H5
app.$mount() app.$mount()
// #endif
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
"name": "index",
"style": { "style": {
"navigationBarTitleText": "题库", "navigationBarTitleText": "题库",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
}, },
{ {
"path": "pages/index/cert", "path": "pages/index/cert",
"name": "cert",
"style": { "style": {
"navigationBarTitleText": "证书", "navigationBarTitleText": "证书",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -21,6 +23,7 @@ ...@@ -21,6 +23,7 @@
}, },
{ {
"path": "pages/index/mine", "path": "pages/index/mine",
"name": "mine",
"style": { "style": {
"navigationBarTitleText": "个人中心", "navigationBarTitleText": "个人中心",
"disableScroll": true "disableScroll": true
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
"pages": [ "pages": [
{ {
"path": "index", "path": "index",
"name": "login",
"style": { "style": {
"navigationBarTitleText": "授权登录", "navigationBarTitleText": "授权登录",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
...@@ -46,6 +50,7 @@ ...@@ -46,6 +50,7 @@
"pages": [ "pages": [
{ {
"path": "detail", "path": "detail",
"name": "learnDetail",
"style": { "style": {
"navigationBarTitleText": "题库详情" "navigationBarTitleText": "题库详情"
} }
...@@ -57,6 +62,7 @@ ...@@ -57,6 +62,7 @@
"pages": [ "pages": [
{ {
"path": "detail", "path": "detail",
"name": "certDetail",
"style": { "style": {
"navigationBarTitleText": "证书详情" "navigationBarTitleText": "证书详情"
} }
...@@ -68,6 +74,7 @@ ...@@ -68,6 +74,7 @@
"pages": [ "pages": [
{ {
"path": "customer", "path": "customer",
"name": "mineCustomer",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTitleText": "联系客服", "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