1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-01 03:24:14 +08:00

fix(container/log): enable close-on-click-modal and wrap log update in nextTick (#7960)

Refs #7547
This commit is contained in:
igophper 2025-02-24 13:34:51 +08:00 committed by GitHub
parent 56858dd74c
commit b1f337020c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 15 deletions

View File

@ -59,7 +59,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import i18n from '@/lang'; import i18n from '@/lang';
import { dateFormatForName } from '@/utils/util'; import { dateFormatForName } from '@/utils/util';
import { computed, onBeforeUnmount, reactive, ref, shallowRef, watch } from 'vue'; import { computed, nextTick, onBeforeUnmount, reactive, ref, shallowRef, watch } from 'vue';
import { Codemirror } from 'vue-codemirror'; import { Codemirror } from 'vue-codemirror';
import { javascript } from '@codemirror/lang-javascript'; import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark'; import { oneDark } from '@codemirror/theme-one-dark';
@ -145,10 +145,12 @@ const searchLogs = async () => {
); );
terminalSocket.value.onmessage = (event) => { terminalSocket.value.onmessage = (event) => {
logInfo.value += event.data; logInfo.value += event.data;
const state = view.value.state; nextTick(() => {
view.value.dispatch({ const state = view.value.state;
selection: { anchor: state.doc.length, head: state.doc.length }, view.value.dispatch({
scrollIntoView: true, selection: { anchor: state.doc.length, head: state.doc.length },
scrollIntoView: true,
});
}); });
}; };
}; };

View File

@ -48,7 +48,7 @@
import { cleanContainerLog } from '@/api/modules/container'; import { cleanContainerLog } from '@/api/modules/container';
import i18n from '@/lang'; import i18n from '@/lang';
import { dateFormatForName, downloadWithContent } from '@/utils/util'; import { dateFormatForName, downloadWithContent } from '@/utils/util';
import { onBeforeUnmount, reactive, ref, shallowRef } from 'vue'; import { nextTick, onBeforeUnmount, reactive, ref, shallowRef } from 'vue';
import { Codemirror } from 'vue-codemirror'; import { Codemirror } from 'vue-codemirror';
import { javascript } from '@codemirror/lang-javascript'; import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark'; import { oneDark } from '@codemirror/theme-one-dark';
@ -113,10 +113,12 @@ const searchLogs = async () => {
); );
terminalSocket.value.onmessage = (event) => { terminalSocket.value.onmessage = (event) => {
logInfo.value += event.data; logInfo.value += event.data;
const state = view.value.state; nextTick(() => {
view.value.dispatch({ const state = view.value.state;
selection: { anchor: state.doc.length, head: state.doc.length }, view.value.dispatch({
scrollIntoView: true, selection: { anchor: state.doc.length, head: state.doc.length },
scrollIntoView: true,
});
}); });
}; };
}; };

View File

@ -69,7 +69,7 @@
import { cleanContainerLog, DownloadFile } from '@/api/modules/container'; import { cleanContainerLog, DownloadFile } from '@/api/modules/container';
import i18n from '@/lang'; import i18n from '@/lang';
import { dateFormatForName } from '@/utils/util'; import { dateFormatForName } from '@/utils/util';
import { computed, onBeforeUnmount, reactive, ref, shallowRef, watch } from 'vue'; import { computed, nextTick, onBeforeUnmount, reactive, ref, shallowRef, watch } from 'vue';
import { Codemirror } from 'vue-codemirror'; import { Codemirror } from 'vue-codemirror';
import { javascript } from '@codemirror/lang-javascript'; import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark'; import { oneDark } from '@codemirror/theme-one-dark';
@ -152,10 +152,12 @@ const searchLogs = async () => {
); );
terminalSocket.value.onmessage = (event) => { terminalSocket.value.onmessage = (event) => {
logInfo.value += event.data.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, ''); logInfo.value += event.data.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '');
const state = view.value.state; nextTick(() => {
view.value.dispatch({ const state = view.value.state;
selection: { anchor: state.doc.length, head: state.doc.length }, view.value.dispatch({
scrollIntoView: true, selection: { anchor: state.doc.length, head: state.doc.length },
scrollIntoView: true,
});
}); });
}; };
}; };