|
@@ -1,14 +1,16 @@
|
|
|
<template>
|
|
|
<div class="mark-body-container" ref="container">
|
|
|
- <template v-for="(item, index) in imageWithStyles" :key="index">
|
|
|
- <img :src="item.url" />
|
|
|
+ <div :style="{ width: answerPaperScale }">
|
|
|
+ <template v-for="(item, index) in imageWithStyles" :key="index">
|
|
|
+ <img :src="item.url" />
|
|
|
+ </template>
|
|
|
<!-- style="border: 1px solid black; background: black" -->
|
|
|
- </template>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, onMounted, reactive, ref, watchEffect } from "vue";
|
|
|
+import { computed, defineComponent, reactive, ref, watchEffect } from "vue";
|
|
|
import { store } from "./store";
|
|
|
import filters from "@/filters";
|
|
|
|
|
@@ -42,16 +44,12 @@ export default defineComponent({
|
|
|
const image = await loadImage(url);
|
|
|
|
|
|
const div: HTMLDivElement = container.value;
|
|
|
- // const containerWidth = +getComputedStyle(div).width.replace("px", "");
|
|
|
- // console.log(div, containerWidth, sliceConfig);
|
|
|
- // console.log(container);
|
|
|
- // const originalWidth = image.naturalWidth;
|
|
|
- // const originalHeight = image.naturalHeight;
|
|
|
- // console.log({ originalWidth, originalHeight });
|
|
|
- // const ratio = containerWidth / originalWidth;
|
|
|
- // getNaturalWidth
|
|
|
+ const maxSliceWidth = Math.max(
|
|
|
+ ...store.currentTask.sliceConfig.map((v) => v.w)
|
|
|
+ );
|
|
|
+
|
|
|
const canvas = document.createElement("canvas");
|
|
|
- canvas.width = sliceConfig.w;
|
|
|
+ canvas.width = Math.max(sliceConfig.w, maxSliceWidth);
|
|
|
canvas.height = sliceConfig.h;
|
|
|
const ctx = canvas.getContext("2d");
|
|
|
ctx?.drawImage(
|
|
@@ -65,16 +63,20 @@ export default defineComponent({
|
|
|
sliceConfig.w,
|
|
|
sliceConfig.h
|
|
|
);
|
|
|
- console.log(image, canvas.height, sliceConfig, ctx);
|
|
|
+ // console.log(image, canvas.height, sliceConfig, ctx);
|
|
|
// console.log(canvas.toDataURL());
|
|
|
imageWithStyles.push({
|
|
|
url: canvas.toDataURL(),
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- console.log("watch effect", imageWithStyles);
|
|
|
});
|
|
|
- return { container, store, imageWithStyles };
|
|
|
+
|
|
|
+ const answerPaperScale = computed(() => {
|
|
|
+ const scale = store.setting.uiSetting["answer.paper.scale"] || 1;
|
|
|
+ return scale * 100 + "%";
|
|
|
+ });
|
|
|
+ return { container, store, imageWithStyles, answerPaperScale };
|
|
|
},
|
|
|
});
|
|
|
</script>
|
|
@@ -82,6 +84,9 @@ export default defineComponent({
|
|
|
<style scoped>
|
|
|
.mark-body-container {
|
|
|
height: calc(100vh - 21px);
|
|
|
- /* overflow: scroll; */
|
|
|
+ overflow: scroll;
|
|
|
+}
|
|
|
+.mark-body-container img {
|
|
|
+ width: 100%;
|
|
|
}
|
|
|
</style>
|