Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

perf(web): deduplicate Aliyun credential fields

Leggett1026c5dfcdd4
diff --git a/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx b/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
index 2add6975..023c7b06 100644
--- a/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
+++ b/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
@@ -16,11 +16,20 @@ import { CreatorServicesSettingsView } from './CreatorServicesSettingsView.js';
describe('CreatorServicesSettingsView', () => {
it('saves an OSS region and optional endpoint in the shared settings form', async () => {
const user = userEvent.setup();
- const service = createService();
+ const service = createService([
+ 'transcription.aliyun.oss.accessKeyId',
+ 'transcription.aliyun.speech.appKey'
+ ]);
render(<CreatorServicesSettingsView connected service={service} modelService={createModelService()} />);
await user.click(await screen.findByRole('tab', { name: '语音识别' }));
await user.click(screen.getByRole('combobox', { name: '语音识别服务' }));
await user.click(screen.getByRole('option', { name: '阿里云百炼' }));
+ const [ossAccessKey, speechAccessKey] = screen.getAllByLabelText('Access Key ID');
+ expect(ossAccessKey).toHaveAttribute('placeholder', '已配置,留空则保持');
+ expect(speechAccessKey).toHaveAttribute('placeholder', '输入密钥');
+ expect(screen.getByLabelText('App Key')).toHaveAttribute('placeholder', '已配置,留空则保持');
+ await user.type(ossAccessKey!, 'oss-key');
+ await user.type(screen.getByLabelText('App Key'), 'speech-key');
expect(screen.getByLabelText('OSS 地域')).toHaveValue('cn-shanghai');
expect(screen.getByLabelText('OSS Endpoint(可选)')).toHaveValue('');
await user.clear(screen.getByLabelText('OSS 地域'));
@@ -30,8 +39,9 @@ describe('CreatorServicesSettingsView', () => {
await user.click(screen.getByRole('button', { name: '保存配置' }));
await waitFor(() => expect(service.saveConfig).toHaveBeenCalled());
expect(vi.mocked(service.saveConfig).mock.calls[0]?.[0].transcription.aliyun.oss).toMatchObject({
- region: 'ap-southeast-1', endpoint: 'https://oss-ap-southeast-1.aliyuncs.com'
+ accessKeyId: 'oss-key', region: 'ap-southeast-1', endpoint: 'https://oss-ap-southeast-1.aliyuncs.com'
});
+ expect(vi.mocked(service.saveConfig).mock.calls[0]?.[0].transcription.aliyun.speech.appKey).toBe('speech-key');
});
it('uses the local Codex runtime without exposing custom provider fields', async () => {
diff --git a/apps/web/src/features/settings/CreatorServicesSettingsView.tsx b/apps/web/src/features/settings/CreatorServicesSettingsView.tsx
index 0dc76829..86a8c2a3 100644
--- a/apps/web/src/features/settings/CreatorServicesSettingsView.tsx
+++ b/apps/web/src/features/settings/CreatorServicesSettingsView.tsx
@@ -1275,20 +1275,16 @@ function AliyunFields(props: {
return (
<>
<h3 className="creator-services-subheading">{l('OSS 存储', 'OSS storage')}</h3>
- <PasswordField
- id={`${props.id}-oss-access-key-id`}
- label="Access Key ID"
- value={props.oss.accessKeyId}
- configured={props.configuredCredentials.has(`${props.credentialPrefix}.oss.accessKeyId` as CreatorServicesCredentialField)}
- onChange={accessKeyId => props.onOssChange({ ...props.oss, accessKeyId })}
- />
- <PasswordField
- id={`${props.id}-oss-access-key-secret`}
- label="Access Key Secret"
- value={props.oss.accessKeySecret}
- configured={props.configuredCredentials.has(`${props.credentialPrefix}.oss.accessKeySecret` as CreatorServicesCredentialField)}
- onChange={accessKeySecret => props.onOssChange({ ...props.oss, accessKeySecret })}
- />
+ {(['accessKeyId', 'accessKeySecret'] as const).map(field => (
+ <PasswordField
+ key={field}
+ id={`${props.id}-oss-${field === 'accessKeyId' ? 'access-key-id' : 'access-key-secret'}`}
+ label={field === 'accessKeyId' ? 'Access Key ID' : 'Access Key Secret'}
+ value={props.oss[field]}
+ configured={props.configuredCredentials.has(`${props.credentialPrefix}.oss.${field}` as CreatorServicesCredentialField)}
+ onChange={value => props.onOssChange({ ...props.oss, [field]: value })}
+ />
+ ))}
<PasswordField
id={`${props.id}-oss-bucket`}
label="Bucket"
@@ -1314,27 +1310,16 @@ function AliyunFields(props: {
'Use the bucket region. Leave endpoint blank for its public endpoint, or enter a public service endpoint without the bucket name so the speech service can read the audio.'
)}</p>
<h3 className="creator-services-subheading">{l('语音服务', 'Speech service')}</h3>
- <PasswordField
- id={`${props.id}-speech-access-key-id`}
- label="Access Key ID"
- value={props.speech.accessKeyId}
- configured={props.configuredCredentials.has(`${props.credentialPrefix}.speech.accessKeyId` as CreatorServicesCredentialField)}
- onChange={accessKeyId => props.onSpeechChange({ ...props.speech, accessKeyId })}
- />
- <PasswordField
- id={`${props.id}-speech-access-key-secret`}
- label="Access Key Secret"
- value={props.speech.accessKeySecret}
- configured={props.configuredCredentials.has(`${props.credentialPrefix}.speech.accessKeySecret` as CreatorServicesCredentialField)}
- onChange={accessKeySecret => props.onSpeechChange({ ...props.speech, accessKeySecret })}
- />
- <PasswordField
- id={`${props.id}-speech-app-key`}
- label="App Key"
- value={props.speech.appKey}
- configured={props.configuredCredentials.has(`${props.credentialPrefix}.speech.appKey` as CreatorServicesCredentialField)}
- onChange={appKey => props.onSpeechChange({ ...props.speech, appKey })}
- />
+ {(['accessKeyId', 'accessKeySecret', 'appKey'] as const).map(field => (
+ <PasswordField
+ key={field}
+ id={`${props.id}-speech-${field === 'appKey' ? 'app-key' : field === 'accessKeyId' ? 'access-key-id' : 'access-key-secret'}`}
+ label={field === 'appKey' ? 'App Key' : field === 'accessKeyId' ? 'Access Key ID' : 'Access Key Secret'}
+ value={props.speech[field]}
+ configured={props.configuredCredentials.has(`${props.credentialPrefix}.speech.${field}` as CreatorServicesCredentialField)}
+ onChange={value => props.onSpeechChange({ ...props.speech, [field]: value })}
+ />
+ ))}
</>
);
}