12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import type { DataSource } from "../types";
- import { defaultsDeep } from "lodash-es";
- import { containerDefaultConfig, chartDefaultConfig } from "../config";
- import { EChartsOption } from "echarts";
- import { PropType } from "vue";
- import { DataSourceType } from "../chartEnum";
- export function getNormalizedContainer(config: Record<string, any>) {
- return defaultsDeep(config, containerDefaultConfig);
- }
- export function getNormalizedChart(config: EChartsOption) {
- return defaultsDeep(config, chartDefaultConfig);
- }
- export const dataSource = {
- type: Object as PropType<DataSource>,
- default: () => ({
- sourceType: DataSourceType.STATIC,
- data: [],
- url: "",
- method: "GET",
- params: {},
- headers: {},
- refreshTime: 0,
- dataProcess: () => [],
- }),
- }
- export const cllJsCode = (code: string, param: string): Promise<any> => {
-
- return new Promise((resove, reject) => {
-
- const blob = new Blob([`
- self.onmessage = function(e) {
- self.postMessage((${code}).call(null, e.data));
- }
- `], { type: 'application/javascript' });
- const worker = new Worker(URL.createObjectURL(blob));
-
- worker.postMessage(JSON.parse(param));
- worker.onmessage = (e) => {
- worker.terminate();
- resove(e.data);
- }
- worker.onerror = (e) => {
- worker.terminate();
- reject(e);
- }
- });
- }
|