feat: 更新 jsEncrypt 导入路径,优化 Vite 配置以支持 cmvr-iot-common

This commit is contained in:
zhanghao 2026-08-25 14:04:27 +08:00
parent 73ee3fe080
commit d81dab5604
3 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
import JSEncrypt from 'jsencrypt'
// 密钥对生成 http://web.chacuo.net/netrsakeypair

View File

@ -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': {

View File

@ -11,6 +11,7 @@ export default function createAutoImport() {
'@/utils/ruoyi': ['selectDictLabel']
}
],
exclude: [/[\\/]cmvr-iot-common[\\/]dist[\\/]/],
dts: false
})
}