From 0cb69e4b4328bd3a8e949325b7231d9017b7fc6b Mon Sep 17 00:00:00 2001 From: chndfang Date: Sat, 10 May 2025 15:41:21 +0800 Subject: [PATCH] temp --- mocks/scene/getByGroupId | 9 + src/_ant.scss | 8 +- src/apis/robot/type.ts | 1 + src/apis/scene/api.ts | 17 ++ src/assets/icons/_icon.scss | 1 + src/assets/icons/dark/edit_group.png | Bin 0 -> 663 bytes src/components/robot-group.vue | 244 +++++++++++++++++++++++++++ src/components/robot-groups.vue | 48 +++++- src/pages/group-editor.vue | 171 ++++++++++++++++++- src/pages/scene-editor.vue | 5 +- src/services/router.ts | 4 +- 11 files changed, 491 insertions(+), 17 deletions(-) create mode 100644 mocks/scene/getByGroupId create mode 100644 src/assets/icons/dark/edit_group.png create mode 100644 src/components/robot-group.vue diff --git a/mocks/scene/getByGroupId b/mocks/scene/getByGroupId new file mode 100644 index 0000000..1927dd6 --- /dev/null +++ b/mocks/scene/getByGroupId @@ -0,0 +1,9 @@ +{ + "code": 200, + "success": true, + "data": { + "id": "mock-group-scene-1", + "label": "模拟组场景A" + }, + "message": "模拟提示" +} diff --git a/src/_ant.scss b/src/_ant.scss index 728cfb1..f0fa6c5 100644 --- a/src/_ant.scss +++ b/src/_ant.scss @@ -466,7 +466,9 @@ } & > .ant-modal-confirm-content { - margin: 0; + margin: 0 0 0 38px; + font: 400 14px/22px Roboto; + color: get-color(text1); } } @@ -733,6 +735,10 @@ color: get-color(text4); } + &.title { + font: 500 16px/22px SourceHanSansSC; + } + &.card-title { font-size: 20px; line-height: 28px; diff --git a/src/apis/robot/type.ts b/src/apis/robot/type.ts index 96997cf..523a18b 100644 --- a/src/apis/robot/type.ts +++ b/src/apis/robot/type.ts @@ -1,6 +1,7 @@ import type { RobotBrand, RobotState, RobotType } from './constant'; export interface RobotGroup { + sid?: string; // 场景id id: string; // 机器人组id label: string; // 机器人组名称 robots?: Array; // 机器人列表 diff --git a/src/apis/scene/api.ts b/src/apis/scene/api.ts index 5f53ddf..7320581 100644 --- a/src/apis/scene/api.ts +++ b/src/apis/scene/api.ts @@ -1,3 +1,4 @@ +import type { RobotGroup } from '@api/robot'; import http from '@core/http'; import type { SceneDetail, SceneInfo } from './type'; @@ -5,6 +6,8 @@ import type { SceneDetail, SceneInfo } from './type'; const enum API { 获取场景 = '/scene/getById', 保存场景 = '/scene/saveById', + + 获取组场景 = '/scene/getByGroupId', } export async function getSceneById(id: SceneInfo['id']): Promise { @@ -34,3 +37,17 @@ export async function saveSceneById(id: SceneInfo['id'], json: string): Promise< return false; } } + +export async function getSceneByGroupId(id: RobotGroup['id'], sid: RobotGroup['sid']): Promise { + if (!id) return null; + type B = { id: string; sid?: string }; + type D = SceneDetail; + try { + const body = { id, sid }; + const data = await http.post(API.获取场景, body); + return data ?? null; + } catch (error) { + console.debug(error); + return null; + } +} diff --git a/src/assets/icons/_icon.scss b/src/assets/icons/_icon.scss index 1d28edc..ecb71af 100644 --- a/src/assets/icons/_icon.scss +++ b/src/assets/icons/_icon.scss @@ -16,6 +16,7 @@ $icons: ( detail, dot, dropdown, + edit_group, edit, exit, pen, diff --git a/src/assets/icons/dark/edit_group.png b/src/assets/icons/dark/edit_group.png new file mode 100644 index 0000000000000000000000000000000000000000..b7faea11e5e0c70cc9e29e6eff226fad9983568a GIT binary patch literal 663 zcmV;I0%-k-P)Px%QAtEWRA@u(m`ifnKoExi#juoYVW5+qYaxuk1ZTR>S>108VDeJ; z#_#YRCfkIl1mOPs+QoeCni#FlIEcijAd(-q4N(fv9u2MmJ~uXA9VF4(qn`NuZJI(j z^oyCh$#aQlN^cH&;^a!`ysH%8?bx3%L)+h<8nFp+;j;60@?3})1jth2`4BG*kPR_+ z{(J}HbVaqOwU1sBH$^UG0pKZw{H8tjLlX!~0F@!a*ek9R76Eb~Zv7Cna3><%&H6!a z2VH2bmae7P_N{*j!i7zMaM9}Ec&*|VCU+9CH#}6aU>P8az2InRNa_kz3RCO_%AFg4 z&D+wf#Pw4^W{L!w84^IX$I=z3h4<-&FgissVa0{2q`3rO)wi=^q5;Uu6vZ(>f{0a% ztQM1)dBYRsLZiVs5r24eFX{rE`=7#!0vXWt3*rrk2EcM5BLVPl{Z<0ll^CefHDvB- z0L;=Tl_;RAY6XCSoFaeJeX#ESe+D4?dVsHW4bs|A x_!0L5qY-|o0$PSx*xUeExb(GGHVW8Q-~rHX{6Ivo{H_21002ovPDHLkV1gnDD`x-z literal 0 HcmV?d00001 diff --git a/src/components/robot-group.vue b/src/components/robot-group.vue new file mode 100644 index 0000000..3c1d13d --- /dev/null +++ b/src/components/robot-group.vue @@ -0,0 +1,244 @@ + + + + + diff --git a/src/components/robot-groups.vue b/src/components/robot-groups.vue index ed5c0ea..b6811d6 100644 --- a/src/components/robot-groups.vue +++ b/src/components/robot-groups.vue @@ -9,9 +9,11 @@ import { watch } from 'vue'; import { reactive } from 'vue'; import { computed, inject, type InjectionKey, ref, type ShallowRef, shallowRef } from 'vue'; import { useI18n } from 'vue-i18n'; +import { useRouter } from 'vue-router'; type Props = { token: InjectionKey>; + sid: string; editable?: boolean; current?: string; }; @@ -24,6 +26,7 @@ type Events = { const emit = defineEmits(); const { t } = useI18n(); +const router = useRouter(); //#region 接口 const seizeRobots = async () => { @@ -87,6 +90,17 @@ const toDeleteGroup = (id: RobotGroup['id']) => okText: t('删除'), onOk: () => editor.value.deleteRobotGroup(id), }); + +const toEditGroup = (id: RobotGroup['id']) => + Modal.confirm({ + class: 'confirm', + title: t('您确定要编辑该机器人组吗?'), + content: t('请确保当前场景已经保存,否则将导致当前场景数据丢失。'), + centered: true, + cancelText: t('取消'), + okText: t('编辑'), + onOk: () => router.push({ name: '组编辑', params: { sid: props.sid, id } }), + }); //#endregion //#region 机器人操作 @@ -197,15 +211,20 @@ const toRemoveRobots = () => @@ -246,3 +265,14 @@ const toRemoveRobots = () => + + diff --git a/src/pages/group-editor.vue b/src/pages/group-editor.vue index 34f22af..505a6c9 100644 --- a/src/pages/group-editor.vue +++ b/src/pages/group-editor.vue @@ -1,10 +1,177 @@ - + + + diff --git a/src/pages/scene-editor.vue b/src/pages/scene-editor.vue index af81a31..dd331fb 100644 --- a/src/pages/scene-editor.vue +++ b/src/pages/scene-editor.vue @@ -107,6 +107,7 @@ const selectRobot = (id: string) => { { height: calc(100% - 96px); overflow: visible; } - -.ant-typography.title { - font: 500 16px/22px SourceHanSansSC; -} diff --git a/src/services/router.ts b/src/services/router.ts index f02f6d4..7b15f7c 100644 --- a/src/services/router.ts +++ b/src/services/router.ts @@ -9,12 +9,14 @@ export const ROUTES = Object.freeze([ }, { + name: '场景编辑', path: '/scene-editor/:id', props: true, component: () => import('@/scene-editor.vue'), }, { - path: '/group-editor/:id', + name: '组编辑', + path: '/group-editor/:sid/:id', props: true, component: () => import('@/group-editor.vue'), },