You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/src/views/teacherEnd/taskReview/StudentTaskReadonlyPreview.vue

334 lines
14 KiB
Vue

<template>
fix(task-review): 评阅预览改用最新学生页并修复新版样式门控失配 1. previewMap 三处指向已废弃的旧页面,改为 router 实际引用的最新页面: industry-demand-analysis -> demand/industry-demand-analysis.vue competitive-environment-analysis -> demand/competitive-environment-analysis.vue market-opportunity-selection -> product/market-opportunity-selection.vue 并在文件头补充契约注释(必须与 router 一致,不得指向废弃页面)。 2. 修复评阅预览"看起来仍在用废弃页面"的根因,两重原因叠加: a) /task-review-preview 是脱离 Layout 的独立路由,DOM 里没有 .studentLayout 与 section.app-main,导致学生页新版皮肤的门控选择器 `#app .studentLayout section.app-main:has(.xxx-page) …` 集体失配, 页面静默回落全局旧版样式(胶囊满宽、步骤说明小字重新出现、按钮配色不一致)。 模板外层补两级空壳祖先容器,只补壳、不渲染顶栏侧栏。 b) 预览 iframe 宽约 1000px,命中 student-training.scss 的 @media (max-width: 1100px):`#app .student-training-shell .step-tab { width: 100% }`(特异性 1,2,0)压过预览自身 :deep() 覆盖(0,4,0), 步骤胶囊被撑成整行、只剩第一个可见并出现横向滚动条。 新增非 scoped 样式用更高特异性复位宽度,并压掉布局级背景与内边距。 实测(真实 Chrome,1000px 视口,与预览 iframe 同宽): 修复前 胶囊宽 952px x4、导航区 scrollWidth 3874/952(溢出); 修复后 214/169/199/200px、952/952(无溢出),与学生端外观一致。
2 months ago
<!--
教师端任务评阅右侧预览(脱离 Layout 的独立路由,不渲染顶栏/侧栏)。
必须补齐 .studentLayout 与 section.app-main 两级祖先:
学生端实训页的「新版皮肤」全部以
#app .studentLayout section.app-main:has(.xxx-page) …
作为样式门控前缀。本路由没有走 Layout,天然缺少这两级祖先,
会导致这些新样式集体失配,页面静默退化到全局旧版样式
(步骤导航变 100% 宽竖排、步骤说明文字重新出现、动作按钮配色不一致)。
这里只补空壳容器,不引入顶栏、侧栏或 TagsView。
-->
<div class="studentLayout student-task-preview-root">
<section class="app-main">
<main ref="previewRoot" class="student-task-readonly-preview" @click.capture="guardPreviewInteraction" @keydown.capture="guardPreviewInteraction">
<component v-if="previewComponent" :is="previewComponent" v-bind="previewProps" />
<el-empty v-else :description="emptyDescription" :image-size="112" />
</main>
</section>
</div>
</template>
<script setup>
import { getTrainingReviewPreviewContext } from "@/utils/trainingReviewPreview";
import { studentTaskPreviewComponentByKey, studentTaskPreviewPropsByKey } from "./studentTaskPreviewMap";
const route = useRoute();
const previewComponent = shallowRef(null);
const previewProps = ref({});
const emptyDescription = ref("正在加载学生任务页面");
const previewRoot = ref();
const PREVIEW_HEIGHT_MESSAGE = "teacher-task-review-preview-height";
let resizeObserver;
let mutationObserver;
let animationFrame;
async function loadPreview() {
previewComponent.value = null;
const taskKey = String(route.query.taskKey || "");
const preview = getTrainingReviewPreviewContext();
const loader = studentTaskPreviewComponentByKey[taskKey];
if (!preview || preview.taskKey !== taskKey) {
emptyDescription.value = "学生作答预览已失效,请返回任务评阅重新选择学生";
return;
}
if (!loader) {
emptyDescription.value = "该实训任务暂不支持页面预览";
return;
}
try {
previewComponent.value = (await loader()).default;
previewProps.value = studentTaskPreviewPropsByKey[taskKey]?.(taskKey) || {};
await nextTick();
schedulePreviewHeight();
} catch (_) {
emptyDescription.value = "学生任务页面加载失败,请刷新后重试";
}
}
watch(() => [route.query.taskKey, route.query.reviewPreviewKey], loadPreview, { immediate: true });
onMounted(() => {
resizeObserver = new ResizeObserver(schedulePreviewHeight);
if (previewRoot.value) resizeObserver.observe(previewRoot.value);
mutationObserver = new MutationObserver(schedulePreviewHeight);
if (previewRoot.value) mutationObserver.observe(previewRoot.value, { childList: true, subtree: true });
schedulePreviewHeight();
});
onBeforeUnmount(() => {
resizeObserver?.disconnect();
mutationObserver?.disconnect();
if (animationFrame) cancelAnimationFrame(animationFrame);
});
function schedulePreviewHeight() {
if (animationFrame) cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(reportPreviewHeight);
}
function reportPreviewHeight() {
animationFrame = 0;
const height = Math.ceil(Math.max(
previewRoot.value?.scrollHeight || 0,
document.body?.scrollHeight || 0,
document.documentElement?.scrollHeight || 0,
window.innerHeight || 0,
));
window.parent?.postMessage({
type: PREVIEW_HEIGHT_MESSAGE,
previewKey: String(route.query.reviewPreviewKey || ""),
height,
}, window.location.origin);
}
function guardPreviewInteraction(event) {
const target = event.target instanceof Element ? event.target : null;
if (!target) return;
if (target.closest("input, textarea, select, [contenteditable='true'], .el-input, .el-textarea, .el-select, .el-checkbox, .el-radio, .el-switch")) {
event.preventDefault();
event.stopImmediatePropagation();
return;
}
const action = target.closest("button, a, [role='button'], [role='tab'], .el-step");
if (action && !isStepNavigation(action)) {
event.preventDefault();
event.stopImmediatePropagation();
}
}
function isStepNavigation(element) {
if (element.matches("[role='tab'], .el-step")) return true;
const label = String(element.getAttribute("aria-label") || "");
const text = `${label} ${String(element.textContent || "")}`.replace(/\s+/g, " ").trim();
return /(上一步|下一步|第\s*\d+\s*步|切换.*步骤|步骤.*切换)/.test(text);
}
</script>
<style lang="scss" scoped>
/*
* 教师端任务评阅右侧预览:
* 学生页面已通过 dynamic component 嵌入,保留学生端样式;
* 仅保留步骤导航与步骤内容,隐藏标题区、任务简介、AI 助手与所有顶部/底部操作按钮(仅查看)。
*/
.student-task-readonly-preview {
background: #ffffff;
font-family: var(--student-font-base, "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif);
}
/* ===== 1. 隐藏 AI 助手、AI 评测、独立的 TrainingTaskBrief 组件(保持原行为) ===== */
.student-task-readonly-preview :deep(.training-ai-sidebar),
.student-task-readonly-preview :deep(.training-ai-evaluation),
.student-task-readonly-preview :deep(.training-task-brief) { display: none !important; }
/* ===== 2. 隐藏学生页顶部 chrome(标题、任务简介、展开/收起按钮、顶部工具栏等) ===== */
.student-task-readonly-preview :deep(.task-header),
.student-task-readonly-preview :deep(.task-head-main),
.student-task-readonly-preview :deep(.task-brief),
.student-task-readonly-preview :deep(.task-brief-toggle),
.student-task-readonly-preview :deep(.task-brief-more),
.student-task-readonly-preview :deep(.workbench-head),
.student-task-readonly-preview :deep(.workbench-head--actions-only),
.student-task-readonly-preview :deep(.workbench-actions),
fix(task-review): 评阅预览改用最新学生页并修复新版样式门控失配 1. previewMap 三处指向已废弃的旧页面,改为 router 实际引用的最新页面: industry-demand-analysis -> demand/industry-demand-analysis.vue competitive-environment-analysis -> demand/competitive-environment-analysis.vue market-opportunity-selection -> product/market-opportunity-selection.vue 并在文件头补充契约注释(必须与 router 一致,不得指向废弃页面)。 2. 修复评阅预览"看起来仍在用废弃页面"的根因,两重原因叠加: a) /task-review-preview 是脱离 Layout 的独立路由,DOM 里没有 .studentLayout 与 section.app-main,导致学生页新版皮肤的门控选择器 `#app .studentLayout section.app-main:has(.xxx-page) …` 集体失配, 页面静默回落全局旧版样式(胶囊满宽、步骤说明小字重新出现、按钮配色不一致)。 模板外层补两级空壳祖先容器,只补壳、不渲染顶栏侧栏。 b) 预览 iframe 宽约 1000px,命中 student-training.scss 的 @media (max-width: 1100px):`#app .student-training-shell .step-tab { width: 100% }`(特异性 1,2,0)压过预览自身 :deep() 覆盖(0,4,0), 步骤胶囊被撑成整行、只剩第一个可见并出现横向滚动条。 新增非 scoped 样式用更高特异性复位宽度,并压掉布局级背景与内边距。 实测(真实 Chrome,1000px 视口,与预览 iframe 同宽): 修复前 胶囊宽 952px x4、导航区 scrollWidth 3874/952(溢出); 修复后 214/169/199/200px、952/952(无溢出),与学生端外观一致。
2 months ago
.student-task-readonly-preview :deep(.task-action-strip),
.student-task-readonly-preview :deep(.training-task-toolbar),
.student-task-readonly-preview :deep(.training-legacy-actions),
.student-task-readonly-preview :deep(.new-product-survey-toolbar),
.student-task-readonly-preview :deep(.comprehensive-training-toolbar),
.student-task-readonly-preview :deep(.release-channel-toolbar),
.student-task-readonly-preview :deep(.purchase-workbench) > .workbench-head,
.student-task-readonly-preview :deep(.process-workbench) > .workbench-head,
.student-task-readonly-preview :deep(.factors-workbench) > .workbench-head,
.student-task-readonly-preview :deep(.channel-toolbar),
.student-task-readonly-preview :deep(.supplier-toolbar),
.student-task-readonly-preview :deep(.promotion-toolbar),
.student-task-readonly-preview :deep(.hardware-workbench-head),
.student-task-readonly-preview :deep(.legacy-toolbar),
.student-task-readonly-preview :deep(.material-actions) { display: none !important; }
/* ===== 2.1 旧版实训页:隐藏 TrainingIntro 组件的标题/简介,仅保留其步骤导航 ===== */
.student-task-readonly-preview :deep(.training-intro__head),
.student-task-readonly-preview :deep(.training-intro__body) { display: none !important; }
.student-task-readonly-preview :deep(.training-intro) {
margin-bottom: 12px !important;
padding: 0 !important;
border: 0 !important;
border-radius: 0 !important;
background: transparent !important;
box-shadow: none !important;
overflow: visible !important;
}
.student-task-readonly-preview :deep(.training-intro__steps.step-indicator) { margin: 4px 0 18px !important; }
/* ===== 2.2 旧版实训页:top_item 是 section 切换 tab,保留作为步骤导航 ===== */
.student-task-readonly-preview :deep(.top_item) {
margin: 0 0 14px !important;
padding: 0 !important;
border: 0 !important;
background: transparent !important;
}
/* ===== 3. 让学生页面把 AI 侧栏所在的网格列收回,让预览通栏展示 ===== */
.student-task-readonly-preview :deep(.student-training-shell) { grid-template-columns: minmax(0, 1fr) !important; }
/* ===== 4. 紧贴 app-main 内边距,复用学生端整体留白 ===== */
.student-task-readonly-preview :deep(.student-training-shell) > main { padding: 14px 16px 24px !important; }
/* ===== 5. 步骤导航横排、并与学生端胶囊样式一致 ===== */
.student-task-readonly-preview :deep(.step-indicator),
.student-task-readonly-preview :deep(.comprehensive-step-nav),
.student-task-readonly-preview :deep(.comprehensive-step-strip),
.student-task-readonly-preview :deep(.step-tabs),
.student-task-readonly-preview :deep(.flow-steps),
.student-task-readonly-preview :deep(.flow-rail),
.student-task-readonly-preview :deep(.training-intro__steps) {
display: flex !important;
flex-direction: row !important;
flex-wrap: nowrap !important;
align-items: stretch !important;
justify-content: flex-start !important;
gap: 0 !important;
width: 100% !important;
max-width: 100% !important;
margin: 4px 0 18px !important;
padding: 0 !important;
border: none !important;
border-radius: 0 !important;
background: transparent !important;
box-shadow: none !important;
overflow-x: auto !important;
overflow-y: hidden !important;
scrollbar-width: thin !important;
-webkit-overflow-scrolling: touch !important;
}
/* 步骤胶囊:固定宽度并排,不让任何一条占满整行 */
.student-task-readonly-preview :deep(.step-indicator) .step-tab,
.student-task-readonly-preview :deep(.comprehensive-step-strip) .step-tab,
.student-task-readonly-preview :deep(.step-tabs) .step-tab,
.student-task-readonly-preview :deep(.step-tabs) .step-pill,
.student-task-readonly-preview :deep(.step-indicator) .flow-pill,
.student-task-readonly-preview :deep(.flow-steps) .step-pill,
.student-task-readonly-preview :deep(.flow-rail) .flow-step,
.student-task-readonly-preview :deep(.training-intro__steps) .step-tab {
flex: 0 0 auto !important;
flex-grow: 0 !important;
flex-shrink: 0 !important;
flex-basis: auto !important;
width: auto !important;
min-width: 132px !important;
max-width: 220px !important;
margin: 0 !important;
}
.student-task-readonly-preview :deep(.comprehensive-step-strip) {
width: max-content !important;
min-width: 100% !important;
}
.student-task-readonly-preview :deep(.step-connector),
.student-task-readonly-preview :deep(.step-arrow),
.student-task-readonly-preview :deep(.flow-arrow) {
flex: 0 0 22px !important;
width: 22px !important;
min-width: 22px !important;
display: inline-block !important;
}
/* ===== 6. 步骤内容卡片:保留学生端白卡 + 灰边样式 ===== */
.student-task-readonly-preview :deep(.step-card),
fix(task-review): 评阅预览改用最新学生页并修复新版样式门控失配 1. previewMap 三处指向已废弃的旧页面,改为 router 实际引用的最新页面: industry-demand-analysis -> demand/industry-demand-analysis.vue competitive-environment-analysis -> demand/competitive-environment-analysis.vue market-opportunity-selection -> product/market-opportunity-selection.vue 并在文件头补充契约注释(必须与 router 一致,不得指向废弃页面)。 2. 修复评阅预览"看起来仍在用废弃页面"的根因,两重原因叠加: a) /task-review-preview 是脱离 Layout 的独立路由,DOM 里没有 .studentLayout 与 section.app-main,导致学生页新版皮肤的门控选择器 `#app .studentLayout section.app-main:has(.xxx-page) …` 集体失配, 页面静默回落全局旧版样式(胶囊满宽、步骤说明小字重新出现、按钮配色不一致)。 模板外层补两级空壳祖先容器,只补壳、不渲染顶栏侧栏。 b) 预览 iframe 宽约 1000px,命中 student-training.scss 的 @media (max-width: 1100px):`#app .student-training-shell .step-tab { width: 100% }`(特异性 1,2,0)压过预览自身 :deep() 覆盖(0,4,0), 步骤胶囊被撑成整行、只剩第一个可见并出现横向滚动条。 新增非 scoped 样式用更高特异性复位宽度,并压掉布局级背景与内边距。 实测(真实 Chrome,1000px 视口,与预览 iframe 同宽): 修复前 胶囊宽 952px x4、导航区 scrollWidth 3874/952(溢出); 修复后 214/169/199/200px、952/952(无溢出),与学生端外观一致。
2 months ago
.student-task-readonly-preview :deep(.industry-step-card),
.student-task-readonly-preview :deep(.process-step-card),
.student-task-readonly-preview :deep(.factor-step-card),
.student-task-readonly-preview :deep(.step-content > .step-card),
.student-task-readonly-preview :deep(.training-step-area) {
border: 1px solid #e5e7eb !important;
border-radius: 12px !important;
background: #ffffff !important;
box-shadow: none !important;
}
/* ===== 7. 关闭底部"提交/导出/清空"等动作按钮区(仅查看,不需要学生端的提交动作) ===== */
.student-task-readonly-preview :deep(.task-actions),
.student-task-readonly-preview :deep(.task-actions-row),
.student-task-readonly-preview :deep(.taskfooter),
.student-task-readonly-preview :deep(.step-footer),
.student-task-readonly-preview :deep(.step-actions),
.student-task-readonly-preview :deep(.footer-actions) {
pointer-events: none !important;
opacity: 0.55 !important;
filter: grayscale(0.4) !important;
}
/* ===== 8. 禁用所有表单交互,确保仅查看 ===== */
.student-task-readonly-preview :deep(input),
.student-task-readonly-preview :deep(textarea),
.student-task-readonly-preview :deep(select),
.student-task-readonly-preview :deep(.el-input__inner),
.student-task-readonly-preview :deep(.el-textarea__inner),
.student-task-readonly-preview :deep(.el-select) { pointer-events: none !important; }
/* ===== 9. 隐藏通用浮层与弹窗,避免误触 ===== */
.student-task-readonly-preview :deep(.gdialog),
.student-task-readonly-preview :deep(.popModal),
.student-task-readonly-preview :deep(.el-popper),
.student-task-readonly-preview :deep(.el-overlay) { display: none !important; }
</style>
fix(task-review): 评阅预览改用最新学生页并修复新版样式门控失配 1. previewMap 三处指向已废弃的旧页面,改为 router 实际引用的最新页面: industry-demand-analysis -> demand/industry-demand-analysis.vue competitive-environment-analysis -> demand/competitive-environment-analysis.vue market-opportunity-selection -> product/market-opportunity-selection.vue 并在文件头补充契约注释(必须与 router 一致,不得指向废弃页面)。 2. 修复评阅预览"看起来仍在用废弃页面"的根因,两重原因叠加: a) /task-review-preview 是脱离 Layout 的独立路由,DOM 里没有 .studentLayout 与 section.app-main,导致学生页新版皮肤的门控选择器 `#app .studentLayout section.app-main:has(.xxx-page) …` 集体失配, 页面静默回落全局旧版样式(胶囊满宽、步骤说明小字重新出现、按钮配色不一致)。 模板外层补两级空壳祖先容器,只补壳、不渲染顶栏侧栏。 b) 预览 iframe 宽约 1000px,命中 student-training.scss 的 @media (max-width: 1100px):`#app .student-training-shell .step-tab { width: 100% }`(特异性 1,2,0)压过预览自身 :deep() 覆盖(0,4,0), 步骤胶囊被撑成整行、只剩第一个可见并出现横向滚动条。 新增非 scoped 样式用更高特异性复位宽度,并压掉布局级背景与内边距。 实测(真实 Chrome,1000px 视口,与预览 iframe 同宽): 修复前 胶囊宽 952px x4、导航区 scrollWidth 3874/952(溢出); 修复后 214/169/199/200px、952/952(无溢出),与学生端外观一致。
2 months ago
<!--
非 scoped:补齐 .studentLayout / section.app-main 空壳祖先之后,
需要压掉布局级背景与内边距;同时复位窄屏媒体查询。
选择器统一带 #app + .student-task-preview-root,确保 ID 级特异性高于
student-training.scss / sidebar.scss 里的
#app .studentLayout .app-main:has(.student-training-shell) …
这类规则,避免预览壳被学生端布局背景与内边距污染。
-->
<style lang="scss">
#app .studentLayout.student-task-preview-root {
min-height: 0 !important;
background: #ffffff !important;
}
#app .studentLayout.student-task-preview-root .app-main,
#app .studentLayout.student-task-preview-root .app-main:has(.student-training-shell) {
height: auto !important;
min-height: 0 !important;
padding: 0 !important;
overflow: visible !important;
background: #ffffff !important;
}
/*
评阅预览的 iframe 宽度约 1000px(左栏 440~520px + 右栏自适应),
会命中 student-training.scss 的 @media (max-width: 1100px):
.student-training-shell .step-indicator { flex-direction: column }
#app .student-training-shell .step-tab { width: 100% }
后者带 #app(ID 级特异性),会压过本组件 :deep() 里的宽度覆盖,
于是预览里的步骤胶囊被撑成整行、只剩第一个可见(横向滚动条)。
预览需要呈现学生端「桌面端」外观,这里用更高特异性把宽度复位。
*/
#app .student-task-preview-root .step-indicator .step-tab,
#app .student-task-preview-root .step-tabs .step-tab,
#app .student-task-preview-root .comprehensive-step-strip .step-tab,
#app .student-task-preview-root .training-intro__steps .step-tab,
#app .student-task-preview-root .step-indicator .flow-pill,
#app .student-task-preview-root .flow-steps .flow-pill,
#app .student-task-preview-root .flow-rail .flow-step,
#app .student-task-preview-root .training-actions .el-button.training-action,
#app .student-task-preview-root .training-actions button.training-action {
width: auto !important;
}
</style>