diff --git a/.eslintrc.js b/.eslintrc.js index b28255ca..669baff1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,8 +21,7 @@ module.exports = defineConfig({ 'plugin:vue/vue3-recommended', 'plugin:@typescript-eslint/recommended', 'prettier', - 'plugin:prettier/recommended', - '@unocss' + 'plugin:prettier/recommended' ], rules: { 'vue/no-setup-props-destructure': 'off', @@ -68,8 +67,6 @@ module.exports = defineConfig({ ], 'vue/multi-word-component-names': 'off', 'vue/no-v-html': 'off', - 'prettier/prettier': 'off', // 芋艿:默认关闭 prettier 的 ESLint 校验,因为我们使用的是 IDE 的 Prettier 插件 - '@unocss/order': 'off', // 芋艿:禁用 unocss 【css】顺序的提示,因为暂时不需要这么严格,警告也有点繁琐 - '@unocss/order-attributify': 'off' // 芋艿:禁用 unocss 【属性】顺序的提示,因为暂时不需要这么严格,警告也有点繁琐 + 'prettier/prettier': 'off' // 芋艿:默认关闭 prettier 的 ESLint 校验,因为我们使用的是 IDE 的 Prettier 插件 } }) diff --git a/build/vite/index.ts b/build/vite/index.ts index 585759f5..7f7e483c 100644 --- a/build/vite/index.ts +++ b/build/vite/index.ts @@ -16,7 +16,7 @@ import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import UnoCSS from 'unocss/vite' -export function createVitePlugins() { +export function createVitePlugins(isBuild = false) { const root = process.cwd() // 路径查找 @@ -24,7 +24,7 @@ export function createVitePlugins() { return resolve(root, '.', dir) } - return [ + const plugins = [ Vue(), VueJsx(), UnoCSS(), @@ -66,10 +66,6 @@ export function createVitePlugins() { resolvers: [ElementPlusResolver()], globs: ["src/components/**/**.{vue, md}", '!src/components/DiyEditor/components/mobile/**'] }), - EslintPlugin({ - cache: false, - include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件 - }), VueI18nPlugin({ runtimeOnly: true, compositionOnly: true, @@ -97,4 +93,16 @@ export function createVitePlugins() { promiseImportName: (i) => `__tla_${i}` }) ] + + // ESLint 校验仅在开发环境启用,打包时跳过以提升构建速度(lint 应在开发/提交阶段单独执行) + if (!isBuild) { + plugins.push( + EslintPlugin({ + cache: true, + include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件 + }) + ) + } + + return plugins } diff --git a/src/assets/imgs/dashboard1.png b/src/assets/imgs/dashboard1.png index 1e6eb88f..751f56ae 100644 Binary files a/src/assets/imgs/dashboard1.png and b/src/assets/imgs/dashboard1.png differ diff --git a/src/assets/imgs/dashboard2.png b/src/assets/imgs/dashboard2.png index 11307654..631d9a56 100644 Binary files a/src/assets/imgs/dashboard2.png and b/src/assets/imgs/dashboard2.png differ diff --git a/src/assets/imgs/dashboard3.png b/src/assets/imgs/dashboard3.png index d2125dbd..992f22bf 100644 Binary files a/src/assets/imgs/dashboard3.png and b/src/assets/imgs/dashboard3.png differ diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index c74144a5..1f54f234 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -2216,7 +2216,6 @@ export default { cancelReason: '取消原因', cancelConfirm: '确认取消选中的任务吗?', cancelSuccess: '取消任务成功', - cancelOnlyUnworkedTip: '只有未作业状态的工单才能取消任务', cancelFail: '取消任务失败', cancelOnlyUnworkedTip: '只有未作业状态的工单才能取消任务', selectAllDecisionError: '请先为所有待检测记录选择通过或不通过', diff --git a/src/main.ts b/src/main.ts index 5d8107d0..874f7668 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,8 +41,6 @@ import '@/plugins/tongji' // 百度统计 import Logger from '@/utils/Logger' import VueDOMPurifyHTML from 'vue-dompurify-html' // 解决v-html 的安全隐患 -import { hiPrintPlugin } from 'vue-plugin-hiprint' -import 'vue-plugin-hiprint/dist/print-lock.css' // 创建实例 const setupAll = async () => { @@ -58,9 +56,6 @@ const setupAll = async () => { setupFormCreate(app) - app.use(hiPrintPlugin, '$hiprint', false) - hiPrintPlugin.disAutoConnect() - setupRouter(app) // directives 指令 diff --git a/src/views/mes/deviceledger/detail/editIndex.vue b/src/views/mes/deviceledger/detail/editIndex.vue index 943f52b6..c889d3c4 100644 --- a/src/views/mes/deviceledger/detail/editIndex.vue +++ b/src/views/mes/deviceledger/detail/editIndex.vue @@ -918,7 +918,7 @@ const bjQueryParams = reactive({ pageSize: 10, barCode: undefined as string | undefined, name: undefined as string | undefined, - categoryId: undefined as number | undefined + categoryType: 3 }) const iotDeviceQueryParams = reactive({ @@ -1057,10 +1057,11 @@ const getList = async () => { const bjGetList = async () => { loading.value = true try { - bjQueryParams.categoryId = 5 + bjQueryParams.categoryType = 3 const data = await ProductApi.getProductPage(bjQueryParams) bjList.value = data.list bjTotal.value = data.total + beijianOptions.value = mergeSelectionOptions(beijianOptions.value, buildBeijianOptions(bjList.value)) nextTick(() => { bjToggleSelection() }) @@ -1605,12 +1606,12 @@ const ensureOptionsLoaded = async () => { DeviceTypeApi.getDeviceTypeTree({ pageNo: 1, pageSize: 10 }), getSimpleUserList(), CriticalComponentApi.getCriticalComponentList(), - ProductApi.getComponentSimpleList() + ProductApi.getProductPage({ pageNo: 1, pageSize: 10, categoryType: 3 }) ]) deviceTypeTree.value = deviceTypeRes ?? [] users.value = userRes ?? [] criticalComponentOptions.value = buildCriticalComponentOptions(criticalRes ?? []) - beijianOptions.value = buildBeijianOptions(beijianRes ?? []) + beijianOptions.value = buildBeijianOptions(beijianRes?.list ?? []) } const bindFormData = async (detail: DeviceLedgerVO) => { diff --git a/vite.config.ts b/vite.config.ts index 66ddb9e5..269c765c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -20,6 +20,12 @@ export default ({command, mode}: ConfigEnv): UserConfig => { } else { env = loadEnv(mode, root) } + + // 打包时需要移除的语句(drop_console / drop_debugger) + const esbuildDrop: ('console' | 'debugger')[] = [] + if (env.VITE_DROP_CONSOLE === 'true') esbuildDrop.push('console') + if (env.VITE_DROP_DEBUGGER === 'true') esbuildDrop.push('debugger') + return { base: env.VITE_BASE_PATH, root: root, @@ -39,7 +45,7 @@ export default ({command, mode}: ConfigEnv): UserConfig => { }, }, // 项目使用的vite插件。 单独提取到build/vite/plugin中管理 - plugins: createVitePlugins(), + plugins: createVitePlugins(isBuild), css: { preprocessorOptions: { scss: { @@ -62,21 +68,59 @@ export default ({command, mode}: ConfigEnv): UserConfig => { } ] }, + // 使用 esbuild 压缩,速度远快于 terser;drop 用于移除 console / debugger + esbuild: { + drop: esbuildDrop + }, build: { - minify: 'terser', + minify: 'esbuild', outDir: env.VITE_OUT_DIR || 'dist', sourcemap: env.VITE_SOURCEMAP === 'true' ? 'inline' : false, // brotliSize: false, - terserOptions: { - compress: { - drop_debugger: env.VITE_DROP_DEBUGGER === 'true', - drop_console: env.VITE_DROP_CONSOLE === 'true' - } - }, + // 提高 chunk 体积告警阈值,避免大量无意义警告 + chunkSizeWarningLimit: 2000, rollupOptions: { output: { - manualChunks: { - echarts: ['echarts'] // 将 echarts 单独打包,参考 https://gitee.com/yudaocode/yudao-ui-admin-vue3/issues/IAB1SX 讨论 + // 将体积较大的第三方依赖拆分为独立 chunk,避免全部打进入口主 chunk 导致首屏阻塞 + manualChunks(id: string) { + if (!id.includes('node_modules')) { + return + } + // 打印插件(体积最大,内含 jQuery 等),单独拆分 + if (id.includes('vue-plugin-hiprint')) { + return 'hiprint' + } + // 表单设计器 / 表单渲染 + if (id.includes('@form-create')) { + return 'form-create' + } + // 富文本编辑器 + if (id.includes('@wangeditor')) { + return 'wangeditor' + } + // 图表库(含词云、底层 zrender) + if (id.includes('echarts') || id.includes('zrender')) { + return 'echarts' + } + // 图片裁剪 + if (id.includes('cropperjs')) { + return 'cropperjs' + } + // Element Plus 组件库 + if (id.includes('element-plus') || id.includes('@element-plus')) { + return 'element-plus' + } + // Vue 全家桶 + if ( + id.includes('/vue/') || + id.includes('/vue-router/') || + id.includes('/@vue/') || + id.includes('/pinia/') || + id.includes('/vue-i18n/') || + id.includes('/@intlify/') + ) { + return 'vue' + } } }, },