Compare commits
No commits in common. "80738cb2a0f31010feca36baa10519d477654165" and "d4386f44808abb76d702c456be9ca88092d0068a" have entirely different histories.
80738cb2a0
...
d4386f4480
13
src/App.vue
13
src/App.vue
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="app" class="app-container">
|
<div id="app">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,14 +13,5 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#app{
|
/* 添加你的样式 */
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
/* .app-container{
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
} */
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,81 +1,167 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="layout" class="layout-container">
|
<div id="layout">
|
||||||
<el-aside width="200px" class="nav-sidebar">
|
<el-header >
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<el-image src="/logo.png" fit="contain" />
|
<span>管理平台</span>
|
||||||
</div>
|
</div>
|
||||||
<el-menu :default-active="activeIndex" class="el-menu-part" router>
|
<div class="nav-menu">
|
||||||
<el-menu-item index="/">告警管理</el-menu-item>
|
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" router>
|
||||||
<el-menu-item index="/test">测试</el-menu-item>
|
<el-menu-item index="/" style="margin-left:230px">告警管理</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-aside>
|
</div>
|
||||||
|
<div class="user-info">
|
||||||
<el-main class="main-content">
|
<span>客流分析</span>
|
||||||
<router-view />
|
<span>|</span>
|
||||||
</el-main>
|
<span @click="showDialog = true" style="cursor: pointer;">选择摊位</span>
|
||||||
|
<span v-if="selectedStoreName">| 已选择: {{ selectedStoreName }}</span>
|
||||||
|
<span>|</span>
|
||||||
|
<span>区域管理</span>
|
||||||
|
<el-dropdown @command="handleCommand" placement="bottom-end">
|
||||||
|
<span class="el-dropdown-link">
|
||||||
|
{{ username }} <i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
|
</span>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item command="logout">登出</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts">
|
||||||
import { ref, watch } from 'vue';
|
import { defineComponent, ref, computed, watch, onMounted } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
|
// import type { Store } from '@/utils/type'
|
||||||
|
|
||||||
const route = useRoute();
|
export default defineComponent({
|
||||||
const activeIndex = ref(route.path);
|
name: 'Layout',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
const token = ref(localStorage.getItem('token') || '');
|
||||||
|
const isUserLoggedIn = computed(() => !!token.value);
|
||||||
|
const username = ref(localStorage.getItem('username') || '');
|
||||||
|
// const isUserLoggedIn = computed(() => !!username.value);
|
||||||
|
const activeIndex = ref(route.path);
|
||||||
|
const showDialog = ref(false);
|
||||||
|
// const selectedStore = ref<Store | null>(null);
|
||||||
|
const selectedStoreName = ref(localStorage.getItem('store_name') || '');
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.path,
|
const handleCommand = (command: string) => {
|
||||||
(newPath) => {
|
if (command === 'logout') {
|
||||||
activeIndex.value = newPath;
|
localStorage.removeItem('username');
|
||||||
}
|
localStorage.removeItem('token');
|
||||||
);
|
localStorage.removeItem('store_id');
|
||||||
|
localStorage.removeItem('store_name');
|
||||||
|
token.value = '';
|
||||||
|
username.value = '';
|
||||||
|
selectedStoreName.value = '';
|
||||||
|
router.push('/login');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.path,
|
||||||
|
(newPath) => {
|
||||||
|
activeIndex.value = newPath;
|
||||||
|
// if (!token.value && newPath !== '/login') {
|
||||||
|
// router.push('/login');
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// if (!token.value) {
|
||||||
|
// router.push('/login');
|
||||||
|
// } else {
|
||||||
|
// selectedStoreName.value = localStorage.getItem('store_name') || '';
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
username,
|
||||||
|
token,
|
||||||
|
isUserLoggedIn,
|
||||||
|
activeIndex,
|
||||||
|
handleCommand,
|
||||||
|
showDialog,
|
||||||
|
selectedStoreName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.layout-container {
|
.el-header {
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
margin: 1px;
|
|
||||||
/* padding: 1px; */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-sidebar {
|
|
||||||
background-color: #1f2d3d;
|
background-color: #1f2d3d;
|
||||||
/* width: 200px; */
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 20px;
|
||||||
|
margin: 10px 20x;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
align-items: center;
|
||||||
margin-bottom: 30px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu-part {
|
.nav-menu {
|
||||||
|
flex-grow: 1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: 110px;
|
||||||
|
margin-right: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-demo {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border: 1px;
|
display: flex;
|
||||||
/* width: 200px; */
|
justify-content: space-between;
|
||||||
|
/* justify-content: flex-start; */
|
||||||
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu-part .el-menu-item {
|
.el-menu-demo .el-menu-item {
|
||||||
/* padding:30px 0; */
|
padding: 0 20px;
|
||||||
padding: 0px;
|
|
||||||
margin: 0;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu-part .el-menu-item:hover {
|
.el-menu-demo .el-menu-item:hover {
|
||||||
color: #00aaff;
|
color: #00aaff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
|
||||||
flex-grow: 1;
|
.user-info {
|
||||||
padding: 20px;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue