From 05ed7dad8a46e7ecfc729ebfc7b70b4f3151effc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mac=C2=B7ufutx?= Date: Thu, 25 Sep 2025 17:00:48 +0800 Subject: [PATCH] feat: 20250925 --- package.json | 1 - tsconfig.app.json | 2 +- vite.config.ts | 35 ++++++++++++++++++++--------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index f02db92..87426ab 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,6 @@ "unplugin-vue-components": "^28.7.0", "vite": "^5.4.19", "vite-plugin-html": "^3.2.2", - "vite-plugin-imagemin": "^0.6.1", "vite-ssg": "^27.0.1", "vue-tsc": "1.8.14" } diff --git a/tsconfig.app.json b/tsconfig.app.json index 3768c3f..21151e2 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -23,7 +23,7 @@ "src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", - "src/**/*.vue", + "src/**/*.vue", "src/auto-imports.d.ts", // 必须包含这行! "vite.config.ts", "src/main.ts" ] diff --git a/vite.config.ts b/vite.config.ts index f1ec7ae..70c05df 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' -import viteImagemin from 'vite-plugin-imagemin' +// import viteImagemin from 'vite-plugin-imagemin' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' @@ -32,14 +32,19 @@ export default defineConfig(({ mode }) => ({ ] : []), AutoImport({ - imports: ['vue', 'vue-router'], - resolvers: [ - ElementPlusResolver({ - importStyle: false, - directives: true - }) + // 1. 自动导入的 API 来源(Vue 核心 API + Vue Router 等) + imports: [ + 'vue', // 自动导入 Vue 组合式 API(ref、reactive、onMounted 等) + 'vue-router' // 可选:自动导入 Vue Router API(useRouter 等) + // 其他来源(如 Pinia)可按需添加 ], - dts: true + // 2. 生成类型声明文件(让 TypeScript 识别自动导入的 API) + dts: 'src/auto-imports.d.ts', // 生成的类型文件路径(必须存在) + // 3. 解决 ESLint 报错(可选,若 ESLint 提示“未定义变量”) + eslintrc: { + enabled: true, // 生成 ESLint 配置片段 + filepath: './.eslintrc-auto-import.json' // 生成的 ESLint 配置文件 + } }), Components({ resolvers: [ @@ -53,13 +58,13 @@ export default defineConfig(({ mode }) => ({ }), ...(process.env.NODE_ENV !== 'development' ? [ - viteImagemin({ - gifsicle: { optimizationLevel: 7 }, - optipng: { optimizationLevel: 7 }, - mozjpeg: { quality: 80 }, - pngquant: { quality: [0.8, 0.9] }, - svgo: { plugins: [{ name: 'removeViewBox' }] } - }) + // viteImagemin({ + // gifsicle: { optimizationLevel: 7 }, + // optipng: { optimizationLevel: 7 }, + // mozjpeg: { quality: 80 }, + // pngquant: { quality: [0.8, 0.9] }, + // svgo: { plugins: [{ name: 'removeViewBox' }] } + // }) ] : []) ],