|
|
@@ -247,10 +247,14 @@ export default defineComponent({
|
|
|
const dialogScroll = ref("");
|
|
|
const scrollToEnd = async () => {
|
|
|
await nextTick();
|
|
|
- dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
|
|
|
+ if (dialogScroll.value) {
|
|
|
+ dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
|
|
|
+ }
|
|
|
};
|
|
|
+ let questionInterval = null;
|
|
|
let answerInterval = null;
|
|
|
const stopWriting = () => {
|
|
|
+ window.clearInterval(questionInterval);
|
|
|
window.clearInterval(answerInterval);
|
|
|
emit("set-readonly", false);
|
|
|
dialogList[dialogIndex].other = {
|
|
|
@@ -278,13 +282,13 @@ export default defineComponent({
|
|
|
let result = { question: "", capacity: null, answer: "", other: null, file: null };
|
|
|
// 第一步,输入问题
|
|
|
const step1 = () => {
|
|
|
- const interval = setInterval(() => {
|
|
|
+ questionInterval = setInterval(() => {
|
|
|
if (num1 < p1.length + 1) {
|
|
|
result.question = p1.slice(0, num1);
|
|
|
num1 += 1;
|
|
|
addData(result);
|
|
|
} else {
|
|
|
- window.clearInterval(interval);
|
|
|
+ window.clearInterval(questionInterval);
|
|
|
// 如果有文件,显示上传文件
|
|
|
if (file) {
|
|
|
result.file = file;
|
|
|
@@ -376,6 +380,7 @@ export default defineComponent({
|
|
|
onBeforeUnmount(() => {
|
|
|
helper.$bus.off("send-message");
|
|
|
helper.$bus.off("clear-message");
|
|
|
+ helper.$bus.off("stop-writing");
|
|
|
});
|
|
|
onMounted(() => {
|
|
|
helper.$bus.on("send-message", (value) => {
|
|
|
@@ -384,6 +389,9 @@ export default defineComponent({
|
|
|
helper.$bus.on("clear-message", () => {
|
|
|
dialogList.splice(0);
|
|
|
});
|
|
|
+ helper.$bus.on("stop-writing", () => {
|
|
|
+ stopWriting();
|
|
|
+ });
|
|
|
});
|
|
|
return {
|
|
|
randomKey,
|