fix: types

This commit is contained in:
Fine 2023-04-06 09:51:59 +08:00
parent 59bfce472d
commit bdd4353b0a
10 changed files with 26 additions and 24 deletions

View File

@ -262,7 +262,7 @@ export function useQueryPodsMetrics(
export function usePodsSource( export function usePodsSource(
pods: Array<Instance | Endpoint>, pods: Array<Instance | Endpoint>,
resp: { errors: string; data: { [key: string]: any } }, resp: { errors: string; data: Recordable },
config: { config: {
metrics: string[]; metrics: string[];
metricTypes: string[]; metricTypes: string[];

View File

@ -85,9 +85,11 @@ limitations under the License. -->
function getPathNames() { function getPathNames() {
const p = route.params; const p = route.params;
// get names
// set names
if (appStore.pathNames.length && p.layerId === appStore.pathNames[0].layerId) { if (appStore.pathNames.length && p.layerId === appStore.pathNames[0].layerId) {
const arr = [...appStore.pathNames, p]; const arr = [...appStore.pathNames, p];
const list = deduplication(arr, ["layerId", "entity", "name"]); const list = deduplication(arr, ["layerId", "entity", "name"]);
appStore.setPathNames(list); appStore.setPathNames(list);
} else { } else {

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;

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

@ -74,7 +74,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,7 +92,7 @@ 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 | any)[], next: Call | any) => {
if (param[next.targetId + next.sourceId]) { if (param[next.targetId + next.sourceId]) {
next.lowerArc = true; next.lowerArc = true;
@ -182,6 +182,6 @@ export const networkProfilingStore = defineStore({
}, },
}); });
export function useNetworkProfilingStore(): any { export function useNetworkProfilingStore(): Recordable {
return networkProfilingStore(store); return networkProfilingStore(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]) {

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() {
return traceStore(store); return traceStore(store);
} }

2
src/types/app.d.ts vendored
View File

@ -44,6 +44,6 @@ export type EventParams = {
dataType: string; dataType: string;
value: number | Array; value: number | Array;
color: string; color: string;
event: any; event: Record<string, T>;
dataIndex: number; dataIndex: number;
}; };

View File

@ -55,8 +55,8 @@ export interface SegmentSpan {
component: string; component: string;
isError: boolean; isError: boolean;
layer: string; layer: string;
tags: any[]; tags: Recordable[];
logs: any[]; logs: Recordable[];
} }
export interface ProfileTaskCreationRequest { export interface ProfileTaskCreationRequest {

View File

@ -71,7 +71,7 @@ limitations under the License. -->
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineEmits, defineProps */ /*global defineEmits, defineProps, Recordable */
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const props = defineProps({ const props = defineProps({
type: { type: String, default: "TRACE" }, type: { type: String, default: "TRACE" },
@ -118,7 +118,7 @@ limitations under the License. -->
emit("update", { tagsMap, tagsList: tagsList.value }); emit("update", { tagsMap, tagsList: tagsList.value });
} }
async function fetchTagKeys() { async function fetchTagKeys() {
let resp: any = {}; let resp: Recordable = {};
if (props.type === "TRACE") { if (props.type === "TRACE") {
resp = await traceStore.getTagKeys(); resp = await traceStore.getTagKeys();
} else { } else {
@ -137,7 +137,7 @@ limitations under the License. -->
async function fetchTagValues() { async function fetchTagValues() {
const param = tags.value.split("=")[0]; const param = tags.value.split("=")[0];
let resp: any = {}; let resp: Recordable = {};
if (props.type === "TRACE") { if (props.type === "TRACE") {
resp = await traceStore.getTagValues(param); resp = await traceStore.getTagValues(param);
} else { } else {