Skip to content

Commit 866a376

Browse files
authored
chore: put data manager cache to sessionStorage (#727)
Co-authored-by: rick <[email protected]>
1 parent dc4262d commit 866a376

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

console/atest-ui/src/views/DataManager.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const queryResultAsJSON = ref('')
3131
const columns = ref([] as string[])
3232
const queryTip = ref('')
3333
const loadingStores = ref(true)
34+
const globalLoading = ref(false)
3435
const showOverflowTooltip = ref(true)
3536
const complexEditor = ref(false)
3637
const dataFormat = ref('table')
@@ -241,7 +242,10 @@ const executeWithQuery = async (sql: string) => {
241242
query.value.sql = sql
242243
243244
try {
244-
const data = await API.DataQueryAsync(query.value);
245+
globalLoading.value = true
246+
const data = await API.DataQueryAsync(query.value, () => {
247+
globalLoading.value = false
248+
});
245249
switch (kind.value) {
246250
case ExtensionKind.ExtensionKindORM:
247251
case ExtensionKind.ExtensionKindCassandra:
@@ -308,7 +312,7 @@ Magic.AdvancedKeys([{
308312
<div class="page-header">
309313
<span class="page-title">{{t('title.dataManager')}}</span>
310314
</div>
311-
<el-container style="height: calc(100vh - 80px);">
315+
<el-container style="height: calc(100vh - 80px);" v-loading="globalLoading">
312316
<el-aside v-if="kind === 'atest-store-orm' || kind === 'atest-store-iotdb' || kind === 'atest-store-cassandra' || kind === 'atest-store-elasticsearch' || kind === 'atest-store-opengemini'">
313317
<el-scrollbar>
314318
<el-select v-model="queryDataMeta.currentDatabase" placeholder="Select database"

console/atest-ui/src/views/cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 API Testing Authors.
2+
Copyright 2023-2025 API Testing Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@ interface DataManagerPreference {
153153

154154
const DataManagerPreferenceKey = "data-manager-preference"
155155
export function GetDataManagerPreference(): DataManagerPreference {
156-
const val = localStorage.getItem(DataManagerPreferenceKey)
156+
const val = sessionStorage.getItem(DataManagerPreferenceKey)
157157
if (val && val !== '') {
158158
return JSON.parse(val)
159159
} else {
@@ -178,7 +178,7 @@ export function SetDataManagerPreference(field: string, value: string) {
178178
default:
179179
return
180180
}
181-
localStorage.setItem(DataManagerPreferenceKey, JSON.stringify(preference))
181+
sessionStorage.setItem(DataManagerPreferenceKey, JSON.stringify(preference))
182182
return
183183
}
184184

console/atest-ui/src/views/net.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ export interface QueryObject {
851851
offset: number
852852
limit: number
853853
}
854-
const DataQueryAsync = (query: QueryObject) => {
854+
const DataQueryAsync = (query: QueryObject, final?: () => void | undefined | null) => {
855855
const requestOptions = {
856856
method: 'POST',
857857
headers: {
@@ -863,7 +863,7 @@ const DataQueryAsync = (query: QueryObject) => {
863863
body: JSON.stringify(query)
864864
}
865865
return fetch(`/api/v1/data/query`, requestOptions)
866-
.then(DefaultResponseProcess)
866+
.then(DefaultResponseProcess).finally(final)
867867
}
868868

869869
var DataQuery = (store: string, kind: string, currentDatabase: string, query: string, callback: (d: any) => void, errHandler: (d: any) => void) => {

0 commit comments

Comments
 (0)