feat: 新增开发脚本和用户查询表单样式,优化依赖链接管理

This commit is contained in:
zhanghao 2026-08-25 14:03:36 +08:00
parent 5fedd87f49
commit 48a2dac738
4 changed files with 161 additions and 2 deletions

View File

@ -21,7 +21,10 @@
"README.md"
],
"scripts": {
"dev": "vite build --watch",
"build": "vite build",
"link:consumers": "node scripts/link-consumers.mjs",
"unlink:consumers": "node scripts/link-consumers.mjs --unlink",
"prepublishOnly": "pnpm build"
},
"publishConfig": {

View File

@ -0,0 +1,69 @@
import { lstatSync, mkdirSync, realpathSync, rmSync, symlinkSync, unlinkSync } from 'node:fs'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const consumers = [
path.resolve(packageRoot, '../cmvr-iot-ui'),
path.resolve(packageRoot, '../cmvr-iot-aima'),
path.resolve(packageRoot, '../changan-inspection')
]
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const pnpmCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
const shouldUnlink = process.argv.includes('--unlink')
function run(command, args, cwd) {
const executable = process.platform === 'win32' ? process.env.ComSpec : command
const commandArgs = process.platform === 'win32'
? ['/d', '/s', '/c', [command, ...args].join(' ')]
: args
const env = { ...process.env }
delete env.npm_config_verify_deps_before_run
const result = spawnSync(executable, commandArgs, {
cwd,
stdio: 'inherit',
env
})
if (result.error) throw result.error
if (result.status !== 0) process.exit(result.status ?? 1)
}
function removePackageLink(linkedPackage) {
try {
const stats = lstatSync(linkedPackage)
if (stats.isSymbolicLink()) unlinkSync(linkedPackage)
else rmSync(linkedPackage, { recursive: true, force: true })
} catch (error) {
if (error.code !== 'ENOENT') throw error
}
}
if (shouldUnlink) {
for (const consumer of consumers) {
const linkedPackage = path.join(consumer, 'node_modules/@cmvr/iot-common')
removePackageLink(linkedPackage)
run(pnpmCommand, ['install', '--offline', '--frozen-lockfile'], consumer)
console.log(`[restored] ${path.basename(consumer)} -> published dependency`)
}
process.exit(0)
}
const linkOptions = [
'--ignore-scripts',
'--package-lock=false',
'--audit=false',
'--fund=false',
'--legacy-peer-deps'
]
run(npmCommand, ['link', ...linkOptions], packageRoot)
for (const consumer of consumers) {
const linkedPackage = path.join(consumer, 'node_modules/@cmvr/iot-common')
removePackageLink(linkedPackage)
mkdirSync(path.dirname(linkedPackage), { recursive: true })
symlinkSync(packageRoot, linkedPackage, process.platform === 'win32' ? 'junction' : 'dir')
console.log(`[linked] ${path.basename(consumer)} -> ${realpathSync(linkedPackage)}`)
}

View File

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

View File

@ -3,7 +3,7 @@
<tree-panel title="组织机构" :tree-data="deptOptions" search-placeholder="请输入部门名称" storage-key="dept-sidebar-width" :defaultExpandAll="true" @node-click="handleNodeClick" @refresh="getDeptTree" ref="deptTreeRef" />
<div class="tree-sidebar-content">
<div class="content-inner">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form class="user-query-form" :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户名称" prop="userName">
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
</el-form-item>
@ -457,3 +457,90 @@ onMounted(() => {
})
})
</script>
<style lang="scss" scoped>
.tree-sidebar-manage-wrap {
display: flex;
align-items: stretch;
width: 100%;
height: 100%;
min-height: 0;
overflow: hidden;
}
.tree-sidebar-content {
flex: 1 1 auto;
min-width: 0;
height: 100%;
padding-left: 20px;
overflow: auto;
}
.content-inner {
min-width: 880px;
}
.user-query-form {
display: grid;
grid-template-columns: repeat(4, minmax(190px, 1fr)) auto;
gap: 16px;
align-items: start;
margin-bottom: 16px;
:deep(.el-form-item) {
width: 100% !important;
margin: 0;
}
:deep(.el-form-item__content) {
min-width: 0;
}
:deep(.el-input),
:deep(.el-select),
:deep(.el-date-editor) {
width: 100% !important;
}
:deep(.el-form-item:last-child .el-form-item__content) {
flex-wrap: nowrap;
}
}
@media (max-width: 1500px) {
.user-query-form {
grid-template-columns: repeat(2, minmax(260px, 1fr));
}
}
@media (max-width: 900px) {
.tree-sidebar-manage-wrap {
flex-direction: column;
height: auto;
min-height: 100%;
overflow: auto;
}
:deep(.tree-sidebar) {
width: 100% !important;
height: 260px;
min-height: 260px;
border-right: 0;
border-bottom: 1px solid #e8eaed;
}
.tree-sidebar-content {
height: auto;
padding: 16px 0 0;
overflow: visible;
}
.content-inner {
min-width: 720px;
}
.user-query-form {
grid-template-columns: 1fr;
}
}
</style>