forked from github/dataease
feat(工作台): 集成MaxKB
This commit is contained in:
parent
a0f504742e
commit
3a4daa48b0
@ -0,0 +1,26 @@
|
||||
package io.dataease.ai.service;
|
||||
|
||||
import io.dataease.api.ai.AiComponentApi;
|
||||
import io.dataease.system.manage.SysParameterManage;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : WangJiaHao
|
||||
* @date : 2024/3/27 09:47
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("aiBase")
|
||||
public class AiBaseService implements AiComponentApi {
|
||||
@Resource
|
||||
private SysParameterManage sysParameterManage;
|
||||
|
||||
@Override
|
||||
public Map<String, String> findTargetUrl() {
|
||||
Map<String, String> templateParams = sysParameterManage.groupVal("ai.");
|
||||
return templateParams;
|
||||
}
|
||||
}
|
3
core/core-frontend/src/api/aiComponent.ts
Normal file
3
core/core-frontend/src/api/aiComponent.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export const findBaseParams = async () => request.get({ url: '/aiBase/findTargetUrl' })
|
15
core/core-frontend/src/assets/svg/dv-ai.svg
Normal file
15
core/core-frontend/src/assets/svg/dv-ai.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="24" height="24" rx="12" fill="url(#paint0_linear_12894_282181)"/>
|
||||
<path d="M12.9473 16.7067H10.6493L9.7976 17.5584C9.74771 17.6083 9.71373 17.6719 9.69997 17.7411C9.68621 17.8103 9.69327 17.882 9.72027 17.9472C9.74727 18.0124 9.793 18.0681 9.85167 18.1073C9.91033 18.1465 9.97931 18.1675 10.0499 18.1675H13.5468C13.6173 18.1674 13.6863 18.1465 13.745 18.1073C13.8036 18.0681 13.8494 18.0124 13.8764 17.9472C13.9034 17.882 13.9104 17.8103 13.8967 17.7411C13.8829 17.6719 13.8489 17.6083 13.799 17.5584L12.9473 16.7067Z" fill="white"/>
|
||||
<path d="M19.2622 10.024H18.8092V13.2107H19.2622C19.3537 13.2107 19.4414 13.1744 19.5061 13.1097C19.5708 13.0451 19.6071 12.9573 19.6071 12.8659V10.3689C19.6071 10.2775 19.5708 10.1897 19.5061 10.1251C19.4414 10.0604 19.3537 10.024 19.2622 10.024Z" fill="white"/>
|
||||
<path d="M5.19074 10.024H4.73772C4.64625 10.024 4.55852 10.0604 4.49384 10.1251C4.42916 10.1897 4.39282 10.2775 4.39282 10.3689V12.8659C4.39282 12.9573 4.42916 13.0451 4.49384 13.1097C4.55852 13.1744 4.64625 13.2107 4.73772 13.2107H5.19074V10.024Z" fill="white"/>
|
||||
<path d="M13.7492 10.4459C13.5781 10.4459 13.414 10.5138 13.2931 10.6348C13.1721 10.7558 13.1041 10.9198 13.1041 11.0909V11.5534C13.1041 11.7245 13.1721 11.8886 13.2931 12.0096C13.414 12.1306 13.5781 12.1985 13.7492 12.1985C13.9203 12.1985 14.0844 12.1306 14.2054 12.0096C14.3263 11.8886 14.3943 11.7245 14.3943 11.5534V11.0909C14.3943 11.0062 14.3776 10.9223 14.3452 10.8441C14.3128 10.7658 14.2653 10.6947 14.2054 10.6348C14.1455 10.5749 14.0743 10.5274 13.9961 10.4949C13.9178 10.4625 13.8339 10.4459 13.7492 10.4459Z" fill="white"/>
|
||||
<path d="M10.3848 10.4459C10.2137 10.4459 10.0497 10.5138 9.92868 10.6348C9.80771 10.7558 9.73975 10.9198 9.73975 11.0909V11.5534C9.73975 11.7245 9.80771 11.8886 9.92869 12.0096C10.0497 12.1306 10.2138 12.1985 10.3848 12.1985C10.5559 12.1985 10.72 12.1306 10.841 12.0096C10.962 11.8886 11.0299 11.7245 11.0299 11.5534V11.0909C11.0299 11.0062 11.0132 10.9223 10.9808 10.8441C10.9484 10.7658 10.9009 10.6947 10.841 10.6348C10.7811 10.5749 10.71 10.5274 10.6317 10.4949C10.5534 10.4625 10.4695 10.4459 10.3848 10.4459Z" fill="white"/>
|
||||
<path d="M15.9194 6.78653H8.08045C7.38822 6.78731 6.72456 7.06264 6.23508 7.55212C5.7456 8.0416 5.47026 8.70526 5.46948 9.39749V13.8169C5.47026 14.5092 5.74559 15.1728 6.23507 15.6623C6.72455 16.1518 7.38821 16.4271 8.08045 16.4279H15.9194C16.6117 16.4272 17.2754 16.1518 17.7648 15.6623C18.2543 15.1728 18.5297 14.5092 18.5304 13.8169V9.39749C18.5297 8.70526 18.2543 8.0416 17.7648 7.55212C17.2753 7.06263 16.6117 6.7873 15.9194 6.78653ZM16.1387 13.7906C16.1387 13.9153 16.0891 14.0349 16.0009 14.1231C15.9127 14.2113 15.7931 14.2609 15.6684 14.2609H11.8448C11.2663 14.2609 10.6974 14.4095 10.1929 14.6926L8.91016 15.4124V14.2609H8.33154C8.2068 14.2609 8.08718 14.2113 7.99898 14.1231C7.91078 14.0349 7.86123 13.9153 7.86123 13.7906V9.10552C7.86123 8.98078 7.91078 8.86116 7.99898 8.77296C8.08718 8.68476 8.2068 8.63521 8.33154 8.63521H15.6684C15.7931 8.63521 15.9127 8.68476 16.0009 8.77296C16.0891 8.86116 16.1387 8.98079 16.1387 9.10552V13.7906Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_12894_282181" x1="24" y1="13" x2="4.55702e-07" y2="13" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#9258F7"/>
|
||||
<stop offset="1" stop-color="#3370FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
66
core/core-frontend/src/layout/components/AiComponent.vue
Normal file
66
core/core-frontend/src/layout/components/AiComponent.vue
Normal file
@ -0,0 +1,66 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
const aiDialogShow = ref(false)
|
||||
|
||||
const closeAi = () => {
|
||||
aiDialogShow.value = false
|
||||
}
|
||||
defineProps({
|
||||
baseUrl: {
|
||||
type: String
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
useEmitt({
|
||||
name: 'aiComponentChange',
|
||||
callback: function () {
|
||||
aiDialogShow.value = !aiDialogShow.value
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="ai-main" :class="{ 'ai-main-active': aiDialogShow }">
|
||||
<div class="ai-content">
|
||||
<el-icon class="close" @click="closeAi"><Close /></el-icon>
|
||||
<iframe :src="baseUrl" style="width: 100%; height: 100%" frameborder="0" allow="microphone">
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ai-main {
|
||||
position: fixed;
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
bottom: 48px;
|
||||
right: 36px;
|
||||
height: 0;
|
||||
width: 25%;
|
||||
min-width: 350px;
|
||||
max-width: 420px;
|
||||
transition: 0.2s;
|
||||
z-index: 10;
|
||||
.ai-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.close {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 12px;
|
||||
font-size: 24px;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
}
|
||||
}
|
||||
.ai-main-active {
|
||||
border: 1px solid #d9d9d9;
|
||||
height: 50%;
|
||||
min-height: 450px;
|
||||
max-height: 600px;
|
||||
}
|
||||
</style>
|
@ -14,15 +14,23 @@ import AccountOperator from '@/layout/components/AccountOperator.vue'
|
||||
import { isDesktop } from '@/utils/ModelUtil'
|
||||
import { XpackComponent } from '@/components/plugin'
|
||||
import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
|
||||
import AiComponent from '@/layout/components/AiComponent.vue'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
import { findBaseParams } from '@/api/aiComponent'
|
||||
const appearanceStore = useAppearanceStoreWithOut()
|
||||
const { push } = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const aiBaseUrl = ref(null)
|
||||
const handleIconClick = () => {
|
||||
if (route.path === '/workbranch/index') return
|
||||
push('/workbranch/index')
|
||||
}
|
||||
|
||||
const handleAiClick = () => {
|
||||
useEmitt().emitter.emit('aiComponentChange')
|
||||
}
|
||||
|
||||
const desktop = isDesktop()
|
||||
const activeIndex = computed(() => {
|
||||
if (route.path.includes('system')) {
|
||||
@ -51,9 +59,19 @@ const initShowToolbox = () => {
|
||||
}
|
||||
const navigateBg = computed(() => appearanceStore.getNavigateBg)
|
||||
const navigate = computed(() => appearanceStore.getNavigate)
|
||||
|
||||
const initAiBase = async () => {
|
||||
await findBaseParams().then(rsp => {
|
||||
const params = rsp.data
|
||||
if (params && params['ai.baseUrl']) {
|
||||
aiBaseUrl.value = params['ai.baseUrl']
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
initShowSystem()
|
||||
initShowToolbox()
|
||||
initAiBase()
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -78,10 +96,14 @@ onMounted(() => {
|
||||
</el-menu>
|
||||
<div class="operate-setting" v-if="!desktop">
|
||||
<XpackComponent jsname="c3dpdGNoZXI=" />
|
||||
<el-icon class="ai-icon" v-if="aiBaseUrl">
|
||||
<Icon name="dv-ai" @click="handleAiClick" />
|
||||
</el-icon>
|
||||
<ToolboxCfg v-if="showToolbox" />
|
||||
<TopDoc />
|
||||
<SystemCfg v-if="showSystem" />
|
||||
<AccountOperator />
|
||||
<ai-component v-if="aiBaseUrl" :base-url="aiBaseUrl"></ai-component>
|
||||
</div>
|
||||
</el-header>
|
||||
</template>
|
||||
@ -182,4 +204,8 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ai-icon {
|
||||
font-size: 24px !important;
|
||||
}
|
||||
</style>
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.api.ai;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : WangJiaHao
|
||||
* @date : 2024/3/27 09:44
|
||||
*/
|
||||
public interface AiComponentApi {
|
||||
@GetMapping("findTargetUrl")
|
||||
Map<String, String> findTargetUrl();
|
||||
}
|
Loading…
Reference in New Issue
Block a user