diff --git a/apps/web/src/oj/problem/components/EditorToolbar.vue b/apps/web/src/oj/problem/components/EditorToolbar.vue index 7802337..94c8853 100644 --- a/apps/web/src/oj/problem/components/EditorToolbar.vue +++ b/apps/web/src/oj/problem/components/EditorToolbar.vue @@ -136,10 +136,21 @@ const toggleHelp = () => { collabStore.requestHelp(problem.value!._id, codeStore.code.language) } +/** + * 右栏窄于 600px(学生把左栏拖宽看长题面、宽 SQL 表时):工具栏折成两行会把编辑器往下挤, + * 所以次要的按钮收进「更多」、「写代码 / 画流程图」缩短一点(设计文档 5.4)。语言下拉不收: + * 窄于 120px 时图标和「Python」会被挤成两行 + */ +const toolbarRef = useTemplateRef<{ $el: HTMLElement }>("toolbarRef") +const { width: toolbarWidth } = useElementSize(() => toolbarRef.value?.$el) +const narrow = computed(() => isDesktop.value && toolbarWidth.value > 0 && toolbarWidth.value < 600) +/** 「课堂统计」常驻在工具栏上:桌面、而且放得下 */ +const statisticsInline = computed(() => isDesktop.value && !narrow.value) + const menuOptions = computed(() => { const options: DropdownOption[] = [] - // 移动端额外收纳桌面端常驻的「课堂统计」。「本题提交」挪到了「我的提交」抽屉的底部 - if (!isDesktop.value && userStore.isTeacherOrAbove) { + // 放不下时(手机、右栏太窄)收进来的「课堂统计」。「本题提交」挪到了「我的提交」抽屉的底部 + if (!statisticsInline.value && userStore.isTeacherOrAbove) { options.push({ label: "课堂统计", key: "statistics", @@ -261,11 +272,11 @@ const goEdit = () => {