feat::自定义路由

This commit is contained in:
hackrobot
2024-09-26 08:43:29 +08:00
parent 0cfcd0c718
commit bfebed2a2c
2 changed files with 23 additions and 22 deletions

View File

@@ -42,14 +42,15 @@ const config = {
}, },
}, },
h5: { h5: {
webpackChain (chain) { webpackChain(chain) {
chain.module chain.module
.rule('markdown') .rule("markdown")
.test(/\.md$/) .test(/\.md$/)
.use('raw-loader') .use("raw-loader")
.loader('raw-loader') .loader("raw-loader")
.end(); .end();
}, },
esnextModules: ["taro-ui"], esnextModules: ["taro-ui"],
publicPath: "/", publicPath: "/",
staticDirectory: "static", staticDirectory: "static",
@@ -66,17 +67,19 @@ const config = {
}, },
}, },
}, },
// customRoutes: {
// // "页面路径": "自定义路由"
// "/pages/index/index": "/index",
// // '/pages/detail/index': ['/detail'], // 可以通过数组为页面配置多个自定义路由
// "pages/my/index": "/my",
// "pages/meetup/index": "/meetup",
// "pages/meetup/Detail/index": "/detail",
// },
router: { router: {
// basename: '/myapp', // basename: '/myapp',
mode: "hash", // 或者是 'browser' // mode: "hash", // 或者是 'browser'
mode: "browser", // 或者是 'browser'
customRoutes: {
// "页面路径": "自定义路由"
"/pages/index/index": "/",
// '/pages/detail/index': ['/detail'], // 可以通过数组为页面配置多个自定义路由
"pages/my/index": "/my",
"pages/meetup/index": "/meetup",
"pages/meetup/Detail/index": "/detail",
},
}, },
// defineConstants: { // defineConstants: {
// HOST: '"/api"' // HOST: '"/api"'
@@ -85,20 +88,20 @@ const config = {
// host: 'nomad.hackrobot.cn', // 替换为您的域名 // host: 'nomad.hackrobot.cn', // 替换为您的域名
// port: 10087, // 选择一个适当的端口号 // port: 10087, // 选择一个适当的端口号
proxy: { proxy: {
'/api/': { "/api/": {
target: JSON.parse('"http://localhost:8700"'), //本地调试端口 target: JSON.parse('"http://localhost:8700"'), //本地调试端口
pathRewrite: { pathRewrite: {
'^/api/': '/' "^/api/": "/",
}, },
changeOrigin: true changeOrigin: true,
} },
}, },
// 允许特定域名访问 // 允许特定域名访问
allowedHosts: [ allowedHosts: [
// 'bot.hackrobot.cn' // 'bot.hackrobot.cn'
"www.digitalnomadchina.com" "www.digitalnomadchina.com",
], ],
} },
}, },
}; };

View File

@@ -7,8 +7,6 @@ export default {
'pages/group/index', 'pages/group/index',
'pages/book/index', 'pages/book/index',
'pages/salon/index', 'pages/salon/index',
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',