|
|
|
@ -1,5 +1,5 @@
|
|
|
|
'use client'
|
|
|
|
'use client'
|
|
|
|
import React, { useState } from 'react'
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear'
|
|
|
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
@ -9,6 +9,7 @@ import type { Item } from '@/app/components/base/select'
|
|
|
|
import { SimpleSelect } from '@/app/components/base/select'
|
|
|
|
import { SimpleSelect } from '@/app/components/base/select'
|
|
|
|
import { TIME_PERIOD_MAPPING } from '@/app/components/app/log/filter'
|
|
|
|
import { TIME_PERIOD_MAPPING } from '@/app/components/app/log/filter'
|
|
|
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
|
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
|
|
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
|
|
|
|
|
|
|
|
|
|
dayjs.extend(quarterOfYear)
|
|
|
|
dayjs.extend(quarterOfYear)
|
|
|
|
|
|
|
|
|
|
|
|
@ -21,12 +22,44 @@ export type IChartViewProps = {
|
|
|
|
headerRight: React.ReactNode
|
|
|
|
headerRight: React.ReactNode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let state = 0
|
|
|
|
|
|
|
|
const useIframeRedirection = () => {
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
// 监听父级指定操作
|
|
|
|
|
|
|
|
const handler = (event: MessageEvent) => {
|
|
|
|
|
|
|
|
// if (event.origin !== "https://gcgj.ngsk.tech:7001") return;
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
event.data.type === 'CHART_VIEW_REDIRECT'
|
|
|
|
|
|
|
|
&& event.data.redirectUrl
|
|
|
|
|
|
|
|
&& state < 3 // 防止无限重定向
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
state++
|
|
|
|
|
|
|
|
router.replace(event.data.redirectUrl)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 首页初始化完成后提示iframe操作
|
|
|
|
|
|
|
|
window.parent.postMessage(
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type: 'CHART_VIEW',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'*',
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('message', handler)
|
|
|
|
|
|
|
|
return () => window.removeEventListener('message', handler)
|
|
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function ChartView({ appId, headerRight }: IChartViewProps) {
|
|
|
|
export default function ChartView({ appId, headerRight }: IChartViewProps) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const appDetail = useAppStore(state => state.appDetail)
|
|
|
|
const appDetail = useAppStore(state => state.appDetail)
|
|
|
|
const isChatApp = appDetail?.mode !== 'completion' && appDetail?.mode !== 'workflow'
|
|
|
|
const isChatApp = appDetail?.mode !== 'completion' && appDetail?.mode !== 'workflow'
|
|
|
|
const isWorkflow = appDetail?.mode === 'workflow'
|
|
|
|
const isWorkflow = appDetail?.mode === 'workflow'
|
|
|
|
const [period, setPeriod] = useState<PeriodParams>({ name: t('appLog.filter.period.last7days'), query: { start: today.subtract(7, 'day').startOf('day').format(queryDateFormat), end: today.endOf('day').format(queryDateFormat) } })
|
|
|
|
const [period, setPeriod] = useState<PeriodParams>({ name: t('appLog.filter.period.last7days'), query: { start: today.subtract(7, 'day').startOf('day').format(queryDateFormat), end: today.endOf('day').format(queryDateFormat) } })
|
|
|
|
|
|
|
|
useIframeRedirection()
|
|
|
|
|
|
|
|
|
|
|
|
const onSelect = (item: Item) => {
|
|
|
|
const onSelect = (item: Item) => {
|
|
|
|
if (item.value === -1) {
|
|
|
|
if (item.value === -1) {
|
|
|
|
|