clear data

This commit is contained in:
Fine 2024-11-28 15:56:30 +08:00
parent c2e551e13e
commit ede9fc40ea
3 changed files with 16 additions and 2 deletions

View File

@ -49,6 +49,9 @@ export const asyncProfilingStore = defineStore({
setSelectedTask(task: Recordable<AsyncProfilingTask>) { setSelectedTask(task: Recordable<AsyncProfilingTask>) {
this.selectedTask = task || {}; this.selectedTask = task || {};
}, },
setAnalyzeTrees(tree: AsyncProfilerStackElement[]) {
this.analyzeTrees = tree;
},
async getTaskList() { async getTaskList() {
const { duration } = useAppStoreWithOut(); const { duration } = useAppStoreWithOut();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
@ -64,6 +67,7 @@ export const asyncProfilingStore = defineStore({
} }
this.taskList = res.data.data.asyncTaskList.tasks || []; this.taskList = res.data.data.asyncTaskList.tasks || [];
this.selectedTask = this.taskList[0] || {}; this.selectedTask = this.taskList[0] || {};
this.setAnalyzeTrees([]);
this.setSelectedTask(this.selectedTask); this.setSelectedTask(this.selectedTask);
if (!this.taskList.length) { if (!this.taskList.length) {
return res.data; return res.data;

View File

@ -37,7 +37,7 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref } from "vue"; import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useAsyncProfilingStore } from "@/store/modules/async-profiling"; import { useAsyncProfilingStore } from "@/store/modules/async-profiling";
@ -60,10 +60,12 @@ limitations under the License. -->
function changeInstances(options: Option[]) { function changeInstances(options: Option[]) {
serviceInstanceIds.value = options.map((d: Option) => d.value); serviceInstanceIds.value = options.map((d: Option) => d.value);
asyncProfilingStore.setAnalyzeTrees([]);
} }
function changeEventType(options: Option[]) { function changeEventType(options: Option[]) {
selectedEventType.value = options[0].value; selectedEventType.value = options[0].value;
asyncProfilingStore.setAnalyzeTrees([]);
} }
async function analyzeProfiling() { async function analyzeProfiling() {
@ -80,6 +82,14 @@ limitations under the License. -->
return; return;
} }
} }
watch(
() => asyncProfilingStore.selectedTask.successInstanceIds,
() => {
serviceInstanceIds.value = [];
selectedEventType.value = "";
},
);
</script> </script>
<style> <style>
.filter-selector { .filter-selector {

View File

@ -160,6 +160,7 @@ limitations under the License. -->
async function changeTask(item: TaskListItem) { async function changeTask(item: TaskListItem) {
asyncProfilingStore.setSelectedTask(item); asyncProfilingStore.setSelectedTask(item);
asyncProfilingStore.setAnalyzeTrees([]);
service.value = (selectorStore.services.filter((s: Service) => s.id === item.serviceId)[0] ?? {}).label; service.value = (selectorStore.services.filter((s: Service) => s.id === item.serviceId)[0] ?? {}).label;
const res = await asyncProfilingStore.getTaskLogs({ taskId: item.id }); const res = await asyncProfilingStore.getTaskLogs({ taskId: item.id });
@ -189,7 +190,6 @@ limitations under the License. -->
instanceLogs.value[d.instanceName] = [{ operationType: d.operationType, operationTime: d.operationTime }]; instanceLogs.value[d.instanceName] = [{ operationType: d.operationType, operationTime: d.operationTime }];
} }
} }
asyncProfilingStore.setSelectedTask(item);
} }
watch( watch(