303 lines
9.2 KiB
Vue
Raw Normal View History

2025-08-21 19:39:07 +08:00
<template>
<div class="course-editor">
<!-- 左侧导航菜单 -->
2025-08-24 18:20:16 +08:00
<div class="sidebar" v-if="!hideSidebar">
2025-08-22 19:52:05 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/courseware`" class="menu-item"
:class="{ active: $route.path.includes('courseware') }">
<img :src="$route.path.includes('courseware') ? '/images/teacher/课件-选中.png' : '/images/teacher/课件.png'"
2025-08-25 10:39:24 +08:00
alt="资源库" />
<span>资源库</span>
2025-08-21 19:39:07 +08:00
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/chapters`" class="menu-item"
:class="{ active: $route.path.includes('chapters') }">
<img :src="$route.path.includes('chapters') ? '/images/teacher/章节-选中.png' : '/images/teacher/章节.png'"
alt="章节" />
2025-08-21 19:39:07 +08:00
<span>章节</span>
</router-link>
2025-08-22 19:52:05 +08:00
<!-- 作业二级导航 -->
<div class="menu-group">
2025-08-23 19:20:14 +08:00
<div class="menu-header" @click="toggleHomework">
2025-08-24 18:20:16 +08:00
<img src="/images/teacher/作业.png" alt="作业" />
2025-08-22 19:52:05 +08:00
<span>作业</span>
2025-08-24 18:20:16 +08:00
<i class="n-base-icon" :class="{ expanded: homeworkExpanded }">
2025-08-22 19:52:05 +08:00
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z"
2025-08-24 18:20:16 +08:00
fill="#C2C2C2" />
2025-08-22 19:52:05 +08:00
</svg>
</i>
</div>
2025-08-23 19:20:14 +08:00
<div class="submenu" v-show="homeworkExpanded">
2025-08-22 19:52:05 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/homework/library`" class="submenu-item"
2025-08-24 18:20:16 +08:00
:class="{ active: $route.path.includes('/homework/library') }">
2025-08-22 19:52:05 +08:00
<span>作业库</span>
</router-link>
<router-link :to="`/teacher/course-editor/${courseId}/homework/review`" class="submenu-item"
2025-08-24 18:20:16 +08:00
:class="{ active: $route.path.includes('/homework/review') }">
2025-08-22 19:52:05 +08:00
<span>批阅作业</span>
</router-link>
2025-08-22 16:59:07 +08:00
</div>
</div>
2025-08-24 18:20:16 +08:00
<!-- 练考通二级导航 -->
<div class="menu-group">
<div class="menu-header" @click="togglePractice">
<img src="/images/teacher/练考通.png" alt="练考通" />
<span>练考通</span>
<i class="n-base-icon" :class="{ expanded: practiceExpanded }">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z"
fill="#C2C2C2" />
</svg>
</i>
</div>
<div class="submenu" v-show="practiceExpanded">
<router-link :to="`/teacher/course-editor/${courseId}/practice/exam`" class="submenu-item"
:class="{ active: $route.path.includes('/practice/exam') }">
<span>试卷</span>
</router-link>
<router-link :to="`/teacher/course-editor/${courseId}/practice/review`" class="submenu-item"
:class="{ active: $route.path.includes('/practice/review') }">
<span>阅卷中心</span>
</router-link>
</div>
</div>
2025-08-22 19:52:05 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/question-bank`" class="menu-item"
:class="{ active: $route.path.includes('question-bank') }">
<img :src="$route.path.includes('question-bank') ? '/images/teacher/题库-选中.png' : '/images/teacher/题库.png'"
alt="题库" />
2025-08-21 19:39:07 +08:00
<span>题库</span>
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/certificate`" class="menu-item"
:class="{ active: $route.path.includes('certificate') }">
<img :src="$route.path.includes('certificate') ? '/images/teacher/证书-选中.png' : '/images/teacher/证书.png'"
alt="证书" />
2025-08-21 19:39:07 +08:00
<span>证书</span>
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/discussion`" class="menu-item"
:class="{ active: $route.path.includes('discussion') }">
<img :src="$route.path.includes('discussion') ? '/images/teacher/讨论-选中.png' : '/images/teacher/讨论.png'"
alt="讨论" />
2025-08-21 19:39:07 +08:00
<span>讨论</span>
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/statistics`" class="menu-item"
:class="{ active: $route.path.includes('statistics') }">
<img :src="$route.path.includes('statistics') ? '/images/teacher/统计-选中.png' : '/images/teacher/统计.png'"
alt="统计" />
2025-08-21 19:39:07 +08:00
<span>统计</span>
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/notification`" class="menu-item"
:class="{ active: $route.path.includes('notification') }">
<img :src="$route.path.includes('notification') ? '/images/teacher/通知-选中.png' : '/images/teacher/通知.png'"
alt="通知" />
2025-08-21 19:39:07 +08:00
<span>通知</span>
</router-link>
2025-08-22 16:59:07 +08:00
<router-link :to="`/teacher/course-editor/${courseId}/management`" class="menu-item"
:class="{ active: $route.path.includes('management') }">
<img :src="$route.path.includes('management') ? '/images/teacher/管理-选中.png' : '/images/teacher/管理.png'"
alt="管理" />
2025-08-21 19:39:07 +08:00
<span>管理</span>
</router-link>
</div>
<!-- 右侧内容区域 -->
2025-08-24 18:20:16 +08:00
<div class="content-area" :class="{ 'full-width': hideSidebar }">
2025-08-21 19:39:07 +08:00
<router-view />
</div>
</div>
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router'
2025-08-24 18:20:16 +08:00
import { ref, computed } from 'vue'
2025-08-21 19:39:07 +08:00
const route = useRoute()
// 获取课程ID
const courseId = route.params.id
2025-08-22 16:59:07 +08:00
2025-08-23 19:20:14 +08:00
// 作业菜单展开状态
const homeworkExpanded = ref(false)
2025-08-22 16:59:07 +08:00
2025-08-22 19:52:05 +08:00
// 切换作业菜单展开/收起
2025-08-23 19:20:14 +08:00
const toggleHomework = () => {
homeworkExpanded.value = !homeworkExpanded.value
2025-08-22 16:59:07 +08:00
}
2025-08-24 18:20:16 +08:00
// 练考通菜单展开状态
const practiceExpanded = ref(false)
// 切换练考通菜单展开/收起
const togglePractice = () => {
practiceExpanded.value = !practiceExpanded.value
}
// 判断是否隐藏左侧导航
const hideSidebar = computed(() => {
const currentPath = route.path
// 定义需要隐藏侧边栏的页面路径
const hideSidebarPaths = [
'add-question', // 新增试题页面
'edit-question', // 编辑试题页面(预留)
'question-preview', // 题目预览页面(预留)
'bulk-import', // 批量导入页面(预留)
'question-analysis' // 题目分析页面(预留)
]
// 检查当前路径是否包含需要隐藏侧边栏的路径
return hideSidebarPaths.some(path => currentPath.includes(path))
})
2025-08-21 19:39:07 +08:00
</script>
<style scoped>
.course-editor {
display: flex;
margin-top: 5px;
height: 100vh;
background: #f5f5f5;
}
/* 左侧导航 */
.sidebar {
2025-08-23 19:20:14 +08:00
width: 220px;
2025-08-21 19:39:07 +08:00
background: #fff;
border-right: 1px solid #e8e8e8;
padding: 20px 15px;
margin-right: 5px;
}
2025-08-24 18:20:16 +08:00
/* 右侧内容区域 */
.content-area {
flex: 1;
overflow: auto;
}
/* 全宽显示(隐藏侧边栏的页面) */
.content-area.full-width {
width: 100%;
margin-left: 0;
}
2025-08-21 19:39:07 +08:00
.menu-item {
display: flex;
align-items: center;
2025-08-23 19:20:14 +08:00
padding: 12px 15px;
2025-08-21 19:39:07 +08:00
margin-bottom: 5px;
cursor: pointer;
transition: all 0.3s ease;
border-left: 3px solid transparent;
text-decoration: none;
color: inherit;
2025-08-23 19:20:14 +08:00
font-size: 16px;
2025-08-21 19:39:07 +08:00
color: #666;
border-radius: 5px;
}
.menu-item:hover {
background: #f5f5f5;
}
.menu-item.active {
background: #F5F8FB;
color: #0288D1;
}
.menu-item.active span {
color: #0288D1;
}
.menu-item img {
2025-08-23 19:20:14 +08:00
margin-left: 30px;
2025-08-21 19:39:07 +08:00
margin-top: 1px;
2025-08-23 19:20:14 +08:00
width: 16px;
height: 16px;
margin-right: 14px;
2025-08-22 16:59:07 +08:00
}
.menu-item span {
2025-08-23 19:20:14 +08:00
font-size: 16px;
2025-08-22 16:59:07 +08:00
color: #666;
}
/* 作业二级导航样式 */
.menu-group {
margin-bottom: 5px;
}
.menu-header {
display: flex;
align-items: center;
2025-08-23 19:20:14 +08:00
padding: 12px 15px;
2025-08-24 18:20:16 +08:00
margin-bottom: 5px;
2025-08-22 16:59:07 +08:00
cursor: pointer;
transition: all 0.3s ease;
border-left: 3px solid transparent;
2025-08-23 19:20:14 +08:00
font-size: 16px;
2025-08-22 16:59:07 +08:00
color: #666;
border-radius: 5px;
}
.menu-header:hover {
background: #f5f5f5;
}
.menu-header img {
2025-08-23 19:20:14 +08:00
margin-left: 30px;
2025-08-22 16:59:07 +08:00
margin-top: 1px;
2025-08-23 19:20:14 +08:00
width: 16px;
height: 16px;
margin-right: 14px;
2025-08-22 16:59:07 +08:00
}
.menu-header span {
2025-08-23 19:20:14 +08:00
font-size: 16px;
2025-08-22 16:59:07 +08:00
color: #666;
}
.menu-header .n-base-icon {
2025-08-24 18:20:16 +08:00
margin-left: auto;
transition: transform 0.3s ease;
width: 16px;
height: 16px;
display: flex;
align-items: center;
justify-content: center;
}
.menu-header .n-base-icon svg {
2025-08-21 19:39:07 +08:00
width: 16px;
height: 16px;
2025-08-24 18:20:16 +08:00
transition: transform 0.3s ease;
2025-08-21 19:39:07 +08:00
}
2025-08-24 18:20:16 +08:00
.menu-header .n-base-icon.expanded svg {
2025-08-22 16:59:07 +08:00
transform: rotate(90deg);
}
.submenu {
2025-08-24 18:20:16 +08:00
margin-left: 30px;
margin-bottom: 5px;
2025-08-22 16:59:07 +08:00
}
.submenu-item {
2025-08-24 18:20:16 +08:00
display: block;
padding: 8px 15px;
margin-bottom: 3px;
2025-08-22 16:59:07 +08:00
text-decoration: none;
2025-08-21 19:39:07 +08:00
color: #666;
2025-08-24 18:20:16 +08:00
font-size: 14px;
border-radius: 3px;
transition: all 0.3s ease;
2025-08-22 16:59:07 +08:00
}
.submenu-item:hover {
2025-08-24 18:20:16 +08:00
background: #f0f8ff;
2025-08-22 16:59:07 +08:00
color: #0288D1;
}
2025-08-24 18:20:16 +08:00
.submenu-item.active {
background: #e6f7ff;
2025-08-22 16:59:07 +08:00
color: #0288D1;
}
2025-08-21 19:39:07 +08:00
</style>