diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index c0c6647..ecd7683 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -9,6 +9,8 @@ import { isPreview, newFunctionHandle, intervalUnitHandle } from '@/utils' import { setOption } from '@/packages/public/chart' import { isNil } from 'lodash' + + // 获取类型 type ChartEditStoreType = typeof useChartEditStore @@ -60,7 +62,8 @@ export const useChartDataFetch = ( } = toRefs(targetComponent.request) // 非请求类型 - console.log(requestDataType.value !== RequestDataTypeEnum.AJAX) + + if (requestDataType.value !== RequestDataTypeEnum.AJAX) return try { @@ -70,13 +73,10 @@ export const useChartDataFetch = ( // requestOriginUrl 允许为空 const completePath = requestOriginUrl && requestOriginUrl.value + requestUrl.value if (!completePath) return - clearInterval(fetchInterval) const fetchFn = async () => { - console.log('看板编辑') const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.getRequestGlobalConfig)) - if (res) { try { const filter = targetComponent.filter @@ -93,10 +93,11 @@ export const useChartDataFetch = ( } // 普通初始化与组件交互处理监听 - watch( + + const stopWatch = watch( () => targetComponent.request.requestParams, () => { - fetchFn() + fetchFn() }, { immediate: true, @@ -104,6 +105,15 @@ export const useChartDataFetch = ( } ) + + if(chartEditStore.isEdit && !isPreview()){ + console.log(chartEditStore.isEdit,'是否编辑') + stopWatch(); + }else{ + console.log(chartEditStore.isEdit,'新增或者预览') + } + + // 定时时间 const time = targetInterval && !isNil(targetInterval.value) ? targetInterval.value : globalRequestInterval.value // 单位 @@ -126,7 +136,8 @@ export const useChartDataFetch = ( if (updateCallback) updateCallback(newData) }) : requestIntervalFn() - } else { + } + else { requestIntervalFn() } return { vChartRef } diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index c0df285..945f433 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -248,6 +248,7 @@ export interface ChartEditStoreType { [ChartEditStoreEnum.RECORD_CHART]?: RecordChartType [ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType [ChartEditStoreEnum.COMPONENT_LIST]: Array + isEdit?:Boolean } // 存储数据类型 diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 5ae93e9..1d05818 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -155,7 +155,8 @@ export const useChartEditStore = defineStore({ } }, // 图表数组(需存储给后端) - componentList: [] + componentList: [], + isEdit: true, }), getters: { getProjectInfo(): ProjectInfoType { @@ -193,6 +194,10 @@ export const useChartEditStore = defineStore({ this.componentList = [] }, + setEdit(booole:Boolean){ + this.isEdit = booole + }, + // * 获取需要存储的数据项 getStorageInfo(): ChartEditStorage { return { diff --git a/src/views/AI/components/history/index.vue b/src/views/AI/components/history/index.vue index 025829b..bd72a0c 100644 --- a/src/views/AI/components/history/index.vue +++ b/src/views/AI/components/history/index.vue @@ -43,6 +43,9 @@ import { onMounted, ref } from 'vue' import { projectListApi, deleteProjectApi, historyMessageRoomList, historyMessageRoomDel } from '@/api/path' import { useRouter } from 'vue-router' +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' + +const chartEditStore = useChartEditStore() let list = ref([]) let boardLsit = ref([]) @@ -63,7 +66,8 @@ const delProjectItem = async id => { } const getBoardInfo = id => { - router.push('/board/' + id) + chartEditStore.setEdit(true) + router.push({path:'/board/' + id}) } const formatFristIssue = value => { @@ -72,7 +76,10 @@ const formatFristIssue = value => { } //获取聊天记录list const messageList = async () => { - const res = await historyMessageRoomList() + const res = await historyMessageRoomList({ + current: 1, + size: 100, + }) list.value = res.data.records } //删除聊天记录 diff --git a/src/views/AI/index.vue b/src/views/AI/index.vue index cf70a48..9a7041b 100644 --- a/src/views/AI/index.vue +++ b/src/views/AI/index.vue @@ -109,6 +109,7 @@ const handlerBoard = async path => { const handlerPath = (path, index) => { history.value.fetchList() chartEditStore.setComponentList() + chartEditStore.setEdit(false) saveMessage(path) diff --git a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue index 313280c..1a4e508 100644 --- a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue @@ -46,7 +46,7 @@