From 0c3b2b405b21dd3d572fedbee6f73afc396558ba Mon Sep 17 00:00:00 2001 From: chndfang Date: Fri, 2 May 2025 00:35:53 +0800 Subject: [PATCH] temp --- mocks/scene/getById | 57 +++++- package-lock.json | 1 + package.json | 1 + src/App.vue | 4 +- src/_ant.scss | 188 ++++++++++++++++++ src/_icon.scss | 19 ++ src/ant.scss | 84 -------- src/apis/robot/type.ts | 2 +- src/assets/icons/_icon.scss | 17 +- src/assets/icons/dark/dropdown.png | Bin 0 -> 317 bytes src/assets/icons/{ => dark}/edit.png | Bin .../icons/{upload.png => dark/exit.png} | Bin src/assets/themes/_dark.scss | 3 +- src/assets/themes/_light.scss | 2 +- src/assets/themes/_theme.scss | 14 +- src/components/robot-group.vue | 71 ++++--- src/components/test.vue | 65 ++++++ src/pages/scene-editor.vue | 13 +- src/services/editor.service.ts | 6 +- src/services/router.ts | 1 + src/style.scss | 20 +- 21 files changed, 413 insertions(+), 155 deletions(-) create mode 100644 src/_ant.scss create mode 100644 src/_icon.scss delete mode 100644 src/ant.scss create mode 100644 src/assets/icons/dark/dropdown.png rename src/assets/icons/{ => dark}/edit.png (100%) rename src/assets/icons/{upload.png => dark/exit.png} (100%) create mode 100644 src/components/test.vue diff --git a/mocks/scene/getById b/mocks/scene/getById index 0c3d458..f912358 100644 --- a/mocks/scene/getById +++ b/mocks/scene/getById @@ -4,7 +4,62 @@ "data": { "id": "mock-scene-1", "label": "模拟场景A", - "robotGroups": [], + "robotGroups": [ + { + "id": "mock-robot-group-1", + "label": "模拟机器人组A", + "robots": [ + { + "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-group-2", + "label": "模拟机器人组B", + "robots": [ + { + "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" + } + ] + } + ], "map": "" }, "message": "模拟提示" diff --git a/package-lock.json b/package-lock.json index 9c7435a..bb3cbce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "arm_system", "version": "0.0.0", "dependencies": { + "@ant-design/icons-vue": "^7.0.1", "@meta2d/core": "^1.0.78", "@vueuse/rxjs": "^13.1.0", "ant-design-vue": "^4.2.6", diff --git a/package.json b/package.json index 8ebb4a1..468c774 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "@ant-design/icons-vue": "^7.0.1", "@meta2d/core": "^1.0.78", "@vueuse/rxjs": "^13.1.0", "ant-design-vue": "^4.2.6", diff --git a/src/App.vue b/src/App.vue index 3af02f3..cb67900 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,8 @@ import sTheme from '@core/theme.service'; :autoInsertSpaceInButton="false" :wave="{ disabled: true }" > - + + + diff --git a/src/_ant.scss b/src/_ant.scss new file mode 100644 index 0000000..b12a982 --- /dev/null +++ b/src/_ant.scss @@ -0,0 +1,188 @@ +@use 'asset/themes/theme' as *; + +@include themed { + .ant-app { + width: 100vw; + height: 100vh; + overflow: hidden; + } + + .ant-btn { + display: inline-flex; + align-items: center; + font: 400 14px/22px Roboto; + border-radius: 2px; + + &.ant-btn-default { + color: get-color(primary); + background-color: get-color(141414); + border-color: get-color(primary); + box-shadow: 0 2px 0 0 get-color(00000005); + } + + &.ant-btn-primary { + font-weight: 500; + color: get-color(141414); + background-color: get-color(primary); + border-color: get-color(primary); + box-shadow: 0 2px 0 0 get-color(0000000a); + } + + &.warning { + font-weight: 500; + color: get-color(141414); + background-color: get-color(warning); + border-color: get-color(warning); + box-shadow: 0 2px 0 0 get-color(0000000a); + } + } + + .ant-collapse.ant-collapse-ghost { + border-radius: 0; + + & > .ant-collapse-item { + & > .ant-collapse-header { + align-items: center; + height: 36px; + padding: 0 0 0 8px; + font: 500 14px/22px Roboto; + color: get-color(ffffffd9); + background: get-color(ffffff14); + border-radius: 2px; + + & > .ant-collapse-expand-icon { + width: 24px; + height: 24px; + padding: 0; + + & > .ant-collapse-arrow { + font-size: 24px; + + &.active { + transform: rotate(180deg); + } + } + } + } + + & > .ant-collapse-content { + & > .ant-collapse-content-box { + padding: 0; + } + } + + & + .ant-collapse-item { + margin-block-start: 8px; + } + } + } + + .ant-input { + color: get-color(ffffffd9); + background-color: transparent; + + &::placeholder { + color: get-color(ffffff40); + } + } + + .ant-input-affix-wrapper { + box-shadow: none; + + &::before { + display: none; + } + + & > .ant-input-suffix { + margin-inline-start: 12px; + font-size: 16px; + color: get-color(ffffffd9); + } + + &.search { + padding-inline-start: 7px; + background-color: transparent; + border-color: get-color(595959); + border-radius: 4px; + } + } + + .ant-layout { + background-color: get-color(2a2c2c); + + & > .ant-layout-header { + line-height: unset; + background-color: get-color(242525); + box-shadow: 0 2px 8px 0 get-color(00000026); + } + + & > .ant-layout-sider { + background-color: get-color(36393a); + border-radius: 8px; + box-shadow: 0 2px 8px 0 get-color(ffffff14); + } + } + + .ant-list-items { + & > .ant-list-item { + padding: 0; + border-color: get-color(f9f9f914); + + &:hover { + background-color: get-color(f9f9f914); + } + } + } + + .ant-tabs { + border-radius: 8px; + + & > .ant-tabs-nav { + margin: 0; + background-color: get-color(ffffff2e); + + & > .ant-tabs-nav-wrap > .ant-tabs-nav-list { + & > .ant-tabs-tab { + padding: 14px 32px; + margin: 0; + font: 400 16px/20px Roboto; + color: get-color(ffffff73); + background-color: transparent; + border: none; + border-radius: 0; + + & > .ant-tabs-tab-btn { + color: inherit; + text-shadow: none; + } + + &.ant-tabs-tab-active { + font-weight: 600; + color: get-color(primary); + background-color: get-color(36393a); + } + } + + & > .ant-tabs-ink-bar { + display: none; + } + } + } + + & > .ant-tabs-content-holder > .ant-tabs-content { + height: 100%; + padding: 16px; + overflow-y: auto; + } + } + + .ant-typography { + font: 400 14px/22px Roboto; + color: get-color(ffffffa6); + + & > strong { + font: 500 16px/22px SourceHanSansSC; + color: get-color(ffffffd9); + } + } +} diff --git a/src/_icon.scss b/src/_icon.scss new file mode 100644 index 0000000..79604ca --- /dev/null +++ b/src/_icon.scss @@ -0,0 +1,19 @@ +@use 'asset/themes/theme' as *; +@use 'asset/icons/icon' as *; + +@include themed { + .icon { + display: inline-block; + width: 1em; + height: 1em; + font-size: 18px; + line-height: 1; + vertical-align: top; + + @each $icon in $icons { + &.#{$icon} { + background: get-icon($icon); + } + } + } +} diff --git a/src/ant.scss b/src/ant.scss deleted file mode 100644 index 4c43d0a..0000000 --- a/src/ant.scss +++ /dev/null @@ -1,84 +0,0 @@ -@use 'asset/themes/theme' as *; - -@include themed { - .ant-btn { - display: inline-flex; - align-items: center; - font: 400 14px/22px Roboto; - border-radius: 2px; - - &.ant-btn-default { - color: get-color(primary); - background-color: get-color(141414); - border-color: get-color(primary); - box-shadow: 0 2px 0 0 get-color(00000005); - } - - &.ant-btn-primary { - font-weight: 500; - color: get-color(141414); - background-color: get-color(primary); - border-color: get-color(primary); - box-shadow: 0 2px 0 0 get-color(0000000a); - } - } - - .ant-layout { - background-color: get-color(2a2c2c); - - & > .ant-layout-header { - line-height: unset; - background-color: get-color(242525); - box-shadow: 0 2px 8px 0 get-color(00000026); - } - - & > .ant-layout-sider { - background-color: get-color(36393a); - border-radius: 8px; - box-shadow: 0 2px 8px 0 get-color(ffffff14); - } - } - - .ant-tabs { - border-radius: 8px; - - & > .ant-tabs-nav { - margin: 0; - background-color: get-color(ffffff2e); - - & > .ant-tabs-nav-wrap > .ant-tabs-nav-list { - & > .ant-tabs-tab { - padding: 14px 32px; - margin: 0; - font: 400 16px/20px Roboto; - color: get-color(ffffff73); - background-color: transparent; - border: none; - border-radius: 0; - - & > .ant-tabs-tab-btn { - color: inherit; - text-shadow: none; - } - - &.ant-tabs-tab-active { - font-weight: 600; - color: get-color(primary); - background-color: get-color(36393a); - } - } - - & > .ant-tabs-ink-bar { - display: none; - } - } - } - } - - .ant-typography { - & > strong { - font: 500 16px/22px SourceHanSansSC; - color: get-color(ffffffd9); - } - } -} diff --git a/src/apis/robot/type.ts b/src/apis/robot/type.ts index b83234c..73f1c5a 100644 --- a/src/apis/robot/type.ts +++ b/src/apis/robot/type.ts @@ -3,7 +3,7 @@ import type { RobotBrand, RobotState, RobotType } from './constant'; export interface RobotGroup { id: string; // 机器人组id label: string; // 机器人组名称 - robotIds: number[]; // 机器人id列表 + robots: RobotInfo[]; // 机器人列表 } export interface RobotInfo { diff --git a/src/assets/icons/_icon.scss b/src/assets/icons/_icon.scss index 414c998..26f002b 100644 --- a/src/assets/icons/_icon.scss +++ b/src/assets/icons/_icon.scss @@ -1,16 +1 @@ -$icons: (edit upload); - -.icon { - display: inline; - width: 1em; - height: 1em; - font-size: 18px; - line-height: 1; - vertical-align: top; - - @each $icon in $icons { - &.#{$icon} { - background: url(./#{$icon}.png) center / contain no-repeat; - } - } -} +$icons: (dropdown, edit, exit); diff --git a/src/assets/icons/dark/dropdown.png b/src/assets/icons/dark/dropdown.png new file mode 100644 index 0000000000000000000000000000000000000000..b1203d9558eb601349c5b421eaea0e4243b32f82 GIT binary patch literal 317 zcmV-D0mA-?P)Px#_en%SRA@u(l)(+cPz*!kIT(O>U=ElD=74z^fH{JSdfP4t+-noZ&#sDC z`Gb}F4+H$VK{wzA$OQZekpa@{Zh(%E6mSD%fb_Z>pd%y&+yEIMz3v9+2uXqeZXh%F z5wRgdyaTw5YETVi=56%w>mGpZs16Hoh=}9p@p +import type { RobotGroup, RobotInfo } from '@api/robot'; import type { EditorService } from '@core/editor.service'; -import { isEmpty } from 'lodash-es'; -import { inject, type InjectionKey, ref, type ShallowRef, watch } from 'vue'; - -const enum Mode { - 常规, - 添加点位 = 0x10, - 添加库区 = 0x31, - 添加互斥区, - 添加非互斥区, -} +import { chain } from 'lodash-es'; +import { computed, inject, type InjectionKey, ref, type ShallowRef } from 'vue'; type Props = { editor: InjectionKey>; editable?: boolean; + groups?: RobotGroup[]; }; const props = defineProps(); const editor = inject(props.editor)!; -const mode = ref(Mode.常规); -watch(editor.value.mouseClick, (v) => { - if (mode.value !== Mode.添加点位) return; - if (isEmpty(v)) return; - editor.value.addPoint(v, 1); - editor.value.addPoint(v, 11); -}); -watch(editor.value.mouseBrush, (v) => { - if (![Mode.添加库区, Mode.添加互斥区, Mode.添加非互斥区].includes(mode.value)) return; - const [p1, p2] = v ?? []; - if (isEmpty(p1) || isEmpty(p2)) return; - editor.value.addArea(p1, p2, mode.value & 0xf); - mode.value = Mode.常规; -}); +const keyword = ref(''); + +//#region 机器人列表 +// const groups = computed(() => chain(props.groups).filter().value()) +const robots = computed(() => chain(props.groups).map('robots').flatten().value()); + +const selected = ref([]); +const isAllSelected = computed(() => robots.value.every(({ id }) => selected.value.includes(id))); +//#endregion diff --git a/src/components/test.vue b/src/components/test.vue new file mode 100644 index 0000000..f44835c --- /dev/null +++ b/src/components/test.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/pages/scene-editor.vue b/src/pages/scene-editor.vue index 8530b21..e3d4820 100644 --- a/src/pages/scene-editor.vue +++ b/src/pages/scene-editor.vue @@ -35,6 +35,9 @@ onMounted(() => { }); const editable = ref(false); +watch(editable, (v) => { + editor.value?.setState(v); +});