|
@@ -208,31 +208,32 @@ function App() {
|
|
|
setCallLoading(true);
|
|
setCallLoading(true);
|
|
|
setResult('');
|
|
setResult('');
|
|
|
|
|
|
|
|
- const token = getToken();
|
|
|
|
|
- const userInfo = getUserInfo();
|
|
|
|
|
-
|
|
|
|
|
- const apiItem = {
|
|
|
|
|
- ...currentApi,
|
|
|
|
|
- aiTableId: customTableId || currentApi.aiTableId,
|
|
|
|
|
- aiTablename: tableName,
|
|
|
|
|
- apiParamAuth: currentApi.apiParamAuth.map(p => ({
|
|
|
|
|
- paramName: p.paramName,
|
|
|
|
|
- value: apiParams[p.paramName] || p.value || ''
|
|
|
|
|
- }))
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ const token = getToken();
|
|
|
|
|
+ const userInfo = getUserInfo();
|
|
|
|
|
+
|
|
|
|
|
+ const apiItem = {
|
|
|
|
|
+ ...currentApi,
|
|
|
|
|
+ aiTableId: customTableId || currentApi.aiTableId,
|
|
|
|
|
+ aiTablename: tableName,
|
|
|
|
|
+ apiParamAuth: currentApi.apiParamAuth.map(p => ({
|
|
|
|
|
+ paramName: p.paramName,
|
|
|
|
|
+ value: apiParams[p.paramName] || p.value || ''
|
|
|
|
|
+ }))
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const response: ApiResponse = await Dingdocs.script.runWithTimeout('callApi', 120000, apiItem, token, userInfo?.userId);
|
|
const response: ApiResponse = await Dingdocs.script.runWithTimeout('callApi', 120000, apiItem, token, userInfo?.userId);
|
|
|
- if (response.code === 200 || response.code === 0) {
|
|
|
|
|
|
|
+ if (response && (response.code === 200 || response.code === 0)) {
|
|
|
setResult(JSON.stringify(response, null, 2));
|
|
setResult(JSON.stringify(response, null, 2));
|
|
|
} else {
|
|
} else {
|
|
|
- setResult(`调用失败: ${response.msg || '未知错误'}`);
|
|
|
|
|
|
|
+ setResult(`调用失败: ${response?.msg || '未知错误'}`);
|
|
|
}
|
|
}
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
|
console.error('调用API失败:', error);
|
|
console.error('调用API失败:', error);
|
|
|
setResult(`调用失败: ${error?.message || '网络请求超时,请检查网络连接'}`);
|
|
setResult(`调用失败: ${error?.message || '网络请求超时,请检查网络连接'}`);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ setCallLoading(false);
|
|
|
}
|
|
}
|
|
|
- setCallLoading(false);
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|