diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 07c1d5f..a97fd25 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -2,6 +2,10 @@ // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 "version": "0.0", "configurations": [{ + "app-plus" : + { + "launchtype" : "local" + }, "default" : { "launchtype" : "local" diff --git a/main.js b/main.js index 7ab0ff0..11f608a 100644 --- a/main.js +++ b/main.js @@ -12,8 +12,14 @@ Vue.prototype.$store = store App.mpType = 'app' const app = new Vue({ ...App -}) -app.$mount() +}) +// #ifdef H5 + RouterMount(app,router,'#app') +// #endif + +// #ifndef H5 + app.$mount(); //为了兼容小程序及app端必须这样写才有效果 +// #endif // #endif // #ifdef VUE3 import { createSSRApp } from 'vue' diff --git a/pages.json b/pages.json index d20e172..c7e0c8e 100644 --- a/pages.json +++ b/pages.json @@ -2,18 +2,21 @@ "pages": [{ "path": "pages/index/index", "name": "Index", + "aliasPath": "/", "style": { "navigationBarTitleText":"发现能量" } }, { "path": "pages/found/index", "name": "Found", + "auth": true, "style": { "navigationBarTitleText":"发现更多" } }, { "path": "pages/user/index", "name": "User", + "auth": true, "style": { "navigationBarTitleText":"节点中心" } @@ -71,6 +74,12 @@ "style": { "navigationBarTitleText":"关联产品" } + }, { + "path": "pages/login/login", + "name": "Login", + "style": { + "navigationBarTitleText":"登录" + } }], "globalStyle": { "navigationStyle": "custom", diff --git a/router/index.js b/router/index.js index 0a49f76..7bfd15d 100644 --- a/router/index.js +++ b/router/index.js @@ -8,6 +8,11 @@ import { RouterMount, createRouter } from 'uni-simple-router'; import store from '../store/index' +// const ROUTESPATH = ROUTES.map(val => { +// val.component: ()=> import('@/' + val.path + '.vue') +// console.log(val) +// }) + const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, routes: [...ROUTES] @@ -17,7 +22,10 @@ const router = createRouter({ router.beforeEach((to, from, next) => { const token = store.getters.getToken || uni.getStorageSync('token') // 检查是否需要登录 - if(to.meta.auth && token === ''){ + if(to.auth && token === ''){ + next({ + name: 'Login' + }) return } next(); diff --git a/vue.config.js b/vue.config.js index 7a5c084..29287c3 100644 --- a/vue.config.js +++ b/vue.config.js @@ -10,7 +10,7 @@ module.exports = { new webpack.DefinePlugin({ ROUTES: webpack.DefinePlugin.runtimeValue(() => { const tfPages = new TransformPages({ - includes: ['path', 'name', 'aliasPath'] + includes: ['path', 'name', 'aliasPath', 'auth'] }); return JSON.stringify(tfPages.routes) }, true)