Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/src/components/auth/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ const LoginForm = () => {
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
name='components-auth-loginform-checkbox-1'
>
<Text size='small' className='text-gray-600'>
{t('我已阅读并同意')}
Expand Down Expand Up @@ -750,6 +751,7 @@ const LoginForm = () => {
label={t('用户名或邮箱')}
placeholder={t('请输入您的用户名或邮箱地址')}
name='username'
autoComplete='username'
onChange={(value) => handleChange('username', value)}
prefix={<IconMail />}
/>
Expand All @@ -760,6 +762,7 @@ const LoginForm = () => {
placeholder={t('请输入您的密码')}
name='password'
mode='password'
autoComplete='current-password'
onChange={(value) => handleChange('password', value)}
prefix={<IconLock />}
/>
Expand All @@ -769,6 +772,7 @@ const LoginForm = () => {
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
name='components-auth-loginform-checkbox-2'
>
<Text size='small' className='text-gray-600'>
{t('我已阅读并同意')}
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/auth/RegisterForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ const RegisterForm = () => {
label={t('用户名')}
placeholder={t('请输入用户名')}
name='username'
autoComplete='username'
onChange={(value) => handleChange('username', value)}
prefix={<IconUser />}
/>
Expand All @@ -588,6 +589,7 @@ const RegisterForm = () => {
placeholder={t('输入密码,最短 8 位,最长 20 位')}
name='password'
mode='password'
autoComplete='new-password'
onChange={(value) => handleChange('password', value)}
prefix={<IconLock />}
/>
Expand All @@ -598,6 +600,7 @@ const RegisterForm = () => {
placeholder={t('确认密码')}
name='password2'
mode='password'
autoComplete='new-password'
onChange={(value) => handleChange('password2', value)}
prefix={<IconLock />}
/>
Expand All @@ -610,6 +613,7 @@ const RegisterForm = () => {
placeholder={t('输入邮箱地址')}
name='email'
type='email'
autoComplete='email'
onChange={(value) => handleChange('email', value)}
prefix={<IconMail />}
suffix={
Expand All @@ -629,6 +633,7 @@ const RegisterForm = () => {
label={t('验证码')}
placeholder={t('输入验证码')}
name='verification_code'
autoComplete='one-time-code'
onChange={(value) =>
handleChange('verification_code', value)
}
Expand All @@ -642,6 +647,7 @@ const RegisterForm = () => {
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
name='components-auth-registerform-checkbox-1'
>
<Text size='small' className='text-gray-600'>
{t('我已阅读并同意')}
Expand Down
18 changes: 16 additions & 2 deletions web/src/components/common/DocumentRenderer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,28 @@ const sanitizeHtml = (html) => {
* @param {string} cacheKey - 本地存储缓存键
* @param {string} emptyMessage - 空内容时的提示消息
*/
const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
const DocumentRenderer = ({
apiEndpoint,
title,
cacheKey,
emptyMessage,
enabled = true,
}) => {
const { t } = useTranslation();
const [content, setContent] = useState('');
const [loading, setLoading] = useState(true);
const [htmlStyles, setHtmlStyles] = useState('');
const [processedHtmlContent, setProcessedHtmlContent] = useState('');

const loadContent = async () => {
if (!enabled) {
setContent('');
setProcessedHtmlContent('');
setHtmlStyles('');
setLoading(false);
return;
}

// 先从缓存中获取
const cachedContent = localStorage.getItem(cacheKey) || '';
if (cachedContent) {
Expand Down Expand Up @@ -124,7 +138,7 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {

useEffect(() => {
loadContent();
}, []);
}, [enabled]);

// 处理HTML样式注入
useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/common/modals/RiskAcknowledgementModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const RiskAcknowledgementModal = React.memo(function RiskAcknowledgementModal({
onChange={(event) => {
handleChecklistChange(index, event.target.checked);
}}
name='components-common-modals-riskacknowledgementmodal-checkbox-1'
>
{item}
</Checkbox>
Expand Down Expand Up @@ -198,6 +199,7 @@ const RiskAcknowledgementModal = React.memo(function RiskAcknowledgementModal({
onCut={(event) => event.preventDefault()}
onPaste={(event) => event.preventDefault()}
onDrop={(event) => event.preventDefault()}
name='components-common-modals-riskacknowledgementmodal-input-1'
/>
{!typedMatched && typedText ? (
<Text type='danger' size='small'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const SecureVerificationModal = ({
</svg>
}
style={{ width: '100%' }}
name='components-common-modals-secureverificationmodal-input-1'
/>
</div>

Expand Down
20 changes: 18 additions & 2 deletions web/src/components/common/ui/JSONEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ const JSONEditor = ({
<Switch
checked={value}
onChange={(newValue) => updateValue(pairId, newValue)}
id='components-common-ui-jsoneditor-switch-1'
/>
<Text type='tertiary' className='ml-2'>
{value ? t('true') : t('false')}
Expand All @@ -360,6 +361,7 @@ const JSONEditor = ({
onChange={(newValue) => updateValue(pairId, newValue)}
style={{ width: '100%' }}
placeholder={t('输入数字')}
name='components-common-ui-jsoneditor-inputnumber-1'
/>
);
}
Expand All @@ -379,6 +381,7 @@ const JSONEditor = ({
}
}}
placeholder={t('输入JSON对象')}
name='components-common-ui-jsoneditor-textarea-1'
/>
);
}
Expand All @@ -402,6 +405,7 @@ const JSONEditor = ({
}
updateValue(pairId, convertedValue);
}}
name='components-common-ui-jsoneditor-input-1'
/>
);
};
Expand Down Expand Up @@ -452,6 +456,7 @@ const JSONEditor = ({
value={pair.key}
onChange={(newKey) => updateKey(pair.id, newKey)}
status={isDuplicate ? 'warning' : undefined}
name='components-common-ui-jsoneditor-input-2'
/>
{isDuplicate && (
<Tooltip
Expand Down Expand Up @@ -548,6 +553,7 @@ const JSONEditor = ({
handleVisualChange(newPairs);
}
}}
name='components-common-ui-jsoneditor-input-3'
/>
</Form.Slot>

Expand All @@ -565,6 +571,7 @@ const JSONEditor = ({
value={pair.key}
onChange={(newKey) => updateKey(pair.id, newKey)}
status={isDuplicate ? 'warning' : undefined}
name='components-common-ui-jsoneditor-input-4'
/>
{isDuplicate && (
<Tooltip content={t('重复的键名')}>
Expand All @@ -581,6 +588,7 @@ const JSONEditor = ({
placeholder={t('区域')}
value={pair.value}
onChange={(newValue) => updateValue(pair.id, newValue)}
name='components-common-ui-jsoneditor-input-5'
/>
</Col>
<Col span={2}>
Expand Down Expand Up @@ -627,7 +635,12 @@ const JSONEditor = ({
const hasJsonError = jsonError && jsonError.trim() !== '';

return (
<Form.Slot label={label}>
<div className='semi-form-field'>
<div className='semi-form-field-label semi-form-field-label-left'>
<div className='semi-form-field-label-text'>
{label}
</div>
</div>
<Card
header={
<div className='flex justify-between items-center'>
Expand Down Expand Up @@ -676,6 +689,7 @@ const JSONEditor = ({
value={value}
rules={rules}
style={{ display: 'none' }}
name={field}
noLabel={true}
{...props}
/>
Expand All @@ -688,13 +702,15 @@ const JSONEditor = ({
onChange={handleManualChange}
showClear={showClear}
rows={Math.max(8, manualText ? manualText.split('\n').length : 8)}
name='components-common-ui-jsoneditor-textarea-2'
/>
{/* 隐藏的Form字段用于验证和数据绑定 */}
<Form.Input
field={field}
value={value}
rules={rules}
style={{ display: 'none' }}
name={field}
noLabel={true}
{...props}
/>
Expand All @@ -711,7 +727,7 @@ const JSONEditor = ({
)}
{extraFooter && <div className='mt-1'>{extraFooter}</div>}
</Card>
</Form.Slot>
</div>
);
};

Expand Down
1 change: 1 addition & 0 deletions web/src/components/common/ui/SelectableButtonGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const SelectableButtonGroup = ({
checked={isActive}
onChange={() => onChange(item.value)}
style={{ pointerEvents: 'auto' }}
name='components-common-ui-selectablebuttongroup-checkbox-1'
/>
}
style={{ width: '100%', cursor: 'default' }}
Expand Down
3 changes: 3 additions & 0 deletions web/src/components/layout/PageLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import App from '../../App';
import FooterBar from './Footer';
import { ToastContainer } from 'react-toastify';
import React, { useContext, useEffect, useState } from 'react';
import useFormFieldA11yPatch from '../../hooks/common/useFormFieldA11yPatch';
import { useIsMobile } from '../../hooks/common/useIsMobile';
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -143,6 +144,8 @@ const PageLayout = () => {
}
}, [i18n, userState?.user?.setting]);

useFormFieldA11yPatch(location.pathname);

return (
<Layout
className='app-layout'
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/playground/ConfigManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const ConfigManager = ({
<input
ref={fileInputRef}
type='file'
name='playground-config-import-mobile'
accept='.json'
onChange={handleFileChange}
style={{ display: 'none' }}
Expand Down Expand Up @@ -270,6 +271,7 @@ const ConfigManager = ({
<input
ref={fileInputRef}
type='file'
name='playground-config-import'
accept='.json'
onChange={handleFileChange}
style={{ display: 'none' }}
Expand Down
26 changes: 26 additions & 0 deletions web/src/components/playground/CustomInputRender.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useRef, useEffect, useCallback } from 'react';
import { Toast } from '@douyinfe/semi-ui';
import { useTranslation } from 'react-i18next';
import useRepeatingDomPatch from '../../hooks/common/useRepeatingDomPatch';
import { usePlayground } from '../../contexts/PlaygroundContext';

const CustomInputRender = (props) => {
Expand Down Expand Up @@ -102,6 +103,31 @@ const CustomInputRender = (props) => {
};
}, [handlePaste]);

useRepeatingDomPatch(() => {
const patchInputs = () => {
const container = containerRef.current;
if (!container) return;

const visibleTextarea = container.querySelector(
'.flex-1 textarea:not([aria-hidden="true"])',
);
if (visibleTextarea) {
visibleTextarea.name = 'playground-message-input';
visibleTextarea.id = 'playground-message-input';
visibleTextarea.setAttribute('data-playground-input', 'true');
}

const hiddenTextarea = container.querySelector(
'textarea[aria-hidden="true"]',
);
if (hiddenTextarea) {
hiddenTextarea.name = 'playground-message-shadow';
}
};

patchInputs();
}, []);

// 清空按钮
const styledClearNode = clearContextNode
? React.cloneElement(clearContextNode, {
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/playground/CustomRequestEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ const CustomRequestEditor = ({
</Typography.Text>
</div>
<Switch
id='playground-custom-request-mode'
name='custom_request_mode'
checked={customRequestMode}
onChange={handleModeToggle}
checkedText={t('开')}
Expand Down Expand Up @@ -185,6 +187,8 @@ const CustomRequestEditor = ({
</div>

<TextArea
id='playground-custom-request-body'
name='custom_request_body'
value={localValue}
onChange={handleValueChange}
placeholder='{"model": "gpt-4o", "messages": [...], ...}'
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/playground/ImageUrlInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const ImageUrlInput = ({
</div>
<div className='flex items-center gap-2'>
<Switch
id='playground-image-toggle'
name='image_enabled'
checked={imageEnabled}
onChange={onImageEnabledChange}
checkedText={t('启用')}
Expand Down Expand Up @@ -114,6 +116,8 @@ const ImageUrlInput = ({
<div key={index} className='flex items-center gap-2'>
<div className='flex-1'>
<Input
id={`playground-image-url-${index}`}
name={`image_url_${index}`}
placeholder={`https://example.com/image${index + 1}.jpg`}
value={url}
onChange={(value) => handleUpdateImageUrl(index, value)}
Expand Down
1 change: 1 addition & 0 deletions web/src/components/playground/MessageContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ const MessageContent = ({
lineHeight: '1.6',
}}
className='!border-blue-200 focus:!border-blue-400 !bg-blue-50/50'
name='components-playground-messagecontent-textarea-1'
/>
<div className='flex items-center gap-2 w-full'>
<Button
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/playground/ParameterControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const ParameterControl = ({
/>
</div>
<InputNumber
id='playground-max-tokens'
placeholder='MaxTokens'
name='max_tokens'
value={inputs.max_tokens}
Expand Down Expand Up @@ -285,6 +286,7 @@ const ParameterControl = ({
/>
</div>
<Input
id='playground-seed'
placeholder={t('随机种子 (留空为随机)')}
name='seed'
autoComplete='new-password'
Expand Down
Loading