Commit 7700f65e authored by xinzhedeai's avatar xinzhedeai

add: togglebutton按钮样式调整,设备状态总览 style

parent 0f5a95e3
<template> <template>
<n-card :bordered="false" class="device-status-card"> <div :bordered="false" class="device-status-card">
<div class="card-header"> <h2 class="card-title">设备状态总览</h2>
<h2 class="card-title">设备状态总览</h2> <!-- <div class="card-header">
</div>
</div> -->
<div class="status-grid"> <div class="status-grid">
<!-- 在线监测 --> <div v-for="item in deviceStatusList" :key="item.id" class="status-item">
<div class="status-item"> <div :class="['percent', item.color]">{{ item.percent }}%</div>
<div class="percent blue">100%</div> <div class="right-content">
<div class="name">在线监测</div> <div class="name">{{ item.name }}</div>
<div class="detail">在线: 56 离线: 0</div> <div class="detail">
</div> <span class="online">在线: {{ item.onlineCount }}</span><br>
<!-- 视频监测 --> <span class="offline">离线: {{ item.offlineCount }}</span>
<div class="status-item"> </div>
<div class="percent yellow">82%</div> </div>
<div class="name">视频监测</div>
<div class="detail">在线: 87 离线: 2</div>
</div>
<!-- 人员定位 -->
<div class="status-item">
<div class="percent cyan">88%</div>
<div class="name">人员定位</div>
<div class="detail">在线: 16 离线: 2</div>
</div>
<!-- 车辆定位 -->
<div class="status-item">
<div class="percent green">100%</div>
<div class="name">车辆定位</div>
<div class="detail">在线: 7 离线: 2</div>
</div> </div>
</div> </div>
</n-card> <div class="card-footer"></div>
</div>
</template> </template>
<script setup lang="ts"></script> <script setup lang="ts">
import { ref, onMounted } from 'vue';
// 定义设备状态数据接口
interface DeviceStatus {
id: string;
name: string;
percent: number;
color: string;
onlineCount: number;
offlineCount: number;
}
// // 定义组件属性
// const props = defineProps<{
// // 如果需要从父组件传递数据,可以添加props
// // deviceStatusList?: DeviceStatus[];
// }>();
// 设备状态数据列表
const deviceStatusList = ref<DeviceStatus[]>([]);
// 模拟接口请求函数
const fetchDeviceStatus = async () => {
try {
// 这里应该是实际的API请求
// const response = await axios.get('/api/device/status');
// deviceStatusList.value = response.data;
// 模拟接口返回数据
deviceStatusList.value = [
{ id: '1', name: '在线监测', percent: 100, color: 'cyan', onlineCount: 56, offlineCount: 0 },
{ id: '2', name: '视频监测', percent: 82, color: 'yellow', onlineCount: 87, offlineCount: 2 },
{ id: '3', name: '人员定位', percent: 88, color: 'blue', onlineCount: 16, offlineCount: 2 },
{ id: '4', name: '车辆定位', percent: 100, color: 'green', onlineCount: 7, offlineCount: 2 }
];
} catch (error) {
console.error('获取设备状态数据失败:', error);
}
};
// 组件挂载时获取数据
onMounted(() => {
fetchDeviceStatus();
});
</script>
<style scoped lang="scss"> <style scoped lang="scss">
.device-status-card { .device-status-card {
width: 4.6rem;
height: 3rem;
position: relative;
padding: 0.15rem; padding: 0.15rem;
background: var(--n-bg-color-secondary); padding-top: .45rem;
// background: var(--n-bg-color-secondary);
.card-header { background-image: url('@/assets/jinrun/module-bg.png');
margin-bottom: 0.15rem; .card-title {
.card-title { position: absolute;
font-size: 0.18rem; left: .25rem;
font-weight: 600; top: -0.15rem;
color: var(--n-text-color-primary); font-weight: 500;
font-size: 0.2rem;
color: #FFFFFF;
text-shadow: 0rem 0rem 0rem rgba(5, 38, 68, 0.5);
} }
.card-header {
position: relative;
width: 4.48rem;
height: 0.46rem;
// margin-bottom: 0.15rem;
// background-image: url('@/assets/jinrun/module-title.png');
// background-size: cover;
// margin-left: -0.1rem;
}
.card-footer {
height: 0.1rem;
background-image: url();
} }
.status-grid { .status-grid {
...@@ -54,30 +106,63 @@ ...@@ -54,30 +106,63 @@
gap: 0.1rem; gap: 0.1rem;
.status-item { .status-item {
text-align: center; display: flex;
align-items: center;
padding: 0.1rem; padding: 0.1rem;
background: rgba(10, 25, 71, 0.6); // background: rgba(10, 25, 71, 0.6);
border-radius: 0.05rem; border-radius: 0.05rem;
.percent { .percent {
font-size: 0.24rem; width: 0.9rem;
height: 0.9rem;
line-height: 0.9rem;
font-size: 0.22rem;
font-weight: bold; font-weight: bold;
margin-bottom: 0.05rem; margin-right: 0.1rem;
&.blue { color: #36a2eb; } min-width: 0.8rem;
&.yellow { color: #facc15; } text-align: center;
&.cyan { color: #4bc0c0; } color:#fff;
&.green { color: #6dd230; } background-image: url('@/assets/jinrun/blue.png');
background-size: cover;
// padding: 0.05rem 0.1rem;
// border-radius: 0.05rem;
&.blue {
background-image: url('@/assets/jinrun/blue.png');
}
&.yellow {
background-image: url('@/assets/jinrun/yellow.png');
}
&.cyan { background-image: url('@/assets/jinrun/cyan.png'); }
&.green { background-image: url('@/assets/jinrun/green.png'); }
}
.right-content {
flex: 1;
text-align: left;
} }
.name { .name {
font-size: 0.14rem; font-weight: 400;
color: var(--n-text-color-secondary); font-size: 0.18rem;
color: #11E0FF;
margin-bottom: 0.03rem; margin-bottom: 0.03rem;
} }
.detail { .detail {
font-size: 0.12rem; font-size: 0.12rem;
color: var(--n-text-color-tertiary);
.online {
font-weight: 400;
font-size: 0.16rem;
color: #FFFFFF;
margin-right: 0.1rem;
}
.offline {
font-weight: 400;
font-size: 0.16rem;
color: #FFCE22;
}
} }
} }
} }
......
...@@ -350,7 +350,9 @@ const navTo = () => { ...@@ -350,7 +350,9 @@ const navTo = () => {
transition: all 0.3s ease; transition: all 0.3s ease;
&.left-toggle { &.left-toggle {
left: 4.65rem; /* 与左侧模块宽度一致 */ // left: 4.65rem; /* 与左侧模块宽度一致 */
left: 5.1rem; /* 与左侧模块宽度一致 */
background-image: url('@/assets/jinrun/toggle-left.png'); background-image: url('@/assets/jinrun/toggle-left.png');
} }
...@@ -360,7 +362,8 @@ const navTo = () => { ...@@ -360,7 +362,8 @@ const navTo = () => {
} }
&.right-toggle { &.right-toggle {
right: 4.65rem;; /* 与右侧模块宽度一致 */ // right: 4.65rem;; /* 与右侧模块宽度一致 */
right: 5.1rem; /* 与左侧模块宽度一致 */
background-image: url('@/assets/jinrun/toggle-right.png'); background-image: url('@/assets/jinrun/toggle-right.png');
} }
...@@ -446,7 +449,7 @@ const navTo = () => { ...@@ -446,7 +449,7 @@ const navTo = () => {
.slide-left-leave-to { .slide-left-leave-to {
transform: translateX(-100%); transform: translateX(-100%);
opacity: 0; opacity: 0;
} }
// 右侧模块滑动动画 // 右侧模块滑动动画
.slide-right-enter-active, .slide-right-enter-active,
...@@ -478,8 +481,10 @@ const navTo = () => { ...@@ -478,8 +481,10 @@ const navTo = () => {
} }
.left-modules, .right-modules { .left-modules, .right-modules {
width: 4.65rem; width: 4.6rem;
background: pink; // background: pink;
margin-top: .6rem;
margin-left: 0.4rem;
} }
.arrow-font{ .arrow-font{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment