Compare commits
No commits in common. "4518ef74eb6cb6f449fa2e2f74956100fa881c20" and "33d8241ce46252bcc486a217a54408c19d92bd14" have entirely different histories.
4518ef74eb
...
33d8241ce4
@ -24,7 +24,6 @@ export namespace WorkflowApi {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
keyword?: string;
|
||||
workflowRunId?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,10 +43,10 @@ export function sendWorkflow(
|
||||
// return requestClient.patch('/v1/workflow/stop', { data });
|
||||
// };
|
||||
//
|
||||
export function getWorkflowInfo(data: WorkflowApi.WorkflowLogParams) {
|
||||
return requestClient.get(`/v1/workflow/info/${data.appid}`, { params: data });
|
||||
}
|
||||
|
||||
export function getWorkflowList(params: WorkflowApi.WorkflowLogParams) {
|
||||
return requestClient.get(`/v1/workflow/list/${params.appid}`);
|
||||
// export function getWorkflowMessage(data){
|
||||
// return requestClient.get('/v1/workflow/info', { data });
|
||||
// };
|
||||
//
|
||||
export function getWorkflowLog(params: WorkflowApi.WorkflowLogParams) {
|
||||
return requestClient.post(`/v1/workflow/logs/${params.appid}`, { ...params });
|
||||
}
|
||||
|
@ -5,55 +5,29 @@ import { onMounted, reactive, ref } from 'vue';
|
||||
|
||||
import { PptHistoryView, PptListView, PptWorkView } from '@vben/common-ui';
|
||||
|
||||
import { getWorkflowInfo, getWorkflowList, sendWorkflow } from '#/api';
|
||||
import { getWorkflowLog, sendWorkflow } from '#/api';
|
||||
|
||||
let temp = reactive<PPTTempItem>({
|
||||
id: 'ee3889b6-50fa-463e-b956-3b93447727fc',
|
||||
name: '从可研申报书生成科技项目PPT',
|
||||
});
|
||||
interface ResultItem {
|
||||
key: number;
|
||||
role: 'ai' | 'user';
|
||||
content: string;
|
||||
footer?: any;
|
||||
}
|
||||
|
||||
const hitsory = ref([]);
|
||||
const loading = ref(true);
|
||||
const itemMessage = ref<ResultItem[]>([]);
|
||||
|
||||
const getLogs = async (appid: string) => {
|
||||
loading.value = true;
|
||||
const res = await getWorkflowList({
|
||||
const res = await getWorkflowLog({
|
||||
appid,
|
||||
limit: 5,
|
||||
page: 1,
|
||||
});
|
||||
hitsory.value = res;
|
||||
hitsory.value = res.data;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
async function handleClick(item: PPTTempItem) {
|
||||
function handleClick(item: PPTTempItem) {
|
||||
temp = item;
|
||||
const res = await getWorkflowInfo({
|
||||
appid: temp.appId,
|
||||
workflowRunId: item.workflowRunId,
|
||||
});
|
||||
itemMessage.value = [];
|
||||
if (res.inputs) {
|
||||
itemMessage.value.push({
|
||||
key: itemMessage.value.length + 1,
|
||||
role: 'user',
|
||||
content: res.inputs.declarationDoc,
|
||||
});
|
||||
}
|
||||
if (res.outputs) {
|
||||
itemMessage.value.push({
|
||||
key: itemMessage.value.length + 1,
|
||||
role: 'ai',
|
||||
content: res.outputs.result,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@ -74,11 +48,7 @@ onMounted(() => {
|
||||
<PptListView title="选择模板" @click="handleClick" />
|
||||
</div>
|
||||
<div class="w-full lg:w-3/4">
|
||||
<PptWorkView
|
||||
:item="temp"
|
||||
:run-workflow="sendWorkflow"
|
||||
:item-message="itemMessage"
|
||||
/>
|
||||
<PptWorkView :item="temp" :run-workflow="sendWorkflow" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,7 +7,7 @@ import VueOfficePptx from '@vue-office/pptx';
|
||||
|
||||
// import '@vue-office/pptx/lib/index.css';
|
||||
// http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
||||
// const url = ref('');
|
||||
const url = ref('');
|
||||
const pptx = ref('/pptx/66f3cfd95e364a239d8036390db658ae.pptx');
|
||||
const pptStyle = ref({
|
||||
height: 'calc(100vh - 100px)',
|
||||
@ -30,11 +30,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (isOpen) {
|
||||
const data = drawerApi.getData<Record<string, any>>();
|
||||
if (data) {
|
||||
pptx.value = `/pptx/${data}`; // 更新 docx 的值
|
||||
}
|
||||
// url.value = drawerApi.getData<Record<string, any>>();
|
||||
url.value = drawerApi.getData<Record<string, any>>();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ import type { DrawerPlacement } from '@vben/common-ui';
|
||||
|
||||
import type { PPTTempItem } from './typing';
|
||||
|
||||
import { h, ref, watch } from 'vue';
|
||||
import { h, ref } from 'vue';
|
||||
|
||||
import { useVbenDrawer } from '@vben/common-ui';
|
||||
|
||||
@ -36,15 +36,7 @@ interface WorkflowResult {
|
||||
};
|
||||
}
|
||||
|
||||
interface ResultItem {
|
||||
key: number;
|
||||
role: 'ai' | 'user';
|
||||
content: string;
|
||||
footer?: any;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
itemMessage?: ResultItem;
|
||||
item?: PPTTempItem;
|
||||
runWorkflow?: (
|
||||
params: WorkflowParams,
|
||||
@ -56,8 +48,7 @@ defineOptions({
|
||||
name: 'SpiderWorkView',
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
itemMessage: () => null,
|
||||
withDefaults(defineProps<Props>(), {
|
||||
item: () => null,
|
||||
runWorkflow: () => async () => ({
|
||||
data: {
|
||||
@ -74,26 +65,8 @@ const [PreviewDrawer, previewDrawerApi] = useVbenDrawer({
|
||||
// placement: 'left',
|
||||
});
|
||||
|
||||
function openPreviewDrawer(
|
||||
placement: DrawerPlacement = 'right',
|
||||
filename?: string,
|
||||
) {
|
||||
const fileData = filename.value;
|
||||
previewDrawerApi.setState({ placement }).setData(fileData).open();
|
||||
}
|
||||
|
||||
// 判断是否是以 .pptx 结尾的 URL
|
||||
function isPptxURL(str: string): boolean {
|
||||
return str.endsWith('.pptx');
|
||||
}
|
||||
|
||||
// 使用正则提取 /static/ 后面的文件名部分
|
||||
function extractPptxFilename(url: string): null | string {
|
||||
const match = url.match(/\/static\/([a-f0-9-]+\.pptx)$/i);
|
||||
if (match) {
|
||||
return match[1]; // 返回类似:9e1c421e-991c-411f-8176-6350a97e70f3.pptx
|
||||
}
|
||||
return null;
|
||||
function openPreviewDrawer(placement: DrawerPlacement = 'right') {
|
||||
previewDrawerApi.setState({ placement }).open();
|
||||
}
|
||||
|
||||
const startFetching = async () => {
|
||||
@ -101,29 +74,21 @@ const startFetching = async () => {
|
||||
fetchStatus.value = 'fetching';
|
||||
|
||||
try {
|
||||
const res = await props.runWorkflow(
|
||||
{
|
||||
appid: 'ee3889b6-50fa-463e-b956-3b93447727fc',
|
||||
},
|
||||
{
|
||||
userId: '1562',
|
||||
conversationId: '',
|
||||
files: [],
|
||||
inputs: {
|
||||
declarationDoc: value.value,
|
||||
},
|
||||
},
|
||||
);
|
||||
const { result } = res.data.outputs;
|
||||
|
||||
const filename = ref('');
|
||||
|
||||
if (result && isPptxURL(result)) {
|
||||
filename.value = extractPptxFilename(result);
|
||||
}
|
||||
|
||||
// const res = await props.runWorkflow(
|
||||
// {
|
||||
// appid: props.item.id,
|
||||
// },
|
||||
// {
|
||||
// userId: '1562',
|
||||
// conversationId: '',
|
||||
// files: [],
|
||||
// inputs: {
|
||||
// declarationDoc: value.value,
|
||||
// },
|
||||
// },
|
||||
// );
|
||||
// 保存抓取结果 url http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
||||
fetchResult.value = `/static/${filename.value}`;
|
||||
fetchResult.value = '/static/66f3cfd95e364a239d8036390db658ae.pptx';
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: 'ai',
|
||||
@ -135,7 +100,7 @@ const startFetching = async () => {
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
onClick: () => {
|
||||
openPreviewDrawer('right', filename);
|
||||
openPreviewDrawer('right');
|
||||
},
|
||||
},
|
||||
'文档预览',
|
||||
@ -148,15 +113,7 @@ const startFetching = async () => {
|
||||
style: {
|
||||
marginLeft: '10px',
|
||||
},
|
||||
onClick: () => {
|
||||
// 创建隐藏的 <a> 标签用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = result; // 设置下载链接
|
||||
link.download = filename; // 设置下载文件名
|
||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
||||
link.click(); // 触发点击事件开始下载
|
||||
link.remove(); // 下载完成后移除 <a> 标签
|
||||
},
|
||||
onClick: () => {},
|
||||
},
|
||||
'文档下载',
|
||||
),
|
||||
@ -211,78 +168,14 @@ const fetchResult = ref('');
|
||||
const fetchStatus = ref('');
|
||||
const value = ref('');
|
||||
|
||||
interface ResultItem {
|
||||
key: number;
|
||||
role: 'ai' | 'user';
|
||||
content: string;
|
||||
footer?: any;
|
||||
}
|
||||
|
||||
const resultItems = ref<ResultItem[]>([]);
|
||||
|
||||
// 监听 itemMessage 变化并更新 resultItems
|
||||
watch(
|
||||
() => props.itemMessage,
|
||||
(newVal) => {
|
||||
resultItems.value = [];
|
||||
if (newVal && newVal.length > 0) {
|
||||
newVal.forEach((msg) => {
|
||||
// resultItems.value.push({
|
||||
// key: resultItems.value.length + 1,
|
||||
// role: msg.role, // 'user' or 'ai'
|
||||
// content: msg.content,
|
||||
// footer: msg.footer,
|
||||
// });
|
||||
if (msg.role === 'user') {
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: msg.role, // 'user' or 'ai'
|
||||
content: msg.content,
|
||||
footer: msg.footer,
|
||||
});
|
||||
} else {
|
||||
const filename = ref('');
|
||||
|
||||
if (msg.content && isPptxURL(msg.content)) {
|
||||
filename.value = extractPptxFilename(msg.content);
|
||||
}
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: msg.role, // 'user' or 'ai'
|
||||
content: '文档已生成',
|
||||
footer: h(Flex, null, [
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
onClick: () => {
|
||||
openPreviewDrawer('right', filename);
|
||||
},
|
||||
},
|
||||
'文档预览',
|
||||
),
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
style: {
|
||||
marginLeft: '10px',
|
||||
},
|
||||
onClick: () => {
|
||||
// 创建隐藏的 <a> 标签用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = msg.content; // 设置下载链接
|
||||
link.download = filename; // 设置下载文件名
|
||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
||||
link.click(); // 触发点击事件开始下载
|
||||
link.remove(); // 下载完成后移除 <a> 标签
|
||||
},
|
||||
},
|
||||
'文档下载',
|
||||
),
|
||||
]),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -1,10 +1,6 @@
|
||||
interface PPTTempItem {
|
||||
id: string;
|
||||
name: string;
|
||||
workflowRunId?: string;
|
||||
appId?: string;
|
||||
userId?: string;
|
||||
taskId?: string;
|
||||
}
|
||||
|
||||
interface PptHistoryItem {
|
||||
|
@ -134,53 +134,47 @@ const startFetching = async () => {
|
||||
|
||||
if (answer && isDocxURL(answer)) {
|
||||
filename.value = extractDocxFilename(answer);
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: 'ai',
|
||||
content: '文档已生成',
|
||||
footer: h(Flex, null, [
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
onClick: () => {
|
||||
openPreviewDrawer('right', filename);
|
||||
},
|
||||
},
|
||||
'文档预览',
|
||||
),
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
style: {
|
||||
marginLeft: '10px',
|
||||
},
|
||||
onClick: () => {
|
||||
// 创建隐藏的 <a> 标签用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = answer; // 设置下载链接
|
||||
link.download = filename; // 设置下载文件名
|
||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
||||
link.click(); // 触发点击事件开始下载
|
||||
link.remove(); // 下载完成后移除 <a> 标签
|
||||
},
|
||||
},
|
||||
'文档下载',
|
||||
),
|
||||
]),
|
||||
});
|
||||
} else {
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: 'ai',
|
||||
content: res.answer,
|
||||
});
|
||||
}
|
||||
|
||||
fetchResult.value = `/static/${filename.value}`;
|
||||
resultItems.value.push({
|
||||
key: resultItems.value.length + 1,
|
||||
role: 'ai',
|
||||
content: res.answer,
|
||||
footer: h(Flex, null, [
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
onClick: () => {
|
||||
openPreviewDrawer('right', filename);
|
||||
},
|
||||
},
|
||||
'文档预览',
|
||||
),
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'nomarl',
|
||||
type: 'primary',
|
||||
style: {
|
||||
marginLeft: '10px',
|
||||
},
|
||||
onClick: () => {
|
||||
// 创建隐藏的 <a> 标签用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = answer; // 设置下载链接
|
||||
link.download = filename; // 设置下载文件名
|
||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
||||
link.click(); // 触发点击事件开始下载
|
||||
link.remove(); // 下载完成后移除 <a> 标签
|
||||
},
|
||||
},
|
||||
'文档下载',
|
||||
),
|
||||
]),
|
||||
});
|
||||
// resultItems.value.push({
|
||||
// key: resultItems.value.length + 1,
|
||||
// role: 'ai',
|
||||
|
Loading…
Reference in New Issue
Block a user