fix: update types

This commit is contained in:
Fine 2023-04-06 17:57:01 +08:00
parent 10b6a70c60
commit 24944d4ad9
11 changed files with 33 additions and 32 deletions

View File

@ -53,7 +53,7 @@ limitations under the License. -->
default: () => [], default: () => [],
}, },
value: { value: {
type: [Array, String, Number, undefined] as PropType<unknown>, type: [Array, String, Number, undefined] as PropType<any>,
default: () => [], default: () => [],
}, },
size: { type: null, default: "default" }, size: { type: null, default: "default" },

View File

@ -74,7 +74,7 @@ export const dashboardStore = defineStore({
this.currentDashboard = item; this.currentDashboard = item;
}, },
addControl(type: string) { addControl(type: string) {
const arr = this.layout.map((d: any) => Number(d.i)); const arr = this.layout.map((d: Recordable) => Number(d.i));
let index = String(Math.max(...arr) + 1); let index = String(Math.max(...arr) + 1);
if (!this.layout.length) { if (!this.layout.length) {
index = "0"; index = "0";
@ -148,7 +148,7 @@ export const dashboardStore = defineStore({
} }
const tabIndex = this.layout[idx].activedTabIndex || 0; const tabIndex = this.layout[idx].activedTabIndex || 0;
const { children } = (this.layout[idx].children || [])[tabIndex]; const { children } = (this.layout[idx].children || [])[tabIndex];
const arr = children.map((d: any) => Number(d.i)); const arr = children.map((d: Recordable) => Number(d.i));
let index = String(Math.max(...arr) + 1); let index = String(Math.max(...arr) + 1);
if (!children.length) { if (!children.length) {
index = "0"; index = "0";
@ -393,7 +393,7 @@ export const dashboardStore = defineStore({
children: this.layout, children: this.layout,
...this.currentDashboard, ...this.currentDashboard,
}; };
let res: any; let res: Recordable;
let json; let json;
if (this.currentDashboard.id) { if (this.currentDashboard.id) {

View File

@ -27,7 +27,7 @@ interface DemandLogState {
containers: Instance[]; containers: Instance[];
instances: Instance[]; instances: Instance[];
conditions: Conditions; conditions: Conditions;
selectorStore: any; selectorStore: Recordable;
logs: Log[]; logs: Log[];
loadLogs: boolean; loadLogs: boolean;
message: string; message: string;
@ -111,6 +111,6 @@ export const demandLogStore = defineStore({
}, },
}); });
export function useDemandLogStore(): any { export function useDemandLogStore(): Recordable {
return demandLogStore(store); return demandLogStore(store);
} }

View File

@ -153,6 +153,6 @@ export const ebpfStore = defineStore({
}, },
}); });
export function useEbpfStore(): any { export function useEbpfStore(): Recordable {
return ebpfStore(store); return ebpfStore(store);
} }

View File

@ -106,6 +106,6 @@ export const eventStore = defineStore({
}, },
}); });
export function useEventStore(): any { export function useEventStore(): Recordable {
return eventStore(store); return eventStore(store);
} }

View File

@ -27,10 +27,10 @@ interface LogState {
services: Service[]; services: Service[];
instances: Instance[]; instances: Instance[];
endpoints: Endpoint[]; endpoints: Endpoint[];
conditions: any; conditions: Recordable;
selectorStore: any; selectorStore: Recordable;
supportQueryLogsByKeywords: boolean; supportQueryLogsByKeywords: boolean;
logs: any[]; logs: Recordable[];
loadLogs: boolean; loadLogs: boolean;
} }
@ -50,7 +50,7 @@ export const logStore = defineStore({
loadLogs: false, loadLogs: false,
}), }),
actions: { actions: {
setLogCondition(data: any) { setLogCondition(data: Recordable) {
this.conditions = { ...this.conditions, ...data }; this.conditions = { ...this.conditions, ...data };
}, },
resetState() { resetState() {
@ -152,6 +152,6 @@ export const logStore = defineStore({
}, },
}); });
export function useLogStore(): any { export function useLogStore(): Recordable {
return logStore(store); return logStore(store);
} }

View File

@ -22,6 +22,7 @@ import type { AxiosResponse } from "axios";
import type { Call } from "@/types/topology"; import type { Call } from "@/types/topology";
import type { LayoutConfig } from "@/types/dashboard"; import type { LayoutConfig } from "@/types/dashboard";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import type { DurationTime } from "@/types/app";
interface NetworkProfilingState { interface NetworkProfilingState {
networkTasks: Array<Recordable<EBPFTaskList>>; networkTasks: Array<Recordable<EBPFTaskList>>;
@ -74,7 +75,7 @@ export const networkProfilingStore = defineStore({
this.activeMetricIndex = index; this.activeMetricIndex = index;
}, },
setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) { setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) {
const obj = {} as any; const obj = {} as Recordable;
let calls = (data.calls || []).reduce((prev: Call[], next: Call) => { let calls = (data.calls || []).reduce((prev: Call[], next: Call) => {
if (!obj[next.id]) { if (!obj[next.id]) {
obj[next.id] = true; obj[next.id] = true;
@ -92,8 +93,8 @@ export const networkProfilingStore = defineStore({
} }
return prev; return prev;
}, []); }, []);
const param = {} as any; const param = {} as Recordable;
calls = data.calls.reduce((prev: (Call | any)[], next: Call | any) => { calls = data.calls.reduce((prev: (Call & Recordable)[], next: Call & Recordable) => {
if (param[next.targetId + next.sourceId]) { if (param[next.targetId + next.sourceId]) {
next.lowerArc = true; next.lowerArc = true;
} }
@ -165,7 +166,7 @@ export const networkProfilingStore = defineStore({
} }
return res.data; return res.data;
}, },
async getProcessTopology(params: { duration: any; serviceInstanceId: string }) { async getProcessTopology(params: { duration: DurationTime; serviceInstanceId: string }) {
this.loadNodes = true; this.loadNodes = true;
const res: AxiosResponse = await graphql.query("getProcessTopology").params(params); const res: AxiosResponse = await graphql.query("getProcessTopology").params(params);
this.loadNodes = false; this.loadNodes = false;
@ -182,6 +183,6 @@ export const networkProfilingStore = defineStore({
}, },
}); });
export function useNetworkProfilingStore(): any { export function useNetworkProfilingStore(): Recordable {
return networkProfilingStore(store); return networkProfilingStore(store);
} }

View File

@ -162,7 +162,7 @@ export const profileStore = defineStore({
return { return {
...d, ...d,
segmentId: this.currentSegment?.segmentId, segmentId: this.currentSegment?.segmentId,
traceId: (this.currentSegment.traceIds as any)[0], traceId: (this.currentSegment.traceIds as string[])[0],
}; };
}); });
if (!(segment.spans && segment.spans.length)) { if (!(segment.spans && segment.spans.length)) {
@ -220,6 +220,6 @@ export const profileStore = defineStore({
}, },
}); });
export function useProfileStore(): any { export function useProfileStore(): Recordable {
return profileStore(store); return profileStore(store);
} }

View File

@ -233,6 +233,6 @@ export const selectorStore = defineStore({
}, },
}); });
export function useSelectorStore(): any { export function useSelectorStore(): Recordable {
return selectorStore(store); return selectorStore(store);
} }

View File

@ -73,7 +73,7 @@ export const topologyStore = defineStore({
this.nodes = data.nodes; this.nodes = data.nodes;
}, },
setTopology(data: { nodes: Node[]; calls: Call[] }) { setTopology(data: { nodes: Node[]; calls: Call[] }) {
const obj = {} as any; const obj = {} as Recordable;
const services = useSelectorStore().services; const services = useSelectorStore().services;
const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => { const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => {
if (!obj[next.id]) { if (!obj[next.id]) {
@ -302,8 +302,8 @@ export const topologyStore = defineStore({
return res.data; return res.data;
} }
const topo = res.data.data; const topo = res.data.data;
const calls = [] as any; const calls = [] as Call[];
const nodes = [] as any; const nodes = [] as Node[];
for (const key of Object.keys(topo)) { for (const key of Object.keys(topo)) {
calls.push(...topo[key].calls); calls.push(...topo[key].calls);
nodes.push(...topo[key].nodes); nodes.push(...topo[key].nodes);
@ -377,7 +377,7 @@ export const topologyStore = defineStore({
} }
const data = res.data.data; const data = res.data.data;
const metrics = Object.keys(data); const metrics = Object.keys(data);
this.nodes = this.nodes.map((d: Node | any) => { this.nodes = this.nodes.map((d: Node & Recordable) => {
for (const m of metrics) { for (const m of metrics) {
for (const val of data[m].values) { for (const val of data[m].values) {
if (d.id === val.id) { if (d.id === val.id) {
@ -410,6 +410,6 @@ export const topologyStore = defineStore({
}, },
}); });
export function useTopologyStore(): any { export function useTopologyStore(): Recordable {
return topologyStore(store); return topologyStore(store);
} }

View File

@ -31,9 +31,9 @@ interface TraceState {
traceList: Trace[]; traceList: Trace[];
traceSpans: Span[]; traceSpans: Span[];
currentTrace: Recordable<Trace>; currentTrace: Recordable<Trace>;
conditions: any; conditions: Recordable;
traceSpanLogs: any[]; traceSpanLogs: Recordable[];
selectorStore: any; selectorStore: Recordable;
} }
export const traceStore = defineStore({ export const traceStore = defineStore({
@ -55,7 +55,7 @@ export const traceStore = defineStore({
selectorStore: useSelectorStore(), selectorStore: useSelectorStore(),
}), }),
actions: { actions: {
setTraceCondition(data: any) { setTraceCondition(data: Recordable) {
this.conditions = { ...this.conditions, ...data }; this.conditions = { ...this.conditions, ...data };
}, },
setCurrentTrace(trace: Recordable<Trace>) { setCurrentTrace(trace: Recordable<Trace>) {
@ -171,7 +171,7 @@ export const traceStore = defineStore({
this.setTraceSpans(data || []); this.setTraceSpans(data || []);
return res.data; return res.data;
}, },
async getSpanLogs(params: any) { async getSpanLogs(params: Recordable) {
const res: AxiosResponse = await graphql.query("queryServiceLogs").params(params); const res: AxiosResponse = await graphql.query("queryServiceLogs").params(params);
if (res.data.errors) { if (res.data.errors) {
this.traceSpanLogs = []; this.traceSpanLogs = [];
@ -197,6 +197,6 @@ export const traceStore = defineStore({
}, },
}); });
export function useTraceStore(): any { export function useTraceStore(): Recordable {
return traceStore(store); return traceStore(store);
} }