From 7ebf69cc2f829b2768a89cec621cc24a25726d6b Mon Sep 17 00:00:00 2001 From: chndfang Date: Mon, 28 Apr 2025 00:43:33 +0800 Subject: [PATCH] temp --- public/point/1.png | Bin 902 -> 0 bytes public/point/11-dark.png | Bin 0 -> 1246 bytes public/point/12-dark.png | Bin 0 -> 1158 bytes public/point/13-dark.png | Bin 0 -> 1464 bytes public/point/14-dark.png | Bin 0 -> 1563 bytes public/point/15-dark.png | Bin 0 -> 2020 bytes src/apis/map/constant.ts | 1 + src/apis/map/type.ts | 1 + src/assets/themes/editor-dark.json | 17 ++++++++ src/assets/themes/editor-light.json | 1 + src/assets/themes/editor.json | 12 ------ src/components/robot-list.vue | 2 +- src/pages/scene-editor.vue | 2 +- src/services/editor.service.ts | 59 ++++++++++++++++++++++------ src/services/locale.service.ts | 7 ++-- src/services/theme.service.ts | 11 ++++++ 16 files changed, 84 insertions(+), 29 deletions(-) delete mode 100644 public/point/1.png create mode 100644 public/point/11-dark.png create mode 100644 public/point/12-dark.png create mode 100644 public/point/13-dark.png create mode 100644 public/point/14-dark.png create mode 100644 public/point/15-dark.png create mode 100644 src/assets/themes/editor-dark.json create mode 100644 src/assets/themes/editor-light.json delete mode 100644 src/assets/themes/editor.json diff --git a/public/point/1.png b/public/point/1.png deleted file mode 100644 index f24f2f07d4b398feef97504b7f4023849bba6a0a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 902 zcmV;119|+3P)Px&KuJVFRA@u(na^tzK@@=BOuK2JjYLJgg<3(c4fI&Sfd7CVy?FIzOOuwKx}FM6 zOYFt7C(r%?LIr!X(0UbWZM{fA8%zVuZZacJvLU3OENqAeQ$ofnJ^gf z!bY4Qt_1#f4;t%%jg5^N%d+OAlr{XUtgIZGkR=tcZ9A9EW?urpqLeb%3(Oe%4ghaC z=Q~SFOEoGPG69TuCX?BfQqDxdp@`!+#kI9H6w)pv0-Kwgb7Ny;2=9w}1YJ!CQKT4F z+5#&0%W(!jZcM<0E8uqBg~^r-`jALy38>&d=cizAb{d)%??NwpyMTqGI=Mt@0Tuk- zz3e~uuwp_Yl|UMJPl#F~v49S|35i4k6!6p%0}D{XQ%VdZU;>^>B38g8JcUH0z%bx- zC6of4+~y#d9z?D4x`~ZyiFIAKpvs*>1v*(J!ut|4lkibJfe9ezybzYfh6-$NZ?8)! z?cRtE13pSZO8Kf>F8i3UzDnS@H~Pbb_aq*F{R8tSjouj6N~O~E;4tkIz=_K_KkzCx z$2nAscXWq$;^!w@0$zMN3udu1rBdm{cTftpT&YwZF~)Yi?@zC1;NASq!~hfzJpJ+; z?w>WgO|{$YC#$Qg??*=9+5RucpF3S%DP^%-E`N*^=p4q6dxy}QgH{K5QX3=E_4!aZEc+cK=*jKpPzyc53UXJPO>_9_`!X_E4Y*{FE8JXoy1t7QmNRC zv31`vIy()x8V#ca;qje`meFdpniE3wZ)8J|2!qGy*X#9yZQFg;6!102agwDH-Z1Ix3Am&hmr%jC+wI8fmx0o0&bd*EwD8JQA~;b^_Jj`nzyes& zgoG}9A^~a%3i!kVR1#G1sRVQ-DB)8Jq?MqC*Ahq~G0_t6@aO{OPkjdzV2st`*7>;9 zC3YW(Ye2O+;r04i)`H7%4*BzD-}O2Lymk-7?bs@LDtIyhY-ptaV)7!5S!}D-TI8HR z4_?V&)P)c`jYi{jSXLP~RF%D%_QAO4aBeWha`EEveOh-7b c{gLm1zbj>9Ph2-K&j0`b07*qoM6N<$g7^Wa(EtDd diff --git a/public/point/11-dark.png b/public/point/11-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..9a57193b00ffd632f1f3520d161871d9f7c7e74a GIT binary patch literal 1246 zcmeAS@N?(olHy`uVBq!ia0vp^i9lSz!3HEB-JkOTNHG=%xjQkeJ16s!fq`X)r;B4q zMcmuDv3??s0>@X^9PgJt!TW`6lE(QWrUxueNfoSd7hUoc<~Yoo3Z%>v@*k*GHxzL% zPn|J0b$NDHThX)oo&Gu3ul%Wx{Tq1suF*o9T}*#o$Q@v0YGLSQ5M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2lfW$g3EP)8SK%eJ= zP8xE9>azHDswU*lM?NkCVd!fuNQf#g^EU(oo8HKy@(qDT1G$t7HAX-sjgVrEf{_lz t5P%v**^h7;WMG{ValaSn@Akjb8@6n~rQl^_HEZjNVUG5$BmvQ%`wwh+n7#l2 literal 0 HcmV?d00001 diff --git a/public/point/14-dark.png b/public/point/14-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..ecccb5410d52bb688384509b35717df1aa406fb2 GIT binary patch literal 1563 zcmbW1`#+Nl0LI_VEALk09rjU_HgVJ@QEnOa8Y0V*R=MO78OL%tjQP|~&AhHrE43Kq z7DY&*6Uv=VNOC!DEte=nIw2~jj(_2tAD-v?%lGsA_#`^9>q0QtUyHdgE?&$&#ms{|(8y634%@#sTrF+jX=B2q{) zAo_TwoCt2-LaWC|9RTU|_+(OAf-5p}*?c_U_s-0=&f>N`sY|c9`EXrQmu)*DR~Zq-3ttxbS?J4N4f0>sDzVI5 z^rRSGQQ;XHWqWLSu>{uZV?VkMUu$$d&V(d^)L{q6VNCCy4#+gV9;5^2hf4aC zMfuXUN6I2+v-Ut-gR`TbJI-oHre7uMU0Cq21kG0MeCYNc=Yt3!v5H~SpE$LfI5uMT z!F(T2fS{>8i|Glqgu0)9cC7HHl+{HE$l`EJ*>cj9x*=wA8`1JIURxX0`tkPj1Q+!> zrcerO=#hIGF1JCx;mGO(R_HSVr*-6`4hVi-I-qoGH9mzjsGFoRqN4l;o%H$ zV9fM{J3V(Vx_cdf%7-X@Zivh^e4yl{?41Z?($) zUATG;>GzVt9#E7(#wZYrl1Sjmiex(%O4BCe78#+0>}^o`QCW|o$5y*C%Htq}6WT*Xw8XYxv zRA@BmVmv63R}Ina{ZjK6tKMkoe#*9%*(v{%nirpC&AEwB z_QmCnRH9{J!Mn8X$IJQf1LrL%sx1zR0kY%|>sg~EZRe?X?o6XYx{Fx0IS!Y_#M*d9;J}6wS|B#(vDI})0=8l2x#}pYhriv$ zi`T;U_XR`PQ@e34K_84sQlzVz0)YLPszMb!I`e=6pwB(_GS!SUR3z2;Md{A|P%v%6 zu$dz}@|)c88jY2*D#dZ(*e%c9^bUtYo_#VwT@&k=&l_+$dGjIloY0`y$m)+U7%B7)rMEd2%uN zu+Edj&l7wPLoSjmB>zNPH1{>c)g8_9ikVt*f)t}C-}k>uI4_-v+pNM;0bX+%5Mn{m zMgcqsQErN1>~@%p@)!xg|YI2=WY#W3u3|G$7CuL3pfnS^fzy8GAO9yn;rvMFVF Gi~a>Ub*>)( literal 0 HcmV?d00001 diff --git a/public/point/15-dark.png b/public/point/15-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..b0fd7ac9f01d50b1f615cdc9816a722fdcf22a25 GIT binary patch literal 2020 zcma)-Z9LNp8^`~f(Vvr9C_AItcHcs+aG0kQwt47;v4klh$Hc-s6hqO-Lk?E5$vlLP z&LU6SolZluMDk3YrbM!$ghJ%Bj@S2_`+jj;wITgfq!ok!f6g<|&{9Xui}Y%=AUvXd+D z7vws+uT%L(5#UMKEbO7%p0$K@Dkpnokiu=l+0BrwHQ=e-h3PS~u!nnOcF*D+pKG3l z^{s$Au!u;1bqiR!Q8HAaV5(#aq2%TdXuQ&{aFcH z-1Z8@nL)Pj1Y;-V>!vU(HBzZ6Bm3gMHpUK#Ua*&6(vSA={{Fk?m**zD_GUY2o*?Ib;~TvtCe zwbns#Zb0>+u7M78(JbByb{wzW5d~&Ts28I_PN-SVECO{^@KJ`q4WHNP!kDTAkN04_ z?~PkkQ)- z!_0?^U*Q3JB=+ERY}KtZthWdmrYXz#C@wR2wV9}Ii^jr2ZJ8mu@keurV~{KIq|R9) z2ua%8j(oieOe3C`B%7`%CJ?#0&oMVKF<;Xvu8Os5O9|ox8brIQYmh=9g_PFqEXe$` z%3Q}J^$SAMh_kk}HoQNlqag1cIExSGgY%%zcVP{B(BaaI)<^gV(h+pH+GsC>Do)mw6>BY%D2@5z@MzW`&h3K{FgryI@0nm*=HI0pY124Fas zA3)y4yHRw%sNnLRHm)#3>_`5va_m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;?S`$c|`G!R-PF4*(REj9QPhVz%EF1N$E8S)@WVkz&}_|D*dDpn|?pvhpY8 d|1$Y|+smOnmETk%LbhrfIA-rksv-EZ{sH78rm+A3 literal 0 HcmV?d00001 diff --git a/src/apis/map/constant.ts b/src/apis/map/constant.ts index d8ba68d..c973444 100644 --- a/src/apis/map/constant.ts +++ b/src/apis/map/constant.ts @@ -56,6 +56,7 @@ export const EDITOR_CONFIG: Options = { maxScale: 2.01, scaleOff: 0.01, defaultAnchors: [], + activeGlobalAlpha: 0, fontSize: 14, lineHeight: 1.5, textAlign: 'center', diff --git a/src/apis/map/type.ts b/src/apis/map/type.ts index 28edb7e..bbaa0f9 100644 --- a/src/apis/map/type.ts +++ b/src/apis/map/type.ts @@ -4,6 +4,7 @@ import type { Pen } from '@meta2d/core'; import type { MapAreaType, MapPointType, MapRouteType } from './constant'; export interface MapPen extends Pen { + label?: string; // 展示名称 desc?: string; // 描述 point?: MapPointInfo; // 点位信息 diff --git a/src/assets/themes/editor-dark.json b/src/assets/themes/editor-dark.json new file mode 100644 index 0000000..89ecdbf --- /dev/null +++ b/src/assets/themes/editor-dark.json @@ -0,0 +1,17 @@ +{ + "color": "#BFBFBF", + "background": "#D9D9D9", + "point-s": { + "stroke": "#8C8C8C", + "strokeActive": "#FCC947", + "fill-1": "#14D1A5", + "fill-2": "#69C6F5", + "fill-3": "#E48B1D" + }, + "point-l": { + "stroke": "#595959", + "strokeActive": "#FCC947", + "fill": "#1F1F1F" + }, + "line": "#8C8C8C" +} \ No newline at end of file diff --git a/src/assets/themes/editor-light.json b/src/assets/themes/editor-light.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/assets/themes/editor-light.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/assets/themes/editor.json b/src/assets/themes/editor.json deleted file mode 100644 index bb7053a..0000000 --- a/src/assets/themes/editor.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "light": { - "background": "", - "color": "#000000" - }, - "dark": { - "background": "", - "color": "#8C8C8C", - "activeColor": "#FCC947", - "textColor": "#BFBFBF" - } -} \ No newline at end of file diff --git a/src/components/robot-list.vue b/src/components/robot-list.vue index fed9789..3db3b5f 100644 --- a/src/components/robot-list.vue +++ b/src/components/robot-list.vue @@ -21,7 +21,7 @@ const mode = ref(Mode.常规); watch(editor.value.mouseClick, (v) => { if (mode.value !== Mode.添加点位) return; if (isEmpty(v)) return; - editor.value.addPoint(v); + editor.value.addPoint(v, 11); }); watch(editor.value.mouseBrush, (v) => { if (![Mode.添加库区, Mode.添加互斥区, Mode.添加非互斥区].includes(mode.value)) return; diff --git a/src/pages/scene-editor.vue b/src/pages/scene-editor.vue index fb9036d..94d9476 100644 --- a/src/pages/scene-editor.vue +++ b/src/pages/scene-editor.vue @@ -28,7 +28,7 @@ onMounted(() => {
- sider + {{ $t('查询') }} diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index 5da0dbb..06efffe 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -2,8 +2,7 @@ import { EDITOR_CONFIG, MapAreaType, type MapPen, MapPointType } from '@api/map' import sTheme from '@core/theme.service'; import { EditType, LockState, Meta2d } from '@meta2d/core'; import { useObservable } from '@vueuse/rxjs'; -import THEME from 'asset/themes/editor.json'; -import { cloneDeep, pick } from 'lodash-es'; +import { cloneDeep, get, pick } from 'lodash-es'; import { debounceTime, filter, map, Subject, switchMap } from 'rxjs'; import { watch } from 'vue'; @@ -48,16 +47,27 @@ export class EditorService extends Meta2d { //#region 点位 public async addPoint(p: Point, type = MapPointType.普通点): Promise { const pen: MapPen = { + ...p, + ...this.#mapPoint(type), name: 'point', - x: p.x, - y: p.y, - width: 24, - height: 24, + text: 'POINT', point: { type }, }; + const { x, y, width, height } = this.getPenRect(pen); + pen.x = x - width / 2; + pen.y = y - height / 2; await this.addPen(pen, false, true, true); this.pushHistory({ type: EditType.Add, pens: [cloneDeep(pen)] }); } + + #mapPoint(type: MapPointType): Required> { + const theme = this.data().theme; + const width = type < 10 ? 24 : 48; + const height = type < 10 ? 24 : 60; + const lineWidth = type < 10 ? 2 : 3; + const image = type < 10 ? '' : `/point/${type}-${theme}.png`; + return { width, height, lineWidth, image }; + } //#endregion //#region 线路 @@ -114,7 +124,6 @@ export class EditorService extends Meta2d { } #register() { - this.store.theme = THEME; this.registerCanvasDraw({ point: drawPoint, line: drawLine, area: drawArea }); this.registerAnchors({ point: anchorPoint }); } @@ -122,14 +131,40 @@ export class EditorService extends Meta2d { //#region 绘制函数 function drawPoint(ctx: CanvasRenderingContext2D, pen: MapPen): void { + const theme = sTheme.editor; + const active = pen.calculative?.active; const { x = 0, y = 0, width = 0, height = 0 } = pen.calculative?.worldRect ?? {}; const { type } = pen.point ?? {}; + const { label = '' } = pen ?? {}; + ctx.save(); - ctx.lineWidth = 2; - ctx.roundRect(x, y, width, height, 4); - ctx.stroke(); - ctx.fillStyle = '#fff'; - ctx.fillText(String(type), x + width / 2, y + height / 2); + switch (type) { + case MapPointType.普通点: + case MapPointType.等待点: + case MapPointType.避让点: + case MapPointType.临时避让点: + ctx.lineWidth = 2; + break; + case MapPointType.电梯点: + case MapPointType.自动门点: + case MapPointType.充电点: + case MapPointType.停靠点: + case MapPointType.动作点: + ctx.rect(x, y, width, height); + // ctx.fillStyle = get(theme, 'point-l.fill') ?? ''; + // ctx.fill(); + ctx.strokeStyle = get(theme, active ? 'point-l.strokeActive' : 'point-l.stroke') ?? ''; + ctx.stroke(); + break; + + default: + break; + } + ctx.fillStyle = get(theme, 'color') ?? ''; + ctx.font = '14px/20px system-ui'; + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + ctx.fillText(label, x + width / 2, y - 10); ctx.restore(); } function anchorPoint(pen: MapPen): void { diff --git a/src/services/locale.service.ts b/src/services/locale.service.ts index 69dca1f..c67ba17 100644 --- a/src/services/locale.service.ts +++ b/src/services/locale.service.ts @@ -22,8 +22,9 @@ enum Locale { export const LOCALES = Object.freeze<[string, Locale][]>(Object.entries(Locale)); export const i18n = createI18n({ - legacy: true, - silentTranslationWarn: true, + legacy: false, + missingWarn: false, + fallbackWarn: false, locale: Locale.简体中文, messages: chain(Locale) .invert() @@ -58,7 +59,7 @@ class LocaleService { } #load(locale: Locale): void { - i18n.global.locale = locale; + i18n.global.locale.value = locale; switch (locale) { case Locale.English: dayjs.locale('en'); diff --git a/src/services/theme.service.ts b/src/services/theme.service.ts index 2327dbc..6382936 100644 --- a/src/services/theme.service.ts +++ b/src/services/theme.service.ts @@ -1,6 +1,13 @@ import { theme, type TokenType as AntdTheme } from 'ant-design-vue'; +import { chain } from 'lodash-es'; import { ref, watch } from 'vue'; +const THEME_FILES = import.meta.glob('asset/themes/*.json', { eager: true, import: 'default' }); +const THEME_MAP = chain(THEME_FILES) + .mapKeys((_, k) => k.match(/^.*[\\|\\/](.+?)\.[^\\.]+$/)?.[1]) + .mapValues((v) => >v) + .value(); + enum Theme { Light = 'light', Dark = 'dark', @@ -29,6 +36,10 @@ class ThemeService { } } + public get editor(): object { + return THEME_MAP[`editor-${this.#theme.value}`] ?? {}; + } + constructor() { watch(this.#theme, (v) => this.#load(v), { immediate: true }); }