From 7bb53a6ea60d209fa43761453b8107e4926c3570 Mon Sep 17 00:00:00 2001 From: zhoumengru Date: Fri, 12 Sep 2025 09:43:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(MainView):=20=E6=B7=BB=E5=8A=A0=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=97=A5=E6=9C=9F=E5=92=8C=E6=97=B6=E9=97=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 MainView 组件中添加了实时更新的日期和时间显示 - 实现了页面加载时初始化日期和时间,并设置每秒更新的定时器 - 优化了组件卸载时清除定时器的逻辑 - 添加了用户信息显示和退出系统的功能 --- web/src/views/MainView.vue | 97 +++++++++++++------------------------- 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/web/src/views/MainView.vue b/web/src/views/MainView.vue index 1701003..f0413a8 100644 --- a/web/src/views/MainView.vue +++ b/web/src/views/MainView.vue @@ -58,68 +58,13 @@ export default { currentKey: '', subCurrentKey: '', menuList: [], - // menuList: [ - // { - // name: '系统总览', - // path: '/home' - // }, - // { - // name: '运行监控', - // path: '/monitor' - // }, - // { - // name: '预测管理', - // path: '/predict' - // }, - // { - // name: '统计分析', - // path: '/statisticalAnalysis' - // }, - // { - // name: '系统管理', - // path: '/system', - // children: [ - // { - // name: '用户管理', - // path: '/user' - // }, - // { - // name: '角色管理', - // path: '/role' - // }, - // { - // name: '权限管理', - // icon: 'icon-caidanguanli' - // }, - // { - // name: '场站管理', - // path: '/station', - // icon: 'icon-caidanguanli' - // }, - // { - // name: '服务管理', - // icon: 'icon-bumenguanli' - // }, - // { - // name: '策略管理', - // path: '/policy' - // }, - // { - // name: '设备管理', - // path: '/device ' - // }, - // { - // name: '告警日志', - // path: '/log' - // }, - // { - // name: '系统日志', - // path: '/syslog' - // } - // ] - // } - // ], - subMenu: [] + + subMenu: [], + currentTime: '', + timer: null, + dateVal: moment().locale('zh-cn').format('ll') + ' ', + weekVal: moment().locale('zh-cn').format('dddd'), + user:localStorage.getItem('account').replace(/^"|"$/g, '') } }, computed: { @@ -149,9 +94,35 @@ export default { }, mounted() { - // this.initRoute() + this.getDateTime() + this.timer = setInterval(() => { + this.getDateTime() + }, 1000) + }, + unmounted() { + clearInterval(this.timer) }, methods: { + logout(){ + const that=this + this.$Modal.confirm({ + title: '你确认退出系统吗?', + icon: createVNode(ExclamationCircleOutlined), + + async onOk() { + localStorage.clear() + that.$router.push('/login') + }, + onCancel() { + }, + class: 'test' + }) + + }, + //getDateTime + getDateTime() { + this.currentTime = moment().locale('zh-cn').format('LTS') + }, // 新增子菜单处理方法 handleSubMenu(pathSegments,to) { // 查找当前激活的主菜单项