mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 20:43:14 +00:00
fix: update types
This commit is contained in:
parent
2fb39ca82f
commit
a836ae20e9
@ -14,12 +14,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { BarSeriesOption, LineSeriesOption } from "echarts/charts";
|
import {
|
||||||
|
BarSeriesOption,
|
||||||
|
LineSeriesOption,
|
||||||
|
HeatmapSeriesOption,
|
||||||
|
PieSeriesOption,
|
||||||
|
} from "echarts/charts";
|
||||||
import {
|
import {
|
||||||
TitleComponentOption,
|
TitleComponentOption,
|
||||||
TooltipComponentOption,
|
TooltipComponentOption,
|
||||||
GridComponentOption,
|
GridComponentOption,
|
||||||
DatasetComponentOption,
|
DatasetComponentOption,
|
||||||
|
LegendComponentOption,
|
||||||
} from "echarts/components";
|
} from "echarts/components";
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import { useTimeoutFn } from "./useTimeout";
|
import { useTimeoutFn } from "./useTimeout";
|
||||||
@ -37,6 +43,9 @@ export type ECOption = echarts.ComposeOption<
|
|||||||
| TooltipComponentOption
|
| TooltipComponentOption
|
||||||
| GridComponentOption
|
| GridComponentOption
|
||||||
| DatasetComponentOption
|
| DatasetComponentOption
|
||||||
|
| LegendComponentOption
|
||||||
|
| HeatmapSeriesOption
|
||||||
|
| PieSeriesOption
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export function useECharts(
|
export function useECharts(
|
||||||
@ -46,7 +55,7 @@ export function useECharts(
|
|||||||
const getDarkMode = computed(() => {
|
const getDarkMode = computed(() => {
|
||||||
return theme === "default" ? "light" : theme;
|
return theme === "default" ? "light" : theme;
|
||||||
});
|
});
|
||||||
let chartInstance: echarts.ECharts | null = null;
|
let chartInstance: Nullable<echarts.ECharts> = null;
|
||||||
let resizeFn: Fn = resize;
|
let resizeFn: Fn = resize;
|
||||||
const cacheOptions = ref({}) as Ref<ECOption>;
|
const cacheOptions = ref({}) as Ref<ECOption>;
|
||||||
let removeResizeFn: Fn = () => ({});
|
let removeResizeFn: Fn = () => ({});
|
||||||
@ -128,7 +137,7 @@ export function useECharts(
|
|||||||
chartInstance = null;
|
chartInstance = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
function getInstance(): echarts.ECharts | null {
|
function getInstance(): Nullable<echarts.ECharts> {
|
||||||
if (!chartInstance) {
|
if (!chartInstance) {
|
||||||
initCharts(getDarkMode.value as "default");
|
initCharts(getDarkMode.value as "default");
|
||||||
}
|
}
|
||||||
|
@ -32,22 +32,6 @@ export function isObject(val: unknown): val is Record<any, any> {
|
|||||||
return val !== null && is(val, "Object");
|
return val !== null && is(val, "Object");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isEmpty<T = unknown>(val: any): val is T {
|
|
||||||
if (isArray(val) || isString(val)) {
|
|
||||||
return val.length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val instanceof Map || val instanceof Set) {
|
|
||||||
return val.size === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isObject(val)) {
|
|
||||||
return Object.keys(val).length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isDate(val: unknown): val is Date {
|
export function isDate(val: unknown): val is Date {
|
||||||
return is(val, "Date");
|
return is(val, "Date");
|
||||||
}
|
}
|
||||||
@ -81,7 +65,7 @@ export function isString(val: unknown): val is string {
|
|||||||
return is(val, "String");
|
return is(val, "String");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFunction(val: unknown): boolean {
|
export function isFunction(val: unknown): val is () => unknown {
|
||||||
return typeof val === "function";
|
return typeof val === "function";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +77,8 @@ export function isRegExp(val: unknown): val is RegExp {
|
|||||||
return is(val, "RegExp");
|
return is(val, "RegExp");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArray(val: any): boolean {
|
export function isArray(val: unknown): boolean {
|
||||||
return val && Array.isArray(val);
|
return Array.isArray(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isWindow(val: unknown): val is Window {
|
export function isWindow(val: unknown): val is Window {
|
||||||
|
Loading…
Reference in New Issue
Block a user