From bdd4353b0a2a35d6fa0f2215185f61286cd808c2 Mon Sep 17 00:00:00 2001 From: Fine Date: Thu, 6 Apr 2023 09:51:59 +0800 Subject: [PATCH] fix: types --- src/hooks/useMetricsProcessor.ts | 2 +- src/layout/components/NavBar.vue | 4 +++- src/store/modules/demand-log.ts | 2 +- src/store/modules/log.ts | 10 +++++----- src/store/modules/network-profiling.ts | 6 +++--- src/store/modules/topology.ts | 2 +- src/store/modules/trace.ts | 12 ++++++------ src/types/app.d.ts | 2 +- src/types/profile.d.ts | 4 ++-- src/views/components/ConditionTags.vue | 6 +++--- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/hooks/useMetricsProcessor.ts b/src/hooks/useMetricsProcessor.ts index 75190861..cf617c2a 100644 --- a/src/hooks/useMetricsProcessor.ts +++ b/src/hooks/useMetricsProcessor.ts @@ -262,7 +262,7 @@ export function useQueryPodsMetrics( export function usePodsSource( pods: Array, - resp: { errors: string; data: { [key: string]: any } }, + resp: { errors: string; data: Recordable }, config: { metrics: string[]; metricTypes: string[]; diff --git a/src/layout/components/NavBar.vue b/src/layout/components/NavBar.vue index 33c8961b..679e6165 100644 --- a/src/layout/components/NavBar.vue +++ b/src/layout/components/NavBar.vue @@ -85,9 +85,11 @@ limitations under the License. --> function getPathNames() { const p = route.params; + // get names + + // set names if (appStore.pathNames.length && p.layerId === appStore.pathNames[0].layerId) { const arr = [...appStore.pathNames, p]; - const list = deduplication(arr, ["layerId", "entity", "name"]); appStore.setPathNames(list); } else { diff --git a/src/store/modules/demand-log.ts b/src/store/modules/demand-log.ts index 1776fa81..8eb7e6d8 100644 --- a/src/store/modules/demand-log.ts +++ b/src/store/modules/demand-log.ts @@ -27,7 +27,7 @@ interface DemandLogState { containers: Instance[]; instances: Instance[]; conditions: Conditions; - selectorStore: any; + selectorStore: Recordable; logs: Log[]; loadLogs: boolean; message: string; diff --git a/src/store/modules/log.ts b/src/store/modules/log.ts index 3509084b..f2e222de 100644 --- a/src/store/modules/log.ts +++ b/src/store/modules/log.ts @@ -27,10 +27,10 @@ interface LogState { services: Service[]; instances: Instance[]; endpoints: Endpoint[]; - conditions: any; - selectorStore: any; + conditions: Recordable; + selectorStore: Recordable; supportQueryLogsByKeywords: boolean; - logs: any[]; + logs: Recordable[]; loadLogs: boolean; } @@ -50,7 +50,7 @@ export const logStore = defineStore({ loadLogs: false, }), actions: { - setLogCondition(data: any) { + setLogCondition(data: Recordable) { this.conditions = { ...this.conditions, ...data }; }, resetState() { @@ -152,6 +152,6 @@ export const logStore = defineStore({ }, }); -export function useLogStore(): any { +export function useLogStore(): Recordable { return logStore(store); } diff --git a/src/store/modules/network-profiling.ts b/src/store/modules/network-profiling.ts index f3648345..842cc0ca 100644 --- a/src/store/modules/network-profiling.ts +++ b/src/store/modules/network-profiling.ts @@ -74,7 +74,7 @@ export const networkProfilingStore = defineStore({ this.activeMetricIndex = index; }, setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) { - const obj = {} as any; + const obj = {} as Recordable; let calls = (data.calls || []).reduce((prev: Call[], next: Call) => { if (!obj[next.id]) { obj[next.id] = true; @@ -92,7 +92,7 @@ export const networkProfilingStore = defineStore({ } return prev; }, []); - const param = {} as any; + const param = {} as Recordable; calls = data.calls.reduce((prev: (Call | any)[], next: Call | any) => { if (param[next.targetId + next.sourceId]) { next.lowerArc = true; @@ -182,6 +182,6 @@ export const networkProfilingStore = defineStore({ }, }); -export function useNetworkProfilingStore(): any { +export function useNetworkProfilingStore(): Recordable { return networkProfilingStore(store); } diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts index 2a4fbb8e..2318e72f 100644 --- a/src/store/modules/topology.ts +++ b/src/store/modules/topology.ts @@ -73,7 +73,7 @@ export const topologyStore = defineStore({ this.nodes = data.nodes; }, setTopology(data: { nodes: Node[]; calls: Call[] }) { - const obj = {} as any; + const obj = {} as Recordable; const services = useSelectorStore().services; const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => { if (!obj[next.id]) { diff --git a/src/store/modules/trace.ts b/src/store/modules/trace.ts index ea6f91f3..aa7214c9 100644 --- a/src/store/modules/trace.ts +++ b/src/store/modules/trace.ts @@ -31,9 +31,9 @@ interface TraceState { traceList: Trace[]; traceSpans: Span[]; currentTrace: Recordable; - conditions: any; - traceSpanLogs: any[]; - selectorStore: any; + conditions: Recordable; + traceSpanLogs: Recordable[]; + selectorStore: Recordable; } export const traceStore = defineStore({ @@ -55,7 +55,7 @@ export const traceStore = defineStore({ selectorStore: useSelectorStore(), }), actions: { - setTraceCondition(data: any) { + setTraceCondition(data: Recordable) { this.conditions = { ...this.conditions, ...data }; }, setCurrentTrace(trace: Recordable) { @@ -171,7 +171,7 @@ export const traceStore = defineStore({ this.setTraceSpans(data || []); return res.data; }, - async getSpanLogs(params: any) { + async getSpanLogs(params: Recordable) { const res: AxiosResponse = await graphql.query("queryServiceLogs").params(params); if (res.data.errors) { this.traceSpanLogs = []; @@ -197,6 +197,6 @@ export const traceStore = defineStore({ }, }); -export function useTraceStore(): any { +export function useTraceStore() { return traceStore(store); } diff --git a/src/types/app.d.ts b/src/types/app.d.ts index e22444fd..fee0d80d 100644 --- a/src/types/app.d.ts +++ b/src/types/app.d.ts @@ -44,6 +44,6 @@ export type EventParams = { dataType: string; value: number | Array; color: string; - event: any; + event: Record; dataIndex: number; }; diff --git a/src/types/profile.d.ts b/src/types/profile.d.ts index c9d64746..ac7fb79f 100644 --- a/src/types/profile.d.ts +++ b/src/types/profile.d.ts @@ -55,8 +55,8 @@ export interface SegmentSpan { component: string; isError: boolean; layer: string; - tags: any[]; - logs: any[]; + tags: Recordable[]; + logs: Recordable[]; } export interface ProfileTaskCreationRequest { diff --git a/src/views/components/ConditionTags.vue b/src/views/components/ConditionTags.vue index a7b2078b..eedb2021 100644 --- a/src/views/components/ConditionTags.vue +++ b/src/views/components/ConditionTags.vue @@ -71,7 +71,7 @@ limitations under the License. --> import { ElMessage } from "element-plus"; import { useAppStoreWithOut } from "@/store/modules/app"; - /*global defineEmits, defineProps */ + /*global defineEmits, defineProps, Recordable */ const emit = defineEmits(["update"]); const props = defineProps({ type: { type: String, default: "TRACE" }, @@ -118,7 +118,7 @@ limitations under the License. --> emit("update", { tagsMap, tagsList: tagsList.value }); } async function fetchTagKeys() { - let resp: any = {}; + let resp: Recordable = {}; if (props.type === "TRACE") { resp = await traceStore.getTagKeys(); } else { @@ -137,7 +137,7 @@ limitations under the License. --> async function fetchTagValues() { const param = tags.value.split("=")[0]; - let resp: any = {}; + let resp: Recordable = {}; if (props.type === "TRACE") { resp = await traceStore.getTagValues(param); } else {