|
@@ -34,9 +34,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted, watch } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted, watch, computed } from 'vue'
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
import { teacherList } from '@/api/teachers.js'
|
|
import { teacherList } from '@/api/teachers.js'
|
|
|
|
|
+import { CONFIG } from '@/utils/roleUtils.js'
|
|
|
|
|
|
|
|
// 导入图片
|
|
// 导入图片
|
|
|
// 白色图标
|
|
// 白色图标
|
|
@@ -72,8 +73,8 @@ const drawerVisible = ref(true)
|
|
|
// 当前选中索引状态
|
|
// 当前选中索引状态
|
|
|
const currentActiveIndex = ref('2')
|
|
const currentActiveIndex = ref('2')
|
|
|
|
|
|
|
|
-// 渲染侧边栏
|
|
|
|
|
-const groupList = ref([
|
|
|
|
|
|
|
+// 原始菜单数据
|
|
|
|
|
+const originalGroupList = ref([
|
|
|
{
|
|
{
|
|
|
icon: question, // 默认图片
|
|
icon: question, // 默认图片
|
|
|
hoverIcon: question02, // 交互图片
|
|
hoverIcon: question02, // 交互图片
|
|
@@ -146,6 +147,24 @@ const groupList = ref([
|
|
|
}
|
|
}
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
+// 获取角色路由菜单集合
|
|
|
|
|
+const roleRouteMenuSet = computed(() => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const roleRouteMenuStr = localStorage.getItem(CONFIG.USER_ROLE_ROUTE_MENU_KEY)
|
|
|
|
|
+ return roleRouteMenuStr ? JSON.parse(roleRouteMenuStr) : []
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('Error parsing roleRouteMenuSet:', error)
|
|
|
|
|
+ return []
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+// 根据角色路由菜单权限过滤后的菜单数据
|
|
|
|
|
+const groupList = computed(() => {
|
|
|
|
|
+ return originalGroupList.value.filter(item => {
|
|
|
|
|
+ return item && item.path && roleRouteMenuSet.value.includes(item.path)
|
|
|
|
|
+ })
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 更新选中状态的方法
|
|
// 更新选中状态的方法
|
|
|
const updateActiveIndex = () => {
|
|
const updateActiveIndex = () => {
|
|
|
const path = route.path
|
|
const path = route.path
|
|
@@ -154,10 +173,10 @@ const updateActiveIndex = () => {
|
|
|
let menuItem = null
|
|
let menuItem = null
|
|
|
// 从其他问答页面进入智能问答页面
|
|
// 从其他问答页面进入智能问答页面
|
|
|
if (path.includes('ai-questions') && from){
|
|
if (path.includes('ai-questions') && from){
|
|
|
- menuItem = groupList.value.find(item => from === item.path.replace('/', ''))
|
|
|
|
|
|
|
+ menuItem = groupList.value.find(item => item && item.path && from === item.path.replace('/', ''))
|
|
|
}else{
|
|
}else{
|
|
|
// 查找路径对应的索引
|
|
// 查找路径对应的索引
|
|
|
- menuItem = groupList.value.find(item => path.includes(item.path.replace('/', '')))
|
|
|
|
|
|
|
+ menuItem = groupList.value.find(item => item && item.path && path.includes(item.path.replace('/', '')))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//保持选中当前页面
|
|
//保持选中当前页面
|