dify-proxy-fontend/apps/web-antd/src/views/ppt/index.vue

86 lines
1.9 KiB
Vue
Raw Normal View History

<script lang="ts" setup>
import type { PPTTempItem } from '@vben/common-ui';
2025-05-02 22:08:36 +08:00
import { onMounted, reactive, ref } from 'vue';
2025-05-02 22:08:36 +08:00
import { PptHistoryView, PptListView, PptWorkView } from '@vben/common-ui';
2025-05-02 22:08:36 +08:00
import { getWorkflowInfo, getWorkflowList, 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({
appid,
limit: 5,
page: 1,
});
hitsory.value = res;
loading.value = false;
};
async 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,
});
}
2025-05-02 22:08:36 +08:00
}
onMounted(() => {
getLogs(temp.id);
});
2025-05-02 22:08:36 +08:00
</script>
<template>
<div class="px-5">
<div class="mt-5 flex flex-col lg:flex-row">
<div class="mr-4 w-full lg:w-1/4">
<PptHistoryView
:loading="loading"
:items="hitsory"
title="运行历史"
@click="handleClick"
/>
<PptListView title="选择模板" @click="handleClick" />
</div>
<div class="w-full lg:w-3/4">
<PptWorkView
:item="temp"
:run-workflow="sendWorkflow"
:item-message="itemMessage"
/>
</div>
</div>
2025-05-02 22:08:36 +08:00
</div>
</template>