Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 71a5388

Browse files
committed
fix: terminal max retry count
1 parent 107e802 commit 71a5388

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

src/components/x-terminal/index.vue

+21-5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
const toRetry = ref(false);
5151
const RECONNECT_MSG = '--- press Y to reconnect! ---';
5252
const appStore = useAppStore();
53+
const totalRetry = 5;
54+
const retryCount = ref(5);
55+
let timer: any = null;
5356
5457
const conReadyState = ref(0);
5558
@@ -278,6 +281,15 @@
278281
actived.value = false;
279282
if (terminalSocket.value) terminalSocket.value?.close?.();
280283
};
284+
const retryWs = () => {
285+
if (retryCount.value > 0) {
286+
retryCount.value -= 1;
287+
term.value?.write?.('');
288+
setWssUrl();
289+
initWS();
290+
term.value.reset();
291+
}
292+
};
281293
watch(
282294
() => props.url,
283295
() => {
@@ -286,6 +298,10 @@
286298
terminalSocket.value?.close?.();
287299
terminalSocket.value = {};
288300
} else {
301+
// reset retry count
302+
retryCount.value = totalRetry;
303+
clearTimeout(timer);
304+
289305
term.value?.reset?.();
290306
debounceCall();
291307
}
@@ -297,11 +313,11 @@
297313
watch(
298314
() => statusCode.value,
299315
(ov) => {
300-
if (statusCode.value === 1003) {
301-
term.value?.write?.('');
302-
setWssUrl();
303-
initWS();
304-
term.value.reset();
316+
if (statusCode.value === 1003 && retryCount.value > 0) {
317+
clearTimeout(timer);
318+
timer = setTimeout(() => {
319+
retryWs();
320+
}, 2 ** (totalRetry - retryCount.value) * 1000);
305321
}
306322
},
307323
{

src/views/operation-hub/templates/pages/gpt.vue

+19-17
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,32 @@
110110
}}
111111
</div>
112112
</template>
113-
<a-button
114-
ref="correctionButton"
115-
:disabled="loading"
116-
type="outline"
117-
shape="circle"
118-
class="correction-btn"
119-
@click="handleViewCorrection"
113+
<a-tooltip
114+
:content="$t('operation.templates.detail.correctionview')"
115+
position="tr"
116+
:arrow-style="{
117+
left: '95px'
118+
}"
120119
>
121-
<a-tooltip
122-
:content="$t('operation.templates.detail.correctionview')"
120+
<a-button
121+
ref="correctionButton"
122+
:disabled="loading"
123+
type="outline"
124+
shape="circle"
125+
class="correction-btn"
126+
@click="handleViewCorrection"
123127
>
124128
<template #content>
125129
<div style="width: max-content">{{
126130
$t('operation.templates.detail.correctionview')
127131
}}</div>
128132
</template>
129-
<span>
130-
<icon-font
131-
type="icon-shoudongxiaoyan"
132-
class="size-16"
133-
></icon-font>
134-
</span>
135-
</a-tooltip>
136-
</a-button>
133+
<icon-font
134+
type="icon-shoudongxiaoyan"
135+
class="size-16"
136+
></icon-font>
137+
</a-button>
138+
</a-tooltip>
137139
</a-tooltip>
138140
</a-space>
139141
</div>

0 commit comments

Comments
 (0)