Files
pqs-9100_client/frontend/src/layouts/components/Footer/index.vue

135 lines
4.1 KiB
Vue
Raw Normal View History

2024-08-22 11:27:06 +08:00
<template>
2025-10-10 13:23:40 +08:00
<div class="footer flx-align-center pl10">
<el-dropdown>
<div class="change_mode">
{{ title }}
<el-icon class="el-icon--right change_mode_down"><arrow-down /></el-icon>
<el-icon class="el-icon--right change_mode_up"><arrow-up /></el-icon>
</div>
<template #dropdown>
<el-dropdown-menu>
2025-10-14 19:00:47 +08:00
<el-dropdown-item
v-for="item in modeList"
:key="item.key"
:disabled="!item.activated"
@click="handelOpen(item.code, item.key)"
>
{{ item.name }}
</el-dropdown-item>
2025-10-10 13:23:40 +08:00
</el-dropdown-menu>
</template>
</el-dropdown>
<p style="margin: 0">
<a href="http://www.shining-electric.com/" target="_blank">2024 © 南京灿能电力自动化股份有限公司</a>
</p>
</div>
2024-08-22 11:27:06 +08:00
</template>
2024-08-27 16:17:42 +08:00
<script lang="ts" setup>
2025-10-10 13:23:40 +08:00
import { computed } from 'vue'
import { useAuthStore } from '@/stores/modules/auth'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useTabsStore } from '@/stores/modules/tabs'
import { useRouter } from 'vue-router'
import { initDynamicRouter } from '@/routers/modules/dynamicRouter'
const router = useRouter()
2025-10-10 13:23:40 +08:00
const authStore = useAuthStore()
const modeStore = useModeStore()
const tabsStore = useTabsStore()
2024-12-05 13:51:47 +08:00
2025-05-06 15:22:26 +08:00
const title = computed(() => {
2025-10-14 19:00:47 +08:00
return modeStore.currentMode === '' ? '选择模块' : modeStore.currentMode + '模块'
2025-10-10 13:23:40 +08:00
})
2025-10-14 19:00:47 +08:00
const activateInfo = authStore.activateInfo
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
const modeList = [
{
name: '模拟式模块',
code: '模拟式',
key: 'simulate',
activated: isActivateOpen === 'true' ? activateInfo.simulate.permanently === 1 : true
2025-10-14 19:00:47 +08:00
},
{
name: '数字式模块',
code: '数字式',
key: 'digital',
activated: isActivateOpen === 'true' ? activateInfo.digital.permanently === 1 : true
2025-10-14 19:00:47 +08:00
},
{
name: '比对式模块',
code: '比对式',
key: 'contrast',
activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
2025-10-14 19:00:47 +08:00
}
]
const handelOpen = async (item: string, key: string) => {
if (isActivateOpen === 'true' && activateInfo[key].permanently !== 1) {
2025-10-14 19:00:47 +08:00
ElMessage.warning(`${item}模块未激活`)
return
}
2025-10-10 13:23:40 +08:00
await authStore.setShowMenu()
modeStore.setCurrentMode(item) // 将模式code存入 store
// 强制刷新页面
await tabsStore.closeMultipleTab()
await initDynamicRouter()
// 只有当目标路径与当前路径不同时才跳转
if (router.currentRoute.value.path !== '/home/index') {
await router.push({ path: '/home/index' })
} else {
// 如果已在目标页面,手动触发组件更新
window.location.reload() // 或者采用其他方式刷新数据
}
2025-10-10 13:23:40 +08:00
}
2024-08-27 16:17:42 +08:00
</script>
2024-08-22 11:27:06 +08:00
<style scoped lang="scss">
2025-10-10 13:23:40 +08:00
@use './index.scss';
.footer {
2025-10-10 13:23:40 +08:00
position: relative;
background-color: var(--el-color-primary);
// .el-button:hover {
// background-color: var(--el-color-primary) !important;
// border: none !important;
// outline: none !important;
// }
.change_mode {
color: #fff;
display: flex;
align-items: center;
justify-content: flex-start;
height: 100%;
width: auto;
font-size: 14px;
.change_mode_down {
display: block;
}
.change_mode_up {
display: none;
}
}
2025-10-10 13:23:40 +08:00
.change_mode:hover {
.change_mode_down {
display: none;
}
.change_mode_up {
display: block;
}
}
2025-10-10 13:23:40 +08:00
.el-dropdown {
z-index: 1001;
}
2025-10-10 13:23:40 +08:00
p {
position: absolute;
width: 100%;
height: 100%;
text-align: right;
line-height: 40px;
a {
color: #fff;
margin-right: 25px; // 增加右边距
}
}
2024-08-27 18:37:46 +08:00
}
2024-08-22 11:27:06 +08:00
</style>