From d81dab5604b6c134e71ca513780caa2df00dedce Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Tue, 25 Aug 2026 14:04:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20jsEncrypt=20?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20Vite=20=E9=85=8D=E7=BD=AE=E4=BB=A5=E6=94=AF=E6=8C=81=20cmvr-?= =?UTF-8?q?iot-common?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/jsencrypt.js | 2 +- vite.config.js | 17 +++++++++++++++++ vite/plugins/auto-import.js | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/utils/jsencrypt.js b/src/utils/jsencrypt.js index 78d9523..91eeff6 100644 --- a/src/utils/jsencrypt.js +++ b/src/utils/jsencrypt.js @@ -1,4 +1,4 @@ -import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' +import JSEncrypt from 'jsencrypt' // 密钥对生成 http://web.chacuo.net/netrsakeypair diff --git a/vite.config.js b/vite.config.js index 39bc171..678a256 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,18 @@ import { defineConfig, loadEnv, normalizePath } from 'vite' import path from 'path' +import { realpathSync } from 'node:fs' import createVitePlugins from './vite/plugins' +const isCommonLinked = (() => { + try { + const linkedPath = realpathSync(path.resolve('node_modules/@cmvr/iot-common')) + const localPath = realpathSync(path.resolve('../cmvr-iot-common')) + return path.relative(linkedPath, localPath) === '' + } catch { + return false + } +})() + // https://vitejs.dev/config/ export default defineConfig(({ mode, command }) => { const env = loadEnv(mode, process.cwd()) @@ -12,6 +23,7 @@ export default defineConfig(({ mode, command }) => { plugins: createVitePlugins(env, command === 'build'), optimizeDeps: { exclude: [ + ...(isCommonLinked ? ['@cmvr/iot-common'] : []), 'monaco-editor', 'monaco-editor/esm/vs/base/worker/workerMain.js', 'monaco-editor/esm/vs/editor/editor.main.js', @@ -57,6 +69,11 @@ export default defineConfig(({ mode, command }) => { port: Number(VITE_PORT || 80), host: true, open: true, + ...(isCommonLinked ? { + watch: { + ignored: ['!**/node_modules/@cmvr/iot-common/**'] + } + } : {}), proxy: { // https://cn.vitejs.dev/config/#server-proxy '/dev-api': { diff --git a/vite/plugins/auto-import.js b/vite/plugins/auto-import.js index 1b6ab1d..723d4dc 100644 --- a/vite/plugins/auto-import.js +++ b/vite/plugins/auto-import.js @@ -11,6 +11,7 @@ export default function createAutoImport() { '@/utils/ruoyi': ['selectDictLabel'] } ], + exclude: [/[\\/]cmvr-iot-common[\\/]dist[\\/]/], dts: false }) }