From 75ad9af648284787f0874af9a9bf708ca6411d07 Mon Sep 17 00:00:00 2001 From: Burt Date: Wed, 1 Jan 2025 18:07:46 +0800 Subject: [PATCH 01/26] =?UTF-8?q?fix:=20navigateBack=20=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E6=8B=A6=E6=88=AA,=E5=AF=BC=E8=87=B4BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interceptors/route.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/interceptors/route.ts b/src/interceptors/route.ts index c1f56c3..ddd6c98 100644 --- a/src/interceptors/route.ts +++ b/src/interceptors/route.ts @@ -49,7 +49,6 @@ export const routeInterceptor = { uni.addInterceptor('navigateTo', navigateToInterceptor) uni.addInterceptor('reLaunch', navigateToInterceptor) uni.addInterceptor('redirectTo', navigateToInterceptor) - uni.addInterceptor('navigateBack', navigateToInterceptor) uni.addInterceptor('switchTab', navigateToInterceptor) }, } From f96a9839851b251e2d43563437aa84294475ef0b Mon Sep 17 00:00:00 2001 From: Burt Date: Sat, 4 Jan 2025 21:15:50 +0800 Subject: [PATCH 02/26] style(vite.config.ts): format --- vite.config.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 0c45d56..f0fec23 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,7 @@ -import path from 'node:path' -import { execSync } from 'node:child_process' -import dayjs from 'dayjs' -import { defineConfig, loadEnv } from 'vite' import Uni from '@dcloudio/vite-plugin-uni' +import dayjs from 'dayjs' +import path from 'node:path' +import { defineConfig, loadEnv } from 'vite' // @see https://uni-helper.js.org/vite-plugin-uni-pages import UniPages from '@uni-helper/vite-plugin-uni-pages' // @see https://uni-helper.js.org/vite-plugin-uni-layouts @@ -13,9 +12,9 @@ import UniPlatform from '@uni-helper/vite-plugin-uni-platform' // @see https://github.com/uni-helper/vite-plugin-uni-manifest import UniManifest from '@uni-helper/vite-plugin-uni-manifest' // @see https://unocss.dev/ +import { visualizer } from 'rollup-plugin-visualizer' 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' @@ -98,13 +97,13 @@ 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(), ], @@ -136,12 +135,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 466724080e4360d6f86c20db84592bc3e92b129b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Mon, 6 Jan 2025 13:32:39 +0800 Subject: [PATCH 03/26] Merge pull request #42 from Rem-Blove/main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 枚举失效问题 & 分离全局声明和模块化内容 --- src/pages/index/index.vue | 2 ++ src/typings.d.ts | 28 ++++++++++++++++++++++++++++ src/typings.ts | 31 ++++--------------------------- tsconfig.json | 3 ++- 4 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 src/typings.d.ts diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 84d3606..59da0ab 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -31,6 +31,7 @@ diff --git a/src/typings.d.ts b/src/typings.d.ts new file mode 100644 index 0000000..0ab0858 --- /dev/null +++ b/src/typings.d.ts @@ -0,0 +1,28 @@ +// 全局要用的类型放到这里 + +declare global { + type IResData = { + code: number + msg: string + data: T + } + + // uni.uploadFile文件上传参数 + type IUniUploadFileOptions = { + file?: File + files?: UniApp.UploadFileOptionFiles[] + filePath?: string + name?: string + formData?: any + } + + type IUserInfo = { + nickname?: string + avatar?: string + /** 微信的 openid,非微信没有这个字段 */ + openid?: string + token?: string + } +} + +export {} // 防止模块污染 diff --git a/src/typings.ts b/src/typings.ts index 06354be..016e462 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -1,29 +1,6 @@ -// 全局要用的类型放到这里 +// 枚举定义 -type IResData = { - code: number - msg: string - data: T -} - -// uni.uploadFile文件上传参数 -type IUniUploadFileOptions = { - file?: File - files?: UniApp.UploadFileOptionFiles[] - filePath?: string - name?: string - formData?: any -} - -type IUserInfo = { - nickname?: string - avatar?: string - /** 微信的 openid,非微信没有这个字段 */ - openid?: string - token?: string -} - -enum TestEnum { - A = 'a', - B = 'b', +export enum TestEnum { + A = '1', + B = '2', } diff --git a/tsconfig.json b/tsconfig.json index 8390fbe..495932e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,8 @@ "@uni-helper/uni-types", "@types/wechat-miniprogram", "wot-design-uni/global.d.ts", - "z-paging/types" + "z-paging/types", + "./src/typings.d.ts" ] }, "vueCompilerOptions": { From 732f286ac1b8b0cf084317a2cd0d09d4fad767df Mon Sep 17 00:00:00 2001 From: Burt Date: Mon, 6 Jan 2025 13:57:55 +0800 Subject: [PATCH 04/26] =?UTF-8?q?fix:=20miniProgram=20=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E4=B8=8D=E5=90=8C=E7=9A=84=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 6 +++++- env/.env | 10 ++++++++++ src/utils/index.ts | 22 +++++++++++----------- src/utils/platform.ts | 7 +++++++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fec1619..4990c35 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,6 +36,7 @@ "manifest.json": "jsonc" // manifest.json 可以写注释 }, "cSpell.words": [ + "Aplipay", "climblee", "commitlint", "dcloudio", @@ -44,9 +45,12 @@ "refresherrefresh", "scrolltolower", "tabbar", + "Toutiao", "unibest", "uvui", - "WechatMiniprogram" + "Wechat", + "WechatMiniprogram", + "Weixin" ], "typescript.tsdk": "node_modules\\typescript\\lib", // 控制相关文件嵌套展示 diff --git a/env/.env b/env/.env index 03c7ecf..b842e46 100644 --- a/env/.env +++ b/env/.env @@ -10,6 +10,16 @@ VITE_APP_PUBLIC_BASE=/unibest/ VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run' VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' +# 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。 +# 下面的变量如果没有设置,会默认使用 VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL +VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run' +VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run' +VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run' + +VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run/upload' +VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run/upload' +VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run/upload' + # h5是否需要配置代理 VITE_APP_PROXY=false VITE_APP_PROXY_PREFIX = '/api' diff --git a/src/utils/index.ts b/src/utils/index.ts index be21dd6..f729525 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ import { pages, subPackages, tabBar } from '@/pages.json' -import { isMp } from './platform' +import { isMpWeixin } from './platform' const getLastPage = () => { // getCurrentPages() 至少有1个元素,所以不再额外判断 @@ -126,21 +126,21 @@ export const getEnvBaseUrl = () => { // 请求基准地址 let baseUrl = import.meta.env.VITE_SERVER_BASEURL - // 小程序端环境区分 - if (isMp) { + // 微信小程序端环境区分 + if (isMpWeixin) { const { miniProgram: { envVersion }, } = uni.getAccountInfoSync() switch (envVersion) { case 'develop': - baseUrl = 'https://ukw0y1.laf.run' + baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_DEVELOP || baseUrl break case 'trial': - baseUrl = 'https://ukw0y1.laf.run' + baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_TRIAL || baseUrl break case 'release': - baseUrl = 'https://ukw0y1.laf.run' + baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_RELEASE || baseUrl break } } @@ -155,21 +155,21 @@ export const getEnvBaseUploadUrl = () => { // 请求基准地址 let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL - // 小程序端环境区分 - if (isMp) { + // 微信小程序端环境区分 + if (isMpWeixin) { const { miniProgram: { envVersion }, } = uni.getAccountInfoSync() switch (envVersion) { case 'develop': - baseUploadUrl = 'https://ukw0y1.laf.run/upload' + baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP || baseUploadUrl break case 'trial': - baseUploadUrl = 'https://ukw0y1.laf.run/upload' + baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_TRIAL || baseUploadUrl break case 'release': - baseUploadUrl = 'https://ukw0y1.laf.run/upload' + baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_RELEASE || baseUploadUrl break } } diff --git a/src/utils/platform.ts b/src/utils/platform.ts index a42200c..c714199 100644 --- a/src/utils/platform.ts +++ b/src/utils/platform.ts @@ -8,10 +8,17 @@ export const platform = __UNI_PLATFORM__ export const isH5 = __UNI_PLATFORM__ === 'h5' export const isApp = __UNI_PLATFORM__ === 'app' export const isMp = __UNI_PLATFORM__.startsWith('mp-') +export const isMpWeixin = __UNI_PLATFORM__.startsWith('mp-weixin') +export const isMpAplipay = __UNI_PLATFORM__.startsWith('mp-alipay') +export const isMpToutiao = __UNI_PLATFORM__.startsWith('mp-toutiao') + const PLATFORM = { platform, isH5, isApp, isMp, + isMpWeixin, + isMpAplipay, + isMpToutiao, } export default PLATFORM From 29ecfdf6174e4238f9847b058b03e0a0a92cdc41 Mon Sep 17 00:00:00 2001 From: Burt Date: Mon, 6 Jan 2025 13:59:48 +0800 Subject: [PATCH 05/26] build: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99d4c06..5bf7579 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unibest", "type": "commonjs", - "version": "2.5.4", + "version": "2.5.5", "description": "unibest - 最好的 uniapp 开发模板", "author": { "name": "feige996", From 78c5cc7fa954a89d6c9cde3ee25ac81ef1ddbb3c Mon Sep 17 00:00:00 2001 From: Burt Date: Mon, 6 Jan 2025 21:32:12 +0800 Subject: [PATCH 06/26] =?UTF-8?q?build:=20sass=20=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E7=89=88=E6=9C=AC=201.77.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止 1.88 版本报错, close pulls #179 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5bf7579..2a95eb9 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,7 @@ "postcss-html": "^1.7.0", "postcss-scss": "^4.0.9", "rollup-plugin-visualizer": "^5.12.0", - "sass": "^1.77.8", + "sass": "1.77.8", "stylelint": "^16.11.0", "stylelint-config-html": "^1.1.0", "stylelint-config-recess-order": "^4.6.0", From ba4310dba36b68e70c3952f8c0a08dd2b40717cb Mon Sep 17 00:00:00 2001 From: Burt Date: Wed, 8 Jan 2025 21:19:33 +0800 Subject: [PATCH 07/26] =?UTF-8?q?feat:=20=E6=B5=8B=E8=AF=95=20standard-ver?= =?UTF-8?q?sion:=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8e4466e..fed8454 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,9 +1,10 @@ +import '@/style/index.scss' +import 'virtual:uno.css' import { createSSRApp } from 'vue' import App from './App.vue' +import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors' import store from './store' -import { routeInterceptor, requestInterceptor, prototypeInterceptor } from './interceptors' -import 'virtual:uno.css' -import '@/style/index.scss' +// 测试 standard-version: feature export function createApp() { const app = createSSRApp(App) From 32820c554376eff71453effc7810571e7772a54a Mon Sep 17 00:00:00 2001 From: Burt Date: Wed, 8 Jan 2025 21:20:22 +0800 Subject: [PATCH 08/26] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=20standard-vers?= =?UTF-8?q?ion:=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index d0dface..77d5cac 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@