refactor(仪表板): 智能助手支持放大对话框网络检查

This commit is contained in:
wangjiahao 2024-04-01 17:54:42 +08:00
parent 0b0042f68a
commit d5a5308e5f
5 changed files with 58 additions and 9 deletions

View File

@ -1,5 +1,7 @@
package io.dataease.commons.utils;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@ -17,4 +19,16 @@ public class UrlTestUtils {
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;
}
}
}

View File

@ -1,5 +1,6 @@
package io.dataease.service.ai;
import io.dataease.commons.utils.UrlTestUtils;
import io.dataease.service.system.SystemParameterService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -23,7 +24,7 @@ public class AiBaseService {
String baseUrl = parameterService.getValue("ai.baseUrl");
Map<String,String> result = new HashMap<>();
if(StringUtils.isNotEmpty(baseUrl)){
if(StringUtils.isNotEmpty(baseUrl) && UrlTestUtils.isURLAvailable(baseUrl)){
result.put("ai.baseUrl",baseUrl);
}

View File

@ -0,0 +1 @@
<svg style="vertical-align: middle;overflow: hidden;" t="1710214539671" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="rgb(100, 106, 115)" width="16" height="16"><path d="M85.333333 384c25.6 0 42.666667-17.066667 42.666667-42.666667V128h213.333333c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666666H85.333333c-25.6 0-42.666667 17.066667-42.666666 42.666666v256c0 25.6 17.066667 42.666667 42.666666 42.666667zM938.666667 640c-25.6 0-42.666667 17.066667-42.666667 42.666667v213.333333h-213.333333c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666666h256c25.6 0 42.666667-17.066667 42.666666-42.666666v-256c0-25.6-17.066667-42.666667-42.666666-42.666667zM601.6 401.066667c4.266667 8.533333 12.8 17.066667 21.333333 21.333333 4.266667 4.266667 12.8 4.266667 17.066667 4.266667h256c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666667h-153.6l226.133333-226.133333c17.066667-17.066667 17.066667-42.666667 0-59.733333-8.533333-8.533333-17.066667-12.8-29.866666-12.8s-21.333333 4.266667-29.866667 12.8L682.666667 281.6V128c0-25.6-17.066667-42.666667-42.666667-42.666667s-42.666667 17.066667-42.666667 42.666667v256c0 4.266667 0 12.8 4.266667 17.066667zM115.2 968.533333L341.333333 742.4V896c0 25.6 17.066667 42.666667 42.666667 42.666667s42.666667-17.066667 42.666667-42.666667v-256c0-4.266667 0-12.8-4.266667-17.066667-4.266667-8.533333-12.8-17.066667-21.333333-21.333333-4.266667-4.266667-12.8-4.266667-17.066667-4.266667H128c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666667h153.6l-226.133333 226.133333c-17.066667 17.066667-17.066667 42.666667 0 59.733333s42.666667 17.066667 59.733333 0z" p-id="10189"></path></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1 @@
<svg t="1710150885892" style="vertical-align: middle;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="rgb(100, 106, 115)" width="16" height="16"><path d="M85.333333 384c25.6 0 42.666667-17.066667 42.666667-42.666667V128h213.333333c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666666H85.333333c-25.6 0-42.666667 17.066667-42.666666 42.666666v256c0 25.6 17.066667 42.666667 42.666666 42.666667zM938.666667 640c-25.6 0-42.666667 17.066667-42.666667 42.666667v213.333333h-213.333333c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666666h256c25.6 0 42.666667-17.066667 42.666666-42.666666v-256c0-25.6-17.066667-42.666667-42.666666-42.666667zM977.066667 68.266667c-4.266667-8.533333-12.8-17.066667-21.333334-21.333334-4.266667-4.266667-12.8-4.266667-17.066666-4.266666h-256c-25.6 0-42.666667 17.066667-42.666667 42.666666s17.066667 42.666667 42.666667 42.666667h153.6l-226.133334 226.133333c-17.066667 17.066667-17.066667 42.666667 0 59.733334 8.533333 8.533333 17.066667 12.8 29.866667 12.8s21.333333-4.266667 29.866667-12.8L896 187.733333V341.333333c0 25.6 17.066667 42.666667 42.666667 42.666667s42.666667-17.066667 42.666666-42.666667V85.333333c0-4.266667 0-12.8-4.266666-17.066666zM354.133333 610.133333L128 836.266667V682.666667c0-25.6-17.066667-42.666667-42.666667-42.666667s-42.666667 17.066667-42.666666 42.666667v256c0 4.266667 0 12.8 4.266666 17.066666 4.266667 8.533333 12.8 17.066667 21.333334 21.333334 4.266667 4.266667 12.8 4.266667 17.066666 4.266666h256c25.6 0 42.666667-17.066667 42.666667-42.666666s-17.066667-42.666667-42.666667-42.666667H187.733333l226.133334-226.133333c17.066667-17.066667 17.066667-42.666667 0-59.733334s-42.666667-17.066667-59.733334 0z" p-id="8645"></path></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -10,7 +10,8 @@ export default {
},
data() {
return {
aiDialogShow: false
aiDialogShow: false,
sizeState: 'min'
}
},
mounted() {
@ -22,6 +23,9 @@ export default {
},
closeAi() {
this.aiDialogShow = false
},
sizeChange() {
this.sizeState = this.sizeState === 'min' ? 'max' : 'min'
}
}
}
@ -29,10 +33,19 @@ export default {
<template>
<div
class="ai-main"
:class="{ 'ai-main-active': aiDialogShow }"
:class="{'ai-main-active': aiDialogShow,
'ai-main-active-max' : aiDialogShow && sizeState=== 'max',
'ai-main-active-min' : aiDialogShow && sizeState=== 'min'}"
>
<div class="ai-content">
<div class="close"><i @click="closeAi" class="el-icon-close" /></div>
<div class="close"><i
class="el-icon-close"
@click="closeAi"
/></div>
<div class="size-class"> <svg-icon
:icon-class="'dv-ai-window-'+sizeState"
@click="sizeChange"
/></div>
<iframe
:src="baseUrl"
style="width: 100%; height: 100%"
@ -48,12 +61,9 @@ export default {
position: fixed;
border-radius: 5px;
overflow: hidden;
height: 0;
bottom: 48px;
right: 36px;
height: 0;
width: 25%;
min-width: 350px;
max-width: 420px;
transition: 0.2s;
z-index: 10;
.ai-content {
@ -65,15 +75,37 @@ export default {
right: 12px;
top: 12px;
font-size: 24px;
color: #1a1a1a;
color: rgb(100, 106, 115);
cursor: pointer;
}
.size-class{
position: absolute;
right: 48px;
font-size: 16px;
top: 17px;
color: rgb(100, 106, 115);
cursor: pointer;
}
}
}
.ai-main-active {
border: 1px solid #d9d9d9;
}
.ai-main-active-min {
min-width: 350px;
max-width: 420px;
height: 50%;
width: 25%;
min-height: 450px;
max-height: 600px;
bottom: 48px;
right: 36px;
}
.ai-main-active-max {
height: 100%;
width: 50%;
bottom: 0px;
right: 0px;
}
</style>