Переглянути джерело

Merge branch 'base' of ssh://ssh.github.com:443/unibest-tech/unibest into base

feige996 5 місяців тому
батько
коміт
89bf7a810e

+ 4 - 3
package.json

@@ -1,9 +1,9 @@
 {
   "name": "unibest",
   "type": "module",
-  "version": "3.18.10",
-  "unibest-version": "3.18.10",
-  "update-time": "2025-10-29",
+  "version": "3.18.11",
+  "unibest-version": "3.18.11",
+  "update-time": "2025-11-06",
   "packageManager": "pnpm@10.10.0",
   "description": "unibest - 最好的 uniapp 开发模板",
   "generate-time": "用户创建项目时生成",
@@ -135,6 +135,7 @@
     "@esbuild/darwin-arm64": "0.20.2",
     "@esbuild/darwin-x64": "0.20.2",
     "@iconify-json/carbon": "^1.2.4",
+    "@iconify/utils": "^3.0.2",
     "@rollup/rollup-darwin-x64": "^4.28.0",
     "@types/node": "^20.17.9",
     "@uni-helper/eslint-config": "0.5.0",

+ 34 - 10
pnpm-lock.yaml

@@ -127,6 +127,9 @@ importers:
       '@iconify-json/carbon':
         specifier: ^1.2.4
         version: 1.2.13
+      '@iconify/utils':
+        specifier: ^3.0.2
+        version: 3.0.2
       '@rollup/rollup-darwin-x64':
         specifier: ^4.28.0
         version: 4.50.0
@@ -320,6 +323,9 @@ packages:
   '@antfu/utils@8.1.1':
     resolution: {integrity: sha512-Mex9nXf9vR6AhcXmMrlz/HVgYYZpVGJ6YlPgwl7UnaFpnshXs6EK/oa5Gpf3CzENMjkvEx2tQtntGnb7UtSTOQ==}
 
+  '@antfu/utils@9.3.0':
+    resolution: {integrity: sha512-9hFT4RauhcUzqOE4f1+frMKLZrgNog5b06I7VmZQV1BkvwvqrbC8EBZf3L1eEL2AKb6rNKjER0sEvJiSP1FXEA==}
+
   '@babel/code-frame@7.27.1':
     resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}
     engines: {node: '>=6.9.0'}
@@ -1393,6 +1399,9 @@ packages:
   '@iconify/utils@2.3.0':
     resolution: {integrity: sha512-GmQ78prtwYW6EtzXRU1rY+KwOKfz32PD7iJh6Iyqw68GiKuoZ2A6pRtzWONz5VQJbp50mEjXh/7NkumtrAgRKA==}
 
+  '@iconify/utils@3.0.2':
+    resolution: {integrity: sha512-EfJS0rLfVuRuJRn4psJHtK2A9TqVnkxPpHY6lYHiB9+8eSuudsxbwMiavocG45ujOo6FJ+CIRlRnlOGinzkaGQ==}
+
   '@intlify/core-base@9.1.9':
     resolution: {integrity: sha512-x5T0p/Ja0S8hs5xs+ImKyYckVkL4CzcEXykVYYV6rcbXxJTe2o58IquSqX9bdncVKbRZP7GlBU1EcRaQEEJ+vw==}
     engines: {node: '>= 10'}
@@ -6343,6 +6352,8 @@ snapshots:
 
   '@antfu/utils@8.1.1': {}
 
+  '@antfu/utils@9.3.0': {}
+
   '@babel/code-frame@7.27.1':
     dependencies:
       '@babel/helper-validator-identifier': 7.27.1
@@ -6416,7 +6427,7 @@ snapshots:
       '@babel/core': 7.28.3
       '@babel/helper-compilation-targets': 7.27.2
       '@babel/helper-plugin-utils': 7.27.1
-      debug: 4.4.1
+      debug: 4.4.3
       lodash.debounce: 4.0.8
       resolve: 1.22.10
     transitivePeerDependencies:
@@ -7083,7 +7094,7 @@ snapshots:
       '@babel/parser': 7.28.3
       '@babel/template': 7.27.2
       '@babel/types': 7.28.2
-      debug: 4.4.1
+      debug: 4.4.3
     transitivePeerDependencies:
       - supports-color
 
@@ -7288,7 +7299,7 @@ snapshots:
       '@vue/compiler-sfc': 3.4.21
       '@vue/consolidate': 1.0.0
       '@vue/shared': 3.4.21
-      debug: 4.4.1
+      debug: 4.4.3
       es-module-lexer: 1.7.0
       estree-walker: 2.0.2
       fast-glob: 3.3.3
@@ -7316,7 +7327,7 @@ snapshots:
       '@vitejs/plugin-vue': 5.1.0(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))(vue@3.4.21(typescript@5.8.3))
       '@vue/compiler-dom': 3.4.21
       '@vue/compiler-sfc': 3.4.21
-      debug: 4.4.1
+      debug: 4.4.3
       fs-extra: 10.1.0
       picocolors: 1.1.1
     transitivePeerDependencies:
@@ -7402,7 +7413,7 @@ snapshots:
       base64url: 3.0.1
       chokidar: 3.6.0
       compare-versions: 3.6.0
-      debug: 4.4.1
+      debug: 4.4.3
       es-module-lexer: 1.7.0
       esbuild: 0.20.2
       estree-walker: 2.0.2
@@ -7548,7 +7559,7 @@ snapshots:
       '@vue/compiler-sfc': 3.4.21
       '@vue/server-renderer': 3.4.21(vue@3.4.21(typescript@5.8.3))
       '@vue/shared': 3.4.21
-      debug: 4.4.1
+      debug: 4.4.3
       fs-extra: 10.1.0
       mime: 3.0.0
       module-alias: 2.2.3
@@ -7782,7 +7793,7 @@ snapshots:
       '@vue/compiler-dom': 3.4.21
       '@vue/compiler-sfc': 3.4.21
       '@vue/shared': 3.4.21
-      debug: 4.4.1
+      debug: 4.4.3
     transitivePeerDependencies:
       - '@nuxt/kit'
       - '@vueuse/core'
@@ -7885,7 +7896,7 @@ snapshots:
     dependencies:
       '@dcloudio/uni-cli-shared': 3.0.0-4070620250821001(postcss@8.5.6)(rollup@4.50.0)(vue@3.4.21(typescript@5.8.3))
       '@dcloudio/uni-shared': 3.0.0-4070620250821001
-      debug: 4.4.1
+      debug: 4.4.3
     transitivePeerDependencies:
       - '@nuxt/kit'
       - '@vueuse/core'
@@ -8157,6 +8168,19 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
+  '@iconify/utils@3.0.2':
+    dependencies:
+      '@antfu/install-pkg': 1.1.0
+      '@antfu/utils': 9.3.0
+      '@iconify/types': 2.0.0
+      debug: 4.4.3
+      globals: 15.15.0
+      kolorist: 1.8.0
+      local-pkg: 1.1.2
+      mlly: 1.8.0
+    transitivePeerDependencies:
+      - supports-color
+
   '@intlify/core-base@9.1.9':
     dependencies:
       '@intlify/devtools-if': 9.1.9
@@ -9015,7 +9039,7 @@ snapshots:
     dependencies:
       '@typescript-eslint/tsconfig-utils': 8.41.0(typescript@5.8.3)
       '@typescript-eslint/types': 8.41.0
-      debug: 4.4.1
+      debug: 4.4.3
       typescript: 5.8.3
     transitivePeerDependencies:
       - supports-color
@@ -9069,7 +9093,7 @@ snapshots:
       '@typescript-eslint/tsconfig-utils': 8.41.0(typescript@5.8.3)
       '@typescript-eslint/types': 8.41.0
       '@typescript-eslint/visitor-keys': 8.41.0
-      debug: 4.4.1
+      debug: 4.4.3
       fast-glob: 3.3.3
       is-glob: 4.0.3
       minimatch: 9.0.5

+ 0 - 6
scripts/postupgrade.js

@@ -13,19 +13,13 @@ const execPromise = promisify(exec)
 
 // 定义要执行的命令
 const dependencies = [
-  '@dcloudio/uni-app-harmony',
   // TODO: 如果不需要某个平台的小程序,请手动删除或注释掉
-  '@dcloudio/uni-mp-alipay',
   '@dcloudio/uni-mp-baidu',
   '@dcloudio/uni-mp-jd',
   '@dcloudio/uni-mp-kuaishou',
-  '@dcloudio/uni-mp-lark',
   '@dcloudio/uni-mp-qq',
-  '@dcloudio/uni-mp-toutiao',
   '@dcloudio/uni-mp-xhs',
   '@dcloudio/uni-quickapp-webview',
-  // i18n模板要注释掉下面的
-  'vue-i18n',
 ]
 
 /**

+ 4 - 0
src/pages-sub/demo/index.vue

@@ -31,6 +31,10 @@ function gotoScroll() {
     </button>
     <view>
       <RequestComp />
+      <view class="mt-4">
+        本地SVG图标示例
+      </view>
+      <view class="i-my-icons-copyright text-red" />
     </view>
   </view>
 </template>

+ 1 - 1
src/router/interceptor.ts

@@ -45,7 +45,7 @@ export const navigateToInterceptor = {
     }
 
     // 处理路由不存在的情况
-    if (getAllPages().every(page => page.path !== path) && path !== '/') {
+    if (path !== '/' && !getAllPages().some(page => page.path !== path)) {
       console.warn('路由不存在:', path)
       uni.navigateTo({ url: NOT_FOUND_PAGE })
       return false // 明确表示阻止原路由继续执行

Різницю між файлами не показано, бо вона завелика
+ 1 - 0
src/static/my-icons/copyright.svg


+ 44 - 4
uno.config.ts

@@ -1,14 +1,14 @@
 import type {
   Preset,
 } from 'unocss'
+import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
+
 // https://www.npmjs.com/package/@uni-helper/unocss-preset-uni
 import { presetUni } from '@uni-helper/unocss-preset-uni'
-
 // @see https://unocss.dev/presets/legacy-compat
 import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
 import {
   defineConfig,
-  presetAttributify,
   presetIcons,
   transformerDirectives,
   transformerVariantGroup,
@@ -26,9 +26,27 @@ export default defineConfig({
         'display': 'inline-block',
         'vertical-align': 'middle',
       },
+      collections: {
+        // 注册本地 SVG 图标集合, 从本地文件系统加载图标
+        // 在 './src/static/my-icons' 目录下的所有 svg 文件将被注册为图标,
+        // my-icons 是图标集合名称,使用 `i-my-icons-图标名` 调用
+        'my-icons': FileSystemIconLoader(
+          './src/static/my-icons',
+          // 可选的,你可以提供一个 transform 回调来更改每个图标
+          (svg) => {
+            let svgStr = svg
+
+            // 如果 SVG 文件未定义 `fill` 属性,则默认填充 `currentColor`, 这样图标颜色会继承文本颜色,方便在不同场景下适配
+            svgStr = svgStr.includes('fill="') ? svgStr : svgStr.replace(/^<svg /, '<svg fill="currentColor" ')
+
+            // 如果 svg 有 width, 和 height 属性,将这些属性改为 1em,否则无法显示图标
+            svgStr = svgStr.replace(/(<svg.*?width=)"(.*?)"/, '$1"1em"').replace(/(<svg.*?height=)"(.*?)"/, '$1"1em"')
+
+            return svgStr
+          },
+        ),
+      },
     }),
-    // 支持css class属性化
-    presetAttributify(),
     // TODO: check 是否会有别的影响
     // 处理低端安卓机的样式问题
     // 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example:
@@ -74,4 +92,26 @@ export default defineConfig({
       '3xs': ['18rpx', '26rpx'],
     },
   },
+  // windows 系统会报错:[plugin:unocss:transformers:pre] Cannot overwrite a zero-length range - use append Left or prependRight instead.
+  // 去掉下面的就正常了
+  // content: {
+  //   /**
+  //    * 解决小程序报错 `./app.wxss(78:2814): unexpected unexpected at pos 5198`
+  //    * 为什么同时使用include和exclude?虽然看起来多余,但同时配置两者是一种常见的 `防御性编程` 做法。
+  //      1. 结构变化保障 : 如果未来项目结构发生变化,某些排除目录可能被移动到包含路径下,exclude配置可以确保它们仍被排除
+  //      2. 明确性 : 明确列出要排除的目录使配置意图更加清晰
+  //      3. 性能优化 : 避免处理不必要的文件,提高构建性能
+  //      4. 防止冲突 : 排除第三方库和构建输出目录,避免潜在的CSS冲突
+  //    */
+  //   pipeline: {
+  //     exclude: [
+  //       'node_modules/**/*',
+  //       'public/**/*',
+  //       'dist/**/*',
+  //     ],
+  //     include: [
+  //       './src/**/*',
+  //     ],
+  //   },
+  // },
 })

+ 8 - 6
vite.config.ts

@@ -65,6 +65,9 @@ export default defineConfig(({ command, mode }) => {
     envDir: './env', // 自定义env目录
     base: VITE_APP_PUBLIC_BASE,
     plugins: [
+      UniLayouts(),
+      UniPlatform(),
+      UniManifest(),
       UniPages({
         exclude: ['**/components/**/**.*'],
         // pages 目录为 src/pages,分包目录不能配置在pages目录下!!
@@ -75,9 +78,6 @@ export default defineConfig(({ command, mode }) => {
         ],
         dts: 'src/types/uni-pages.d.ts',
       }),
-      UniLayouts(),
-      UniPlatform(),
-      UniManifest(),
       // Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
       Optimization({
         enable: {
@@ -91,6 +91,11 @@ export default defineConfig(({ command, mode }) => {
         logger: false,
       }),
       // UniXXX 需要在 Uni 之前引入
+      // 若存在改变 pages.json 的插件,请将 UniKuRoot 放置其后
+      UniKuRoot({
+        excludePages: ['**/components/**/**.*'],
+      }),
+      Uni(),
       {
         // 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
         // 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
@@ -145,9 +150,6 @@ export default defineConfig(({ command, mode }) => {
         directoryAsNamespace: false, // 是否把目录名作为命名空间前缀,true 时组件名为 目录名+组件名,
         dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
       }),
-      // 若存在改变 pages.json 的插件,请将 UniKuRoot 放置其后
-      UniKuRoot(),
-      Uni(),
       // 自动打开开发者工具插件 (必须修改 .env 文件中的 VITE_WX_APPID)
       openDevTools(),
     ],