refactor: improve signature component resize handling
This commit is contained in:
parent
30695c234d
commit
6b6a7ada79
|
|
@ -57,7 +57,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, computed, onUnmounted, watch } from "vue";
|
import { ref, onMounted, computed, onUnmounted, watch, nextTick } from "vue";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { Local } from "@/utils/storage.js";
|
import { Local } from "@/utils/storage.js";
|
||||||
import { receiveCode } from "@/api/index.js";
|
import { receiveCode } from "@/api/index.js";
|
||||||
|
|
@ -126,6 +126,10 @@ function getSignatureHeight() {
|
||||||
);
|
);
|
||||||
if (content) {
|
if (content) {
|
||||||
content.style.height = `${signatureHeight}px`;
|
content.style.height = `${signatureHeight}px`;
|
||||||
|
nextTick(() => {
|
||||||
|
var _a;
|
||||||
|
(_a = vanSignatureRef.value) == null ? void 0 : _a.resize();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
@ -201,6 +205,10 @@ function updateGridSize() {
|
||||||
size = Math.min(size, availableWidth);
|
size = Math.min(size, availableWidth);
|
||||||
gridSize.value = size;
|
gridSize.value = size;
|
||||||
}
|
}
|
||||||
|
function handleResize() {
|
||||||
|
updateGridSize();
|
||||||
|
getSignatureHeight();
|
||||||
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 组件挂载后获取高度
|
// 组件挂载后获取高度
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -216,10 +224,10 @@ onMounted(() => {
|
||||||
receiveName.value = marriageInfo.receiveName;
|
receiveName.value = marriageInfo.receiveName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener("resize", updateGridSize);
|
window.addEventListener("resize", handleResize);
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener("resize", updateGridSize);
|
window.removeEventListener("resize", handleResize);
|
||||||
});
|
});
|
||||||
watch(nameChars, () => {
|
watch(nameChars, () => {
|
||||||
updateGridSize();
|
updateGridSize();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue