Skip to content

Commit c2e4c3e

Browse files
committed
fix: Fix the issue where the connection method is missing due to frequent clicking of nodes
1 parent 9e768e9 commit c2e4c3e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/app/services/app.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export class AppService {
3030
private protocolPreferKey = 'ProtocolPreferLoginType';
3131
private accountPreferKey = 'PreferAccount';
3232
private protocolConnectTypesMap: object = {};
33+
private connectMethodsRequestSeq = 0;
34+
private connectMethodsAppliedSeq = 0;
3335
private checkIntervalId: number;
3436
private newLoginHasOpen = false; // 避免多次打开新登录页
3537
private checkSecond = 120;
@@ -202,13 +204,21 @@ export class AppService {
202204

203205
getConnectMethods(): Promise<void> {
204206
const url = '/api/v1/terminal/components/connect-methods/';
207+
const requestSeq = ++this.connectMethodsRequestSeq;
205208

206209
// 当用户先打开 luna 并进行操作时如果后在 lina 中去设置连接方式的 ACL 此时并不生效,因此修改为在 toPromise 后直接赋值
207210
return this._http
208211
.get(url)
209212
.toPromise()
210213
.then(response => {
214+
// 每次发起请求都自增 connectMethodsRequestSeq,记录当前请求序号 requestSeq
215+
// 响应回来时,如果 requestSeq 小于已经应用过的 connectMethodsAppliedSeq,说明这是“过期响应”,直接丢弃
216+
// 只有最新的响应才会更新 protocolConnectTypesMap,并把 connectMethodsAppliedSeq 同步为最新
217+
if (requestSeq < this.connectMethodsAppliedSeq) {
218+
return;
219+
}
211220
this.protocolConnectTypesMap = response;
221+
this.connectMethodsAppliedSeq = requestSeq;
212222
})
213223
.catch(error => {
214224
this._logger.error('Get connect methods error:', error);

0 commit comments

Comments
 (0)