Commit 67d011bf by pangchong

fix(modal): 细化弹窗双向绑定规则校验

- 说明业务弹窗禁止使用v-model:show简写限制不适用于CommonModal组件内部
- 更新规则文档,明确封装n-modal的CommonModal组件例外情况
- 调整校验脚本,排除CommonModal.vue文件的v-model:show错误检测
- 优化dtdManager代码格式,简化子元素名称拼接逻辑
parent dccdbde4
......@@ -206,7 +206,7 @@
- **统一组件**:所有业务弹窗必须使用封装的 `CommonModal` 组件。
- **宽度配置**:弹窗宽度定义**必须**使用 `:width="数字"` 形式(如 `:width="600"`),禁止使用非绑定的 `width="600"` 或手写样式。
- **双向绑定**:在业务逻辑中,**禁止**使用 `v-model:show="xxx"` 语法,必须统一简写为 **`v-model="xxx"`**。
- **双向绑定**:在业务逻辑中,**禁止**使用 `v-model:show="xxx"` 语法,必须统一简写为 **`v-model="xxx"`**(底层组件 `src/components/CommonModal.vue` 内部封装 Naive UI 原生 `<n-modal>` 时除外)。
- **组件内置事件优先**:提交/确认动作**必须**绑定至组件的 **`@confirm`** 事件,严禁在业务层手动通过 `footer` slot 覆写确认按钮。配置确定文本必须通过 **`confirm-text`** 属性。
- **弹窗加载状态与反馈**:
- **禁用全局 Loading**:弹窗内进行请求时,**禁止**调用 `window.$loadingBar`,且在请求配置中**严禁**开启 `showLoading: true`。
......
......@@ -254,8 +254,9 @@ for (const relPath of stagedFiles) {
})
}
// 规则 12: 弹窗双向绑定禁止使用 v-model:show="xxx",必须统一简写为 v-model="xxx"
if (/v-model:show\s*=/.test(line)) {
// 规则 12: 弹窗双向绑定禁止使用 v-model:show="xxx",必须统一简写为 v-model="xxx"(CommonModal.vue 自身封装 n-modal 除外)
const isCommonModalComponent = relPath.replace(/\\/g, '/').endsWith('src/components/CommonModal.vue')
if (/v-model:show\s*=/.test(line) && !isCommonModalComponent) {
violations.push({
file: relPath,
line: lineNum,
......
......@@ -635,9 +635,7 @@ function findMissingRequiredChildDesc(model: DtdContentModel, tags: string[]): s
if (model.children && model.children.length > 0) {
const anySatisfied = model.children.some((child) => validateTagsAgainstModel(child, tags))
if (!anySatisfied) {
const childNames = model.children
.map((c) => (c.name ? `<${c.name}>` : c.type))
.join(' 或 ')
const childNames = model.children.map((c) => (c.name ? `<${c.name}>` : c.type)).join(' 或 ')
return `缺少必选子元素之一(必须包含 [${childNames}] 之一)`
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment