|
@@ -6,12 +6,14 @@ import { getBaseItem } from "@/core/components/util";
|
|
|
import { LineData, defaultStyle } from "@/core/components/line";
|
|
|
import { getInitCtx, normalLineData } from "@/core/components/line/use-draw";
|
|
|
import { defaultStyle as iconDefaultStyle } from "@/core/components/icon";
|
|
|
+import { defaultStyle as textDefaultStyle } from "@/core/components/text";
|
|
|
import { Transform } from "konva/lib/Util";
|
|
|
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";
|
|
|
+import { TextData } from "@/core/components/text";
|
|
|
|
|
|
const scaleResource = (info: AIExposeData, scale: number) => {
|
|
|
const floors = info.floors.map((item) => ({
|
|
@@ -165,6 +167,7 @@ const drawLayerResource = async (
|
|
|
) => {
|
|
|
const bound = genBound();
|
|
|
const images: any[] = [];
|
|
|
+ const texts: TextData[] = [];
|
|
|
const createTime = Date.now();
|
|
|
|
|
|
let geo: LineData = {
|
|
@@ -286,40 +289,58 @@ const drawLayerResource = async (
|
|
|
if (item.rotate) {
|
|
|
tf.rotate(item.rotate);
|
|
|
}
|
|
|
- let svgAttach: any = {}
|
|
|
- if (item.url.includes(".svg")) {
|
|
|
- svgAttach = {
|
|
|
- ...iconDefaultStyle,
|
|
|
- stroke: "#000000" ,
|
|
|
- fill: null
|
|
|
+ if (item.isText) {
|
|
|
+ texts.push({
|
|
|
+ ...getBaseItem(),
|
|
|
+ ...textDefaultStyle,
|
|
|
+ content: item.url,
|
|
|
+ mat: tf.m,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let svgAttach: any = {};
|
|
|
+ if (item.url.includes(".svg")) {
|
|
|
+ svgAttach = {
|
|
|
+ ...iconDefaultStyle,
|
|
|
+ stroke: "#000000",
|
|
|
+ fill: null,
|
|
|
+ width: item.size ? item.size.width : 100,
|
|
|
+ height: item.size ? item.size.height : 100,
|
|
|
+ };
|
|
|
+ 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;
|
|
|
+ if (!svgAttach.fill && !svgAttach.stroke) {
|
|
|
+ svgAttach.stroke = "#000000";
|
|
|
+ }
|
|
|
+ if (svg.width && svg.height) {
|
|
|
+ if (svg.width > svg.height) {
|
|
|
+ svgAttach.height = (svg.height / svg.width) * svgAttach.width;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
}
|
|
|
- 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,
|
|
|
- });
|
|
|
+ images.push({
|
|
|
+ ...getBaseItem(),
|
|
|
+ name: item.name,
|
|
|
+ createTime: createTime + layerResource.geos.length + ndx,
|
|
|
+ url: item.url,
|
|
|
+ lock: import.meta.env.DEV ? false : true,
|
|
|
+ mat: tf.m,
|
|
|
+ cornerRadius: 0,
|
|
|
+ ...svgAttach,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
draw.store.addItems(
|
|
|
"icon",
|
|
|
images.filter((item) => item.url.includes(".svg"))
|
|
|
);
|
|
|
+ draw.store.addItems("text", texts);
|
|
|
|
|
|
draw.store.addItems(
|
|
|
"image",
|