|
@@ -2,6 +2,8 @@ import { computed, reactive, ref, Ref, watchEffect } from "vue";
|
|
|
import { PropertyDescribes } from "../html-mount/propertys";
|
|
|
import { installGlobalVar } from "./use-global-vars";
|
|
|
import { inRevise, mergeFuns } from "@/utils/shared";
|
|
|
+import { useStore } from "../store";
|
|
|
+import { ShapeType } from "../components";
|
|
|
|
|
|
export const useGlobalDescribes = installGlobalVar(() => {
|
|
|
const shapesDescribes: Record<string, PropertyDescribes> = reactive({});
|
|
@@ -37,21 +39,32 @@ export const useGlobalDescribes = installGlobalVar(() => {
|
|
|
|
|
|
export const useComponentsDescribes = (ids: Ref<string[]>) => {
|
|
|
const gdesc = useGlobalDescribes();
|
|
|
+ const store = useStore()
|
|
|
const excludeKeys = ["length", "name"];
|
|
|
const groups = computed(() => {
|
|
|
- return ids.value.map((id) => gdesc.get(id)).filter((item) => !!item);
|
|
|
+ return ids.value.map((id) => gdesc.get(id)).filter((item) => !!item).map(item => ({...item, type: store.getType(item.data.id)}));
|
|
|
});
|
|
|
+ const similars = [
|
|
|
+ ['rectangle', 'circle', 'triangle', 'polygon']
|
|
|
+ ] as ShapeType[][]
|
|
|
+
|
|
|
const shareDescribes = computed(() => {
|
|
|
if (groups.value.length === 0) {
|
|
|
return {};
|
|
|
}
|
|
|
+ const types = [...new Set(groups.value.map(item => item.type))] as ShapeType[]
|
|
|
+ if (types.length > 1) {
|
|
|
+ if (!similars.some(similar => types.every(t => similar.includes(t)))) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
const shareDescribes: Record<
|
|
|
string,
|
|
|
{ desc: PropertyDescribes[string][]; data: { id: string }[] }
|
|
|
> = {};
|
|
|
const shareKeys: string[] = Object.keys(groups.value[0].desc);
|
|
|
-
|
|
|
for (const item of groups.value) {
|
|
|
const keys = Object.keys(item.desc);
|
|
|
for (const key of keys) {
|