From 2302ff35e85987c0ece8739c4c7352c1fc81267e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=89=91=E6=9C=AF?= <27618209+icjs-cc@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:51:28 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3vscode=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=B1=BB=E5=9E=8B=E2=80=9CIntrinsicElements=E2=80=9D?= =?UTF-8?q?=E4=B8=8A=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=B1=9E=E6=80=A7=E2=80=9C?= =?UTF-8?q?template=E2=80=9D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 8d5bd6a..c0755ed 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,6 @@ ] }, "vueCompilerOptions": { - "target": 3, "plugins": ["@uni-helper/uni-types/volar-plugin"] }, "exclude": ["node_modules"], From 0e77899084dd101de45a5aeee9b6d752ff8888af Mon Sep 17 00:00:00 2001 From: GeraltWang Date: Tue, 10 Dec 2024 09:57:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20env=20utils=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=8B=BC=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useUpload.ts | 4 ++-- src/interceptors/request.ts | 4 ++-- src/utils/index.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hooks/useUpload.ts b/src/hooks/useUpload.ts index b043cfd..adc083d 100644 --- a/src/hooks/useUpload.ts +++ b/src/hooks/useUpload.ts @@ -1,7 +1,7 @@ // TODO: 别忘加更改环境变量的 VITE_UPLOAD_BASEURL 地址。 -import { getEvnBaseUploadUrl } from '@/utils' +import { getEnvBaseUploadUrl } from '@/utils' -const VITE_UPLOAD_BASEURL = `${getEvnBaseUploadUrl()}` +const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}` /** * useUpload 是一个定制化的请求钩子,用于处理上传图片。 diff --git a/src/interceptors/request.ts b/src/interceptors/request.ts index 79c0a49..1f84b31 100644 --- a/src/interceptors/request.ts +++ b/src/interceptors/request.ts @@ -2,7 +2,7 @@ import qs from 'qs' import { useUserStore } from '@/store' import { platform } from '@/utils/platform' -import { getEvnBaseUrl } from '@/utils' +import { getEnvBaseUrl } from '@/utils' export type CustomRequestOptions = UniApp.RequestOptions & { query?: Record @@ -11,7 +11,7 @@ export type CustomRequestOptions = UniApp.RequestOptions & { } & IUniUploadFileOptions // 添加uni.uploadFile参数类型 // 请求基准地址 -const baseUrl = getEvnBaseUrl() +const baseUrl = getEnvBaseUrl() // 拦截器配置 const httpInterceptor = { diff --git a/src/utils/index.ts b/src/utils/index.ts index 70131bf..be21dd6 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -122,7 +122,7 @@ export const needLoginPages: string[] = getAllPages('needLogin').map((page) => p /** * 根据微信小程序当前环境,判断应该获取的BaseUrl */ -export const getEvnBaseUrl = () => { +export const getEnvBaseUrl = () => { // 请求基准地址 let baseUrl = import.meta.env.VITE_SERVER_BASEURL @@ -151,7 +151,7 @@ export const getEvnBaseUrl = () => { /** * 根据微信小程序当前环境,判断应该获取的UPLOAD_BASEURL */ -export const getEvnBaseUploadUrl = () => { +export const getEnvBaseUploadUrl = () => { // 请求基准地址 let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL From 61fa2e773a87880467bdcd382ffdbcf188acb7ba Mon Sep 17 00:00:00 2001 From: fifteen Date: Thu, 12 Dec 2024 16:34:32 +0800 Subject: [PATCH 3/7] =?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 4/7] 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 5/7] 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 6/7] 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", From c47eb871322989b8b919e3ad4ed0294273572e88 Mon Sep 17 00:00:00 2001 From: Burt Date: Tue, 31 Dec 2024 12:18:17 +0800 Subject: [PATCH 7/7] =?UTF-8?q?feat:=20=E8=B7=AF=E7=94=B1=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=85=A8=E9=83=A8=E5=8A=A0=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interceptors/route.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interceptors/route.ts b/src/interceptors/route.ts index fb8ad33..c1f56c3 100644 --- a/src/interceptors/route.ts +++ b/src/interceptors/route.ts @@ -5,7 +5,7 @@ * 我这里应为大部分都可以随便进入,所以使用黑名单 */ import { useUserStore } from '@/store' -import { getNeedLoginPages, needLoginPages as _needLoginPages } from '@/utils' +import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils' // TODO Check const loginRoute = '/pages/login/index' @@ -49,5 +49,7 @@ export const routeInterceptor = { uni.addInterceptor('navigateTo', navigateToInterceptor) uni.addInterceptor('reLaunch', navigateToInterceptor) uni.addInterceptor('redirectTo', navigateToInterceptor) + uni.addInterceptor('navigateBack', navigateToInterceptor) + uni.addInterceptor('switchTab', navigateToInterceptor) }, }