From 61fa2e773a87880467bdcd382ffdbcf188acb7ba Mon Sep 17 00:00:00 2001 From: fifteen Date: Thu, 12 Dec 2024 16:34:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(tsconfig):=20=E4=BF=AE=E5=A4=8Dz-paging?= =?UTF-8?q?=E5=BA=93=E7=9A=84TS=E7=B1=BB=E5=9E=8B=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index c0755ed..8390fbe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "@dcloudio/types", "@uni-helper/uni-types", "@types/wechat-miniprogram", - "wot-design-uni/global.d.ts" + "wot-design-uni/global.d.ts", + "z-paging/types" ] }, "vueCompilerOptions": { From 22e0bd5cfb47a4927373fe88be6809216f43d046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Thu, 26 Dec 2024 12:24:31 +0800 Subject: [PATCH 2/4] Merge pull request #34 from Lastly1999/main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: app-plus、dev/prod、nativeResources插件未被正确移 --- vite-plugins/copyNativeRes.ts | 39 +++++++++++++++++++++++++++++++++++ vite.config.ts | 29 ++++++++++++++------------ 2 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 vite-plugins/copyNativeRes.ts diff --git a/vite-plugins/copyNativeRes.ts b/vite-plugins/copyNativeRes.ts new file mode 100644 index 0000000..976ad82 --- /dev/null +++ b/vite-plugins/copyNativeRes.ts @@ -0,0 +1,39 @@ +import fs from 'fs-extra' +import path from 'path' + +export function copyNativeRes() { + const waitPath = path.resolve(__dirname, '../src/nativeResources') + const buildPath = path.resolve( + __dirname, + '../dist', + process.env.NODE_ENV === 'production' ? 'build' : 'dev', + process.env.UNI_PLATFORM, + 'nativeResources', + ) + + return { + enforce: 'post', + async writeBundle() { + try { + // 检查源目录是否存在 + const sourceExists = await fs.pathExists(waitPath) + if (!sourceExists) { + console.warn(`[copyNativeRes] 警告:源目录 "${waitPath}" 不存在,跳过复制操作。`) + return + } + + // 确保目标目录及中间目录存在 + await fs.ensureDir(buildPath) + console.log(`[copyNativeRes] 确保目标目录存在:${buildPath}`) + + // 执行文件夹复制 + await fs.copy(waitPath, buildPath) + console.log( + `[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`, + ) + } catch (error) { + console.error(`[copyNativeRes] 复制资源失败:`, error) + } + }, + } +} diff --git a/vite.config.ts b/vite.config.ts index 1d5bfff..0c45d56 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,7 @@ import UnoCSS from 'unocss/vite' import AutoImport from 'unplugin-auto-import/vite' import { visualizer } from 'rollup-plugin-visualizer' import ViteRestart from 'vite-plugin-restart' +import { copyNativeRes } from './vite-plugins/copyNativeRes' // https://vitejs.dev/config/ export default ({ command, mode }) => { @@ -97,13 +98,15 @@ export default ({ command, mode }) => { }, // 打包分析插件,h5 + 生产环境才弹出 UNI_PLATFORM === 'h5' && - mode === 'production' && - visualizer({ - filename: './node_modules/.cache/visualizer/stats.html', - open: true, - gzipSize: true, - brotliSize: true, - }), + mode === 'production' && + visualizer({ + filename: './node_modules/.cache/visualizer/stats.html', + open: true, + gzipSize: true, + brotliSize: true, + }), + // 只有在 app 平台时才启用 copyNativeRes 插件 + UNI_PLATFORM === 'app' && copyNativeRes(), ], define: { __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM), @@ -133,12 +136,12 @@ export default ({ command, mode }) => { // 仅 H5 端生效,其他端不生效(其他端走build,不走devServer) proxy: JSON.parse(VITE_APP_PROXY) ? { - [VITE_APP_PROXY_PREFIX]: { - target: VITE_SERVER_BASEURL, - changeOrigin: true, - rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''), - }, - } + [VITE_APP_PROXY_PREFIX]: { + target: VITE_SERVER_BASEURL, + changeOrigin: true, + rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''), + }, + } : undefined, }, build: { From abff1dac3a30d070388a974fdd524b318790f34f Mon Sep 17 00:00:00 2001 From: Burt Date: Thu, 26 Dec 2024 12:28:50 +0800 Subject: [PATCH 3/4] build: fix ts --- vite-plugins/copyNativeRes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite-plugins/copyNativeRes.ts b/vite-plugins/copyNativeRes.ts index 976ad82..f92aebc 100644 --- a/vite-plugins/copyNativeRes.ts +++ b/vite-plugins/copyNativeRes.ts @@ -7,7 +7,7 @@ export function copyNativeRes() { __dirname, '../dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', - process.env.UNI_PLATFORM, + process.env.UNI_PLATFORM!, 'nativeResources', ) From e1da7afd5889df8c7396a2a39cb3c77442d33e7a Mon Sep 17 00:00:00 2001 From: Burt Date: Thu, 26 Dec 2024 12:31:07 +0800 Subject: [PATCH 4/4] build: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc29425..99d4c06 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unibest", "type": "commonjs", - "version": "2.5.3", + "version": "2.5.4", "description": "unibest - 最好的 uniapp 开发模板", "author": { "name": "feige996",