From e523f7317bae0e65991c9677dced6eea5c7a543e Mon Sep 17 00:00:00 2001 From: chndfang Date: Wed, 30 Apr 2025 00:17:09 +0800 Subject: [PATCH] temp --- .env.development | 3 +- mocks/robot/getAll | 49 ++++++++++++++++++++++++++++++++ mocks/scene/getById | 11 +++++++ src/ant.scss | 18 ++++++++++++ src/apis/robot/api.ts | 13 +++++++++ src/apis/robot/type.ts | 24 ++++++++-------- src/apis/scene/api.ts | 13 ++++++++- src/apis/scene/type.ts | 6 ++-- src/assets/themes/_dark.scss | 1 + src/assets/themes/_light.scss | 1 + src/assets/themes/antd-dark.json | 9 ------ src/pages/scene-editor.vue | 27 +++++++++++++++++- src/services/http.ts | 4 +-- 13 files changed, 151 insertions(+), 28 deletions(-) create mode 100644 mocks/robot/getAll create mode 100644 mocks/scene/getById delete mode 100644 src/assets/themes/antd-dark.json diff --git a/.env.development b/.env.development index 2e995b3..6c82fc8 100644 --- a/.env.development +++ b/.env.development @@ -1 +1,2 @@ -ENV_APP_TITLE=运输控制系统(开发) \ No newline at end of file +ENV_APP_TITLE=运输控制系统(开发) +ENV_HTTP_BASE=/mocks \ No newline at end of file diff --git a/mocks/robot/getAll b/mocks/robot/getAll new file mode 100644 index 0000000..57067c9 --- /dev/null +++ b/mocks/robot/getAll @@ -0,0 +1,49 @@ +{ + "code": 200, + "success": true, + "data": [ + { + "id": "mock-robot-1", + "label": "模拟机器人A", + "brand": "模拟品牌A", + "type": 1, + "ip": "127.0.1.1" + }, + { + "id": "mock-robot-2", + "label": "模拟机器人B", + "brand": "模拟品牌A", + "type": 2, + "ip": "127.0.1.2" + }, + { + "id": "mock-robot-3", + "label": "模拟机器人C", + "brand": "模拟品牌A", + "type": 3, + "ip": "127.0.1.3" + }, + { + "id": "mock-robot-4", + "label": "模拟机器人D", + "brand": "模拟品牌B", + "type": 1, + "ip": "127.0.2.1" + }, + { + "id": "mock-robot-5", + "label": "模拟机器人E", + "brand": "模拟品牌B", + "type": 2, + "ip": "127.0.2.2" + }, + { + "id": "mock-robot-6", + "label": "模拟机器人F", + "brand": "模拟品牌B", + "type": 3, + "ip": "127.0.2.3" + } + ], + "message": "模拟提示" +} diff --git a/mocks/scene/getById b/mocks/scene/getById new file mode 100644 index 0000000..0c3d458 --- /dev/null +++ b/mocks/scene/getById @@ -0,0 +1,11 @@ +{ + "code": 200, + "success": true, + "data": { + "id": "mock-scene-1", + "label": "模拟场景A", + "robotGroups": [], + "map": "" + }, + "message": "模拟提示" +} diff --git a/src/ant.scss b/src/ant.scss index e69de29..5106d69 100644 --- a/src/ant.scss +++ b/src/ant.scss @@ -0,0 +1,18 @@ +// @use 'asset/themes/dark' as dark; +// @use 'asset/themes/light' as light; + +// $theme: dark; + +// :root { +// [theme='dark'] { +// $theme: dark !global; +// } + +// [theme='light'] { +// $theme: light !global; +// } +// } + +// .ant-typography { +// color: #{$theme}.$text-1; +// } diff --git a/src/apis/robot/api.ts b/src/apis/robot/api.ts index e69de29..ac27a42 100644 --- a/src/apis/robot/api.ts +++ b/src/apis/robot/api.ts @@ -0,0 +1,13 @@ +import http from '@core/http'; + +import type { RobotInfo } from './type'; + +const enum API { + 获取所有机器人 = '/robot/getAll', +} + +export async function getAllRobot(): Promise { + type D = RobotInfo[]; + const data = await http.get(API.获取所有机器人); + return data ?? []; +} diff --git a/src/apis/robot/type.ts b/src/apis/robot/type.ts index f882037..b83234c 100644 --- a/src/apis/robot/type.ts +++ b/src/apis/robot/type.ts @@ -1,30 +1,30 @@ import type { RobotBrand, RobotState, RobotType } from './constant'; export interface RobotGroup { - id: number; // 机器人组id + id: string; // 机器人组id label: string; // 机器人组名称 robotIds: number[]; // 机器人id列表 } export interface RobotInfo { - group?: number; // 机器人组id - id: number; // 机器人id + id: string; // 机器人id label: string; // 机器人名称 brand: RobotBrand; // 机器人品牌 type: RobotType; // 机器人类型 ip: string; // 机器人ip - isConnected?: boolean; // 机器人连接状态 +} + +export interface RobotDetail extends RobotInfo { + group?: string; // 机器人组id + isSimulative?: boolean; // 是否仿真机器人 battery?: number; // 机器人电量 + minBattery?: number; // 最小电量 + maxBattery?: number; // 最大电量 + chargeBattery?: number; // 充电电量 + swapBattery?: number; // 交换电量 + isConnected?: boolean; // 机器人连接状态 state?: RobotState; // 机器人状态 canOrder?: boolean; // 接单状态 canStop?: boolean; // 急停状态 canControl?: boolean; // 控制状态 } - -export interface RobotDetail extends RobotInfo { - isSimulative?: boolean; // 是否仿真机器人 - minBattery?: number; // 最小电量 - maxBattery?: number; // 最大电量 - chargeBattery?: number; // 充电电量 - swapBattery?: number; // 交换电量 -} diff --git a/src/apis/scene/api.ts b/src/apis/scene/api.ts index a1afc86..1fe4446 100644 --- a/src/apis/scene/api.ts +++ b/src/apis/scene/api.ts @@ -1,5 +1,16 @@ +import http from '@core/http'; + +import type { SceneDetail, SceneInfo } from './type'; + const enum API { 获取场景 = '/scene/getById', } -export function getSceneById(id: number) {} +export async function getSceneById(id: SceneInfo['id']): Promise { + if (!id) return null; + type B = { id: string }; + type D = SceneDetail; + const body = { id }; + const data = await http.post(API.获取场景, body); + return data ?? null; +} diff --git a/src/apis/scene/type.ts b/src/apis/scene/type.ts index 38fb285..84c52f3 100644 --- a/src/apis/scene/type.ts +++ b/src/apis/scene/type.ts @@ -1,8 +1,10 @@ import type { RobotGroup } from '@api/robot'; export interface SceneInfo { - id: number; // 场景id + id: string; // 场景id label: string; // 场景名称 - robotGrroups?: RobotGroup[]; // 机器人组列表 +} +export interface SceneDetail extends SceneInfo { + robotGroups?: RobotGroup[]; // 机器人组列表 map?: string; // 地图JSON } diff --git a/src/assets/themes/_dark.scss b/src/assets/themes/_dark.scss index e69de29..f7ac19a 100644 --- a/src/assets/themes/_dark.scss +++ b/src/assets/themes/_dark.scss @@ -0,0 +1 @@ +$text-1: #ffffffd9 !global; diff --git a/src/assets/themes/_light.scss b/src/assets/themes/_light.scss index e69de29..efdd921 100644 --- a/src/assets/themes/_light.scss +++ b/src/assets/themes/_light.scss @@ -0,0 +1 @@ +$text-1: #000000d9 !global; diff --git a/src/assets/themes/antd-dark.json b/src/assets/themes/antd-dark.json deleted file mode 100644 index 64184af..0000000 --- a/src/assets/themes/antd-dark.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "token": { - "colorInfo": "#0ea278", - "colorPrimary": "#0dbb8a", - "colorTextBase": "#fafafa", - "colorBgBase": "#2a2c2c", - "colorBorderSecondary": "#595e5e" - } -} \ No newline at end of file diff --git a/src/pages/scene-editor.vue b/src/pages/scene-editor.vue index 94d9476..f268271 100644 --- a/src/pages/scene-editor.vue +++ b/src/pages/scene-editor.vue @@ -1,5 +1,10 @@