From 79776eca516cb4502c614e555e2f3599498d0312 Mon Sep 17 00:00:00 2001 From: GentleLijie Date: Fri, 17 Apr 2026 12:23:40 +0800 Subject: [PATCH 1/4] feat: add import config functionality for re-editing generated YAML Supports uploading a previously generated config.yaml, parsing it back into the editor data structure with all 14 task types mapped correctly. Includes strict type tag validation and meaningful error reporting for corrupted configs. --- package.json | 1 + pnpm-lock.yaml | 3 + .../module-settings/ImportConfigDialog.vue | 191 ++++++++ src/pages/ModuleSettings.vue | 12 + src/utils/parse-config.js | 454 ++++++++++++++++++ 5 files changed, 661 insertions(+) create mode 100644 src/components/module-settings/ImportConfigDialog.vue create mode 100644 src/utils/parse-config.js diff --git a/package.json b/package.json index 29464a7..490c629 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "lint": "eslint --ext .js,.vue src" }, "dependencies": { + "@element-plus/icons-vue": "^2.3.2", "element-plus": "^2.11.2", "highlight.js": "^11.11.1", "vue": "^3.5.22" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b5783ce..36eda72 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@element-plus/icons-vue': + specifier: ^2.3.2 + version: 2.3.2(vue@3.5.32) element-plus: specifier: ^2.11.2 version: 2.13.7(vue@3.5.32) diff --git a/src/components/module-settings/ImportConfigDialog.vue b/src/components/module-settings/ImportConfigDialog.vue new file mode 100644 index 0000000..d45125f --- /dev/null +++ b/src/components/module-settings/ImportConfigDialog.vue @@ -0,0 +1,191 @@ + + + diff --git a/src/pages/ModuleSettings.vue b/src/pages/ModuleSettings.vue index 5210f34..cf4c8dd 100644 --- a/src/pages/ModuleSettings.vue +++ b/src/pages/ModuleSettings.vue @@ -6,6 +6,9 @@ Module List + + Import Config +
@@ -850,11 +853,14 @@
+ + diff --git a/src/utils/parse-config.js b/src/utils/parse-config.js index 2fc6e43..f33112a 100644 --- a/src/utils/parse-config.js +++ b/src/utils/parse-config.js @@ -23,11 +23,13 @@ const INT_TAGS = new Set([ function parseTypedValue(rawValue, tag, lineNum, errors) { if (tag === 'std::string') { - if ((rawValue.startsWith("'") && rawValue.endsWith("'")) || - (rawValue.startsWith('"') && rawValue.endsWith('"'))) { - return rawValue.slice(1, -1); + let v = rawValue; + while (v.length >= 2 && + ((v[0] === "'" && v[v.length - 1] === "'") || + (v[0] === '"' && v[v.length - 1] === '"'))) { + v = v.slice(1, -1); } - return rawValue; + return v; } if (tag === 'float') { const num = parseFloat(rawValue); diff --git a/src/utils/verify-config.js b/src/utils/verify-config.js index fade4e7..a19d5b0 100644 --- a/src/utils/verify-config.js +++ b/src/utils/verify-config.js @@ -477,6 +477,7 @@ export function verifyConfig(yamlText) { code: 'TASK_COUNT_MISMATCH', module: mod.sn, line: mod.line, + fixable: true, message: `Declared task_count=${mod.task_count_declared} but found ${mod.tasks.length} task(s)`, }); } @@ -492,6 +493,7 @@ export function verifyConfig(yamlText) { code: 'SDO_LEN_MISMATCH', module: mod.sn, line: mod.line, + fixable: true, message: `Declared sdo_len=${mod.sdo_len_declared} but calculated=${expectedSdoLen}`, }); } @@ -756,6 +758,7 @@ export function verifyConfig(yamlText) { module: mod.sn, task: `app_${task.appNum}`, line: task.line, + fixable: true, message: `pdoread_offset=${flat['pdoread_offset']} but expected ${expected.pdoread_offset}`, }); } @@ -765,6 +768,7 @@ export function verifyConfig(yamlText) { module: mod.sn, task: `app_${task.appNum}`, line: task.line, + fixable: true, message: `pdowrite_offset=${flat['pdowrite_offset']} but expected ${expected.pdowrite_offset}`, }); }