From b9aa0e3cb9699d0ba4a6c161df749c777aaaa8cb Mon Sep 17 00:00:00 2001 From: zggmd Date: Tue, 2 Apr 2024 17:42:00 +0800 Subject: [PATCH 1/2] chore: chat page -> gpts chat debug page --- config/routes.js | 6 +++--- src/__constants.js | 2 +- src/pages/Chat/index.tsx | 1 + src/pages/ModelAppDetail/Header/index.tsx | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/routes.js b/config/routes.js index f8b9095..9834473 100644 --- a/config/routes.js +++ b/config/routes.js @@ -116,8 +116,8 @@ const routes = [ path: '/model-app/detail/:name', component: '@/pages/ModelAppDetail', }, - { - name: '对话管理', + process.env.NODE_ENV === 'production' ? undefined : { + name: 'GPTS chat debug (dev only)', path: '/chat', component: '@/pages/Chat', }, @@ -135,7 +135,7 @@ const routes = [ }, ], }, -]; +].filter(Boolean); const filterNameInProduction = routes => routes.map(route => ({ ...route, diff --git a/src/__constants.js b/src/__constants.js index e358413..1f695fb 100644 --- a/src/__constants.js +++ b/src/__constants.js @@ -149,7 +149,7 @@ export const DESCRIPTION_LENGTH_REG = constants.DESCRIPTION_LENGTH_REG; constants.FILES_API_ORIGIN = function applyThis() { return process.env.NODE_ENV === 'production' ? window.location.origin - : 'https://portal.172.22.96.136.nip.io'; + : 'https://portal.172.22.96.167.nip.io'; }.apply(constants); export const FILES_API_ORIGIN = constants.FILES_API_ORIGIN; diff --git a/src/pages/Chat/index.tsx b/src/pages/Chat/index.tsx index 9c28a70..b97ef76 100644 --- a/src/pages/Chat/index.tsx +++ b/src/pages/Chat/index.tsx @@ -63,6 +63,7 @@ const Chat: React.FC = props => { appName={appName as string} appNamespace={appNamespace as string} conversationId={selectedConversationId} + gpts isDark={qiankun?.theme?.isDark} onNewChat={onNewChat} refresh={refresh} diff --git a/src/pages/ModelAppDetail/Header/index.tsx b/src/pages/ModelAppDetail/Header/index.tsx index b0a3fbe..fce55f5 100644 --- a/src/pages/ModelAppDetail/Header/index.tsx +++ b/src/pages/ModelAppDetail/Header/index.tsx @@ -16,6 +16,7 @@ import { getUnifiedHistory } from '@tenx-ui/utils/es/UnifiedLink/index.prod'; import { Card } from 'antd'; import React, { useState } from 'react'; +import { IS_PROD } from '@/__constants'; import I18N from '@/utils/kiwiI18N'; import utils from '../../../utils/__utils'; @@ -241,6 +242,13 @@ const Header: React.FC = props => { key: 'delete', label: I18N.DataHandle.shanChu, }, + // 用于 gpts 那边的对话调试 + IS_PROD + ? null + : { + key: 'GTPS', + label: 'GPTS chat debug (dev only)', + }, ].filter(Boolean), onClick: ({ key }) => { switch (key) { @@ -278,6 +286,13 @@ const Header: React.FC = props => { ); break; } + case 'GTPS': { + !IS_PROD && + history.push( + `/chat?appNamespace=${data?.metadata?.namespace}&appName=${data?.metadata?.name}` + ); + break; + } // No default } }, From 1869cf5b3c7dd5acdbe4c45e79e683e812cfb8bf Mon Sep 17 00:00:00 2001 From: zggmd Date: Tue, 2 Apr 2024 17:43:43 +0800 Subject: [PATCH 2/2] fix: DatasetVersionDetail pageChange issue --- src/pages/DatasetVersionDetail/index.jsx | 49 +++++++++++++++--------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/pages/DatasetVersionDetail/index.jsx b/src/pages/DatasetVersionDetail/index.jsx index f535036..8f5955e 100644 --- a/src/pages/DatasetVersionDetail/index.jsx +++ b/src/pages/DatasetVersionDetail/index.jsx @@ -122,7 +122,7 @@ class DatasetVersionDetail$$Page extends React.Component { ) { this.setState({ versionDetail: - this.props.useGetVersionedDataset.data?.VersionedDataset?.getVersionedDataset, + this.props.useGetVersionedDataset.data?.VersionedDataset?.getVersionedDataset, }); } } @@ -147,16 +147,16 @@ class DatasetVersionDetail$$Page extends React.Component { ]; const body = isEdit ? { - updateLines: [ - { - lineNumber: this.state.addCsvOriginData?.lineNumber, - values: line, - }, - ], - } + updateLines: [ + { + lineNumber: this.state.addCsvOriginData?.lineNumber, + values: line, + }, + ], + } : { - newLines: [line], - }; + newLines: [line], + }; const errorMsg = isEdit ? '编辑数据失败' : '新增数据失败'; const res = await this.updateCsv(body, errorMsg); if (res.status === 200) { @@ -418,7 +418,7 @@ class DatasetVersionDetail$$Page extends React.Component { this.state.cvsData?.current }&size=10&bucket=${ this.utils.getAuthData?.()?.project - }&bucketPath=${this.getBucketPath()}&fileName=${encodeURIComponent(this.state.fileData?.path)}`, + }&bucketPath=${this.getBucketPath()}&fileName=${this.state.fileData?.path}`, { headers: { Authorization: this.utils.getAuthorization(), @@ -493,6 +493,19 @@ class DatasetVersionDetail$$Page extends React.Component { }); } + onCsvPageChange(page, pageSize) { + // 页码或 pageSize 改变的回调 + this.setState( + { + cvsData: { + ...this.state.cvsData, + current: page, + }, + }, + this.getFile.bind(this) + ); + } + onDatasourceChange(v) { this.setState({ addFileDatasource: v, @@ -579,9 +592,9 @@ class DatasetVersionDetail$$Page extends React.Component { ) { this.fileUploadSuccessList = []; this.state.upload.uploadThis?.state?.fileList?.length >= 2 && - this.utils.notification.success({ - message: '所有文件上传完成', - }); + this.utils.notification.success({ + message: '所有文件上传完成', + }); this.clearFileBuffer(); this.setState({ addFileLoading: false, @@ -618,9 +631,9 @@ class DatasetVersionDetail$$Page extends React.Component { ) .catch(e => { errorMsg && - this.utils.notification.warn({ - message: errorMsg, - }); + this.utils.notification.warn({ + message: errorMsg, + }); }); return res; } @@ -1172,7 +1185,7 @@ class DatasetVersionDetail$$Page extends React.Component { pagination={{ current: __$$eval(() => this.state.cvsData?.current || 1), onChange: function () { - return this.onFilePageChange.apply( + return this.onCsvPageChange.apply( this, Array.prototype.slice.call(arguments).concat([]) );