fix: 讯飞配置字段名统一+WebSocket错误码拦截
- SystemSettings: state初始化和表单绑定中xfIatConfig统一改为xfSpeechConfig,与编辑器读取字段一致 - ReportEditor: ws.onmessage增加jsonData.code错误码拦截,展示具体讯飞报错信息
This commit is contained in:
@@ -971,6 +971,12 @@ export default function ReportEditor() {
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const jsonData = JSON.parse(event.data);
|
||||
if (jsonData.code !== 0 && jsonData.code !== undefined) {
|
||||
alert(`讯飞语音报错: ${jsonData.message || '未知错误'} (错误码: ${jsonData.code})`);
|
||||
setIsListening(false);
|
||||
ws.close();
|
||||
return;
|
||||
}
|
||||
if (jsonData.data?.result?.ws) {
|
||||
let seg = '';
|
||||
for (const w of jsonData.data.result.ws) { if (w.cw?.[0]?.w) seg += w.cw[0].w; }
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function SystemSettings() {
|
||||
frameMode: 'keep',
|
||||
activeAiProvider: 'kimi',
|
||||
aiProviders: { ...DEFAULT_AI_PROVIDERS },
|
||||
xfIatConfig: { appId: 'e0fe23e3', apiKey: '7fd08be316718c2280e85af4fe126306', apiSecret: 'ZGI5MjAzZDA0YzYwNDhjMWZiNTM2NDE0' }
|
||||
xfSpeechConfig: { appId: 'e0fe23e3', apiKey: '7fd08be316718c2280e85af4fe126306', apiSecret: 'ZGI5MjAzZDA0YzYwNDhjMWZiNTM2NDE0' }
|
||||
});
|
||||
const [templates, setTemplates] = useState<Template[]>([]);
|
||||
const [isSaved, setIsSaved] = useState(false);
|
||||
@@ -437,10 +437,10 @@ export default function SystemSettings() {
|
||||
<label className="block text-xs font-bold text-text-main uppercase tracking-wider">APPID</label>
|
||||
<input
|
||||
type="password"
|
||||
value={settings.xfIatConfig?.appId || ''}
|
||||
value={settings.xfSpeechConfig?.appId || ''}
|
||||
onChange={(e) => {
|
||||
const next = { ...(settings.xfIatConfig || { appId: '', apiKey: '', apiSecret: '' }), appId: e.target.value };
|
||||
setSettings({ ...settings, xfIatConfig: next });
|
||||
const next = { ...(settings.xfSpeechConfig || { appId: '', apiKey: '', apiSecret: '' }), appId: e.target.value };
|
||||
setSettings({ ...settings, xfSpeechConfig: next });
|
||||
}}
|
||||
placeholder="e0fe23e3"
|
||||
className="input-minimal"
|
||||
@@ -450,10 +450,10 @@ export default function SystemSettings() {
|
||||
<label className="block text-xs font-bold text-text-main uppercase tracking-wider">APIKey</label>
|
||||
<input
|
||||
type="password"
|
||||
value={settings.xfIatConfig?.apiKey || ''}
|
||||
value={settings.xfSpeechConfig?.apiKey || ''}
|
||||
onChange={(e) => {
|
||||
const next = { ...(settings.xfIatConfig || { appId: '', apiKey: '', apiSecret: '' }), apiKey: e.target.value };
|
||||
setSettings({ ...settings, xfIatConfig: next });
|
||||
const next = { ...(settings.xfSpeechConfig || { appId: '', apiKey: '', apiSecret: '' }), apiKey: e.target.value };
|
||||
setSettings({ ...settings, xfSpeechConfig: next });
|
||||
}}
|
||||
placeholder="7fd08be316718c2280e85af4fe126306"
|
||||
className="input-minimal"
|
||||
@@ -463,10 +463,10 @@ export default function SystemSettings() {
|
||||
<label className="block text-xs font-bold text-text-main uppercase tracking-wider">APISecret</label>
|
||||
<input
|
||||
type="password"
|
||||
value={settings.xfIatConfig?.apiSecret || ''}
|
||||
value={settings.xfSpeechConfig?.apiSecret || ''}
|
||||
onChange={(e) => {
|
||||
const next = { ...(settings.xfIatConfig || { appId: '', apiKey: '', apiSecret: '' }), apiSecret: e.target.value };
|
||||
setSettings({ ...settings, xfIatConfig: next });
|
||||
const next = { ...(settings.xfSpeechConfig || { appId: '', apiKey: '', apiSecret: '' }), apiSecret: e.target.value };
|
||||
setSettings({ ...settings, xfSpeechConfig: next });
|
||||
}}
|
||||
placeholder="ZGI5MjAzZDA0YzYwNDhjMWZiNTM2NDE0"
|
||||
className="input-minimal"
|
||||
|
||||
Reference in New Issue
Block a user