From 697c5df699305a117f3d071054d969b3665e5ef7 Mon Sep 17 00:00:00 2001 From: xiaogang <825201136@qq.com> Date: Fri, 7 Jun 2024 14:21:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=89=93?= =?UTF-8?q?=E5=8C=85=E8=84=9A=E6=9C=AC=E5=88=9D=E6=AD=A5=E5=B0=B1=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages.json | 46 ---------------------------------------- src/types/uni-pages.d.ts | 8 +------ vite.config.ts | 12 ++++++++++- 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/src/pages.json b/src/pages.json index 8141159..0609871 100644 --- a/src/pages.json +++ b/src/pages.json @@ -38,52 +38,6 @@ ] }, "pages": [ - { - "path": "pages/coupon/index", - "type": "home", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "卡券页" - } - }, - { - "path": "pages/about/about", - "type": "page", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "关于" - } - }, - { - "path": "pages/activity/index", - "type": "page", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "活动页" - } - }, - { - "path": "pages/coupon/order", - "type": "page", - "style": { - "navigationBarTitleText": "订单页" - } - }, - { - "path": "pages/coupon/product", - "type": "page", - "style": { - "navigationBarTitleText": "产品页" - } - }, - { - "path": "pages/index/index", - "type": "page", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "首页" - } - }, { "path": "pages/login/index", "type": "page", diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts index 1c3a2ee..0925902 100644 --- a/src/types/uni-pages.d.ts +++ b/src/types/uni-pages.d.ts @@ -4,13 +4,7 @@ // Generated by vite-plugin-uni-pages interface NavigateToOptions { - url: "/pages/coupon/index" | - "/pages/about/about" | - "/pages/activity/index" | - "/pages/coupon/order" | - "/pages/coupon/product" | - "/pages/index/index" | - "/pages/login/index"; + url: "/pages/login/index"; } interface RedirectToOptions extends NavigateToOptions {} diff --git a/vite.config.ts b/vite.config.ts index 8b38a38..8a480a7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,16 @@ import AutoImport from 'unplugin-auto-import/vite' import { visualizer } from 'rollup-plugin-visualizer' import ViteRestart from 'vite-plugin-restart' +import fs from 'fs' +const pages = fs.readdirSync('./src/pages') +const target = process.argv.slice(2) +const result = pages + .filter((dir) => { + return !target.includes(dir) + }) + .map((ele) => `**/${ele}`) +console.log(result) + // https://vitejs.dev/config/ export default ({ command, mode }) => { // console.log(mode === process.env.NODE_ENV) // true @@ -50,7 +60,7 @@ export default ({ command, mode }) => { plugins: [ UniPages({ - exclude: ['**/components/**/**.*'], + exclude: ['**/components/**/**.*', ...result], routeBlockLang: 'json5', // 虽然设了默认值,但是vue文件还是要加上 lang="json5", 这样才能很好地格式化 // homePage 通过 vue 文件的 route-block 的type="home"来设定 // pages 目录为 src/pages,分包目录不能配置在pages目录下 From 088f8912716813854fcd81ea3b666de718990118 Mon Sep 17 00:00:00 2001 From: xiaogang <825201136@qq.com> Date: Fri, 7 Jun 2024 14:37:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 8a480a7..b97d44d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -25,7 +25,6 @@ const result = pages return !target.includes(dir) }) .map((ele) => `**/${ele}`) -console.log(result) // https://vitejs.dev/config/ export default ({ command, mode }) => {