Merge branch 'feature/tool_yjp' into release/v0.2.7
This commit is contained in:
@@ -1990,6 +1990,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
|||||||
marketUrlPlaceholder: 'Market URL',
|
marketUrlPlaceholder: 'Market URL',
|
||||||
marketCopy: 'Copy',
|
marketCopy: 'Copy',
|
||||||
marketApiKeyOptional: 'Optional',
|
marketApiKeyOptional: 'Optional',
|
||||||
|
marketApiKeyRequired: 'API Key is required',
|
||||||
marketApiKeyExtra: 'Some markets require an API Key to access the full service list',
|
marketApiKeyExtra: 'Some markets require an API Key to access the full service list',
|
||||||
marketApiKeyPlaceholder: 'Enter API Key to access more services',
|
marketApiKeyPlaceholder: 'Enter API Key to access more services',
|
||||||
marketConnectionStatus: 'Connection Status',
|
marketConnectionStatus: 'Connection Status',
|
||||||
|
|||||||
@@ -1986,6 +1986,7 @@ export const zh = {
|
|||||||
marketUrlPlaceholder: '市场地址',
|
marketUrlPlaceholder: '市场地址',
|
||||||
marketCopy: '复制',
|
marketCopy: '复制',
|
||||||
marketApiKeyOptional: '可选',
|
marketApiKeyOptional: '可选',
|
||||||
|
marketApiKeyRequired: '请输入 API Key',
|
||||||
marketApiKeyExtra: '部分市场需要 API Key 才能获取完整的服务列表',
|
marketApiKeyExtra: '部分市场需要 API Key 才能获取完整的服务列表',
|
||||||
marketApiKeyPlaceholder: '输入 API Key 以获取更多服务',
|
marketApiKeyPlaceholder: '输入 API Key 以获取更多服务',
|
||||||
marketConnectionStatus: '连接状态',
|
marketConnectionStatus: '连接状态',
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ const Market: React.FC<{ getStatusTag?: (status: string) => ReactNode }> = () =>
|
|||||||
if (!source) return;
|
if (!source) return;
|
||||||
try {
|
try {
|
||||||
const config: any = await getMarketConfig(sourceId);
|
const config: any = await getMarketConfig(sourceId);
|
||||||
|
console.log('获取到的配置数据:', config);
|
||||||
marketConfigModalRef.current?.handleOpen({
|
marketConfigModalRef.current?.handleOpen({
|
||||||
...source,
|
...source,
|
||||||
connected: config?.status === 1,
|
connected: config?.status === 1,
|
||||||
@@ -431,7 +432,7 @@ const Market: React.FC<{ getStatusTag?: (status: string) => ReactNode }> = () =>
|
|||||||
dataLength={mcpList.length}
|
dataLength={mcpList.length}
|
||||||
next={loadMore}
|
next={loadMore}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
loader={<Skeleton active paragraph={{ rows: 2 }} className="rb:mt-4" />}
|
loader={null}
|
||||||
scrollableTarget="mcpScrollableDiv"
|
scrollableTarget="mcpScrollableDiv"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [currentSource, setCurrentSource] = useState<MarketSource | null>(null);
|
const [currentSource, setCurrentSource] = useState<MarketSource | null>(null);
|
||||||
const [showApiKey, setShowApiKey] = useState(false);
|
const [showApiKey, setShowApiKey] = useState(false);
|
||||||
|
const [initialValues, setInitialValues] = useState<{ token: string }>({ token: '' });
|
||||||
const formValues = Form.useWatch([], form);
|
const formValues = Form.useWatch([], form);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
@@ -45,16 +46,29 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
setCurrentSource(null);
|
setCurrentSource(null);
|
||||||
setShowApiKey(false);
|
setShowApiKey(false);
|
||||||
|
setInitialValues({ token: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpen = (source: MarketSource) => {
|
const handleOpen = (source: MarketSource) => {
|
||||||
|
console.log('Modal 接收到的数据:', source);
|
||||||
setCurrentSource(source);
|
setCurrentSource(source);
|
||||||
form.setFieldsValue({
|
setInitialValues({ token: source.token || '' });
|
||||||
token: source.token || '',
|
|
||||||
});
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAfterOpenChange = (open: boolean) => {
|
||||||
|
if (open && currentSource) {
|
||||||
|
// Modal 完全打开后再设置表单值,使用 setTimeout 确保在下一个事件循环
|
||||||
|
setTimeout(() => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
token: currentSource.token || '',
|
||||||
|
});
|
||||||
|
console.log('Modal 打开后设置表单值:', { token: currentSource.token || '' });
|
||||||
|
console.log('当前表单所有值:', form.getFieldsValue());
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
form
|
form
|
||||||
.validateFields()
|
.validateFields()
|
||||||
@@ -103,7 +117,7 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 检查是否可以保存:token 字段必须有值
|
// 检查是否可以保存:token 字段必须有值
|
||||||
const canSave = formValues?.token && formValues.token.trim().length > 0;
|
const canSave = formValues?.token?.trim().length > 0;
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
handleOpen,
|
handleOpen,
|
||||||
@@ -117,6 +131,7 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
title={t('tool.marketConfig', { name: currentSource.name })}
|
title={t('tool.marketConfig', { name: currentSource.name })}
|
||||||
open={visible}
|
open={visible}
|
||||||
onCancel={handleClose}
|
onCancel={handleClose}
|
||||||
|
afterOpenChange={handleAfterOpenChange}
|
||||||
okText={t('tool.marketSaveAndConnect')}
|
okText={t('tool.marketSaveAndConnect')}
|
||||||
onOk={handleSave}
|
onOk={handleSave}
|
||||||
confirmLoading={loading}
|
confirmLoading={loading}
|
||||||
@@ -152,8 +167,10 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form
|
<Form
|
||||||
|
key={currentSource?.id || 'new'}
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
|
initialValues={initialValues}
|
||||||
>
|
>
|
||||||
<FormItem label={t('tool.marketUrl')}>
|
<FormItem label={t('tool.marketUrl')}>
|
||||||
<Space.Compact style={{ width: '100%' }}>
|
<Space.Compact style={{ width: '100%' }}>
|
||||||
@@ -177,19 +194,25 @@ const MarketConfigModal = forwardRef<MarketConfigModalRef, MarketConfigModalProp
|
|||||||
API Key
|
API Key
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: t('tool.marketApiKeyRequired') },
|
||||||
|
{ whitespace: true, message: t('tool.marketApiKeyRequired') }
|
||||||
|
]}
|
||||||
extra={<span style={{ display: 'inline-block', marginTop: 8 }}>{t('tool.marketApiKeyExtra')}</span>}
|
extra={<span style={{ display: 'inline-block', marginTop: 8 }}>{t('tool.marketApiKeyExtra')}</span>}
|
||||||
>
|
>
|
||||||
<Space.Compact style={{ width: '100%' }}>
|
<Input
|
||||||
<Input
|
type={showApiKey ? 'text' : 'password'}
|
||||||
type={showApiKey ? 'text' : 'password'}
|
placeholder={t('tool.marketApiKeyPlaceholder')}
|
||||||
placeholder={t('tool.marketApiKeyPlaceholder')}
|
autoComplete="off"
|
||||||
autoComplete="off"
|
suffix={
|
||||||
/>
|
<Button
|
||||||
<Button
|
type="text"
|
||||||
icon={showApiKey ? <EyeInvisibleOutlined /> : <EyeOutlined />}
|
size="small"
|
||||||
onClick={() => setShowApiKey(!showApiKey)}
|
icon={showApiKey ? <EyeInvisibleOutlined /> : <EyeOutlined />}
|
||||||
/>
|
onClick={() => setShowApiKey(!showApiKey)}
|
||||||
</Space.Compact>
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<div className="rb:flex rb:items-center rb:gap-2 rb:p-3 rb:bg-gray-50 rb:rounded rb:text-sm">
|
<div className="rb:flex rb:items-center rb:gap-2 rb:p-3 rb:bg-gray-50 rb:rounded rb:text-sm">
|
||||||
|
|||||||
Reference in New Issue
Block a user