fix: 修复webUI刷新跳转登录页面的问题

This commit is contained in:
TOM88812
2025-02-16 23:01:44 +08:00
parent 1598f6cd14
commit 68ab05b220
12 changed files with 288 additions and 299 deletions
+2 -47
View File
@@ -1,64 +1,19 @@
<template>
<div id="app">
<div class="app-content" :class="{ 'auth-layout': !isLoggedIn }">
<div v-if="!isLoggedIn">
<Login v-if="!showRegistration" @show-registration="showRegistration = true" @login-success="handleLoginSuccess" />
<Registration v-else @show-login="showRegistration = false" />
</div>
<div v-else class="main-layout">
<role-setting v-if="currentView === 'RoleSetting'"
:device-id="selectedDeviceId"
@back-to-panel="switchView('panel')"/>
<panel v-else-if="currentView === 'panel'"
@go-home="switchView('main')"
@show-role="handleShowRole"
/>
<main-page v-else @enter-panel="switchView('panel')"/>
</div>
<div class="app-content">
<router-view></router-view>
</div>
<Footer />
</div>
</template>
<script>
import Login from './components/Login.vue';
import Registration from './components/Registration.vue';
import panel from './components/panel.vue';
import MainPage from './components/Main.vue';
import RoleSetting from './components/RoleSetting.vue';
import Footer from './components/Footer.vue';
export default {
name: 'App',
components: {
Login,
Registration,
panel,
MainPage,
RoleSetting,
Footer
},
data() {
return {
showRegistration: false,
isLoggedIn: false,
currentView: 'main',
selectedDeviceId: null // 添加selectedDeviceId状态
};
},
methods: {
handleLoginSuccess() {
this.isLoggedIn = true;
this.currentView = 'panel';
},
switchView(view) {
console.log('Switching to view:', view); // 添加调试日志
this.currentView = view;
},
handleShowRole(deviceId) {
this.selectedDeviceId = deviceId;
this.switchView('RoleSetting');
}
}
};
</script>