Files
ylhp-ai-project-manager-fro…/src/views/chatai/components/ChatGPT.vue
JiaoTianBo 5b96f54d71
Some checks failed
Lint Code / Lint Code (push) Failing after 17m14s
feat(ai-chat): 重构项目选择逻辑并合并OpenAPI定义文件
- 将项目选择面板改为下拉选择器,简化UI交互
- 新增 `setDraftByProjectId` 和 `applyProjectSelection` 函数统一处理项目切换
- 删除分散的OpenAPI JSON文件,合并为统一的日报分析查询接口定义
- 在 `project.ts` 中添加 `getDailyReportWithAnalysisReports` API及相关类型定义
- 修复ChatGPT组件样式空格格式问题
2026-04-01 16:03:26 +08:00

144 lines
4.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import "deep-chat";
import { ref, onMounted, watch } from "vue";
type HistoryItem = { text: string; role: "user" | "ai" };
const props = withDefaults(
defineProps<{
history?: HistoryItem[];
onRequest?: (messageText: string) => Promise<string> | string;
}>(),
{
history: () => []
}
);
const chatRef = ref<any>();
function normalizeUserText(rawMessage: any): string {
if (typeof rawMessage === "string") return rawMessage;
if (rawMessage?.text) return String(rawMessage.text);
return "";
}
function applyHistory() {
if (!chatRef.value) return;
chatRef.value.history = props.history || [];
}
onMounted(() => {
applyHistory();
chatRef.value.demo = {
response: async (rawMessage: any) => {
const messageText = normalizeUserText(rawMessage);
if (props.onRequest) {
const replyText = await props.onRequest(messageText);
return { text: replyText };
}
return {
text: "仅演示如需AI服务请参考 https://deepchat.dev/docs/connect"
};
}
};
});
watch(
() => props.history,
() => {
applyHistory();
}
);
</script>
<template>
<deep-chat
ref="chatRef"
style="width: 100%; height: 100%; border-radius: 10px"
:messageStyles="{
default: {
shared: {
bubble: {
maxWidth: '100%',
backgroundColor: 'unset',
marginTop: '10px',
marginBottom: '10px'
}
},
user: {
bubble: {
marginLeft: '0px',
color: 'black'
}
},
ai: {
outerContainer: {
backgroundColor: 'rgba(247,247,248)',
borderTop: '1px solid rgba(0,0,0,.1)',
borderBottom: '1px solid rgba(0,0,0,.1)'
}
}
}
}"
:avatars="{
default: { styles: { position: 'start' } },
ai: { src: 'https://xiaoxian521.github.io/hyperlink/svg/openai.svg' }
}"
:submitButtonStyles="{
submit: {
container: {
default: {
padding: '1px 0 0 5px',
backgroundColor: '#19c37d'
},
hover: { backgroundColor: '#0bab69' },
click: { backgroundColor: '#068e56' }
},
svg: {
content:
'<?xml version=&quot;1.0&quot; ?> <svg viewBox=&quot;0 0 28 28&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;> <g> <path d=&quot;M21.66,12a2,2,0,0,1-1.14,1.81L5.87,20.75A2.08,2.08,0,0,1,5,21a2,2,0,0,1-1.82-2.82L5.46,13H11a1,1,0,0,0,0-2H5.46L3.18,5.87A2,2,0,0,1,5.86,3.25h0l14.65,6.94A2,2,0,0,1,21.66,12Z&quot;> </path> </g> </svg>',
styles: {
default: {
filter:
'brightness(0) saturate(100%) invert(100%) sepia(28%) saturate(2%) hue-rotate(69deg) brightness(107%) contrast(100%)'
}
}
}
},
loading: {
container: { default: { backgroundColor: 'white' } },
svg: {
styles: {
default: {
filter:
'brightness(0) saturate(100%) invert(72%) sepia(0%) saturate(3044%) hue-rotate(322deg) brightness(100%) contrast(96%)'
}
}
}
},
stop: {
container: {
default: { backgroundColor: 'white' },
hover: { backgroundColor: '#dadada52' }
},
svg: {
content:
'<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <svg viewBox=&quot;0 0 24 24&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;> <rect width=&quot;24&quot; height=&quot;24&quot; rx=&quot;4&quot; ry=&quot;4&quot; /> </svg>',
styles: {
default: {
width: '0.95em',
marginTop: '0.32em',
filter:
'brightness(0) saturate(100%) invert(72%) sepia(0%) saturate(3044%) hue-rotate(322deg) brightness(100%) contrast(96%)'
}
}
}
}
}"
:textInput="{ placeholder: { text: '发送消息' } }"
:history="props.history"
:demo="true"
:connect="{ stream: true }"
/>
</template>