mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
perf: 优化部分组件接口返回错误数据,页面会卡死的问题
This commit is contained in:
parent
f96a9c9d6f
commit
96def0107d
@ -27,7 +27,6 @@ axiosInstance.interceptors.response.use(
|
||||
return Promise.resolve(res.data)
|
||||
},
|
||||
(err: AxiosResponse) => {
|
||||
window['$message'].error('接口异常,请检查!')
|
||||
Promise.reject(err)
|
||||
}
|
||||
)
|
||||
|
@ -24,6 +24,7 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { isPreview } from '@/utils'
|
||||
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
|
||||
import isObject from 'lodash/isObject'
|
||||
|
||||
const props = defineProps({
|
||||
themeSetting: {
|
||||
@ -51,8 +52,9 @@ const option = computed(() => {
|
||||
// dataset 无法变更条数的补丁
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData, oldData) => {
|
||||
if (newData.dimensions.length !== oldData.dimensions.length) {
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
|
@ -23,6 +23,7 @@ import { useChartDataFetch } from '@/hooks'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { isPreview } from '@/utils'
|
||||
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
|
||||
import isObject from 'lodash/isObject'
|
||||
|
||||
const props = defineProps({
|
||||
themeSetting: {
|
||||
@ -50,7 +51,8 @@ const option = computed(() => {
|
||||
// dataset 无法变更条数的补丁
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData, oldData) => {
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
|
@ -24,6 +24,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { isPreview } from '@/utils'
|
||||
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
|
||||
import isObject from 'lodash/isObject'
|
||||
|
||||
const props = defineProps({
|
||||
themeSetting: {
|
||||
@ -51,7 +52,8 @@ const option = computed(() => {
|
||||
// dataset 无法变更条数的补丁
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData, oldData) => {
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
|
@ -14,7 +14,7 @@ import { mergeTheme } from '@/packages/public/chart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { isPreview } from '@/utils'
|
||||
import { isPreview, isArray } from '@/utils'
|
||||
|
||||
const props = defineProps({
|
||||
themeSetting: {
|
||||
@ -49,6 +49,7 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
if(!isArray(newData)) return
|
||||
dataSetHandle(newData)
|
||||
},
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import 'echarts-liquidfill/src/liquidFill.js'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
import { GridComponent } from 'echarts/components'
|
||||
import config from './config'
|
||||
import { isPreview, isString } from '@/utils'
|
||||
import { isPreview, isString, isNumber } from '@/utils'
|
||||
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
@ -75,6 +75,7 @@ const dataHandle = (newData: number | string) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
if(!isString(newData) && !isNumber(newData)) return
|
||||
props.chartConfig.option.series[0].data = [dataHandle(newData)]
|
||||
option.value = props.chartConfig.option
|
||||
},
|
||||
|
@ -50,7 +50,7 @@ watch(
|
||||
props.chartConfig.option.series[0].roseType = true
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
{ deep: false, immediate: true }
|
||||
)
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||
|
@ -20,7 +20,7 @@ import config, { includes, seriesItem } from './config'
|
||||
import { mergeTheme } from '@/packages/public/chart'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { isPreview } from '@/utils'
|
||||
import { isPreview, isArray } from '@/utils'
|
||||
import {
|
||||
DatasetComponent,
|
||||
GridComponent,
|
||||
@ -69,6 +69,7 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData, oldData) => {
|
||||
if (!isArray(newData)) return
|
||||
if (newData?.length !== oldData?.length) {
|
||||
replaceMergeArr.value = ['series']
|
||||
// eslint-disable-next-line vue/no-mutating-props
|
||||
|
Loading…
x
Reference in New Issue
Block a user