Selaa lähdekoodia

初始化插件库

yuanmingze 8 kuukautta sitten
vanhempi
commit
71fc9f9369
4 muutettua tiedostoa jossa 86 lisäystä ja 3 poistoa
  1. 1 0
      package.json
  2. 54 0
      pnpm-lock.yaml
  3. 0 1
      src/pages.json
  4. 31 2
      vite.config.ts

+ 1 - 0
package.json

@@ -68,6 +68,7 @@
     "sass": "^1.78.0",
     "tsx": "^4.21.0",
     "typescript": "^4.9.4",
+    "unplugin-auto-import": "^20.3.0",
     "vite": "5.2.8",
     "vite-tsconfig-paths": "^6.0.3",
     "vue-tsc": "^1.0.24"

+ 54 - 0
pnpm-lock.yaml

@@ -162,6 +162,9 @@ importers:
       typescript:
         specifier: ^4.9.4
         version: 4.9.5
+      unplugin-auto-import:
+        specifier: ^20.3.0
+        version: 20.3.0
       vite:
         specifier: 5.2.8
         version: 5.2.8(@types/node@25.0.3)(sass@1.97.2)(terser@5.44.1)
@@ -4199,6 +4202,10 @@ packages:
     resolution: {integrity: sha512-j9+fijH6aDd05yv1fXlyt7HSxtOWtGtrZeYTVBsSUg57Iuf+Ps2itIZjeyu7bEQ4k0WOgYhHrdW8m/pJgOpl5g==}
     engines: {node: '>=18.12.0'}
 
+  unimport@5.6.0:
+    resolution: {integrity: sha512-8rqAmtJV8o60x46kBAJKtHpJDJWkA2xcBqWKPI14MgUb05o1pnpnCnXSxedUXyeq7p8fR5g3pTo2BaswZ9lD9A==}
+    engines: {node: '>=18.12.0'}
+
   universalify@0.2.0:
     resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}
     engines: {node: '>= 4.0.0'}
@@ -4223,10 +4230,26 @@ packages:
       '@vueuse/core':
         optional: true
 
+  unplugin-auto-import@20.3.0:
+    resolution: {integrity: sha512-RcSEQiVv7g0mLMMXibYVKk8mpteKxvyffGuDKqZZiFr7Oq3PB1HwgHdK5O7H4AzbhzHoVKG0NnMnsk/1HIVYzQ==}
+    engines: {node: '>=14'}
+    peerDependencies:
+      '@nuxt/kit': ^4.0.0
+      '@vueuse/core': '*'
+    peerDependenciesMeta:
+      '@nuxt/kit':
+        optional: true
+      '@vueuse/core':
+        optional: true
+
   unplugin-utils@0.2.5:
     resolution: {integrity: sha512-gwXJnPRewT4rT7sBi/IvxKTjsms7jX7QIDLOClApuZwR49SXbrB1z2NLUZ+vDHyqCj/n58OzRRqaW+B8OZi8vg==}
     engines: {node: '>=18.12.0'}
 
+  unplugin-utils@0.3.1:
+    resolution: {integrity: sha512-5lWVjgi6vuHhJ526bI4nlCOmkCIF3nnfXkCMDeMJrtdvxTs6ZFCM8oNufGTsDbKv/tJ/xj8RpvXjRuPBZJuJog==}
+    engines: {node: '>=20.19.0'}
+
   unplugin@2.3.11:
     resolution: {integrity: sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==}
     engines: {node: '>=18.12.0'}
@@ -9525,6 +9548,23 @@ snapshots:
       unplugin: 2.3.11
       unplugin-utils: 0.2.5
 
+  unimport@5.6.0:
+    dependencies:
+      acorn: 8.15.0
+      escape-string-regexp: 5.0.0
+      estree-walker: 3.0.3
+      local-pkg: 1.1.2
+      magic-string: 0.30.21
+      mlly: 1.8.0
+      pathe: 2.0.3
+      picomatch: 4.0.3
+      pkg-types: 2.3.0
+      scule: 1.3.0
+      strip-literal: 3.1.0
+      tinyglobby: 0.2.15
+      unplugin: 2.3.11
+      unplugin-utils: 0.3.1
+
   universalify@0.2.0: {}
 
   universalify@2.0.1: {}
@@ -9540,11 +9580,25 @@ snapshots:
       unplugin: 2.3.11
       unplugin-utils: 0.2.5
 
+  unplugin-auto-import@20.3.0:
+    dependencies:
+      local-pkg: 1.1.2
+      magic-string: 0.30.21
+      picomatch: 4.0.3
+      unimport: 5.6.0
+      unplugin: 2.3.11
+      unplugin-utils: 0.3.1
+
   unplugin-utils@0.2.5:
     dependencies:
       pathe: 2.0.3
       picomatch: 4.0.3
 
+  unplugin-utils@0.3.1:
+    dependencies:
+      pathe: 2.0.3
+      picomatch: 4.0.3
+
   unplugin@2.3.11:
     dependencies:
       '@jridgewell/remapping': 2.3.5

+ 0 - 1
src/pages.json

@@ -2,7 +2,6 @@
   "easycom": {
     "autoscan": true,
     "custom": {
-      "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue",
       // uni-ui 规则如下配置
       "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
     }

+ 31 - 2
vite.config.ts

@@ -1,11 +1,40 @@
 import { defineConfig } from 'vite'
 import uni from '@dcloudio/vite-plugin-uni'
+import AutoImport from 'unplugin-auto-import/vite'
+import Components from 'unplugin-vue-components/vite'
+import { WotResolver } from 'unplugin-vue-components/resolvers'
 
-// https://vitejs.dev/config/
 export default defineConfig(async () => {
   const { default: tsconfigPaths } = await import('vite-tsconfig-paths')
 
   return {
-    plugins: [tsconfigPaths(), uni()],
+    plugins: [
+      // 1️⃣ tsconfig 路径别名
+      tsconfigPaths(),
+
+      // 2️⃣ uni-app 核心插件(必须)
+      uni(),
+
+      // 3️⃣ 自动导入 Vue / Pinia API
+      AutoImport({
+        imports: [
+          'vue',
+          'pinia',
+          {
+            'vue-i18n': ['useI18n'],
+          },
+        ],
+        dts: 'src/auto-imports.d.ts',
+        eslintrc: {
+          enabled: true,
+        },
+      }),
+
+      // 4️⃣ 自动注册组件(wot-design-uni)
+      Components({
+        dts: 'src/components.d.ts',
+        resolvers: [WotResolver()],
+      }),
+    ],
   }
 })