/** * IntelliUnitGen:任务配置路径相对「任务目录/项目」子目录的展示与说明。 * 库中存相对路径;服务端解析为 任务目录/项目/… 绝对路径后访问。 */ (function (global) { const PROJECT_SUBDIR = '项目'; const ABS_PATH_RE = /^[a-zA-Z]:[\\/]|^\\\\/; function isAbsConfiguredPath(s) { const t = String(s || '').trim(); return !!t && ABS_PATH_RE.test(t); } function fmtProjectRelPath(p, emptyLabel) { const empty = emptyLabel != null ? emptyLabel : '(未配置)'; const s = String(p == null ? '' : p).trim(); if (!s) return empty; if (isAbsConfiguredPath(s)) return s; if (s === '.' || s === './') return PROJECT_SUBDIR + '/'; return PROJECT_SUBDIR + '/' + s.replace(/^\.?\//, ''); } function joinUnderProject(baseRel, extraParts) { let base = fmtProjectRelPath(baseRel || '.', '.'); if (!base.endsWith('/')) base += '/'; const parts = (extraParts || []).filter(Boolean); return parts.length ? base + parts.join('/') : base.replace(/\/$/, '') || PROJECT_SUBDIR; } function sutPathHint(t) { if (!t) return ''; const sut = (t.sut_code_path || '').trim(); if (!sut) { return '被测代码路径(相对「' + PROJECT_SUBDIR + '」):未配置。请在「生成任务创建」中上传项目并填写路径。'; } if (t.sut_path_kind === 'missing') { return '被测代码路径在 任务目录/' + PROJECT_SUBDIR + ' 下不存在:' + fmtProjectRelPath(sut, sut); } const kind = t.sut_path_kind === 'directory' ? '目录' : '文件'; return '被测代码路径(' + PROJECT_SUBDIR + ' 内' + kind + '):' + fmtProjectRelPath(sut, sut); } function taskPathSummary(t) { if (!t) return ''; const bits = []; const sut = (t.sut_code_path || '').trim(); const save = (t.test_code_save_path || '').trim(); const compile = (t.compile_path || '').trim(); if (sut) bits.push('被测 ' + fmtProjectRelPath(sut, sut)); if (save) bits.push('测试保存 ' + fmtProjectRelPath(save, save)); if (compile || t.compile_path !== undefined) { bits.push('项目运行 ' + fmtProjectRelPath(compile || '.', compile || '.')); } return bits.join(' · '); } function fmtExternalSavePath(t, r) { if (!r) return ''; const parts = (r.output_parent_parts || []).slice(); const cls = String(r.test_class_name || '').trim(); if (cls) { parts.push(cls.endsWith('.java') ? cls : cls + '.java'); } const saveRel = t && String(t.test_code_save_path || '').trim(); if (saveRel && parts.length) { return joinUnderProject(saveRel, parts); } if (saveRel) return fmtProjectRelPath(saveRel, saveRel); return r.external_save_path || ''; } global.UNITGEN_PROJECT_SUBDIR = PROJECT_SUBDIR; global.unitgenFmtProjectRelPath = fmtProjectRelPath; global.unitgenJoinUnderProject = joinUnderProject; global.unitgenSutPathHint = sutPathHint; global.unitgenTaskPathSummary = taskPathSummary; global.unitgenFmtExternalSavePath = fmtExternalSavePath; })(typeof window !== 'undefined' ? window : this);