zhuguifei
2025-06-17 c1cc49dd93d38f51790558541d6835d1598ecccf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<script setup lang="ts">
import {
  useDarkMode,
  useToggleDarkMode
} from "@/composables/useToggleDarkMode";
import { ref, onMounted, onBeforeUnmount } from "vue";
import dayjs from "dayjs";
import { useRouter } from "vue-router";
const router = useRouter();
 
const onClickRight = (event: TouchEvent | MouseEvent) => {
  useToggleDarkMode(event);
};
 
const menuList = ref([
  {
    name: "检测",
    icon: "tv-o",
    path: "/demo"
  },
  {
    name: "分析",
    icon: "chart-trending-o",
    path: "/analy"
  },
  {
    name: "校准",
    icon: "aim",
    path: "/calibration"
  },
  {
    name: "设置",
    icon: "setting-o",
    path: "/setting"
  },
  {
    name: "系统",
    icon: "info-o",
    path: "/system"
  }
]);
const clickMenuIndex = ref(0);
const onClickMenu = (item: any, index: number) => {
  if (clickMenuIndex.value === index) return false;
  clickMenuIndex.value = index;
  goToPage(item.path);
};
 
const goToPage = (page: string) => {
  router.push(`${page}`);
};
 
const currentTime = ref("");
 
// 更新时间函数
const updateTime = () => {
  currentTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
};
 
let timer = null;
 
onMounted(() => {
  updateTime(); // 立即更新一次
  timer = setInterval(updateTime, 1000); // 每秒更新
});
 
onBeforeUnmount(() => {
  clearInterval(timer); // 组件卸载时清除定时器
});
</script>
 
<template>
  <div class="app">
    <div class="menu_logo_box">
      <img class="logo" src="@/assets/logo.png" />
      <span class="ml-2">粮食水分仪系统</span>
    </div>
    <div class="menu_box">
      <div
        v-for="(item, index) in menuList"
        :key="index"
        class="item"
        :class="{ active: index === clickMenuIndex }"
        @click="onClickMenu(item, index)"
      >
        <van-icon :name="item.icon" size="30" />
        {{ item.name }}
      </div>
    </div>
 
    <div class="menu-info">
      <div class="info-time mr-6 font-sans">
        {{ currentTime }}
      </div>
      <div class="info-setting pr-8">
<!--        <div class="img-border mr-5" @click.stop="goToPage('/system')">
          <img src="@/assets/icon/icon-tips.png" class="w-[30px]" />
        </div>-->
        <div class="img-border">
          <img src="@/assets/icon/icon-close.png" class="w-[30px]" />
        </div>
      </div>
    </div>
  </div>
</template>
 
<style lang="less" scoped>
.app {
  width: 100vw;
  height: 85px;
  background: var(--base-green);
  color: white;
  display: flex;
  user-select: none;
  font-family: "Microsoft YaHei", sans-serif;
  cursor: pointer;
 
  .menu_logo_box {
    width: 30%;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    padding-left: 5px;
 
    .logo {
      width: 120px;
      height: 30px;
    }
  }
 
  .menu_box {
    width: 45%;
    display: flex;
    padding: 0 10px;
    .item {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      font-size: 20px;
      font-weight: bold;
    }
    .active {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: var(--color-background-2);
      color: var(--base-green);
      font-weight: bold;
      box-sizing: border-box;
    }
    .active::after {
      content: "";
      position: absolute;
      bottom: 0;
      left: 50%;
      width: 30%;
      height: 6px;
      background-color: var(--base-green);
      border-radius: 3px;
      transform: translateX(-50%);
    }
  }
  .menu-info {
    width: 25%;
    display: flex;
    justify-content: flex-end;
 
    .info-time {
      width: 50%;
    }
    .info-time,
    .info-setting {
      display: flex;
      justify-content: center;
      align-items: center;
      font-weight: bold;
      .img-border {
        padding: 2px;
        border: 3px solid white;
        border-radius: 8px;
      }
    }
  }
}
</style>