diff --git a/core/core-backend/src/main/java/io/dataease/ai/service/AiBaseService.java b/core/core-backend/src/main/java/io/dataease/ai/service/AiBaseService.java index 2e91b96728..bb188bdae0 100644 --- a/core/core-backend/src/main/java/io/dataease/ai/service/AiBaseService.java +++ b/core/core-backend/src/main/java/io/dataease/ai/service/AiBaseService.java @@ -1,11 +1,14 @@ package io.dataease.ai.service; import io.dataease.api.ai.AiComponentApi; +import io.dataease.commons.utils.UrlTestUtils; import io.dataease.system.manage.SysParameterManage; import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; import java.util.Map; /** @@ -21,6 +24,11 @@ public class AiBaseService implements AiComponentApi { @Override public Map findTargetUrl() { Map templateParams = sysParameterManage.groupVal("ai."); - return templateParams; + if (templateParams != null && StringUtils.isNotEmpty(templateParams.get("ai.baseUrl")) && UrlTestUtils.isURLAvailable(templateParams.get("ai.baseUrl"))) { + return templateParams; + + } else { + return new HashMap<>(); + } } } diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/UrlTestUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/UrlTestUtils.java new file mode 100644 index 0000000000..0a4a9208fc --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/UrlTestUtils.java @@ -0,0 +1,34 @@ +package io.dataease.commons.utils; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; + +public class UrlTestUtils { + + public static boolean testUrlWithTimeOut(String urlString, int timeOutMillSeconds) { + try { + URL url = new URL(urlString); + URLConnection co = url.openConnection(); + co.setConnectTimeout(timeOutMillSeconds); + co.connect(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public static boolean isURLAvailable(String urlString) { + try { + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("HEAD"); + int responseCode = connection.getResponseCode(); + return responseCode == HttpURLConnection.HTTP_OK; + } catch (IOException e) { + return false; + } + } +} diff --git a/core/core-frontend/src/assets/svg/dv-ai-window-max.svg b/core/core-frontend/src/assets/svg/dv-ai-window-max.svg new file mode 100644 index 0000000000..65f2115172 --- /dev/null +++ b/core/core-frontend/src/assets/svg/dv-ai-window-max.svg @@ -0,0 +1 @@ + diff --git a/core/core-frontend/src/assets/svg/dv-ai-window-min.svg b/core/core-frontend/src/assets/svg/dv-ai-window-min.svg new file mode 100644 index 0000000000..58794a4b18 --- /dev/null +++ b/core/core-frontend/src/assets/svg/dv-ai-window-min.svg @@ -0,0 +1 @@ + diff --git a/core/core-frontend/src/layout/components/AiComponent.vue b/core/core-frontend/src/layout/components/AiComponent.vue index 04b240c7d7..2c4246802a 100644 --- a/core/core-frontend/src/layout/components/AiComponent.vue +++ b/core/core-frontend/src/layout/components/AiComponent.vue @@ -12,6 +12,12 @@ defineProps({ } }) +const sizeChange = () => { + sizeState.value = sizeState.value === 'min' ? 'max' : 'min' +} + +const sizeState = ref('min') + onMounted(() => { useEmitt({ name: 'aiComponentChange', @@ -22,9 +28,19 @@ onMounted(() => { })