Browse Source
Merge branch 'zhangrenyuan/feature-20250728113353-金币前端三期' into milestone-20250728-金币前端三期
zhangrenyuan/feature-20250728113353-金币前端三期
Merge branch 'zhangrenyuan/feature-20250728113353-金币前端三期' into milestone-20250728-金币前端三期
zhangrenyuan/feature-20250728113353-金币前端三期
6 changed files with 213 additions and 5 deletions
-
38src/router/index.js
-
11src/views/consume/addBeanConsume.vue
-
11src/views/consume/articleVideo.vue
-
136src/views/consume/beanConsume.vue
-
11src/views/consume/dieHardFan.vue
-
11src/views/consume/liveStream.vue
@ -0,0 +1,11 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div>addBeanConsume</div> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,11 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div>article videos</div> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
@ -1,11 +1,137 @@ |
|||||
<script setup lang="ts"> |
|
||||
|
<template> |
||||
|
<div> |
||||
|
<!-- 这里放置标签切换的按钮 --> |
||||
|
<el-button-group> |
||||
|
<!-- 切换后状态显示 primary 样式否则是默认样式 --> |
||||
|
<el-button |
||||
|
:type="activeTab === 'add' ? 'primary' : 'default'" |
||||
|
@click="goToAdd" |
||||
|
class="uniform-btn" |
||||
|
> |
||||
|
新增消耗 |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
:type="activeTab === 'live' ? 'primary' : 'default'" |
||||
|
@click="goToLive" |
||||
|
class="uniform-btn" |
||||
|
> |
||||
|
直播 |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
:type="activeTab === 'fan' ? 'primary' : 'default'" |
||||
|
@click="goToFan" |
||||
|
class="uniform-btn" |
||||
|
> |
||||
|
铁粉 |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
:type="activeTab === 'article' ? 'primary' : 'default'" |
||||
|
@click="goToArticle" |
||||
|
class="uniform-btn" |
||||
|
> |
||||
|
文章/视频 |
||||
|
</el-button> |
||||
|
</el-button-group> |
||||
|
<!-- 渲染子路由组件 --> |
||||
|
<router-view></router-view> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
</script> |
|
||||
|
<script setup> |
||||
|
import {onMounted, ref, watch} from 'vue'; |
||||
|
import {useRouter, useRoute} from 'vue-router'; |
||||
|
import {storeToRefs} from "pinia"; |
||||
|
import {useAdminStore} from "@/store/index.js"; |
||||
|
|
||||
<template> |
|
||||
|
const router = useRouter();// 获取路由实例 |
||||
|
const route = useRoute();// 获取当前路由信息 |
||||
|
// 定义响应式变量 activeTab 来跟踪当前激活的标签 |
||||
|
const activeTab = ref(route.name === 'liveStream' ? 'live' : 'add'); |
||||
|
//也就是说如果当前在coinConsumeDetail页面,那么就是detail,否则默认情况都展示add页面 |
||||
|
//此时获取到的路由信息是coinConsume,所以默认是add |
||||
|
const adminStore = useAdminStore(); |
||||
|
const {menuTree} = storeToRefs(adminStore); |
||||
|
|
||||
</template> |
|
||||
|
const goToAdd = () => { |
||||
|
// 点击按钮时更新 activeTab 为 add |
||||
|
activeTab.value = 'add'; |
||||
|
router.push({name: 'addBeanConsume'}); |
||||
|
}; |
||||
|
|
||||
<style scoped> |
|
||||
|
const goToLive = () => { |
||||
|
// 点击按钮时更新 activeTab 为 live |
||||
|
activeTab.value = 'live'; |
||||
|
router.push({name: 'liveStream'}); |
||||
|
}; |
||||
|
const goToFan = () => { |
||||
|
// 点击按钮时更新 activeTab 为 fan |
||||
|
activeTab.value = 'fan'; |
||||
|
router.push({name: 'dieHardFan'}); |
||||
|
}; |
||||
|
const goToArticle = () => { |
||||
|
// 点击按钮时更新 activeTab 为 article |
||||
|
activeTab.value = 'article'; |
||||
|
router.push({name: 'articleVideo'}); |
||||
|
}; |
||||
|
|
||||
|
// 导航方法 |
||||
|
const navigateTo = (name) => { |
||||
|
activeTab.value = name; |
||||
|
if (name === 'add') { |
||||
|
router.push({name: 'addBeanConsume'}); |
||||
|
} else if (name === 'live') { |
||||
|
router.push({name: 'liveStream'}); |
||||
|
} else if (name === 'fan') { |
||||
|
router.push({name: 'dieHardFan'}); |
||||
|
} else if (name === 'article') { |
||||
|
router.push({name: 'articleVideo'}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 递归判断某个 menuName 是否存在 |
||||
|
const hasMenuPermission = (tree, targetName) => { |
||||
|
for (const node of tree) { |
||||
|
if (node.menuName === targetName) return true; |
||||
|
if (node.children && hasMenuPermission(node.children, targetName)) return true; |
||||
|
} |
||||
|
return false; |
||||
|
}; |
||||
|
|
||||
|
// 默认路由判断 |
||||
|
const getDefaultRoute = () => { |
||||
|
if (!menuTree.value) return 'add'; |
||||
|
const hasRecharge = hasMenuPermission(menuTree.value, '提交金豆消耗'); |
||||
|
return hasRecharge ? 'add' : 'live'; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
// 监听路由变化更新标签状态 |
||||
|
watch(() => route.name, (newName) => { |
||||
|
if (newName === 'add' || newName === 'live') { |
||||
|
activeTab.value = newName; |
||||
|
} else if (newName === 'beanConsume') { |
||||
|
const defaultRoute = getDefaultRoute(); |
||||
|
navigateTo(defaultRoute); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 初始化逻辑 |
||||
|
onMounted(() => { |
||||
|
if (route.name === 'beanConsume') { |
||||
|
const defaultRoute = getDefaultRoute(); |
||||
|
navigateTo(defaultRoute); |
||||
|
} else { |
||||
|
// 非父路由初始化当前标签状态 |
||||
|
if (route.name === 'add' || route.name === 'live') { |
||||
|
activeTab.value = route.name; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.uniform-btn { |
||||
|
width: 120px; |
||||
|
} |
||||
</style> |
</style> |
@ -0,0 +1,11 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div>die-hard fans</div> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,11 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div>live stream</div> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue