diff --git a/package.json b/package.json index 753a2e5..5f9cdbf 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "@uni-helper/uni-ui-types": "^0.5.11", "@uni-helper/unocss-preset-uni": "^0.2.5", "@uni-helper/vite-plugin-uni-pages": "^0.2.13", + "@uni-helper/vite-plugin-uni-platform": "^0.0.4", "@vue/runtime-core": "^3.2.45", "@vue/tsconfig": "^0.1.3", "autoprefixer": "^10.4.16", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c69e1b..f70529f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,6 +112,9 @@ devDependencies: '@uni-helper/vite-plugin-uni-pages': specifier: ^0.2.13 version: 0.2.13(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21) + '@uni-helper/vite-plugin-uni-platform': + specifier: ^0.0.4 + version: 0.0.4 '@vue/runtime-core': specifier: ^3.2.45 version: 3.3.13 @@ -3974,6 +3977,12 @@ packages: - supports-color dev: true + /@uni-helper/vite-plugin-uni-platform@0.0.4: + resolution: {integrity: sha512-aQnhpiLpxlxr6C2i6FsEbY6aFJH1igZUC5DsqoDscD/dBnpCPnovW9bFL/ig8qHsq87iAnqwhZtEpsLrzgrDaw==} + dependencies: + '@uni-helper/uni-env': 0.0.3 + dev: true + /@unocss-applet/preset-applet@0.7.8: resolution: {integrity: sha512-KWzYD88eRf7hMa0SZv8X19eT1X1fwkInM47cjNZ36i/2brt77DSnZF3y61F1zxzdf28SRH/wzgkm2e0I7JepCQ==} dependencies: diff --git a/screenshots/uni-platform.png b/screenshots/uni-platform.png new file mode 100644 index 0000000..e29c678 Binary files /dev/null and b/screenshots/uni-platform.png differ diff --git a/uni-pages.d.ts b/uni-pages.d.ts index 79b9205..6cfba54 100644 --- a/uni-pages.d.ts +++ b/uni-pages.d.ts @@ -7,8 +7,7 @@ interface NavigateToOptions { url: "pages/index/index" | "pages/demo/index" | "pages/my/index" | - "pages/throughout/index" | - "pages/index/components/demo"; + "pages/throughout/index"; } interface RedirectToOptions extends NavigateToOptions {} diff --git a/vite.config.ts b/vite.config.ts index 834291f..9300af3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,9 @@ import { defineConfig, loadEnv } from 'vite' import Uni from '@dcloudio/vite-plugin-uni' // @see https://uni-helper.js.org/vite-plugin-uni-pages import UniPages from '@uni-helper/vite-plugin-uni-pages' +// @see https://github.com/uni-helper/vite-plugin-uni-platform +// 需要与 @uni-helper/vite-plugin-uni-pages 插件一起使用 +import UniPlatform from '@uni-helper/vite-plugin-uni-platform' import dayjs from 'dayjs' import svgLoader from 'vite-svg-loader' import { visualizer } from 'rollup-plugin-visualizer' @@ -44,8 +47,9 @@ export default ({ command, mode }) => { console.log(process.env.UNI_PLATFORM) // 得到 mp-weixin, h5 等 return defineConfig({ plugins: [ - // UniPages() 需要在 Uni() 之前引入 UniPages({ exclude: ['**/components/**/**.*'] }), + UniPlatform(), + // UniXX() 都需要在 Uni() 之前引入 Uni(), UnoCSS(), process.env.UNI_PLATFORM === 'h5' && htmlPlugin(env.VITE_APP_TITLE),