修复了编辑非数组变量时不能修改的错误;

修改了导入数据时变量类型不支持时的替换操作
This commit is contained in:
jinchao 2025-05-07 13:59:43 +08:00
parent 1e07a82611
commit a9a4b1832e
3 changed files with 24 additions and 4 deletions

Binary file not shown.

View File

@ -179,6 +179,10 @@ class VariableForm extends HTMLElement {
e.preventDefault(); e.preventDefault();
const formData = new FormData(form); const formData = new FormData(form);
const isArray = formData.get('interfaceIsArray') ? 1 : 0;
const arraySize1 = parseInt(formData.get('interfaceArraySize_1')) || 0;
const arraySize2 = parseInt(formData.get('interfaceArraySize_2')) || 0;
const data = { const data = {
SystemName: 'XNSim', SystemName: 'XNSim',
ProductName: formData.get('productName'), ProductName: formData.get('productName'),
@ -187,9 +191,9 @@ class VariableForm extends HTMLElement {
InterfaceName: formData.get('interfaceName'), InterfaceName: formData.get('interfaceName'),
InterfaceType: formData.get('interfaceType'), InterfaceType: formData.get('interfaceType'),
InterfaceOption: 1, InterfaceOption: 1,
InterfaceIsArray: formData.get('interfaceIsArray') ? 1 : 0, InterfaceIsArray: isArray,
InterfaceArraySize_1: formData.get('interfaceArraySize_1'), InterfaceArraySize_1: isArray && arraySize1 > 1 ? arraySize1 : 0,
InterfaceArraySize_2: formData.get('interfaceArraySize_2'), InterfaceArraySize_2: isArray && arraySize1 > 1 ? arraySize2 : 0,
InterfaceNotes: formData.get('interfaceNotes') InterfaceNotes: formData.get('interfaceNotes')
}; };

View File

@ -41,6 +41,22 @@ function parseArrayDimensions(dimensions) {
return { isArray: false, arraySize1: 0, arraySize2: 0 }; return { isArray: false, arraySize1: 0, arraySize2: 0 };
} }
/**
* 处理变量类型替换规则
* @param {string} type - 原始变量类型
* @returns {string} 替换后的变量类型
*/
function processVariableType(type) {
if (!type) return '';
const typeMap = {
'unsigned char': 'char',
'int': 'long'
};
return typeMap[type] || type;
}
/** /**
* 解析单个工作表 * 解析单个工作表
* @param {Object} worksheet - Excel工作表对象 * @param {Object} worksheet - Excel工作表对象
@ -60,7 +76,7 @@ function parseWorksheet(worksheet, structName) {
isArray: dimensions.isArray, isArray: dimensions.isArray,
arraySize1: dimensions.arraySize1, arraySize1: dimensions.arraySize1,
arraySize2: dimensions.arraySize2, arraySize2: dimensions.arraySize2,
variableType: row['Variable Type'] || '' variableType: processVariableType(row['Variable Type'] || '')
}; };
}); });
} }