|
@@ -11,6 +11,7 @@ import { ElMessage } from "element-plus";
|
|
|
import { ImageData } from "@/core/components/image";
|
|
|
import { Size } from "@/utils/math";
|
|
|
import { watchEffect } from "vue";
|
|
|
+import { getSvgContent, parseSvgContent } from "@/utils/resource";
|
|
|
|
|
|
const scaleResource = (info: AIExposeData, scale: number) => {
|
|
|
const floors = info.floors.map((item) => ({
|
|
@@ -220,7 +221,7 @@ const drawLayerResource = async (
|
|
|
lock: import.meta.env.DEV ? false : true,
|
|
|
height,
|
|
|
cornerRadius: 0,
|
|
|
- zIndex: -1
|
|
|
+ zIndex: -1,
|
|
|
};
|
|
|
images.push(thumb);
|
|
|
}
|
|
@@ -253,7 +254,7 @@ const drawLayerResource = async (
|
|
|
});
|
|
|
});
|
|
|
} else if (sGeo) {
|
|
|
- sGeo.itemName = "1";
|
|
|
+ sGeo.itemName = "1";
|
|
|
} else {
|
|
|
geo.itemName = "1";
|
|
|
}
|
|
@@ -263,44 +264,57 @@ const drawLayerResource = async (
|
|
|
});
|
|
|
|
|
|
if (sGeo) {
|
|
|
- sGeo.points = sGeo.points.concat(geo.points)
|
|
|
- sGeo.lines = sGeo.lines.concat(geo.lines)
|
|
|
- sGeo.polygon = sGeo.polygon.concat(geo.polygon)
|
|
|
- geo = sGeo
|
|
|
+ sGeo.points = sGeo.points.concat(geo.points);
|
|
|
+ sGeo.lines = sGeo.lines.concat(geo.lines);
|
|
|
+ sGeo.polygon = sGeo.polygon.concat(geo.polygon);
|
|
|
+ geo = sGeo;
|
|
|
draw.store.setItem("line", { id: geo.id, value: geo });
|
|
|
} else {
|
|
|
draw.store.addItem("line", geo);
|
|
|
}
|
|
|
if (thumb!) {
|
|
|
- thumb.mat[4] = offset.x
|
|
|
- thumb.mat[5] = offset.y
|
|
|
+ thumb.mat[4] = offset.x;
|
|
|
+ thumb.mat[5] = offset.y;
|
|
|
}
|
|
|
- images.push(
|
|
|
- ...layerResource.taggings.map((item, ndx) => {
|
|
|
- bound.update(item.position);
|
|
|
- const tf = new Transform().translate(
|
|
|
- item.position.x + offset.x,
|
|
|
- item.position.y + offset.y
|
|
|
- );
|
|
|
- if (item.rotate) {
|
|
|
- tf.rotate(item.rotate);
|
|
|
- }
|
|
|
- return {
|
|
|
- ...getBaseItem(),
|
|
|
+ for (let ndx = 0; ndx < layerResource.taggings.length; ndx++) {
|
|
|
+ const item = layerResource.taggings[ndx];
|
|
|
+ bound.update(item.position);
|
|
|
+ const tf = new Transform().translate(
|
|
|
+ item.position.x + offset.x,
|
|
|
+ item.position.y + offset.y
|
|
|
+ );
|
|
|
+ if (item.rotate) {
|
|
|
+ tf.rotate(item.rotate);
|
|
|
+ }
|
|
|
+ let svgAttach: any = {}
|
|
|
+ if (item.url.includes(".svg")) {
|
|
|
+ svgAttach = {
|
|
|
...iconDefaultStyle,
|
|
|
- name: item.name,
|
|
|
- stroke: item.url.includes(".svg") ? "#000000" : undefined,
|
|
|
- fill: null,
|
|
|
- createTime: createTime + layerResource.geos.length + ndx,
|
|
|
- url: item.url,
|
|
|
- lock: import.meta.env.DEV ? false : true,
|
|
|
- mat: tf.m,
|
|
|
- width: item.size ? item.size.width : 100,
|
|
|
- height: item.size ? item.size.height : 100,
|
|
|
- cornerRadius: 0,
|
|
|
- };
|
|
|
- })
|
|
|
- );
|
|
|
+ stroke: "#000000" ,
|
|
|
+ fill: null
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const svg = parseSvgContent(await getSvgContent(item.url))
|
|
|
+ if (svg.paths.length) {
|
|
|
+ svgAttach.fill = svg.paths[0].fill || null
|
|
|
+ svgAttach.stroke = svg.paths[0].stroke || null
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
+
|
|
|
+ images.push({
|
|
|
+ ...getBaseItem(),
|
|
|
+ ...svgAttach,
|
|
|
+ name: item.name,
|
|
|
+ createTime: createTime + layerResource.geos.length + ndx,
|
|
|
+ url: item.url,
|
|
|
+ lock: import.meta.env.DEV ? false : true,
|
|
|
+ mat: tf.m,
|
|
|
+ width: item.size ? item.size.width : 100,
|
|
|
+ height: item.size ? item.size.height : 100,
|
|
|
+ cornerRadius: 0,
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
draw.store.addItems(
|
|
|
"icon",
|
|
@@ -327,8 +341,8 @@ const drawLayerResource = async (
|
|
|
center: {
|
|
|
x: box.center.x + offset.x,
|
|
|
y: box.center.y + offset.y,
|
|
|
- }
|
|
|
- }
|
|
|
+ },
|
|
|
+ };
|
|
|
};
|
|
|
|
|
|
export const drawPlatformResource = async (data: AIExposeData, draw: Draw) => {
|