提交 2b798ac2 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 95c96252
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.6.1", "@ant-design/icons": "^5.6.1",
"@fortaine/fetch-event-source": "^3.0.6", "@fortaine/fetch-event-source": "^3.0.6",
"@tanstack/react-query": "^5.67.1", "@tanstack/react-query": "^5.69.0",
"@tanstack/react-query-devtools": "^5.69.0", "@tanstack/react-query-devtools": "^5.69.0",
"antd": "^5.24.4", "antd": "^5.24.4",
"axios": "^1.8.3", "axios": "^1.8.3",
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.6.1", "@ant-design/icons": "^5.6.1",
"@fortaine/fetch-event-source": "^3.0.6", "@fortaine/fetch-event-source": "^3.0.6",
"@tanstack/react-query": "^5.67.1", "@tanstack/react-query": "^5.69.0",
"@tanstack/react-query-devtools": "^5.69.0", "@tanstack/react-query-devtools": "^5.69.0",
"antd": "^5.24.4", "antd": "^5.24.4",
"axios": "^1.8.3", "axios": "^1.8.4",
"blueimp-md5": "^2.19.0", "blueimp-md5": "^2.19.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"lucide-react": "^0.477.0", "lucide-react": "^0.477.0",
......
...@@ -712,7 +712,7 @@ export function getMyList(params?: Partial<{ page: number; 'per-page': number }> ...@@ -712,7 +712,7 @@ export function getMyList(params?: Partial<{ page: number; 'per-page': number }>
// }, // },
// }, // },
// }) // })
return httpRequest.get('/api/bi/v1/data/my/list', { params }) return httpRequest.get('/api/resource/bi/v1/data/my/list', { params })
} }
// 查看字段详情 // 查看字段详情
...@@ -1133,7 +1133,7 @@ export function getMyField() { ...@@ -1133,7 +1133,7 @@ export function getMyField() {
// }, // },
// ], // ],
// }) // })
return httpRequest.get('/api/bi/v1/data/my/field-detail') return httpRequest.get('/api/resource/bi/v1/data/my/field-detail')
} }
// 我的数据集列表 // 我的数据集列表
...@@ -1171,5 +1171,5 @@ export function getChartList(params?: Partial<{ page: number; 'per-page': number ...@@ -1171,5 +1171,5 @@ export function getChartList(params?: Partial<{ page: number; 'per-page': number
], ],
}, },
}) })
return httpRequest.get('/api/bi/v1/data/my/list', { params }) return httpRequest.get('/api/resource/bi/v1/data/my/list', { params })
} }
...@@ -31,7 +31,7 @@ const AppList = forwardRef<AppListRef, AppListProps>( ...@@ -31,7 +31,7 @@ const AppList = forwardRef<AppListRef, AppListProps>(
queryFn: async () => { queryFn: async () => {
return fetchApi ? await fetchApi(queryParams) : { list: dataSource || [], total: dataSource?.length || 0 } return fetchApi ? await fetchApi(queryParams) : { list: dataSource || [], total: dataSource?.length || 0 }
}, },
initialData: (): any => { placeholderData: (): any => {
return { list: dataSource || [], total: dataSource?.length || 0 } return { list: dataSource || [], total: dataSource?.length || 0 }
}, },
enabled: !!fetchApi, enabled: !!fetchApi,
......
...@@ -20,12 +20,7 @@ export const MessageItem = ({ message }: { message: AIMessage }) => { ...@@ -20,12 +20,7 @@ export const MessageItem = ({ message }: { message: AIMessage }) => {
} }
export default function AIChat() { export default function AIChat() {
const [collapsed, setCollapsed] = useState(true) const { ai, setAI, options, post, messages, isLoading, collapsed, toggleCollapsed } = useAIStore()
const toggleCollapsed = () => {
setCollapsed(!collapsed)
}
const { ai, setAI, options, post, messages, isLoading } = useAIStore()
const [content, setContent] = useState('') const [content, setContent] = useState('')
......
import { lazy, ReactNode } from 'react' import { lazy, ReactNode } from 'react'
import { Card, Flex } from 'antd' import { Card, Flex } from 'antd'
import AIChat from '@/components/ai/AIChat'
import DataRender from './DataRender' import DataRender from './DataRender'
import { useDataQuery } from '@/hooks/useQuery' import { useDataQuery } from '@/hooks/useQuery'
const ViewDataFiledButtonModal = lazy(() => import('./ViewDataFiledButtonModal')) const ViewDataFiledButtonModal = lazy(() => import('./ViewDataFieldButtonModal'))
export default function DataWrap({ export default function DataWrap({
hasAI = true,
title, title,
headerRender, headerRender,
buttons, buttons,
...@@ -17,7 +15,6 @@ export default function DataWrap({ ...@@ -17,7 +15,6 @@ export default function DataWrap({
buttons?: ReactNode buttons?: ReactNode
headerRender?: (data: any) => ReactNode headerRender?: (data: any) => ReactNode
empty?: ReactNode empty?: ReactNode
hasAI?: boolean
}) { }) {
const { data, isPending } = useDataQuery() const { data, isPending } = useDataQuery()
...@@ -53,7 +50,6 @@ export default function DataWrap({ ...@@ -53,7 +50,6 @@ export default function DataWrap({
</> </>
)} )}
</Card> </Card>
{hasAI && <AIChat />}
</Flex> </Flex>
) )
} }
...@@ -19,7 +19,7 @@ export default function ViewDataButtonModal({ data }: { data: any }) { ...@@ -19,7 +19,7 @@ export default function ViewDataButtonModal({ data }: { data: any }) {
const workbook = read(res.data) const workbook = read(res.data)
const sheetName = workbook.SheetNames[0] const sheetName = workbook.SheetNames[0]
const worksheet = workbook.Sheets[sheetName] const worksheet = workbook.Sheets[sheetName]
const jsonData = utils.sheet_to_json(worksheet) const jsonData = utils.sheet_to_json(worksheet, { defval: '' })
setDataset(jsonData) setDataset(jsonData)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
} from 'lucide-react' } from 'lucide-react'
import { Menu, MenuProps } from 'antd' import { Menu, MenuProps } from 'antd'
import './DataLayout.scss' import './DataLayout.scss'
import AIChat from '../ai/AIChat'
type MyMenuItem = { type MyMenuItem = {
name: string name: string
...@@ -200,6 +201,7 @@ export default function DataLayout() { ...@@ -200,6 +201,7 @@ export default function DataLayout() {
<div className="data-layout-container"> <div className="data-layout-container">
<Outlet /> <Outlet />
</div> </div>
<AIChat></AIChat>
</div> </div>
) )
} }
...@@ -3,6 +3,8 @@ import { useQuery } from '@tanstack/react-query' ...@@ -3,6 +3,8 @@ import { useQuery } from '@tanstack/react-query'
import { getUser, getMapList, getMyList, getMyField } from '@/api/base' import { getUser, getMapList, getMyList, getMyField } from '@/api/base'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useMapStore } from '@/stores/map' import { useMapStore } from '@/stores/map'
import axios from 'axios'
import { read, utils } from 'xlsx'
export function useUserQuery() { export function useUserQuery() {
const { setUser } = useUserStore() const { setUser } = useUserStore()
...@@ -40,26 +42,32 @@ export function useDataQuery() { ...@@ -40,26 +42,32 @@ export function useDataQuery() {
return getMyList({ page: 1, 'per-page': 1000 }) return getMyList({ page: 1, 'per-page': 1000 })
}, },
select: (res) => res.data, select: (res) => res.data,
initialData: (): any => { placeholderData: (): any => {
return { data: { total: 0, list: [], title: [] } } return { data: { total: 0, list: [], title: [] } }
}, },
}) })
// useEffect(() => { useEffect(() => {
// if (query.data) { if (query.data?.info) {
// localStorage.setItem('dataset', JSON.stringify(query.data)) const file = query.data.info.source
// } axios(file.url, { responseType: 'arraybuffer' }).then((res) => {
// }, [query.data]) const workbook = read(res.data)
const sheetName = workbook.SheetNames[0]
const worksheet = workbook.Sheets[sheetName]
const jsonData = utils.sheet_to_json(worksheet, { defval: '' })
localStorage.setItem('dataset', JSON.stringify(jsonData))
})
}
}, [query.data])
return query return query
} }
// 查看字段详情
export function useDataFieldQuery() { export function useDataFieldQuery() {
const query = useQuery({ const query = useQuery({
queryKey: ['dataFiled'], queryKey: ['dataFiled'],
queryFn: getMyField, queryFn: getMyField,
select: (res) => res.data, select: (res) => res.data,
initialData: () => { placeholderData: (): any => {
return { data: [] } return { data: [] }
}, },
}) })
......
...@@ -6,7 +6,13 @@ import { ConfigProvider } from 'antd' ...@@ -6,7 +6,13 @@ import { ConfigProvider } from 'antd'
import zhCN from 'antd/locale/zh_CN' import zhCN from 'antd/locale/zh_CN'
import App from './App.tsx' import App from './App.tsx'
// import { ReactQueryDevtools } from '@tanstack/react-query-devtools' // import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
const queryClient = new QueryClient() const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 10,
},
},
})
const antdTheme = { const antdTheme = {
cssVar: true, cssVar: true,
......
...@@ -12,7 +12,7 @@ export default function ButtonModal() { ...@@ -12,7 +12,7 @@ export default function ButtonModal() {
const checked = Form.useWatch('checked', form) const checked = Form.useWatch('checked', form)
const [step, setStep] = useState<number>(null) const [step, setStep] = useState<number>(-1)
const steps = [ const steps = [
{ {
......
...@@ -3,12 +3,12 @@ import type { CreateDatasetParams } from './types' ...@@ -3,12 +3,12 @@ import type { CreateDatasetParams } from './types'
// 创建内置数据集 // 创建内置数据集
export function createDataset(data: CreateDatasetParams) { export function createDataset(data: CreateDatasetParams) {
return httpRequest.post('/api/bi/v1/data/built-in/create', data) return httpRequest.post('/api/resource/bi/v1/data/built-in/create', data)
} }
// 删除内置数据集 // 删除内置数据集
export function deleteDataset(data: { id: string }) { export function deleteDataset(data: { id: string }) {
return httpRequest.post('/api/bi/v1/data/built-in/delete', data) return httpRequest.post('/api/resource/bi/v1/data/built-in/delete', data)
} }
// 内置数据集列表 // 内置数据集列表
...@@ -23,5 +23,5 @@ export function getDatasetList( ...@@ -23,5 +23,5 @@ export function getDatasetList(
'per-page': number 'per-page': number
}> }>
) { ) {
return httpRequest.get('/api/bi/v1/data/built-in/list', { params }) return httpRequest.get('/api/resource/bi/v1/data/built-in/list', { params })
} }
...@@ -12,10 +12,10 @@ export function getDatasetList( ...@@ -12,10 +12,10 @@ export function getDatasetList(
'per-page': number 'per-page': number
}> }>
) { ) {
return httpRequest.get('/api/bi/v1/data/built-in/list', { params }) return httpRequest.get('/api/resource/bi/v1/data/built-in/list', { params })
} }
// 复制数据集 // 复制数据集
export function copyDataset(data: { id: string; name: string; force: string }) { export function copyDataset(data: { id: string; name: string; force: string }) {
return httpRequest.post('/api/bi/v1/data/my/copy-built-in', data) return httpRequest.post('/api/resource/bi/v1/data/my/copy-built-in', data)
} }
...@@ -34,7 +34,6 @@ export default function DataWriteMy() { ...@@ -34,7 +34,6 @@ export default function DataWriteMy() {
return ( return (
<DataWrap <DataWrap
title="我的数据集" title="我的数据集"
hasAI={false}
headerRender={(data) => ( headerRender={(data) => (
<Flex justify="space-between" align="middle" style={{ marginBottom: '20px' }}> <Flex justify="space-between" align="middle" style={{ marginBottom: '20px' }}>
<h4>数据集名称:{data.info.name}</h4> <h4>数据集名称:{data.info.name}</h4>
......
...@@ -2,5 +2,5 @@ import httpRequest from '@/utils/axios' ...@@ -2,5 +2,5 @@ import httpRequest from '@/utils/axios'
// 导入我的数据集 // 导入我的数据集
export function importDataset(data: { name: string; file: string }) { export function importDataset(data: { name: string; file: string }) {
return httpRequest.post('/api/bi/v1/data/my/import', data) return httpRequest.post('/api/resource/bi/v1/data/my/import', data)
} }
...@@ -33,11 +33,9 @@ export default function DataWriteUpload() { ...@@ -33,11 +33,9 @@ export default function DataWriteUpload() {
const workbook = read(data) const workbook = read(data)
const sheetName = workbook.SheetNames[0] const sheetName = workbook.SheetNames[0]
const worksheet = workbook.Sheets[sheetName] const worksheet = workbook.Sheets[sheetName]
const jsonData = utils.sheet_to_json(worksheet) const jsonData = utils.sheet_to_json(worksheet, { defval: '' })
setDataset(jsonData) setDataset(jsonData)
localStorage.setItem('dataset', JSON.stringify(jsonData))
return false return false
}, },
} }
......
...@@ -6,7 +6,9 @@ interface AIState { ...@@ -6,7 +6,9 @@ interface AIState {
options: AIOption[] options: AIOption[]
messages: AIMessage[] messages: AIMessage[]
isLoading: boolean isLoading: boolean
collapsed: boolean
setAI: (ai: string) => void setAI: (ai: string) => void
toggleCollapsed: () => void
post: (data: AIData) => Promise<void> post: (data: AIData) => Promise<void>
} }
...@@ -15,16 +17,22 @@ export const useAIStore = create<AIState>((set, get) => ({ ...@@ -15,16 +17,22 @@ export const useAIStore = create<AIState>((set, get) => ({
options: AI_OPTIONS, options: AI_OPTIONS,
messages: [], messages: [],
isLoading: false, isLoading: false,
collapsed: false,
setAI: (ai) => { setAI: (ai) => {
localStorage.setItem('ai', ai) localStorage.setItem('ai', ai)
set({ ai }) set({ ai })
}, },
toggleCollapsed: () => {
set((state) => ({ collapsed: !state.collapsed }))
},
post: async (data) => { post: async (data) => {
const { ai, messages } = get() const { ai, messages } = get()
set({ isLoading: true, messages: [...messages, ...data.messages.filter((item) => item.role !== 'system')] }) set({
collapsed: true,
isLoading: true,
messages: [...messages, ...data.messages.filter((item) => item.role !== 'system')],
})
try { try {
await aiService.post(ai, data, { await aiService.post(ai, data, {
......
...@@ -10,12 +10,12 @@ export default defineConfig({ ...@@ -10,12 +10,12 @@ export default defineConfig({
open: true, open: true,
host: 'dev.ezijing.com', host: 'dev.ezijing.com',
proxy: { proxy: {
'/api/bi': { // '/api/resource/bi': {
target: 'https://saas-lab.ezijing.com', // target: 'https://saas-lab.ezijing.com',
changeOrigin: true, // changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/bi/, '/api/resource/bi'), // rewrite: (path) => path.replace(/^\/api\/bi/, '/api/resource/bi'),
}, // },
// '/api/bi': 'https://saas-lab.ezijing.com/api/resource/bi', // '/api/resource/bi': 'https://saas-lab.ezijing.com/api/resource/bi',
'/api': 'https://saas-lab.ezijing.com', '/api': 'https://saas-lab.ezijing.com',
}, },
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论