diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..05a69b4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +**/node_modules +dist +**/dist +.git +.env +.env.* +!.env.example +coverage +*.log diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1df144a --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +VITE_API_BASE_URL=http://localhost:3000 +VITE_WS_URL=ws://localhost:3000/ws/screen +VITE_ENABLE_STAGE_DEBUG=true diff --git a/.gitignore b/.gitignore index 07d58ae..83ed7b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ dist/ .env .env.* +!.env.example .DS_Store *.log coverage/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11c4082 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:22-alpine AS build + +WORKDIR /app + +RUN corepack enable + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.base.json ./ +COPY packages ./packages +COPY apps ./apps +COPY templates ./templates + +RUN pnpm install --frozen-lockfile +ARG APP_FILTER=@dev-screen-starter/demo-screen +RUN pnpm --filter ${APP_FILTER:-@dev-screen-starter/demo-screen} build + +FROM nginx:1.27-alpine + +ARG APP_PATH=apps/demo-screen + +COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/${APP_PATH}/dist /usr/share/nginx/html + +EXPOSE 80 diff --git a/README.md b/README.md index 173ba3d..e04c577 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,4 @@ pnpm build - [交付流程](doc/delivery-workflow.md) - [图表工厂与 visual-kit 使用教程](doc/charts-and-visual-kit-guide.md) - [外部数据接入设计与使用教程](doc/data-integration-guide.md) +- [部署与上线检查清单](doc/deployment-and-checklist.md) diff --git a/apps/demo-screen/src/pages/DemoOverview.tsx b/apps/demo-screen/src/pages/DemoOverview.tsx index bfb1ff8..49bf6ca 100644 --- a/apps/demo-screen/src/pages/DemoOverview.tsx +++ b/apps/demo-screen/src/pages/DemoOverview.tsx @@ -1,4 +1,5 @@ import { + ChartPanel, createAreaTrendOption, createDualAxisOption, createGaugeOption, @@ -6,9 +7,8 @@ import { createRadarOption, createRankBarOption, createStackedBarOption, - EChart } from '@dev-screen-starter/charts' -import { MetricCard, Panel, ScreenStage, type ScaleMode } from '@dev-screen-starter/screen-core' +import { MetricCard, ScreenStage, type ScaleMode } from '@dev-screen-starter/screen-core' import { CornerFrame, Divider, @@ -112,75 +112,80 @@ export function DemoOverview() { - - {capacityTrend ? ( - - ) : null} - + }) + : null + } + /> - - {stackedOrders ? ( - - ) : null} - + }) + : null + } + /> - - {regionRank ? ( - - ) : null} - + }) + : null + } + /> - - - + - - {fulfillmentMix ? ( - - ) : null} - + }) + : null + } + /> - - {qualityRadar ? ( - - ) : null} - + }) + : null + } + /> - - - + ) diff --git a/apps/demo-screen/src/styles/screen.css b/apps/demo-screen/src/styles/screen.css index 114a8b4..b71c5a1 100644 --- a/apps/demo-screen/src/styles/screen.css +++ b/apps/demo-screen/src/styles/screen.css @@ -170,9 +170,12 @@ body { } .screen-panel header { + align-items: center; color: #d7e6f7; + display: flex; font-size: 18px; font-weight: 700; + justify-content: space-between; margin-bottom: 12px; } @@ -202,6 +205,28 @@ body { width: 100%; } +.chart-panel-body { + position: relative; +} + +.chart-panel-extra { + color: #88a1bd; + font-size: 12px; + font-weight: 400; +} + +.chart-panel-state { + align-items: center; + color: #88a1bd; + display: flex; + height: 100%; + justify-content: center; +} + +.chart-panel-state.is-error { + color: #ff9fa7; +} + .debug-badge { background: rgb(3 8 13 / 80%); border: 1px solid rgb(100 135 170 / 35%); diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 0000000..393f74a --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,17 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /assets/ { + expires 30d; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } +} diff --git a/doc/data-integration-guide.md b/doc/data-integration-guide.md index 3cc1230..9aa51a5 100644 --- a/doc/data-integration-guide.md +++ b/doc/data-integration-guide.md @@ -166,6 +166,11 @@ const sources = defineDataSources({ 字段说明: - `url`: 请求地址。 +- `baseUrl`: API 基础地址,建议来自 `.env`。 +- `query`: 查询参数。 +- `headers`: 静态 header 或返回 header 的函数。 +- `authToken`: token 字符串或返回 token 的函数,会自动写入 `Authorization: Bearer `。 +- `timeoutMs`: 超时时间。 - `init`: `fetch` 的 RequestInit 参数。 - `intervalMs`: 轮询间隔,不传则只请求一次。 - `immediate`: 是否立即请求,默认 `true`。 @@ -186,6 +191,8 @@ const sources = defineDataSources({ url: 'ws://localhost:3000/ws/alerts', mode: 'append', maxItems: 20, + reconnect: { enabled: true, maxRetries: 10, delayMs: 3000 }, + heartbeat: { message: 'ping', intervalMs: 30000 }, transform: (raw) => ({ time: raw.time, message: raw.message @@ -200,6 +207,8 @@ const sources = defineDataSources({ - `protocols`: 可选 WebSocket protocols。 - `mode`: `replace` 或 `append`,默认 `replace`。 - `maxItems`: `append` 模式最多保留多少条。 +- `reconnect`: 断线重连设置。 +- `heartbeat`: 心跳消息设置。 - `transform`: 单条消息的清洗函数。 WebSocket 消息如果是字符串,会优先尝试 `JSON.parse`。如果不是 JSON,会把原始字符串传给 `transform`。 diff --git a/doc/deployment-and-checklist.md b/doc/deployment-and-checklist.md new file mode 100644 index 0000000..52bfb47 --- /dev/null +++ b/doc/deployment-and-checklist.md @@ -0,0 +1,104 @@ +# 部署与上线检查清单 + +本文档用于客户大屏项目交付前的最后检查。 + +## 1. 本地构建 + +```bash +pnpm install +pnpm typecheck +pnpm build +``` + +单个客户项目构建: + +```bash +pnpm --filter @dev-screen-starter/customer-a build +``` + +## 2. 环境变量 + +新项目会带 `.env.example`: + +```txt +VITE_API_BASE_URL=http://localhost:3000 +VITE_WS_URL=ws://localhost:3000/ws/screen +VITE_ENABLE_STAGE_DEBUG=true +``` + +交付环境建议: + +- 开发环境可以打开 `VITE_ENABLE_STAGE_DEBUG=true`。 +- 生产环境建议关闭调试浮层。 +- API 和 WebSocket 地址不要写死在组件里,统一放到 `dataSources.ts` 或 `.env`。 + +## 3. Nginx 静态部署 + +构建完成后,把对应项目的 `dist` 发布到静态服务器。 + +示例 Nginx 配置在: + +```txt +deploy/nginx.conf +``` + +## 4. Docker 部署 + +默认构建 demo: + +```bash +docker build -t dev-screen-demo . +docker run --rm -p 8080:80 dev-screen-demo +``` + +构建指定客户项目: + +```bash +docker build \ + --build-arg APP_FILTER=@dev-screen-starter/customer-a \ + --build-arg APP_PATH=apps/customer-a \ + -t customer-a-screen . +``` + +## 5. 屏幕适配验收 + +至少检查这些尺寸: + +- `1366x768` +- `1920x1080` +- `2560x1440` +- `3840x2160` + +至少检查这些模式: + +- `?scaleMode=fit` +- `?scaleMode=fill` +- `?scaleMode=stretch` + +默认建议生产使用 `fit`。 + +## 6. 数据接入检查 + +- HTTP 数据源是否配置 `baseUrl`、`timeoutMs`、错误兜底。 +- WebSocket 是否配置 `reconnect` 和 `heartbeat`。 +- 实时列表是否设置 `maxItems`。 +- 图表数据是否在 `transform` 中清洗成组件需要的结构。 +- 断网、接口 500、空数据时页面是否仍可读。 + +## 7. 视觉检查 + +- 标题、指标、图例、坐标轴在 1080p 和 4K 下都清晰。 +- 自动滚动列表没有超出父容器。 +- 图表容器没有空白 canvas。 +- 关键数字没有挤压、换行或遮挡。 +- 客户看屏页面不出现开发调试信息。 + +## 8. 上线前清单 + +- `pnpm typecheck` 通过。 +- `pnpm build` 通过。 +- 客户接口地址已切换为正式地址。 +- `.env` 未提交到 git。 +- 生产关闭 `VITE_ENABLE_STAGE_DEBUG`。 +- 浏览器全屏查看无滚动条、无遮挡。 +- 大屏实际设备上验收一次。 diff --git a/doc/framework.md b/doc/framework.md index 4ea498a..3f08259 100644 --- a/doc/framework.md +++ b/doc/framework.md @@ -146,6 +146,8 @@ const metrics = data.metrics.data ?? [] 其中 `mockSource`、`httpSource`、`websocketSource` 已可用;`mqttSource`、`signalrSource` 已预留类型和声明入口,具体 SDK 在客户项目需要时再接。 +HTTP 数据源支持 `baseUrl`、`query`、`headers`、`authToken`、`timeoutMs`。WebSocket 数据源支持断线重连和心跳。 + ## 5. debug `debug` 提供开发时调试组件。 @@ -189,7 +191,14 @@ const metrics = data.metrics.data ?? [] ## 7. 项目模板 -`templates/project-basic` 是新客户项目起点。 +`templates/project-basic` 是新客户项目起点,默认包含: + +- `ScreenStage` 适配和 debug。 +- `dataSources.ts` 页面级数据源声明。 +- `mockData.ts` 本地 mock 数据。 +- `ChartPanel` 图表面板。 +- `visual-kit` 状态区和告警区。 +- `.env.example` 接口配置示例。 创建命令: diff --git a/doc/project-plan.md b/doc/project-plan.md index 7fc2a96..5f2341d 100644 --- a/doc/project-plan.md +++ b/doc/project-plan.md @@ -129,12 +129,14 @@ doc/ - 图表工厂覆盖常用交付场景,并保留 ECharts 原生 option 覆盖能力。 - demo-screen 已包含状态区、运行事件、指标卡、趋势、堆叠、排行、玫瑰、双轴、雷达和仪表盘示例。 - `data` 包已新增统一数据源设计,支持页面集中声明 mock、HTTP、WebSocket 数据源,并预留 MQTT、SignalR 类型。 +- `project-basic` 模板已升级,默认包含数据源声明、图表面板、visual-kit、`.env.example` 和屏幕适配 debug。 +- 新增 `ChartPanel`,封装图表标题、loading、empty、error 和 ECharts 容器。 +- 新增 Dockerfile、Nginx 配置和部署上线检查清单。 下一步建议: -- 做 `ChartPanel` 组合组件,把 `Panel + EChart + loading/empty/error` 固化下来。 -- 给 `data` 包补 WebSocket 重连、心跳、鉴权 header/token 约定。 -- 增加 `.env.example` 和项目级接口配置约定。 +- 继续完善真实 MQTT、SignalR adapter。 +- 按客户项目沉淀更多模板分支,例如运营大屏、设备大屏、销售驾驶舱。 - 对 `ScreenStage` 做更多截图验收,覆盖 1366x768、1920x1080、4K 和不同 `scaleMode`。 ## 8. 成功标准 diff --git a/packages/charts/src/ChartPanel.tsx b/packages/charts/src/ChartPanel.tsx new file mode 100644 index 0000000..31156f5 --- /dev/null +++ b/packages/charts/src/ChartPanel.tsx @@ -0,0 +1,41 @@ +import type { EChartsOption } from 'echarts' +import type { ReactNode } from 'react' +import { EChart } from './EChart' + +type ChartPanelProps = { + title: string + option?: EChartsOption | null + loading?: boolean + error?: string | null + empty?: boolean + emptyText?: string + className?: string + extra?: ReactNode +} + +export function ChartPanel({ + title, + option, + loading = false, + error, + empty, + emptyText = '暂无数据', + className = '', + extra +}: ChartPanelProps) { + const isEmpty = empty ?? !option + + return ( + + + {title} + {extra ? {extra} : null} + + + {error ? {error} : null} + {!error && isEmpty ? {emptyText} : null} + {!error && !isEmpty && option ? : null} + + + ) +} diff --git a/packages/charts/src/index.ts b/packages/charts/src/index.ts index 41d1146..c9f21cb 100644 --- a/packages/charts/src/index.ts +++ b/packages/charts/src/index.ts @@ -1,3 +1,4 @@ export * from './EChart' +export * from './ChartPanel' export * from './chartTheme' export * from './optionFactories' diff --git a/packages/data/src/types.ts b/packages/data/src/types.ts index eabfb84..3316492 100644 --- a/packages/data/src/types.ts +++ b/packages/data/src/types.ts @@ -29,17 +29,35 @@ export type MockDataSource = BaseDataSource & { export type HttpDataSource = BaseDataSource & { type: 'http' url: string + baseUrl?: string + query?: Record + headers?: HeadersInit | (() => HeadersInit) + authToken?: string | (() => string | null | undefined) + timeoutMs?: number init?: RequestInit intervalMs?: number immediate?: boolean } +export type ReconnectOptions = { + enabled?: boolean + maxRetries?: number + delayMs?: number +} + +export type HeartbeatOptions = { + message: string + intervalMs: number +} + export type WebSocketDataSource = BaseDataSource & { type: 'websocket' url: string protocols?: string | string[] mode?: RealtimeUpdateMode maxItems?: number + reconnect?: boolean | ReconnectOptions + heartbeat?: string | HeartbeatOptions } export type SignalRDataSource = BaseDataSource & { diff --git a/packages/data/src/useScreenDataSources.ts b/packages/data/src/useScreenDataSources.ts index 38891c2..6632a02 100644 --- a/packages/data/src/useScreenDataSources.ts +++ b/packages/data/src/useScreenDataSources.ts @@ -1,6 +1,6 @@ import { useEffect, useMemo, useState } from 'react' import { requestJson } from './request' -import type { DataSource, DataSourceMap, DataState, DataStates, RealtimeUpdateMode } from './types' +import type { DataSource, DataSourceMap, DataState, DataStates, HeartbeatOptions, RealtimeUpdateMode } from './types' function createInitialState(source: DataSource): DataState { return { @@ -56,6 +56,46 @@ function toErrorMessage(error: unknown): string { return error instanceof Error ? error.message : String(error) } +function resolveHeaders(sourceHeaders?: HeadersInit | (() => HeadersInit), authToken?: string | (() => string | null | undefined)): HeadersInit { + const headers = new Headers(typeof sourceHeaders === 'function' ? sourceHeaders() : sourceHeaders) + const token = typeof authToken === 'function' ? authToken() : authToken + + if (token && !headers.has('authorization')) { + headers.set('authorization', `Bearer ${token}`) + } + + return headers +} + +function resolveHttpUrl(url: string, baseUrl?: string, query?: Record): string { + const resolved = baseUrl ? new URL(url, baseUrl).toString() : url + + if (!query) { + return resolved + } + + const parsed = new URL(resolved, window.location.origin) + for (const [key, value] of Object.entries(query)) { + if (value !== null && value !== undefined) { + parsed.searchParams.set(key, String(value)) + } + } + + if (!baseUrl && url.startsWith('/')) { + return `${parsed.pathname}${parsed.search}` + } + + return parsed.toString() +} + +function resolveHeartbeat(heartbeat: string | HeartbeatOptions | undefined): HeartbeatOptions | null { + if (!heartbeat) { + return null + } + + return typeof heartbeat === 'string' ? { message: heartbeat, intervalMs: 30000 } : heartbeat +} + export function useScreenDataSources(sources: TSources): DataStates { const sourceEntries = useMemo(() => Object.entries(sources), [sources]) @@ -124,10 +164,14 @@ export function useScreenDataSources(sources: TS abortController?.abort() abortController = new AbortController() updateState({ loading: true, error: null, status: 'connecting' }) + const timeout = source.timeoutMs + ? window.setTimeout(() => abortController?.abort(), source.timeoutMs) + : null try { - const raw = await requestJson(source.url, { + const raw = await requestJson(resolveHttpUrl(source.url, source.baseUrl, source.query), { ...source.init, + headers: resolveHeaders(source.headers ?? source.init?.headers, source.authToken), signal: abortController.signal }) @@ -138,6 +182,10 @@ export function useScreenDataSources(sources: TS if (active && !(error instanceof DOMException && error.name === 'AbortError')) { updateState({ loading: false, error: toErrorMessage(error), status: 'error' }) } + } finally { + if (timeout) { + window.clearTimeout(timeout) + } } } @@ -162,17 +210,69 @@ export function useScreenDataSources(sources: TS continue } - updateState({ status: 'connecting', error: null }) - const socket = new WebSocket(source.url, source.protocols) + let closedByCleanup = false + let retryCount = 0 + let reconnectTimer: number | null = null + let heartbeatTimer: number | null = null + let socket: WebSocket | null = null + const reconnect = source.reconnect === undefined ? { enabled: true, maxRetries: 5, delayMs: 3000 } : source.reconnect + const reconnectOptions = typeof reconnect === 'boolean' + ? { enabled: reconnect, maxRetries: 5, delayMs: 3000 } + : { enabled: reconnect.enabled ?? true, maxRetries: reconnect.maxRetries ?? 5, delayMs: reconnect.delayMs ?? 3000 } + const heartbeat = resolveHeartbeat(source.heartbeat) - socket.addEventListener('open', () => updateState({ loading: false, status: 'open', error: null })) - socket.addEventListener('message', (event) => { - commitData(parsePayload(event.data), source.mode, source.maxItems) + const clearHeartbeat = () => { + if (heartbeatTimer) { + window.clearInterval(heartbeatTimer) + heartbeatTimer = null + } + } + + const connect = () => { + updateState({ status: 'connecting', error: null }) + socket = new WebSocket(source.url, source.protocols) + + socket.addEventListener('open', () => { + retryCount = 0 + updateState({ loading: false, status: 'open', error: null }) + + if (heartbeat) { + clearHeartbeat() + heartbeatTimer = window.setInterval(() => { + if (socket?.readyState === WebSocket.OPEN) { + socket.send(heartbeat.message) + } + }, heartbeat.intervalMs) + } + }) + + socket.addEventListener('message', (event) => { + commitData(parsePayload(event.data), source.mode, source.maxItems) + }) + + socket.addEventListener('close', () => { + clearHeartbeat() + updateState({ loading: false, status: 'closed' }) + + if (!closedByCleanup && reconnectOptions.enabled && retryCount < reconnectOptions.maxRetries) { + retryCount += 1 + reconnectTimer = window.setTimeout(connect, reconnectOptions.delayMs) + } + }) + + socket.addEventListener('error', () => updateState({ loading: false, status: 'error', error: 'WebSocket connection error.' })) + } + + connect() + + cleanups.push(() => { + closedByCleanup = true + clearHeartbeat() + if (reconnectTimer) { + window.clearTimeout(reconnectTimer) + } + socket?.close() }) - socket.addEventListener('close', () => updateState({ loading: false, status: 'closed' })) - socket.addEventListener('error', () => updateState({ loading: false, status: 'error', error: 'WebSocket connection error.' })) - - cleanups.push(() => socket.close()) } if (source.type === 'signalr' || source.type === 'mqtt') { diff --git a/templates/project-basic/.env.example b/templates/project-basic/.env.example new file mode 100644 index 0000000..1df144a --- /dev/null +++ b/templates/project-basic/.env.example @@ -0,0 +1,3 @@ +VITE_API_BASE_URL=http://localhost:3000 +VITE_WS_URL=ws://localhost:3000/ws/screen +VITE_ENABLE_STAGE_DEBUG=true diff --git a/templates/project-basic/src/ProjectScreen.tsx b/templates/project-basic/src/ProjectScreen.tsx index 2a0e287..23cbe50 100644 --- a/templates/project-basic/src/ProjectScreen.tsx +++ b/templates/project-basic/src/ProjectScreen.tsx @@ -1,17 +1,91 @@ -import { MetricCard, ScreenStage } from '@dev-screen-starter/screen-core' +import { ChartPanel, createAreaTrendOption, createRankBarOption } from '@dev-screen-starter/charts' +import { useScreenDataSources } from '@dev-screen-starter/data' +import { MetricCard, ScreenStage, type ScaleMode } from '@dev-screen-starter/screen-core' +import { CornerFrame, Divider, GlowPanel, ScrollTable, SectionTitle, StatusPill } from '@dev-screen-starter/visual-kit' +import { screenDataSources } from './dataSources' + +const scaleModes: ScaleMode[] = ['fit', 'fill', 'stretch', 'none'] + +function readScaleMode(): ScaleMode { + if (typeof window === 'undefined') { + return 'fit' + } + + const value = new URLSearchParams(window.location.search).get('scaleMode') + return scaleModes.includes(value as ScaleMode) ? (value as ScaleMode) : 'fit' +} export function ProjectScreen() { + const scaleMode = readScaleMode() + const data = useScreenDataSources(screenDataSources) + const metrics = data.metrics.data ?? [] + const trend = data.trend.data + const rank = data.rank.data + const alerts = data.alerts.data ?? [] + const debug = import.meta.env.VITE_ENABLE_STAGE_DEBUG === 'true' + return ( - + __PROJECT_TITLE__ 大屏总览 + scaleMode={scaleMode} + + + + + + + + + + + + + + + + - - - + {metrics.map((metric) => ( + + ))} + + + + + ) diff --git a/templates/project-basic/src/dataSources.ts b/templates/project-basic/src/dataSources.ts new file mode 100644 index 0000000..a2d8190 --- /dev/null +++ b/templates/project-basic/src/dataSources.ts @@ -0,0 +1,44 @@ +import { defineDataSources, httpSource, mockSource, websocketSource } from '@dev-screen-starter/data' +import { alerts, metrics, rank, trend } from './mockData' + +const apiBaseUrl = import.meta.env.VITE_API_BASE_URL +const wsUrl = import.meta.env.VITE_WS_URL + +export const screenDataSources = defineDataSources({ + metrics: mockSource({ + data: metrics, + intervalMs: 15000 + }), + + trend: mockSource({ + data: trend + }), + + rank: mockSource({ + data: rank + }), + + alerts: mockSource({ + data: alerts, + intervalMs: 10000 + }), + + // Replace the mock source above with this source when the customer API is ready. + overviewApi: httpSource({ + enabled: false, + baseUrl: apiBaseUrl, + url: '/api/screen/overview', + timeoutMs: 8000, + intervalMs: 10000 + }), + + // Enable this source for pushed event streams. + realtimeAlerts: websocketSource({ + enabled: false, + url: wsUrl, + mode: 'append', + maxItems: 20, + reconnect: { enabled: true, maxRetries: 10, delayMs: 3000 }, + heartbeat: { message: 'ping', intervalMs: 30000 } + }) +}) diff --git a/templates/project-basic/src/main.tsx b/templates/project-basic/src/main.tsx index 0395884..4deaf21 100644 --- a/templates/project-basic/src/main.tsx +++ b/templates/project-basic/src/main.tsx @@ -1,5 +1,6 @@ import { createRoot } from 'react-dom/client' import { ProjectScreen } from './ProjectScreen' +import '@dev-screen-starter/visual-kit/styles.css' import './screen.css' createRoot(document.getElementById('root')!).render() diff --git a/templates/project-basic/src/mockData.ts b/templates/project-basic/src/mockData.ts new file mode 100644 index 0000000..a59bdb9 --- /dev/null +++ b/templates/project-basic/src/mockData.ts @@ -0,0 +1,21 @@ +export const metrics = [ + { label: '今日订单', value: 1280, unit: '单', tone: 'blue' as const }, + { label: '在线设备', value: 342, unit: '台', tone: 'green' as const }, + { label: '告警数量', value: 17, unit: '条', tone: 'amber' as const } +] + +export const trend = { + categories: ['08:00', '10:00', '12:00', '14:00', '16:00', '18:00'], + values: [120, 240, 380, 520, 760, 920] +} + +export const rank = { + categories: ['华东', '华南', '华北', '西南', '东北'], + values: [960, 820, 680, 520, 390] +} + +export const alerts = [ + { time: '18:20', area: '华东仓', status: '履约延迟' }, + { time: '18:12', area: '华南仓', status: '库存预警' }, + { time: '17:48', area: '华北仓', status: '接口抖动' } +] diff --git a/templates/project-basic/src/screen.css b/templates/project-basic/src/screen.css index 744569d..47f0de7 100644 --- a/templates/project-basic/src/screen.css +++ b/templates/project-basic/src/screen.css @@ -27,6 +27,9 @@ body { } .screen-title { + display: flex; + flex-direction: column; + gap: 8px; left: 56px; position: absolute; top: 42px; @@ -34,9 +37,7 @@ body { .screen-title span { color: #88a1bd; - display: block; font-size: 16px; - margin-bottom: 8px; } .screen-title strong { @@ -44,6 +45,32 @@ body { font-size: 42px; } +.screen-title small { + border: 1px solid rgb(99 164 255 / 22%); + border-radius: 999px; + color: #9fb4cc; + font-size: 12px; + padding: 5px 9px; + width: fit-content; +} + +.status-strip { + display: grid; + gap: 18px; + grid-template-columns: 0.9fr 1.1fr; + height: 150px; + left: 720px; + position: absolute; + right: 56px; + top: 42px; +} + +.status-row { + display: flex; + gap: 8px; + margin-top: 18px; +} + .metric-row { display: grid; gap: 24px; @@ -51,7 +78,7 @@ body { left: 56px; position: absolute; right: 56px; - top: 150px; + top: 230px; } .metric-card { @@ -80,3 +107,88 @@ body { font-size: 18px; margin-left: 8px; } + +.tone-green { + border-color: rgb(78 170 116 / 42%); +} + +.tone-amber { + border-color: rgb(216 161 62 / 42%); +} + +.screen-panel { + background: rgb(8 22 36 / 86%); + border: 1px solid rgb(88 130 171 / 36%); + border-radius: 8px; + display: flex; + flex-direction: column; + padding: 18px; +} + +.screen-panel header { + align-items: center; + color: #d7e6f7; + display: flex; + font-size: 18px; + font-weight: 700; + justify-content: space-between; + margin-bottom: 12px; +} + +.screen-panel-body { + flex: 1; + min-height: 0; +} + +.chart-grid { + bottom: 56px; + display: grid; + gap: 20px; + grid-template-columns: repeat(2, 1fr); + left: 56px; + position: absolute; + right: 56px; + top: 420px; +} + +.chart-host { + height: 100%; + width: 100%; +} + +.chart-panel-body { + position: relative; +} + +.chart-panel-state { + align-items: center; + color: #88a1bd; + display: flex; + height: 100%; + justify-content: center; +} + +.chart-panel-state.is-error { + color: #ff9fa7; +} + +.screen-stage-debug { + background: rgb(3 8 13 / 84%); + border: 1px solid rgb(100 135 170 / 35%); + border-radius: 6px; + bottom: 18px; + color: #9fb4cc; + display: flex; + flex-wrap: wrap; + gap: 10px; + max-width: min(760px, calc(100vw - 36px)); + padding: 8px 10px; + position: absolute; + right: 18px; + z-index: 10; +} + +.screen-stage-debug span { + font-size: 12px; + white-space: nowrap; +}