|
@@ -2,7 +2,12 @@
|
|
|
<v-group :config="groupConfig" v-if="groupConfig && svg" ref="shape">
|
|
|
<v-group :config="initDecMat" name="rep-position">
|
|
|
<v-rect :config="rectConfig" name="repShape" />
|
|
|
- <v-path v-for="config in pathConfigs" :config="config" name="icon-path" />
|
|
|
+ <Path
|
|
|
+ v-for="config in pathConfigs"
|
|
|
+ :config="(config as any)"
|
|
|
+ :mat="mat"
|
|
|
+ />
|
|
|
+ <!-- <v-path v-for="config in pathConfigs" :config="config" name="icon-path" /> -->
|
|
|
</v-group>
|
|
|
</v-group>
|
|
|
</template>
|
|
@@ -14,10 +19,9 @@ import { getSvgContent, parseSvgContent, SVGParseResult } from "@/utils/resource
|
|
|
import { Group } from "konva/lib/Group";
|
|
|
import { DC } from "@/deconstruction.js";
|
|
|
import { Transform } from "konva/lib/Util";
|
|
|
-import { useViewerInvertTransform, useViewSize } from "@/core/hook/use-viewer.ts";
|
|
|
-import { getFixPosition } from "@/utils/bound.ts";
|
|
|
import { useStore } from "@/core/store/index.ts";
|
|
|
import { useHistory } from "@/core/hook/use-history.ts";
|
|
|
+import Path from "./temp-path.vue";
|
|
|
|
|
|
const props = defineProps<{ data: IconData; addMode?: boolean }>();
|
|
|
const svg = ref<SVGParseResult | null>(null);
|
|
@@ -37,13 +41,12 @@ watch(
|
|
|
async (url) => {
|
|
|
svg.value = null;
|
|
|
const svgContent = await getSvgContent(url);
|
|
|
-
|
|
|
const content = parseSvgContent(svgContent);
|
|
|
if (content.paths.length === 0) {
|
|
|
svg.value = null;
|
|
|
- console.error(props.data.url, content, "路径数据不正确不是svg");
|
|
|
history.preventTrack(() => store.delItem("icon", props.data.id));
|
|
|
} else {
|
|
|
+ console.log(content);
|
|
|
svg.value = content;
|
|
|
}
|
|
|
},
|
|
@@ -71,7 +74,6 @@ const pathConfigs = computed(() => {
|
|
|
...path,
|
|
|
...data.value,
|
|
|
id: undefined,
|
|
|
- lineWidth: 1000,
|
|
|
zIndex: undefined,
|
|
|
offset: { x: svg.value!.x, y: svg.value!.y },
|
|
|
}));
|
|
@@ -84,21 +86,10 @@ const initDecMat = computed(() => {
|
|
|
.decompose();
|
|
|
});
|
|
|
|
|
|
-const viewInvTransform = useViewerInvertTransform();
|
|
|
-const size = useViewSize();
|
|
|
+const mat = computed(() => new Transform(data.value.mat));
|
|
|
const groupConfig = computed(() => {
|
|
|
- let mat = new Transform(data.value.mat);
|
|
|
-
|
|
|
- if (data.value.fixScreen) {
|
|
|
- if (!size.value) return {};
|
|
|
- const pos = getFixPosition(data.value.fixScreen, data.value, size.value);
|
|
|
- pos.x += data.value.width / 2;
|
|
|
- pos.y += data.value.height / 2;
|
|
|
- mat = viewInvTransform.value.copy().translate(pos.x, pos.y).multiply(mat);
|
|
|
- }
|
|
|
-
|
|
|
return {
|
|
|
- ...mat.decompose(),
|
|
|
+ ...mat.value.decompose(),
|
|
|
zIndex: undefined,
|
|
|
listening: data.value.listening,
|
|
|
id: data.value.id,
|