refactor: 移除旧版大屏示例并接入新版数据大屏

删除 demo 下大屏与路由面板示例;新增数据大屏页面;部署脚本纳入版本库
This commit is contained in:
Ray.Hao committed 2026-09-30 19:00:47 +08:00
1 parent 30ff18951f
commit f852b22d07
109 files changed
+33216 -3580

No files matched your search

+4
View File
@@ -46,6 +46,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "DictDemo",
});
const stringValue = ref("1"); // 性别(值为 String)
const numberValue = ref(1); // 性别(值为 Number)
const arrayValue = ref(["1", "2"]); // 性别(值为 Array)
+4 -1
View File
@@ -18,6 +18,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "DemoIconSelect",
});
// ❌ 踩坑:页面文件名 icon-select.vue 与模板标签 <icon-select> 同名会触发 Vue 隐式自引用
// (unplugin-vue-components 对同名组件禁用自动导入,运行时解析到页面自身 → 无限递归栈溢出白屏)
// ✅ 显式导入公共组件,优先级高于隐式自引用,杜绝递归
@@ -26,5 +30,4 @@ import IconSelect from "@/components/IconSelect/index.vue";
// element-plus 图标格式以 el-icon-开头
const iconName = ref("el-icon-edit");
// 本地 SVG 图标格式为 src/assets/icons 下的文件名,不需要 svg 后缀
// const iconName = ref("api");
</script>
+1 -1
View File
@@ -39,7 +39,7 @@
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
defineOptions({
name: "Icons",
name: "IconDemo",
inheritAttrs: false,
});
const svg_icons: string[] = [
@@ -27,6 +27,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "TableSelect",
});
import selectConfig from "./config/select";
import { useDictStore } from "@/stores";
const dictStore = useDictStore();
+4
View File
@@ -118,6 +118,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "Upload",
});
// 单图
const picUrl = ref("https://s2.loli.net/2023/05/24/yNsxFC8rLHMZQcK.jpg");
const picUrls = ref(["https://s2.loli.net/2023/05/24/yNsxFC8rLHMZQcK.jpg"]);
+4
View File
@@ -22,6 +22,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "WangEditor",
});
// 必须显式导入:页面文件名 wang-editor.vue 与标签 <WangEditor> 同名,会触发 Vue 隐式自引用
// (自动导入对同名组件不生效,运行时解析到页面自身 → 递归栈溢出白屏)
import WangEditor from "@/components/WangEditor/index.vue";
-8
View File
@@ -1,11 +1,5 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="页面缓存:切走再回来,状态还在"
description="缓存由菜单 keep_alive 与路由 meta.keepAlive 共同控制;匹配键是完整路径(含 query),所以同一个页面带不同参数会各存一份缓存。"
/>
<el-card class="page-content" shadow="never">
<template #header>缓存对照实验</template>
@@ -41,8 +35,6 @@ let mountedTotal = 0;
<script setup lang="ts">
import { onActivated, onDeactivated } from "vue";
import RouteInfoPanel from "@/views/demo/route/components/RouteInfoPanel.vue";
defineOptions({
name: "RouteCache",
});
@@ -1,81 +0,0 @@
<template>
<section
class="p-4 bg-[var(--el-bg-color)] border border-solid border-[var(--el-border-color-lighter)] rounded-md"
>
<header class="mb-3">
<h3 class="m-0 text-base font-600 text-[var(--el-text-color-primary)]">{{ title }}</h3>
<p
v-if="description"
class="mt-1.5 mb-0 text-13px leading-[1.6] text-[var(--el-text-color-secondary)]"
>
{{ description }}
</p>
</header>
<el-descriptions :column="2" border size="small">
<el-descriptions-item label="路由 name">{{ route.name || "-" }}</el-descriptions-item>
<el-descriptions-item label="完整路径">{{ route.fullPath }}</el-descriptions-item>
<el-descriptions-item label="路径参数 params">
{{ formatValue(route.params) }}
</el-descriptions-item>
<el-descriptions-item label="查询参数 query">
{{ formatValue(route.query) }}
</el-descriptions-item>
<el-descriptions-item label="页面缓存 keepAlive">
<el-tag :type="route.meta.keepAlive ? 'success' : 'info'" size="small" disable-transitions>
{{ route.meta.keepAlive ? "开启" : "关闭" }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="菜单参数 meta.params">
{{ formatValue(route.meta.params) }}
</el-descriptions-item>
<el-descriptions-item label="路由匹配链 matched" :span="2">
<div class="flex flex-wrap items-center gap-2">
<template v-for="(item, index) in matchedChain" :key="index">
<el-tag size="small" effect="plain">{{ item.name }}</el-tag>
<span class="font-mono text-12px text-[var(--el-text-color-secondary)]">
{{ item.path || "/" }}
</span>
<span
v-if="index < matchedChain.length - 1"
class="text-[var(--el-text-color-placeholder)]"
>
/
</span>
</template>
</div>
</el-descriptions-item>
</el-descriptions>
</section>
</template>
<script setup lang="ts">
defineOptions({
name: "RouteInfoPanel",
});
defineProps<{
/** 面板标题 */
title: string;
/** 标题下方的补充说明 */
description?: string;
}>();
const route = useRoute();
// 路由匹配链,自顶向下每一层的 name 与 path
const matchedChain = computed(() =>
route.matched.map((item) => ({
name: typeof item.name === "string" ? item.name : "(无名)",
path: item.path,
}))
);
/**
* 空对象与空值统一显示为「无」,避免面板出现 {} 这种无信息量内容
*/
function formatValue(value: unknown): string {
if (!value || typeof value !== "object") return "无";
return Object.keys(value as object).length ? JSON.stringify(value) : "无";
}
</script>
@@ -1,11 +1,5 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="三级菜单 A:多级菜单的最底层页面"
description="上方「路由匹配链」列出了从顶级目录到本页的每一层;菜单在侧边栏逐层折叠,路由上则是逐层拼接路径。"
/>
<el-card class="page-content" shadow="never">
<template #header>三级结构逐层拆解</template>
@@ -48,7 +42,6 @@
</template>
<script lang="ts" setup>
import RouteInfoPanel from "@/views/demo/route/components/RouteInfoPanel.vue";
import LevelOnePanel from "@/views/demo/route/multi-level/components/LevelOnePanel.vue";
import LevelTwoPanel from "@/views/demo/route/multi-level/components/LevelTwoPanel.vue";
import ToDetail from "@/views/demo/route/multi-level/components/ToDetail";
@@ -1,11 +1,5 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="三级菜单 B:与三级菜单 A 同层"
description="A 与 B 是同一层的两个兄弟页面,路由匹配链长度相同,只有最末一段路径和渲染的组件不同。"
/>
<el-card class="page-content" shadow="never">
<template #header>三级结构逐层拆解</template>
@@ -48,7 +42,6 @@
</template>
<script lang="ts" setup>
import RouteInfoPanel from "@/views/demo/route/components/RouteInfoPanel.vue";
import LevelOnePanel from "@/views/demo/route/multi-level/components/LevelOnePanel.vue";
import LevelTwoPanel from "@/views/demo/route/multi-level/components/LevelTwoPanel.vue";
import ToDetail from "@/views/demo/route/multi-level/components/ToDetail";
-7
View File
@@ -1,11 +1,5 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="独立编辑页"
description="本页不在菜单里,由列表页携 ID 跳转打开(路由 /route-example/edit/:id)。保存后返回列表,列表会读到最新数据。"
/>
<el-card class="page-content" shadow="never">
<template #header>编辑成员信息</template>
@@ -32,7 +26,6 @@
import { ElMessage } from "element-plus";
import router from "@/router";
import RouteInfoPanel from "@/views/demo/route/components/RouteInfoPanel.vue";
import { getMember, updateMember } from "./data";
import type { MemberItem } from "./data";
-7
View File
@@ -1,11 +1,5 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="列表 → 独立编辑页"
description="点「编辑」跳到独立页面改数据,改完返回列表。本页开了 keepAlive,筛选条件不会丢,返回时还会重新读取数据源,把修改结果显示出来。"
/>
<el-card class="page-content" shadow="never">
<template #header>成员列表</template>
@@ -45,7 +39,6 @@
<script setup lang="ts">
import router from "@/router";
import RouteInfoPanel from "@/views/demo/route/components/RouteInfoPanel.vue";
import { listMembers } from "./data";
import type { MemberItem } from "./data";
+40 -88
View File
@@ -1,61 +1,26 @@
<template>
<div class="page-container">
<RouteInfoPanel
class="mb-4"
title="路由参数:同一个页面,两条菜单进入"
description="侧边栏两条菜单指向同一个文件 demo/route/route-param,靠各自 sys_menu.params 里的 type 决定页面显示哪套内容。"
/>
<el-card class="page-content" shadow="never">
<template #header>参数传递链路</template>
<template #header>
<div class="flex items-center justify-between">
<span>当前视图(由 query 的 type 决定)</span>
<code class="param-query">?type={{ currentType }}</code>
</div>
</template>
<div class="flex flex-wrap items-center gap-2.5">
<template v-for="(node, index) in flowNodes" :key="node.label">
<div class="flex flex-col gap-1 py-2.5 px-3.5 bg-[var(--el-fill-color-light)] rounded-md">
<span class="text-12px text-[var(--el-text-color-secondary)]">{{ node.label }}</span>
<code class="font-mono text-13px text-[var(--el-color-primary)]">{{ node.code }}</code>
</div>
<span v-if="index < flowNodes.length - 1" class="text-[var(--el-text-color-placeholder)]">
→
</span>
</template>
</div>
<el-radio-group :model-value="currentType" class="mb-4" @change="switchView">
<el-radio-button v-for="item in views" :key="item.value" :value="item.value">
{{ item.label }}
</el-radio-button>
</el-radio-group>
<el-row class="mt-4" :gutter="16">
<el-col v-for="entry in entries" :key="entry.type" :span="12">
<div
class="param-entry h-full p-3.5"
:class="{ 'is-active': currentType === entry.type }"
>
<div class="flex items-center justify-between mb-2">
<span class="text-14px font-600 text-[var(--el-text-color-primary)]">
菜单「{{ entry.menu }}」
</span>
<el-tag v-if="currentType === entry.type" type="success" size="small">
当前入口
</el-tag>
</div>
<div class="font-mono text-12px leading-[1.8] text-[var(--el-text-color-secondary)]">
{{ entry.path }}
</div>
<div class="font-mono text-12px leading-[1.8] text-[var(--el-text-color-secondary)]">
sys_menu.params:{{ entry.params }}
</div>
</div>
</el-col>
</el-row>
</el-card>
<el-card class="page-content mt-4" shadow="never">
<template #header>当前视图(由 type 决定,两条菜单看到的完全不同)</template>
<el-table v-if="currentType === '1'" :data="employees" border>
<el-table v-if="currentType === 'staff'" :data="employees" border>
<el-table-column prop="name" label="姓名" width="120" />
<el-table-column prop="post" label="岗位" />
<el-table-column prop="city" label="城市" />
</el-table>
<el-row v-else-if="currentType === '2'" :gutter="16">
<el-row v-else :gutter="16">
<el-col v-for="item in deptStats" :key="item.label" :span="6">
<div class="p-3 bg-[var(--el-fill-color-light)] rounded-md">
<div class="text-13px text-[var(--el-text-color-secondary)]">{{ item.label }}</div>
@@ -65,56 +30,45 @@
</div>
</el-col>
</el-row>
<el-empty v-else description="没有收到 type 参数,通常是直接在地址栏输入路径访问的" />
</el-card>
</div>
</template>
<script setup lang="ts">
import RouteInfoPanel from "./components/RouteInfoPanel.vue";
defineOptions({
name: "RouteParamDemo",
name: "RouteParam",
});
const route = useRoute();
const router = useRouter();
// 当前入口携带的 type 参数
const currentType = computed(() => String(route.query.type ?? ""));
// 参数从数据库到页面的四步链路
const flowNodes = [
{ label: "数据库", code: "sys_menu.params" },
{ label: "后端下发", code: "route.meta.params" },
{ label: "侧边栏跳转", code: "query: meta.params" },
{ label: "页面读取", code: "route.query.type" },
// 页内可切换的视图,取值对应 query 的 type
const views = [
{ value: "staff", label: "员工数据" },
{ value: "dept", label: "部门统计" },
];
// 两条菜单入口的对照信息
const entries = [
{
type: "1",
menu: "路由参数(type=1)",
path: "/route-example/params-type-1?type=1",
params: '{ "type": "1" }',
},
{
type: "2",
menu: "路由参数(type=2)",
path: "/route-example/params-type-2?type=2",
params: '{ "type": "2" }',
},
];
// 当前视图:非法取值回退到第一个视图
const currentType = computed(() => {
const value = String(route.query.type ?? "");
return views.some((item) => item.value === value) ? value : views[0].value;
});
// type=1 时展示的列表视图数据
/**
* 切换视图:改 query,与菜单 params 并入 query 是同一机制
*/
function switchView(value: string | number | boolean | undefined) {
router.replace({ query: { ...route.query, type: String(value) } });
}
// staff 视图数据
const employees = [
{ name: "张三", post: "前端开发", city: "杭州" },
{ name: "李四", post: "后端开发", city: "上海" },
{ name: "王五", post: "产品经理", city: "北京" },
];
// type=2 时展示的统计视图数据
// dept 视图数据
const deptStats = [
{ label: "研发部", value: 42 },
{ label: "产品部", value: 18 },
@@ -125,14 +79,12 @@ const deptStats = [
<style lang="scss" scoped>
/* 仅保留带状态与修饰符的样式,其余排版走原子类 */
.param-entry {
border: 1px solid var(--el-border-color-lighter);
border-radius: 6px;
transition: all 0.2s;
&.is-active {
background: var(--el-color-primary-light-9);
border-color: var(--el-color-primary);
}
.param-query {
padding: 2px 10px;
font-family: var(--el-font-family-mono, monospace);
font-size: 12px;
color: var(--el-color-primary);
background: var(--el-fill-color-light);
border-radius: 4px;
}
</style>
@@ -1,75 +0,0 @@
<template>
<header class="flex shrink-0 items-center gap-4">
<div class="flex w-72 items-center">
<div class="screen__clock">
<span class="screen__clock-time">{{ time }}</span>
<span class="screen__clock-divider" />
<div class="screen__clock-meta">
<span class="screen__clock-date">{{ date }}</span>
<span class="screen__clock-week">{{ weekday }}</span>
</div>
</div>
</div>
<div class="flex-1 text-center">
<h1 class="screen__title m-0">{{ title }}</h1>
<p class="screen__subtitle m-0">{{ subtitle }}</p>
</div>
<div class="flex w-72 items-center justify-end">
<el-tooltip :content="isFullscreen ? '退出全屏' : '全屏查看'" placement="bottom">
<el-button class="screen__action" circle @click="emit('toggleFullscreen')">
<el-icon :size="16"><FullScreen /></el-icon>
</el-button>
</el-tooltip>
</div>
</header>
</template>
<script setup lang="ts">
defineOptions({
name: "ScreenHeader",
});
defineProps<{
/** 主标题 */
title: string;
/** 英文副标题 */
subtitle: string;
/** 当前是否处于全屏,用于切换按钮提示 */
isFullscreen: boolean;
}>();
const emit = defineEmits<{
toggleFullscreen: [];
}>();
const WEEKDAYS = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
const date = ref("");
const weekday = ref("");
const time = ref("");
/**
* 刷新当前时间
*/
function updateClock(): void {
const now = new Date();
// 数值补零为两位
const pad = (value: number) => String(value).padStart(2, "0");
date.value = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
weekday.value = WEEKDAYS[now.getDay()];
time.value = `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
}
let timer: number | undefined;
onMounted(() => {
updateClock();
timer = window.setInterval(updateClock, 1000);
});
onBeforeUnmount(() => {
window.clearInterval(timer);
});
</script>
-595
View File
@@ -1,595 +0,0 @@
<template>
<div class="page-container">
<div ref="screenRef" class="screen flex min-h-0 flex-1 flex-col gap-3 p-4">
<ScreenHeader
:title="SCREEN_TITLE"
:subtitle="SCREEN_SUBTITLE"
:is-fullscreen="isFullscreen"
@toggle-fullscreen="toggleFullscreen()"
/>
<div class="grid shrink-0 grid-cols-6 gap-3">
<div
v-for="item in metrics"
:key="item.label"
class="screen__metric flex items-center gap-3 p-3"
:style="{ '--metric-color': item.color }"
>
<div
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-md"
:style="{
color: item.color,
backgroundColor: hexToRgba(item.color, 0.14),
border: `1px solid ${hexToRgba(item.color, 0.35)}`,
}"
>
<el-icon :size="19"><component :is="item.icon" /></el-icon>
</div>
<div class="min-w-0">
<div class="truncate text-12px text-[var(--screen-text-2)]">{{ item.label }}</div>
<div class="flex items-baseline gap-1">
<span class="screen__metric-value text-22px font-700">
{{ formatNumber(item.value) }}
</span>
<span class="text-12px text-[var(--screen-text-2)]">{{ item.unit }}</span>
</div>
</div>
<span
class="ml-auto shrink-0 text-11px"
:class="item.up ? 'text-[var(--screen-success)]' : 'text-[var(--screen-danger)]'"
>
{{ item.up ? "↑" : "↓" }}{{ item.trend }}%
</span>
</div>
</div>
<!-- 布局范式:左右分屏 —— 左大地图跨两行,右列竖排两图,底部三格(告警列表并入网格) -->
<div class="grid min-h-0 flex-1 grid-cols-12 grid-rows-3 gap-3">
<section
class="screen__panel screen__panel--map col-span-8 col-start-1 row-span-2 row-start-1 flex min-h-0 flex-col"
>
<h2 class="screen__panel-title">
<el-icon :size="14"><MapLocation /></el-icon>
<span>设备地域分布</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts
v-if="mapStatus === 'ready'"
:options="mapOptions"
width="100%"
height="100%"
/>
<div
v-else
class="flex h-full items-center justify-center text-13px text-[var(--screen-text-2)]"
>
{{ mapStatus === "loading" ? "地图数据加载中…" : "地图数据加载失败" }}
</div>
</div>
</section>
<section class="screen__panel col-span-4 col-start-9 row-start-1 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><TrendCharts /></el-icon>
<span>24 小时数据采集量</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="hourlyOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-9 row-start-2 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Odometer /></el-icon>
<span>近 7 日设备在线率</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="weekOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-1 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Histogram /></el-icon>
<span>区域设备数 TOP 5</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="regionOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-5 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><PieChart /></el-icon>
<span>设备类型占比</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="typeOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-9 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Bell /></el-icon>
<span>实时告警</span>
</h2>
<ul class="min-h-0 flex-1 overflow-hidden">
<li v-for="item in logs" :key="item.id" class="alert-item">
<span class="shrink-0 text-12px text-[var(--screen-text-2)]">{{ item.time }}</span>
<span class="flex-1 truncate text-12px text-[var(--screen-text-1)]">
{{ item.text }}
</span>
</li>
</ul>
</section>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useFullscreen } from "@vueuse/core";
import * as echarts from "echarts/core";
import ScreenHeader from "@/views/demo/screen/components/ScreenHeader.vue";
import {
formatNumber,
hexToRgba,
registerChinaMap,
SCREEN_COLORS,
tweenValue,
verticalGradient,
} from "@/views/demo/screen/utils";
defineOptions({
name: "ScreenDevice",
});
// 大屏主题
const SCREEN_TITLE = "设备监控大屏";
const SCREEN_SUBTITLE = "DEVICE MONITOR CENTER";
// 顶部核心指标
const METRICS = [
{
label: "设备总数",
value: 12860,
unit: "台",
trend: 2.4,
up: true,
icon: "Monitor",
color: "#a78bfa",
},
{
label: "在线设备",
value: 11842,
unit: "台",
trend: 3.1,
up: true,
icon: "Connection",
color: "#3ba9ff",
},
{
label: "离线设备",
value: 1018,
unit: "台",
trend: 5.2,
up: false,
icon: "SwitchButton",
color: "#38bdf8",
},
{
label: "告警设备",
value: 24,
unit: "台",
trend: 12.6,
up: false,
icon: "Warning",
color: "#f87171",
},
{
label: "今日采集",
value: 486240,
unit: "条",
trend: 7.8,
up: true,
icon: "DataLine",
color: "#22d3ee",
},
{
label: "采集网关",
value: 186,
unit: "个",
trend: 1.2,
up: true,
icon: "Odometer",
color: "#818cf8",
},
];
// 各省设备数(台),名称需与 GeoJSON 中的 properties.name 完全一致
const PROVINCE_DEVICES: Record<string, number> = {
北京市: 862,
天津市: 420,
河北省: 640,
山西省: 320,
内蒙古自治区: 260,
辽宁省: 480,
吉林省: 240,
黑龙江省: 280,
上海市: 940,
江苏省: 1120,
浙江省: 1060,
安徽省: 580,
福建省: 640,
江西省: 380,
山东省: 1020,
河南省: 820,
湖北省: 680,
湖南省: 620,
广东省: 1480,
广西壮族自治区: 360,
海南省: 180,
重庆市: 460,
四川省: 780,
贵州省: 280,
云南省: 320,
西藏自治区: 60,
陕西省: 440,
甘肃省: 200,
青海省: 80,
宁夏回族自治区: 90,
新疆维吾尔自治区: 220,
台湾省: 160,
香港特别行政区: 280,
澳门特别行政区: 90,
};
/**
* 日内维度:近 24 小时数据采集量(条)
*/
const HOURLY_LABELS = Array.from(
{ length: 24 },
(_, hour) => `${String(hour).padStart(2, "0")}:00`
);
const HOURLY_COLLECTED = [
2860, 1980, 1620, 1480, 1420, 1680, 3260, 6840, 12460, 18620, 22480, 24620, 19860, 21240, 23460,
25680, 26820, 24860, 27640, 30240, 31620, 28460, 18620, 8620,
];
// 周维度:近 7 日设备在线率(%)
const WEEK_LABELS = ["09-13", "09-14", "09-15", "09-16", "09-17", "09-18", "09-19"];
const WEEK_ONLINE_RATE = [91.2, 92.4, 93.1, 90.8, 94.2, 95.6, 92.8];
// 设备类型占比
const DEVICE_TYPE_SHARE = [
{ value: 4860, name: "智能电表" },
{ value: 3240, name: "环境传感器" },
{ value: 2680, name: "视频监控" },
{ value: 1420, name: "工业网关" },
{ value: 660, name: "其它" },
];
// 区域设备数 TOP 5
const REGION_DEVICES = [
{ name: "华东", value: 4620 },
{ name: "华南", value: 3480 },
{ name: "华北", value: 2860 },
{ name: "西南", value: 1840 },
{ name: "西北", value: 1060 },
];
// 实时告警池
const LOG_TEMPLATES = [
"设备 DEV-10284 通信中断,已持续 5 分钟",
"华东区域网关 GW-0231 心跳超时",
"智能电表 MET-4820 数据异常",
"设备 DEV-33820 已恢复在线",
"华南区域 3 台传感器电量不足",
"网关 GW-0118 固件升级至 v2.4.1",
"环境传感器 SEN-2840 温度超阈值",
"设备 DEV-19820 离线超过 30 分钟",
];
// 设备监控大屏主题色为紫色,与电商(蓝)、系统(青)区分
const ACCENT_COLOR = "#a78bfa";
const {
axis: AXIS_COLOR,
grid: GRID_COLOR,
success: SUCCESS_COLOR,
pie: PIE_COLORS,
} = SCREEN_COLORS;
// 初始为 0,进入页面后滚动到真实值
const metrics = ref(METRICS.map((item) => ({ ...item, value: 0 })));
const logs = ref([
{ id: 5, time: "15:50:12", text: "设备 DEV-10284 通信中断,已持续 5 分钟" },
{ id: 4, time: "15:49:38", text: "华东区域网关 GW-0231 心跳超时" },
{ id: 3, time: "15:48:05", text: "智能电表 MET-4820 数据异常" },
{ id: 2, time: "15:46:52", text: "设备 DEV-33820 已恢复在线" },
{ id: 1, time: "15:45:20", text: "华南区域 3 台传感器电量不足" },
]);
/**
* 指标值平滑过渡到目标值
*/
function tweenMetrics(targets: number[], duration: number): void {
metrics.value.forEach((item, index) => {
tweenValue(
item.value,
targets[index],
(value) => {
item.value = value;
},
duration
);
});
}
// 中国地图数据体积较大,放在 public 下运行时加载,避免打进主包
const mapStatus = ref<"loading" | "ready" | "error">("loading");
// 省份中心点坐标,加载地图后填充,用于绘制散点
const provinceCenters = ref<Record<string, [number, number]>>({});
/**
* 注册中国地图并取省份坐标
*/
async function loadChinaMap(): Promise<void> {
try {
provinceCenters.value = await registerChinaMap(echarts);
mapStatus.value = "ready";
} catch {
// 地图失败不影响其它图表,面板内显示占位文案
mapStatus.value = "error";
}
}
// 设备数前 8 的省份,作为地图上的涟漪散点
const scatterData = computed(() =>
Object.entries(PROVINCE_DEVICES)
.filter(([name]) => provinceCenters.value[name])
.sort(([, a], [, b]) => b - a)
.slice(0, 8)
.map(([name, value]) => ({ name, value: [...provinceCenters.value[name], value] }))
);
const mapOptions = computed<echarts.EChartsCoreOption>(() => ({
tooltip: {
trigger: "item",
formatter: (params: { name: string; value?: number | number[] }) => {
const value = Array.isArray(params.value) ? params.value[2] : (params.value ?? 0);
return `${params.name}<br/>设备数:${formatNumber(value)} 台`;
},
},
// geo 只提供投影坐标系,地图着色交给 map 系列,避免与散点错位
geo: {
map: "china",
roam: false,
silent: true,
itemStyle: { areaColor: "transparent", borderColor: "transparent" },
},
visualMap: {
min: 0,
max: 1500,
left: 8,
bottom: 8,
text: ["高", "低"],
textStyle: { color: AXIS_COLOR },
inRange: { color: ["#241f4d", "#40348a", "#6a55c4", ACCENT_COLOR] },
calculable: true,
},
series: [
{
name: "设备数",
type: "map",
map: "china",
roam: false,
label: { show: false },
itemStyle: {
areaColor: "#241f4d",
borderColor: "#6f5fc4",
borderWidth: 0.8,
shadowColor: "rgba(167, 139, 250, 0.5)",
shadowBlur: 18,
},
emphasis: {
label: { show: true, color: "#ffffff", fontSize: 11 },
itemStyle: { areaColor: ACCENT_COLOR },
},
select: { disabled: true },
data: Object.entries(PROVINCE_DEVICES).map(([name, value]) => ({ name, value })),
},
{
name: "重点省份",
type: "effectScatter",
coordinateSystem: "geo",
data: scatterData.value,
symbolSize: (value: number[]) => Math.max(6, Math.round(value[2] / 120)),
rippleEffect: { brushType: "stroke", scale: 3.5 },
itemStyle: { color: SUCCESS_COLOR, shadowBlur: 12, shadowColor: SUCCESS_COLOR },
},
],
}));
const hourlyOptions = {
tooltip: { trigger: "axis" },
grid: { left: 60, right: 20, top: 20, bottom: 28 },
xAxis: {
type: "category",
boundaryGap: false,
data: HOURLY_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, interval: 3 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "条",
nameTextStyle: { color: AXIS_COLOR },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR },
},
series: [
{
name: "采集量",
type: "line",
smooth: true,
showSymbol: false,
data: HOURLY_COLLECTED,
itemStyle: { color: ACCENT_COLOR },
lineStyle: { width: 2, color: ACCENT_COLOR, shadowColor: ACCENT_COLOR, shadowBlur: 8 },
areaStyle: { color: verticalGradient("rgba(167, 139, 250, 0.45)", "rgba(167, 139, 250, 0)") },
},
],
};
const weekOptions = {
tooltip: { trigger: "axis" },
grid: { left: 60, right: 20, top: 20, bottom: 28 },
xAxis: {
type: "category",
boundaryGap: false,
data: WEEK_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "%",
nameTextStyle: { color: AXIS_COLOR },
min: 85,
max: 100,
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR },
},
series: [
{
name: "在线率",
type: "line",
smooth: true,
symbolSize: 6,
data: WEEK_ONLINE_RATE,
itemStyle: { color: ACCENT_COLOR },
lineStyle: { width: 2, color: ACCENT_COLOR, shadowColor: ACCENT_COLOR, shadowBlur: 8 },
areaStyle: { color: verticalGradient("rgba(167, 139, 250, 0.35)", "rgba(167, 139, 250, 0)") },
},
],
};
const regionOptions = {
tooltip: { trigger: "axis", axisPointer: { type: "shadow" } },
grid: { left: 76, right: 40, top: 12, bottom: 12 },
xAxis: {
type: "value",
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR },
},
yAxis: {
type: "category",
// 反转后最大值显示在顶部
data: REGION_DEVICES.map((item) => item.name).reverse(),
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 11 },
axisTick: { show: false },
},
series: [
{
name: "设备数",
type: "bar",
barWidth: 10,
data: REGION_DEVICES.map((item) => item.value).reverse(),
itemStyle: {
borderRadius: [0, 4, 4, 0],
color: verticalGradient("rgba(167, 139, 250, 0.85)", "rgba(167, 139, 250, 0.22)"),
},
label: { show: true, position: "right", color: AXIS_COLOR, fontSize: 11 },
},
],
};
const typeOptions = {
tooltip: { trigger: "item" },
legend: {
bottom: 0,
itemWidth: 10,
itemHeight: 10,
textStyle: { color: AXIS_COLOR, fontSize: 11 },
},
series: [
{
name: "设备类型",
type: "pie",
radius: ["42%", "64%"],
center: ["50%", "42%"],
label: { color: AXIS_COLOR, fontSize: 11 },
labelLine: { lineStyle: { color: AXIS_COLOR } },
data: DEVICE_TYPE_SHARE.map((item, index) => ({
...item,
itemStyle: { color: [...PIE_COLORS, "#c4b5fd"][index] },
})),
},
],
};
const screenRef = ref<HTMLElement | null>(null);
const { isFullscreen, toggle: toggleFullscreen } = useFullscreen(screenRef);
let logId = 5;
/**
* 追加一条实时日志
*/
function pushLog(): void {
logs.value.unshift({
id: ++logId,
time: new Date().toLocaleTimeString("zh-CN", { hour12: false }),
text: LOG_TEMPLATES[Math.floor(Math.random() * LOG_TEMPLATES.length)],
});
logs.value = logs.value.slice(0, 6);
}
let dataTimer: number | undefined;
onMounted(() => {
dataTimer = window.setInterval(() => {
tweenMetrics(
metrics.value.map((item) => item.value + Math.round(Math.random() * 60)),
900
);
pushLog();
}, 3000);
loadChinaMap();
tweenMetrics(
METRICS.map((item) => item.value),
1200
);
});
onBeforeUnmount(() => {
window.clearInterval(dataTimer);
});
</script>
<style lang="scss" scoped>
/* 覆盖公共大屏样式里的主题色变量 */
.screen {
--screen-accent: #a78bfa;
--screen-accent-rgb: 167 139 250;
}
/* 告警列表项分隔线 */
.alert-item {
display: flex;
gap: 8px;
align-items: center;
padding: 6px 0;
border-bottom: 1px dashed rgb(var(--screen-accent-rgb) / 12%);
}
</style>
-591
View File
@@ -1,591 +0,0 @@
<template>
<div class="page-container">
<div ref="screenRef" class="screen flex min-h-0 flex-1 flex-col gap-3 p-4">
<ScreenHeader
:title="SCREEN_TITLE"
:subtitle="SCREEN_SUBTITLE"
:is-fullscreen="isFullscreen"
@toggle-fullscreen="toggleFullscreen()"
/>
<!-- 布局范式:中心对称驾驶舱 —— 指标卡竖排两侧,地图居中作视觉核心,底部三图通栏 -->
<div class="grid min-h-0 flex-1 grid-cols-12 grid-rows-3 gap-3">
<div class="col-span-3 col-start-1 row-span-2 row-start-1 flex min-h-0 flex-col gap-3">
<div
v-for="item in leftMetrics"
:key="item.label"
class="screen__metric flex min-h-0 flex-1 items-center gap-3 p-3"
:style="{ '--metric-color': item.color }"
>
<div
class="flex h-11 w-11 shrink-0 items-center justify-center rounded-md"
:style="{
color: item.color,
backgroundColor: hexToRgba(item.color, 0.14),
border: `1px solid ${hexToRgba(item.color, 0.35)}`,
}"
>
<el-icon :size="21"><component :is="item.icon" /></el-icon>
</div>
<div class="min-w-0">
<div class="truncate text-13px text-[var(--screen-text-2)]">{{ item.label }}</div>
<div class="flex items-baseline gap-1">
<span class="screen__metric-value text-26px font-700">
{{ formatNumber(item.value) }}
</span>
<span class="text-12px text-[var(--screen-text-2)]">{{ item.unit }}</span>
</div>
</div>
<span
class="ml-auto shrink-0 text-12px"
:class="item.up ? 'text-[var(--screen-success)]' : 'text-[var(--screen-danger)]'"
>
{{ item.up ? "↑" : "↓" }}{{ item.trend }}%
</span>
</div>
</div>
<section
class="screen__panel screen__panel--map col-span-6 col-start-4 row-span-2 row-start-1 flex min-h-0 flex-col"
>
<h2 class="screen__panel-title">
<el-icon :size="14"><MapLocation /></el-icon>
<span>全国销售额实时分布</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts
v-if="mapStatus === 'ready'"
:options="mapOptions"
width="100%"
height="100%"
/>
<div
v-else
class="flex h-full items-center justify-center text-13px text-[var(--screen-text-2)]"
>
{{ mapStatus === "loading" ? "地图数据加载中…" : "地图数据加载失败" }}
</div>
</div>
</section>
<div class="col-span-3 col-start-10 row-span-2 row-start-1 flex min-h-0 flex-col gap-3">
<div
v-for="item in rightMetrics"
:key="item.label"
class="screen__metric flex min-h-0 flex-1 items-center gap-3 p-3"
:style="{ '--metric-color': item.color }"
>
<div
class="flex h-11 w-11 shrink-0 items-center justify-center rounded-md"
:style="{
color: item.color,
backgroundColor: hexToRgba(item.color, 0.14),
border: `1px solid ${hexToRgba(item.color, 0.35)}`,
}"
>
<el-icon :size="21"><component :is="item.icon" /></el-icon>
</div>
<div class="min-w-0">
<div class="truncate text-13px text-[var(--screen-text-2)]">{{ item.label }}</div>
<div class="flex items-baseline gap-1">
<span class="screen__metric-value text-26px font-700">
{{ formatNumber(item.value) }}
</span>
<span class="text-12px text-[var(--screen-text-2)]">{{ item.unit }}</span>
</div>
</div>
<span
class="ml-auto shrink-0 text-12px"
:class="item.up ? 'text-[var(--screen-success)]' : 'text-[var(--screen-danger)]'"
>
{{ item.up ? "↑" : "↓" }}{{ item.trend }}%
</span>
</div>
</div>
<section class="screen__panel col-span-4 col-start-1 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><TrendCharts /></el-icon>
<span>24 小时订单趋势</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="hourlyOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-5 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Trophy /></el-icon>
<span>品类销售 TOP 5</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="categoryOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-span-4 col-start-9 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><PieChart /></el-icon>
<span>支付方式占比</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="paymentOptions" width="100%" height="100%" />
</div>
</section>
</div>
<div class="screen__panel flex shrink-0 items-center gap-4 px-3 py-2">
<span
class="flex shrink-0 items-center gap-1 text-12px font-600 text-[var(--screen-accent)]"
>
<el-icon :size="13"><Bell /></el-icon>
实时订单动态
</span>
<div
v-for="item in logs.slice(0, 3)"
:key="item.id"
class="flex min-w-0 flex-1 items-center gap-2"
>
<span class="shrink-0 text-12px text-[var(--screen-text-2)]">{{ item.time }}</span>
<span class="truncate text-12px text-[var(--screen-text-1)]">{{ item.text }}</span>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useFullscreen } from "@vueuse/core";
import * as echarts from "echarts/core";
import ScreenHeader from "@/views/demo/screen/components/ScreenHeader.vue";
import {
formatNumber,
hexToRgba,
registerChinaMap,
SCREEN_COLORS,
tweenValue,
verticalGradient,
} from "@/views/demo/screen/utils";
defineOptions({
name: "ScreenEcommerce",
});
// 大屏主题:主标题用行业通用叫法,副标题为英文对照
const SCREEN_TITLE = "电商销售数据大屏";
const SCREEN_SUBTITLE = "E-COMMERCE SALES DASHBOARD";
// 顶部核心指标
// icon 取 Element Plus 图标名,同一行内需保证形状可区分; color 统一取冷色系,仅告警类用红
const METRICS = [
{
label: "今日销售额",
value: 128460,
unit: "元",
trend: 12.5,
up: true,
icon: "Money",
color: "#3ba9ff",
},
{
label: "订单量",
value: 3842,
unit: "单",
trend: 8.3,
up: true,
icon: "Tickets",
color: "#38bdf8",
},
{
label: "新增用户",
value: 1286,
unit: "人",
trend: 15.2,
up: true,
icon: "UserFilled",
color: "#818cf8",
},
{
label: "活跃用户",
value: 26480,
unit: "人",
trend: 3.7,
up: true,
icon: "Avatar",
color: "#a78bfa",
},
{
label: "加购件数",
value: 8642,
unit: "件",
trend: 6.1,
up: true,
icon: "ShoppingCart",
color: "#22d3ee",
},
{
label: "退款订单",
value: 42,
unit: "单",
trend: 4.8,
up: false,
icon: "DocumentRemove",
color: "#f87171",
},
];
// 各省销售额(万元),名称需与 GeoJSON 中的 properties.name 完全一致
const PROVINCE_SALES: Record<string, number> = {
北京市: 9860,
天津市: 4620,
河北省: 6840,
山西省: 3260,
内蒙古自治区: 2480,
辽宁省: 5120,
吉林省: 2860,
黑龙江省: 3120,
上海市: 11240,
江苏省: 12480,
浙江省: 11860,
安徽省: 6240,
福建省: 7820,
江西省: 4120,
山东省: 10420,
河南省: 8640,
湖北省: 7260,
湖南省: 6840,
广东省: 15860,
广西壮族自治区: 3860,
海南省: 2140,
重庆市: 5420,
四川省: 9260,
贵州省: 3280,
云南省: 3620,
西藏自治区: 620,
陕西省: 4820,
甘肃省: 2260,
青海省: 780,
宁夏回族自治区: 860,
新疆维吾尔自治区: 2460,
台湾省: 1860,
香港特别行政区: 3240,
澳门特别行政区: 980,
};
/**
* 日内维度:近 24 小时订单量
*/
const HOURLY_LABELS = Array.from(
{ length: 24 },
(_, hour) => `${String(hour).padStart(2, "0")}:00`
);
const HOURLY_ORDERS = [
220, 160, 120, 96, 88, 120, 320, 860, 1580, 2260, 2680, 2940, 2180, 2460, 2860, 3120, 3280, 2980,
3420, 3860, 4120, 3620, 2480, 1260,
];
// 品类销售 TOP 5
const CATEGORY_SALES = [
{ name: "手机数码", value: 4860 },
{ name: "家用电器", value: 3920 },
{ name: "服饰鞋包", value: 3480 },
{ name: "美妆护肤", value: 2860 },
{ name: "食品生鲜", value: 2140 },
];
// 支付方式占比
const PAYMENT_SHARE = [
{ value: 48200, name: "微信支付" },
{ value: 32600, name: "支付宝" },
{ value: 12400, name: "银行卡" },
{ value: 6800, name: "其它" },
];
// 实时动态消息池
const LOG_TEMPLATES = [
"用户 138****2846 下单成功,金额 ¥1,286",
"商品「无线降噪耳机」库存低于预警值",
"订单 20260919001284 已完成支付",
"用户 159****6620 申请退款 ¥328",
"促销活动「秋季大促」已上线",
"接口 /api/order/create 响应耗时 1.2s",
"新用户 186****0384 完成注册",
"商品「智能手表」加入秒杀活动",
];
const {
axis: AXIS_COLOR,
grid: GRID_COLOR,
accent: ACCENT_COLOR,
success: SUCCESS_COLOR,
pie: PIE_COLORS,
} = SCREEN_COLORS;
// 初始为 0,进入页面后滚动到真实值
const metrics = ref(METRICS.map((item) => ({ ...item, value: 0 })));
// 驾驶舱布局把指标卡分列地图左右两侧
const leftMetrics = computed(() => metrics.value.slice(0, 3));
const rightMetrics = computed(() => metrics.value.slice(3));
const logs = ref([
{ id: 5, time: "15:50:12", text: "用户 138****2846 下单成功,金额 ¥1,286" },
{ id: 4, time: "15:49:38", text: "商品「无线降噪耳机」库存低于预警值" },
{ id: 3, time: "15:48:05", text: "订单 20260919001284 已完成支付" },
{ id: 2, time: "15:46:52", text: "促销活动「秋季大促」已上线" },
{ id: 1, time: "15:45:20", text: "新用户 186****0384 完成注册" },
]);
/**
* 指标值平滑过渡到目标值
*/
function tweenMetrics(targets: number[], duration: number): void {
metrics.value.forEach((item, index) => {
tweenValue(
item.value,
targets[index],
(value) => {
item.value = value;
},
duration
);
});
}
// 中国地图数据体积较大,放在 public 下运行时加载,避免打进主包
const mapStatus = ref<"loading" | "ready" | "error">("loading");
// 省份中心点坐标,加载地图后填充,用于绘制散点与飞线
const provinceCenters = ref<Record<string, [number, number]>>({});
/**
* 注册中国地图并取省份坐标
*/
async function loadChinaMap(): Promise<void> {
try {
provinceCenters.value = await registerChinaMap(echarts);
mapStatus.value = "ready";
} catch {
// 地图失败不影响其它图表,面板内显示占位文案
mapStatus.value = "error";
}
}
// 销售额前 8 的省份,作为地图上的涟漪散点
const scatterData = computed(() =>
Object.entries(PROVINCE_SALES)
.filter(([name]) => provinceCenters.value[name])
.sort(([, a], [, b]) => b - a)
.slice(0, 8)
.map(([name, value]) => ({ name, value: [...provinceCenters.value[name], value] }))
);
// 销售额前 12 的省份汇聚到总部北京的飞线
const flyLines = computed(() => {
const target = provinceCenters.value["北京市"];
if (!target) return [];
return Object.entries(PROVINCE_SALES)
.filter(([name]) => name !== "北京市" && provinceCenters.value[name])
.sort(([, a], [, b]) => b - a)
.slice(0, 12)
.map(([name]) => ({ coords: [provinceCenters.value[name], target] }));
});
const mapOptions = computed<echarts.EChartsCoreOption>(() => ({
tooltip: {
trigger: "item",
formatter: (params: { name: string; value?: number | number[] }) => {
const value = Array.isArray(params.value) ? params.value[2] : (params.value ?? 0);
return `${params.name}<br/>销售额:${formatNumber(value)} 万元`;
},
},
// geo 只提供投影坐标系,地图着色交给 map 系列,避免与散点、飞线错位
geo: {
map: "china",
roam: false,
silent: true,
itemStyle: { areaColor: "transparent", borderColor: "transparent" },
},
visualMap: {
min: 0,
max: 16000,
left: 8,
bottom: 8,
text: ["高", "低"],
textStyle: { color: AXIS_COLOR },
inRange: { color: ["#0f3355", "#1c5486", "#2b7fc4", ACCENT_COLOR] },
calculable: true,
},
series: [
{
name: "销售额",
type: "map",
map: "china",
roam: false,
label: { show: false },
itemStyle: {
areaColor: "#0f3355",
borderColor: "#3d86c6",
borderWidth: 0.8,
shadowColor: "rgba(59, 169, 255, 0.55)",
shadowBlur: 18,
},
emphasis: {
label: { show: true, color: "#ffffff", fontSize: 11 },
itemStyle: { areaColor: ACCENT_COLOR },
},
select: { disabled: true },
data: Object.entries(PROVINCE_SALES).map(([name, value]) => ({ name, value })),
},
{
name: "重点省份",
type: "effectScatter",
coordinateSystem: "geo",
data: scatterData.value,
symbolSize: (value: number[]) => Math.max(6, Math.round(value[2] / 1400)),
rippleEffect: { brushType: "stroke", scale: 3.5 },
itemStyle: { color: SUCCESS_COLOR, shadowBlur: 12, shadowColor: SUCCESS_COLOR },
},
{
name: "订单流向",
type: "lines",
coordinateSystem: "geo",
data: flyLines.value,
effect: {
show: true,
period: 4,
trailLength: 0.55,
symbol: "arrow",
symbolSize: 5,
color: "#7dd3fc",
},
lineStyle: { color: ACCENT_COLOR, width: 1, opacity: 0.3, curveness: 0.25 },
},
],
}));
const hourlyOptions = {
tooltip: { trigger: "axis" },
grid: { left: 52, right: 20, top: 20, bottom: 28 },
xAxis: {
type: "category",
boundaryGap: false,
data: HOURLY_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, interval: 3 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "单",
nameTextStyle: { color: AXIS_COLOR },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR },
},
series: [
{
name: "订单量",
type: "line",
smooth: true,
showSymbol: false,
data: HOURLY_ORDERS,
itemStyle: { color: ACCENT_COLOR },
lineStyle: { width: 2, color: ACCENT_COLOR, shadowColor: ACCENT_COLOR, shadowBlur: 8 },
areaStyle: { color: verticalGradient("rgba(59, 169, 255, 0.45)", "rgba(59, 169, 255, 0)") },
},
],
};
const categoryOptions = {
tooltip: { trigger: "axis", axisPointer: { type: "shadow" } },
grid: { left: 72, right: 40, top: 12, bottom: 12 },
xAxis: {
type: "value",
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR },
},
yAxis: {
type: "category",
// 反转后最大值显示在顶部
data: CATEGORY_SALES.map((item) => item.name).reverse(),
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 11 },
axisTick: { show: false },
},
series: [
{
name: "销量",
type: "bar",
barWidth: 10,
data: CATEGORY_SALES.map((item) => item.value).reverse(),
itemStyle: {
borderRadius: [0, 4, 4, 0],
color: verticalGradient("rgba(56, 189, 248, 0.85)", "rgba(56, 189, 248, 0.22)"),
},
label: { show: true, position: "right", color: AXIS_COLOR, fontSize: 11 },
},
],
};
const paymentOptions = {
tooltip: { trigger: "item" },
legend: { bottom: 0, itemWidth: 10, itemHeight: 10, textStyle: { color: AXIS_COLOR } },
series: [
{
name: "支付方式",
type: "pie",
radius: ["46%", "68%"],
center: ["50%", "44%"],
label: { color: AXIS_COLOR, fontSize: 11 },
labelLine: { lineStyle: { color: AXIS_COLOR } },
data: PAYMENT_SHARE.map((item, index) => ({
...item,
itemStyle: { color: PIE_COLORS[index] },
})),
},
],
};
const screenRef = ref<HTMLElement | null>(null);
const { isFullscreen, toggle: toggleFullscreen } = useFullscreen(screenRef);
let logId = 5;
/**
* 追加一条实时日志
*/
function pushLog(): void {
logs.value.unshift({
id: ++logId,
time: new Date().toLocaleTimeString("zh-CN", { hour12: false }),
text: LOG_TEMPLATES[Math.floor(Math.random() * LOG_TEMPLATES.length)],
});
logs.value = logs.value.slice(0, 6);
}
let dataTimer: number | undefined;
onMounted(() => {
dataTimer = window.setInterval(() => {
tweenMetrics(
metrics.value.map((item) => item.value + Math.round(Math.random() * 60)),
900
);
pushLog();
}, 3000);
loadChinaMap();
tweenMetrics(
METRICS.map((item) => item.value),
1200
);
});
onBeforeUnmount(() => {
window.clearInterval(dataTimer);
});
</script>
-720
View File
@@ -1,720 +0,0 @@
<template>
<div class="page-container">
<div ref="screenRef" class="screen flex min-h-0 flex-1 flex-col gap-3 p-4">
<ScreenHeader
:title="SCREEN_TITLE"
:subtitle="SCREEN_SUBTITLE"
:is-fullscreen="isFullscreen"
@toggle-fullscreen="toggleFullscreen()"
/>
<!-- 布局范式:等权监控墙 —— 顶部细状态条(不是大卡片)+ 4×3 等分网格,无单一视觉中心 -->
<div class="grid shrink-0 grid-cols-6 gap-3">
<div
v-for="item in metrics"
:key="item.label"
class="screen__metric flex items-center gap-2 px-3 py-2"
:style="{ '--metric-color': item.color }"
>
<el-icon :size="16" :style="{ color: item.color }">
<component :is="item.icon" />
</el-icon>
<span class="truncate text-12px text-[var(--screen-text-2)]">{{ item.label }}</span>
<span class="screen__metric-value ml-auto text-16px font-700">
{{ formatNumber(item.value) }}
</span>
<span
class="shrink-0 text-11px"
:class="item.up ? 'text-[var(--screen-success)]' : 'text-[var(--screen-danger)]'"
>
{{ item.up ? "↑" : "↓" }}{{ item.trend }}%
</span>
</div>
</div>
<div class="grid min-h-0 flex-1 grid-cols-4 grid-rows-3 gap-3">
<section class="screen__panel col-start-1 row-start-1 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><TrendCharts /></el-icon>
<span>24 小时接口调用趋势</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="hourlyOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-start-2 row-start-1 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Histogram /></el-icon>
<span>近 7 日活跃用户</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="weekOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-start-3 row-start-1 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Menu /></el-icon>
<span>系统模块访问 TOP 5</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="moduleOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-start-4 row-start-1 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><PieChart /></el-icon>
<span>登录终端占比</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="terminalOptions" width="100%" height="100%" />
</div>
</section>
<section
class="screen__panel screen__panel--map col-span-2 col-start-1 row-span-2 row-start-2 flex min-h-0 flex-col"
>
<h2 class="screen__panel-title">
<el-icon :size="14"><MapLocation /></el-icon>
<span>用户地域分布</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts
v-if="mapStatus === 'ready'"
:options="mapOptions"
width="100%"
height="100%"
/>
<div
v-else
class="flex h-full items-center justify-center text-13px text-[var(--screen-text-2)]"
>
{{ mapStatus === "loading" ? "地图数据加载中…" : "地图数据加载失败" }}
</div>
</div>
</section>
<section class="screen__panel col-start-3 row-start-2 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Timer /></el-icon>
<span>24 小时接口响应耗时</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="responseOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-start-4 row-start-2 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Clock /></el-icon>
<span>24 小时登录时段分布</span>
</h2>
<div class="min-h-0 flex-1">
<ECharts :options="loginOptions" width="100%" height="100%" />
</div>
</section>
<section class="screen__panel col-start-3 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Odometer /></el-icon>
<span>服务健康度</span>
</h2>
<ul class="flex min-h-0 flex-1 flex-col justify-center gap-3 px-1">
<li v-for="item in healthItems" :key="item.label">
<div class="mb-1 flex items-center justify-between text-12px">
<span class="text-[var(--screen-text-2)]">{{ item.label }}</span>
<span class="text-[var(--screen-text-1)]">{{ item.value }}%</span>
</div>
<div class="health-bar">
<div
class="h-full transition-all duration-500"
:style="{ width: `${item.value}%`, backgroundColor: item.color }"
/>
</div>
</li>
</ul>
</section>
<section class="screen__panel col-start-4 row-start-3 flex min-h-0 flex-col">
<h2 class="screen__panel-title">
<el-icon :size="14"><Bell /></el-icon>
<span>实时系统日志</span>
</h2>
<ul class="min-h-0 flex-1 overflow-hidden">
<li v-for="item in logs" :key="item.id" class="log-item">
<span class="shrink-0 text-12px text-[var(--screen-text-2)]">{{ item.time }}</span>
<span class="flex-1 truncate text-12px text-[var(--screen-text-1)]">
{{ item.text }}
</span>
</li>
</ul>
</section>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useFullscreen } from "@vueuse/core";
import * as echarts from "echarts/core";
import ScreenHeader from "@/views/demo/screen/components/ScreenHeader.vue";
import {
formatNumber,
registerChinaMap,
SCREEN_COLORS,
tweenValue,
verticalGradient,
} from "@/views/demo/screen/utils";
defineOptions({
name: "ScreenSystem",
});
// 大屏主题
const SCREEN_TITLE = "系统运营监控大屏";
const SCREEN_SUBTITLE = "SYSTEM OPERATION MONITOR";
// 顶部状态条指标
const METRICS = [
{
label: "注册用户",
value: 286450,
unit: "人",
trend: 6.2,
up: true,
icon: "User",
color: "#22d3ee",
},
{
label: "在线用户",
value: 3842,
unit: "人",
trend: 12.8,
up: true,
icon: "Avatar",
color: "#3ba9ff",
},
{
label: "今日登录",
value: 18620,
unit: "次",
trend: 4.5,
up: true,
icon: "Key",
color: "#38bdf8",
},
{
label: "待办任务",
value: 128,
unit: "项",
trend: 8.3,
up: false,
icon: "Tickets",
color: "#818cf8",
},
{
label: "消息推送",
value: 46820,
unit: "条",
trend: 9.1,
up: true,
icon: "Bell",
color: "#a78bfa",
},
{
label: "异常告警",
value: 7,
unit: "条",
trend: 15.4,
up: false,
icon: "Warning",
color: "#f87171",
},
];
// 各省用户数(人),名称需与 GeoJSON 中的 properties.name 完全一致
const PROVINCE_USERS: Record<string, number> = {
北京市: 18620,
天津市: 8420,
河北省: 14260,
山西省: 6840,
内蒙古自治区: 4620,
辽宁省: 9860,
吉林省: 5240,
黑龙江省: 6180,
上海市: 22480,
江苏省: 26840,
浙江省: 24260,
安徽省: 12840,
福建省: 14620,
江西省: 8620,
山东省: 22640,
河南省: 18640,
湖北省: 15260,
湖南省: 14860,
广东省: 32680,
广西壮族自治区: 8260,
海南省: 4260,
重庆市: 11240,
四川省: 19860,
贵州省: 6840,
云南省: 7620,
西藏自治区: 1240,
陕西省: 10620,
甘肃省: 4620,
青海省: 1580,
宁夏回族自治区: 1860,
新疆维吾尔自治区: 5240,
台湾省: 3860,
香港特别行政区: 6840,
澳门特别行政区: 2060,
};
const HOURLY_LABELS = Array.from(
{ length: 24 },
(_, hour) => `${String(hour).padStart(2, "0")}:00`
);
// 近 24 小时接口调用量(次)
const HOURLY_REQUESTS = [
1260, 980, 820, 760, 720, 860, 1580, 3260, 5860, 8240, 9860, 10420, 8620, 9240, 10260, 11240,
11860, 10820, 12240, 13620, 14260, 12680, 8420, 4260,
];
// 近 24 小时接口平均响应耗时(ms)
const HOURLY_RESPONSE = [
86, 72, 64, 58, 56, 62, 78, 96, 128, 146, 158, 162, 138, 142, 152, 166, 172, 158, 176, 192, 204,
186, 142, 98,
];
// 近 24 小时登录次数
const HOURLY_LOGINS = [
12, 6, 4, 3, 2, 5, 42, 186, 486, 862, 1124, 1286, 846, 924, 1086, 1248, 1362, 1186, 1428, 1682,
1846, 1524, 642, 186,
];
// 周维度:近 7 日活跃用户(人)
const WEEK_LABELS = ["09-13", "09-14", "09-15", "09-16", "09-17", "09-18", "09-19"];
const WEEK_ACTIVE_USERS = [8620, 9240, 8860, 10240, 11260, 12680, 9860];
// 模块访问 TOP 5
const MODULE_VISITS = [
{ name: "用户管理", value: 8620 },
{ name: "角色权限", value: 6240 },
{ name: "系统配置", value: 4860 },
{ name: "数据字典", value: 3840 },
{ name: "操作日志", value: 2680 },
];
// 登录终端占比
const TERMINAL_SHARE = [
{ value: 46820, name: "PC 浏览器" },
{ value: 18640, name: "移动端" },
{ value: 8620, name: "小程序" },
{ value: 3240, name: "平板" },
];
// 服务健康度
const HEALTH_ITEMS = [
{ label: "CPU 使用率", value: 42, color: "#22d3ee" },
{ label: "内存占用", value: 68, color: "#3ba9ff" },
{ label: "磁盘空间", value: 54, color: "#818cf8" },
{ label: "网络带宽", value: 76, color: "#a78bfa" },
];
// 实时系统日志池
const LOG_TEMPLATES = [
"用户 admin 通过 PC 浏览器登录",
"角色「运营专员」权限变更",
"定时任务「日志归档」执行成功",
"接口 /api/v1/users 平均耗时 86ms",
"配置项 sys.upload.limit 已更新",
"用户 zhangsan 连续 3 次登录失败",
"部门「研发中心」新增成员 6 人",
"系统缓存已刷新",
];
// 系统运营大屏主题色为青色,与电商大屏的蓝色区分
const ACCENT_COLOR = "#22d3ee";
const {
axis: AXIS_COLOR,
grid: GRID_COLOR,
success: SUCCESS_COLOR,
pie: PIE_COLORS,
} = SCREEN_COLORS;
// 初始为 0,进入页面后滚动到真实值
const metrics = ref(METRICS.map((item) => ({ ...item, value: 0 })));
const healthItems = ref(HEALTH_ITEMS.map((item) => ({ ...item })));
const logs = ref([
{ id: 5, time: "15:50:12", text: "用户 admin 通过 PC 浏览器登录" },
{ id: 4, time: "15:49:38", text: "角色「运营专员」权限变更" },
{ id: 3, time: "15:48:05", text: "定时任务「日志归档」执行成功" },
{ id: 2, time: "15:46:52", text: "配置项 sys.upload.limit 已更新" },
{ id: 1, time: "15:45:20", text: "部门「研发中心」新增成员 6 人" },
]);
/**
* 指标值平滑过渡到目标值
*/
function tweenMetrics(targets: number[], duration: number): void {
metrics.value.forEach((item, index) => {
tweenValue(
item.value,
targets[index],
(value) => {
item.value = value;
},
duration
);
});
}
// 中国地图数据体积较大,放在 public 下运行时加载,避免打进主包
const mapStatus = ref<"loading" | "ready" | "error">("loading");
// 省份中心点坐标,加载地图后填充,用于绘制散点
const provinceCenters = ref<Record<string, [number, number]>>({});
/**
* 注册中国地图并取省份坐标
*/
async function loadChinaMap(): Promise<void> {
try {
provinceCenters.value = await registerChinaMap(echarts);
mapStatus.value = "ready";
} catch {
// 地图失败不影响其它图表,面板内显示占位文案
mapStatus.value = "error";
}
}
// 用户数前 8 的省份,作为地图上的涟漪散点
const scatterData = computed(() =>
Object.entries(PROVINCE_USERS)
.filter(([name]) => provinceCenters.value[name])
.sort(([, a], [, b]) => b - a)
.slice(0, 8)
.map(([name, value]) => ({ name, value: [...provinceCenters.value[name], value] }))
);
const mapOptions = computed<echarts.EChartsCoreOption>(() => ({
tooltip: {
trigger: "item",
formatter: (params: { name: string; value?: number | number[] }) => {
const value = Array.isArray(params.value) ? params.value[2] : (params.value ?? 0);
return `${params.name}<br/>用户数:${formatNumber(value)} 人`;
},
},
// geo 只提供投影坐标系,地图着色交给 map 系列,避免与散点错位
geo: {
map: "china",
roam: false,
silent: true,
itemStyle: { areaColor: "transparent", borderColor: "transparent" },
},
visualMap: {
min: 0,
max: 34000,
left: 8,
bottom: 8,
text: ["高", "低"],
textStyle: { color: AXIS_COLOR },
inRange: { color: ["#0d3b45", "#116b7d", "#189bb5", ACCENT_COLOR] },
calculable: true,
},
series: [
{
name: "用户数",
type: "map",
map: "china",
roam: false,
label: { show: false },
itemStyle: {
areaColor: "#0d3b45",
borderColor: "#2f9fb5",
borderWidth: 0.8,
shadowColor: "rgba(34, 211, 238, 0.5)",
shadowBlur: 18,
},
emphasis: {
label: { show: true, color: "#ffffff", fontSize: 11 },
itemStyle: { areaColor: ACCENT_COLOR },
},
select: { disabled: true },
data: Object.entries(PROVINCE_USERS).map(([name, value]) => ({ name, value })),
},
{
name: "重点省份",
type: "effectScatter",
coordinateSystem: "geo",
data: scatterData.value,
symbolSize: (value: number[]) => Math.max(6, Math.round(value[2] / 3000)),
rippleEffect: { brushType: "stroke", scale: 3.5 },
itemStyle: { color: SUCCESS_COLOR, shadowBlur: 12, shadowColor: SUCCESS_COLOR },
},
],
}));
const hourlyOptions = {
tooltip: { trigger: "axis" },
grid: { left: 56, right: 16, top: 16, bottom: 24 },
xAxis: {
type: "category",
boundaryGap: false,
data: HOURLY_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, interval: 5, fontSize: 10 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "次",
nameTextStyle: { color: AXIS_COLOR, fontSize: 10 },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
},
series: [
{
name: "调用量",
type: "line",
smooth: true,
showSymbol: false,
data: HOURLY_REQUESTS,
itemStyle: { color: ACCENT_COLOR },
lineStyle: { width: 2, color: ACCENT_COLOR, shadowColor: ACCENT_COLOR, shadowBlur: 8 },
areaStyle: { color: verticalGradient("rgba(34, 211, 238, 0.42)", "rgba(34, 211, 238, 0)") },
},
],
};
const responseOptions = {
tooltip: { trigger: "axis" },
grid: { left: 48, right: 16, top: 16, bottom: 24 },
xAxis: {
type: "category",
boundaryGap: false,
data: HOURLY_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, interval: 5, fontSize: 10 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "ms",
nameTextStyle: { color: AXIS_COLOR, fontSize: 10 },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
},
series: [
{
name: "响应耗时",
type: "line",
smooth: true,
showSymbol: false,
data: HOURLY_RESPONSE,
itemStyle: { color: SUCCESS_COLOR },
lineStyle: { width: 2, color: SUCCESS_COLOR, shadowColor: SUCCESS_COLOR, shadowBlur: 8 },
areaStyle: { color: verticalGradient("rgba(52, 211, 153, 0.4)", "rgba(52, 211, 153, 0)") },
},
],
};
const loginOptions = {
tooltip: { trigger: "axis" },
grid: { left: 56, right: 16, top: 16, bottom: 24 },
xAxis: {
type: "category",
data: HOURLY_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, interval: 5, fontSize: 10 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "次",
nameTextStyle: { color: AXIS_COLOR, fontSize: 10 },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
},
series: [
{
name: "登录次数",
type: "bar",
barWidth: "55%",
data: HOURLY_LOGINS,
itemStyle: {
borderRadius: [2, 2, 0, 0],
color: verticalGradient(ACCENT_COLOR, "rgba(34, 211, 238, 0.2)"),
},
},
],
};
const weekOptions = {
tooltip: { trigger: "axis" },
grid: { left: 56, right: 16, top: 16, bottom: 24 },
xAxis: {
type: "category",
data: WEEK_LABELS,
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
axisTick: { show: false },
},
yAxis: {
type: "value",
name: "人",
nameTextStyle: { color: AXIS_COLOR, fontSize: 10 },
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
},
series: [
{
name: "活跃用户",
type: "bar",
barWidth: 14,
data: WEEK_ACTIVE_USERS,
itemStyle: {
borderRadius: [3, 3, 0, 0],
color: verticalGradient(ACCENT_COLOR, "rgba(34, 211, 238, 0.2)"),
},
},
],
};
const moduleOptions = {
tooltip: { trigger: "axis", axisPointer: { type: "shadow" } },
grid: { left: 68, right: 32, top: 10, bottom: 10 },
xAxis: {
type: "value",
splitLine: { lineStyle: { color: GRID_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
},
yAxis: {
type: "category",
// 反转后最大值显示在顶部
data: MODULE_VISITS.map((item) => item.name).reverse(),
axisLine: { lineStyle: { color: AXIS_COLOR } },
axisLabel: { color: AXIS_COLOR, fontSize: 10 },
axisTick: { show: false },
},
series: [
{
name: "访问量",
type: "bar",
barWidth: 9,
data: MODULE_VISITS.map((item) => item.value).reverse(),
itemStyle: {
borderRadius: [0, 4, 4, 0],
color: verticalGradient("rgba(56, 189, 248, 0.85)", "rgba(56, 189, 248, 0.22)"),
},
label: { show: true, position: "right", color: AXIS_COLOR, fontSize: 10 },
},
],
};
const terminalOptions = {
tooltip: { trigger: "item" },
legend: {
bottom: 0,
itemWidth: 9,
itemHeight: 9,
textStyle: { color: AXIS_COLOR, fontSize: 10 },
},
series: [
{
name: "登录终端",
type: "pie",
radius: ["42%", "64%"],
center: ["50%", "42%"],
label: { color: AXIS_COLOR, fontSize: 10 },
labelLine: { lineStyle: { color: AXIS_COLOR } },
data: TERMINAL_SHARE.map((item, index) => ({
...item,
itemStyle: { color: PIE_COLORS[index] },
})),
},
],
};
const screenRef = ref<HTMLElement | null>(null);
const { isFullscreen, toggle: toggleFullscreen } = useFullscreen(screenRef);
let logId = 5;
/**
* 追加一条实时日志
*/
function pushLog(): void {
logs.value.unshift({
id: ++logId,
time: new Date().toLocaleTimeString("zh-CN", { hour12: false }),
text: LOG_TEMPLATES[Math.floor(Math.random() * LOG_TEMPLATES.length)],
});
logs.value = logs.value.slice(0, 6);
}
/**
* 健康度小幅波动,模拟实时采集
*/
function refreshHealth(): void {
healthItems.value.forEach((item) => {
item.value = Math.min(99, Math.max(10, item.value + Math.round(Math.random() * 8) - 4));
});
}
let dataTimer: number | undefined;
onMounted(() => {
dataTimer = window.setInterval(() => {
tweenMetrics(
metrics.value.map((item) => item.value + Math.round(Math.random() * 60)),
900
);
refreshHealth();
pushLog();
}, 3000);
loadChinaMap();
tweenMetrics(
METRICS.map((item) => item.value),
1200
);
});
onBeforeUnmount(() => {
window.clearInterval(dataTimer);
});
</script>
<style lang="scss" scoped>
/* 覆盖公共大屏样式里的主题色变量 */
.screen {
--screen-accent: #22d3ee;
--screen-accent-rgb: 34 211 238;
}
/* 服务健康度进度条轨道:圆角只由外层裁切,内层保持直角,避免两层圆角叠加出缺口 */
.health-bar {
height: 6px;
overflow: hidden;
background: rgb(var(--screen-accent-rgb) / 18%);
border-radius: 3px;
}
/* 日志列表项分隔线 */
.log-item {
display: flex;
gap: 8px;
align-items: center;
padding: 6px 0;
border-bottom: 1px dashed rgb(var(--screen-accent-rgb) / 12%);
}
</style>
-107
View File
@@ -1,107 +0,0 @@
// 数据大屏示例共用的工具函数与配色
import type * as echartsCore from "echarts/core";
/**
* 图表通用配色
*/
export const SCREEN_COLORS = {
/** 坐标轴文字 */
axis: "#5c7fa8",
/** 分隔线 */
grid: "rgba(92, 127, 168, 0.16)",
/** 主题色 */
accent: "#3ba9ff",
/** 正向色 */
success: "#34d399",
/** 强调色 */
purple: "#a78bfa",
/** 环形图配色:同一冷色系内的明度递进,避免彩虹色观感 */
pie: ["#2f8fd4", "#3ba9ff", "#38bdf8", "#22d3ee"],
} as const;
/**
* hex 转 rgba,用于指标图标的半透明底色
*/
export function hexToRgba(hex: string, alpha: number): string {
const value = Number.parseInt(hex.slice(1), 16);
return `rgba(${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}, ${alpha})`;
}
/**
* 竖向渐变填充,面积图与柱状图共用
*/
export function verticalGradient(from: string, to: string) {
return {
type: "linear" as const,
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: from },
{ offset: 1, color: to },
],
};
}
/**
* 千分位格式化
*/
export function formatNumber(value: number): string {
return value.toLocaleString("zh-CN");
}
/**
* 数值平滑过渡到目标值(easeOutCubic)
*
* 大屏多处需要「数字滚动」效果:首次进入时 0 → 真实值,定时刷新时小幅增涨
*
* @param from 当前值
* @param to 目标值
* @param onUpdate 每帧回调
* @param duration 动画时长,单位毫秒
*/
export function tweenValue(
from: number,
to: number,
onUpdate: (value: number) => void,
duration = 1200
): void {
const startAt = performance.now();
// 逐帧推进动画
const step = (now: number) => {
const progress = Math.min(1, (now - startAt) / duration);
const eased = 1 - (1 - progress) ** 3;
onUpdate(Math.round(from + (to - from) * eased));
if (progress < 1) requestAnimationFrame(step);
};
requestAnimationFrame(step);
}
/**
* 加载并注册中国地图
*
* 地图数据放在 public 下运行时加载,避免 582KB 的 GeoJSON 打进主包
*
* @param echarts echarts 核心模块
* @returns 省份中心点坐标,用于绘制散点与飞线
*/
export async function registerChinaMap(
echarts: typeof echartsCore
): Promise<Record<string, [number, number]>> {
const response = await fetch(`${import.meta.env.BASE_URL}map/china.json`);
const geoJson = await response.json();
echarts.registerMap("china", geoJson);
const centers: Record<string, [number, number]> = {};
(geoJson.features as { properties: { name: string; cp?: [number, number] } }[]).forEach(
(feature) => {
const { name, cp } = feature.properties;
if (cp) centers[name] = cp;
}
);
return centers;
}
@@ -52,6 +52,10 @@
</template>
<script lang="ts" setup>
defineOptions({
name: "AutoOperationColumn",
});
const checked1 = ref(true);
const checked2 = ref(false);
const checked3 = ref(false);
+1 -1
View File
@@ -94,7 +94,7 @@ import { useAppStore } from "@/stores";
import useCrudPage from "@/components/Crud/useCrudPage";
defineOptions({
name: "CrudDemo",
name: "CrudSingle",
inheritAttrs: false,
});
@@ -16,7 +16,6 @@ const modalConfig: IModalConfig = {
* 表单提交(示例不发请求,直接提示)
*/
formAction(data) {
// return UserAPI.update(data.id as string, data);
// 模拟发起网络请求修改字段
ElMessage.success(JSON.stringify(data));
return Promise.resolve(null);
+4
View File
@@ -117,6 +117,10 @@
</template>
<script setup lang="ts">
defineOptions({
name: "Crud",
});
import UserAPI from "@/api/system/user";
import type { IObject, IOperateData, CrudModalInstance } from "@/components/Crud/types";
import useCrudPage from "@/components/Crud/useCrudPage";
+1 -7
View File
@@ -97,6 +97,7 @@ import {
} from "vxe-pc-ui";
defineOptions({
name: "VxeTable",
components: {
VxeButton,
VxeButtonGroup,
@@ -488,13 +489,6 @@ const xGridOpt = reactive<VxeGridProps<RowMeta>>({
xGridOpt.loading = true;
return new Promise<{ total: number; result: RowMeta[] }>((resolve) => {
// 接口需要的参数
// const params = {
// page: currentPage,
// limit: pageSize,
// username: form.username,
// roles: form.roles === null ? undefined : form.roles.join(","),
// createTime: form.createTime.length > 0 ? form.createTime.join(",") : undefined,
// };
// 模拟异步加载数据
setTimeout(() => {
const list = [