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

View File

@ -189,6 +189,14 @@ export class EditorService extends Meta2d {
this.render(); 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 { public updatePen(id: string, pen: Partial<MapPen>, record = true): void {
this.setValue({ ...pen, id }, { render: true, history: record, doEvent: true }); this.setValue({ ...pen, id }, { render: true, history: record, doEvent: true });
} }

View File

@ -24,7 +24,11 @@ http.interceptors.response.use(
message.error(hint); message.error(hint);
return Promise.reject(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'> & { type HttpInstance = Omit<AxiosInstance, 'get' | 'post'> & {

View File

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