This commit is contained in:
chndfang 2025-05-13 22:37:34 +08:00
parent 7ba4691787
commit 6319afa218
4 changed files with 20 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import { MapAreaType } from '@api/map';
import { saveSceneByGroupId, saveSceneById } from '@api/scene';
import type { EditorService } from '@core/editor.service';
import { isEmpty } from 'lodash-es';
import { computed } from 'vue';
import { inject, type InjectionKey, ref, type ShallowRef, watch } from 'vue';
type Props = {
@ -34,6 +35,8 @@ watch(editor.value.mouseBrush, (v) => {
editor.value.addArea(p1, p2, mode.value);
mode.value = undefined;
});
const canDelete = computed<boolean>(() => editor.value.current.value?.name === 'area');
</script>
<template>
@ -77,8 +80,8 @@ watch(editor.value.mouseBrush, (v) => {
<a-button
class="icon-btn tool-btn ml-12"
size="large"
@click="editor.delete(undefined, true)"
:disabled="!editor.selected.value.length"
@click="editor.deleteById(editor.current.value?.id)"
:disabled="!canDelete"
>
<i class="mask trash" />
</a-button>

View File

@ -189,6 +189,14 @@ export class EditorService extends Meta2d {
this.render();
}
public deleteById(id?: string): void {
const pen = this.getPenById(id);
console.log(pen);
if (pen?.name !== 'area') return;
this.delete([pen], true, true);
}
public updatePen(id: string, pen: Partial<MapPen>, record = true): void {
this.setValue({ ...pen, id }, { render: true, history: record, doEvent: true });
}

View File

@ -24,7 +24,11 @@ http.interceptors.response.use(
message.error(hint);
return Promise.reject(hint);
},
(error) => Promise.reject(error.message),
(error) => {
const hint = error.response.data?.message || error.message;
message.error(hint ?? '未知异常');
return Promise.reject(hint);
},
);
type HttpInstance = Omit<AxiosInstance, 'get' | 'post'> & {

View File

@ -43,8 +43,8 @@ export default ({ mode }: Record<string, unknown>) =>
port: 8888,
host: true,
proxy: {
// '/api/': {
// target: 'http://82.157.33.186:26981/jeecg-boot',
// '/mocks/': {
// target: 'http://82.156.39.91:18085/jeecg-boot',
// rewrite: (path) => path.replace(/^\/api/, ''),
// changeOrigin: true,
// },