feat(@vben/web-antd): 重构PPT生成页面并调整
This commit is contained in:
parent
83953c07c4
commit
53a0137cb4
@ -24,15 +24,21 @@ export namespace ChatflowApi {
|
||||
}
|
||||
|
||||
export interface ChatListResult {
|
||||
id: string;
|
||||
name: string;
|
||||
inputs: {
|
||||
[key: string]: any;
|
||||
};
|
||||
status: string;
|
||||
introduction: string;
|
||||
createAt: string;
|
||||
updatedAt: string;
|
||||
data: [
|
||||
{
|
||||
createAt: string;
|
||||
id: string;
|
||||
inputs: {
|
||||
[key: string]: any;
|
||||
};
|
||||
introduction: string;
|
||||
name: string;
|
||||
status: string;
|
||||
updatedAt: string;
|
||||
},
|
||||
];
|
||||
hasMore: boolean;
|
||||
limit: number;
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +57,7 @@ export async function getChatList(
|
||||
const url = params.appid
|
||||
? `/v1/chat/conversations/${params.appid}`
|
||||
: '/v1/chat/conversations/';
|
||||
return requestClient.request<ChatflowApi.ChatListResult[]>(url, {
|
||||
return requestClient.request<ChatflowApi.ChatListResult>(url, {
|
||||
data,
|
||||
method: 'POST',
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
import type { SpiderItem } from '@vben/common-ui';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace RepositoryApi {
|
||||
@ -9,9 +7,9 @@ export namespace RepositoryApi {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAppList(params: RepositoryApi.AppListParams) {
|
||||
return requestClient.get<SpiderItem[]>(`/v1/server/apps`, { params });
|
||||
}
|
||||
export const getAppList = (params: RepositoryApi.AppListParams) => {
|
||||
return requestClient.get(`/v1/server/apps`, { params });
|
||||
};
|
||||
|
||||
// export const getAppDetail = (id) => {
|
||||
// return requestClient.get(`/v1/server/${id}`)
|
||||
|
@ -51,7 +51,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
realName: user.username,
|
||||
username: user.username,
|
||||
roles: [user.role.name],
|
||||
homePath: '/home',
|
||||
homePath: '/analytics',
|
||||
token: csrf.token,
|
||||
};
|
||||
accessStore.setAccessToken(csrf.token);
|
||||
@ -114,7 +114,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
realName: user.username,
|
||||
username: user.username,
|
||||
roles: [user.role.name],
|
||||
homePath: '/home',
|
||||
homePath: '/analytics',
|
||||
token: csrf.token,
|
||||
};
|
||||
userStore.setUserInfo(userInfo);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="tsx">
|
||||
import type {
|
||||
AttachmentsProps,
|
||||
BubbleListProps,
|
||||
@ -15,6 +15,7 @@ import {
|
||||
CommentOutlined,
|
||||
CopyOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
EllipsisOutlined,
|
||||
FireOutlined,
|
||||
HeartOutlined,
|
||||
@ -48,6 +49,8 @@ import {
|
||||
|
||||
import { getChatList, sendWorkflow } from '#/api';
|
||||
|
||||
import '@vue-office/pptx/lib/index.css';
|
||||
|
||||
defineOptions({ name: 'PlaygroundIndependentSetup' });
|
||||
|
||||
const { token } = theme.useToken();
|
||||
@ -132,6 +135,11 @@ const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
const menuConfig: ConversationsProps['menu'] = (conversation) => ({
|
||||
items: [
|
||||
{
|
||||
label: '重命名',
|
||||
key: 'operation1',
|
||||
icon: h(EditOutlined),
|
||||
},
|
||||
{
|
||||
label: '删除此对话',
|
||||
key: 'operation3',
|
||||
@ -148,16 +156,43 @@ const acticeModeKey = ref('1');
|
||||
|
||||
// 定义模板数据
|
||||
const templates = ref([
|
||||
{ label: '模板1', key: '1' },
|
||||
{ label: '模板2', key: '2' },
|
||||
{ label: '模板3', key: '3' },
|
||||
{ label: '模板34', key: '4' },
|
||||
{ label: '模板35', key: '5' },
|
||||
{ label: '模板36', key: '7' },
|
||||
{ label: '模板37', key: '8' },
|
||||
{ label: '模板38', key: '9' },
|
||||
{ label: '模板1', key: '333', group: 'model' },
|
||||
{ label: '模板2', key: '334', group: 'model' },
|
||||
{ label: '模板3', key: '335', group: 'model' },
|
||||
{ label: '模板34', key: '336', group: 'model' },
|
||||
{ label: '模板35', key: '337', group: 'model' },
|
||||
{ label: '模板36', key: '338', group: 'model' },
|
||||
{ label: '模板37', key: '339', group: 'model' },
|
||||
{ label: '模板38', key: '340', group: 'model' },
|
||||
]);
|
||||
|
||||
// 获取 templates 和 conversationsItems 的集合
|
||||
// const combinedItems = computed(() => {
|
||||
// return [
|
||||
// ...templates.value, // 添加 templates 数据
|
||||
// ...conversationsItems.value, // 添加 conversationsItems 数据
|
||||
// ];
|
||||
// });
|
||||
|
||||
const groupable: ConversationsProps['groupable'] = {
|
||||
sort(a, b) {
|
||||
if (a === b) return 0;
|
||||
|
||||
return a === 'history' ? -1 : 1;
|
||||
},
|
||||
title: (group, { components: { GroupTitle } }) =>
|
||||
group ? (
|
||||
<GroupTitle>
|
||||
<Space>
|
||||
<CommentOutlined />
|
||||
<span>{group === 'history' ? '会话记录' : 'PPT模板'}</span>
|
||||
</Space>
|
||||
</GroupTitle>
|
||||
) : (
|
||||
<GroupTitle />
|
||||
),
|
||||
};
|
||||
|
||||
// const sleep = () => new Promise(resolve => setTimeout(resolve, 500))
|
||||
|
||||
function renderTitle(icon: VNode, title: string) {
|
||||
@ -176,21 +211,21 @@ const placeholderPromptsItems: PromptsProps['items'] = [
|
||||
key: '1',
|
||||
label: renderTitle(
|
||||
h(FireOutlined, { style: { color: '#FF4D4F' } }),
|
||||
'Hot Topics',
|
||||
'热门话题',
|
||||
),
|
||||
description: 'What are you interested in?',
|
||||
description: '你对什么感兴趣?',
|
||||
children: [
|
||||
{
|
||||
key: '1-1',
|
||||
description: `What's new in X?`,
|
||||
description: `X有什么新功能?`,
|
||||
},
|
||||
{
|
||||
key: '1-2',
|
||||
description: `What's AGI?`,
|
||||
description: `AGI是什么?`,
|
||||
},
|
||||
{
|
||||
key: '1-3',
|
||||
description: `Where is the doc?`,
|
||||
description: `医生在哪里?`,
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -198,24 +233,24 @@ const placeholderPromptsItems: PromptsProps['items'] = [
|
||||
key: '2',
|
||||
label: renderTitle(
|
||||
h(ReadOutlined, { style: { color: '#1890FF' } }),
|
||||
'Design Guide',
|
||||
'设计指导',
|
||||
),
|
||||
description: 'How to design a good product?',
|
||||
description: '如何设计一个好的产品?',
|
||||
children: [
|
||||
{
|
||||
key: '2-1',
|
||||
icon: h(HeartOutlined),
|
||||
description: `Know the well`,
|
||||
description: `了解情况`,
|
||||
},
|
||||
{
|
||||
key: '2-2',
|
||||
icon: h(SmileOutlined),
|
||||
description: `Set the AI role`,
|
||||
description: `设置AI角色`,
|
||||
},
|
||||
{
|
||||
key: '2-3',
|
||||
icon: h(CommentOutlined),
|
||||
description: `Express the feeling`,
|
||||
description: `表达感受`,
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -224,12 +259,12 @@ const placeholderPromptsItems: PromptsProps['items'] = [
|
||||
const senderPromptsItems: PromptsProps['items'] = [
|
||||
{
|
||||
key: '1',
|
||||
description: 'Hot Topics',
|
||||
description: '热门话题',
|
||||
icon: h(FireOutlined, { style: { color: '#FF4D4F' } }),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
description: 'Design Guide',
|
||||
description: '设计指导',
|
||||
icon: h(ReadOutlined, { style: { color: '#1890FF' } }),
|
||||
},
|
||||
];
|
||||
@ -317,7 +352,8 @@ function onAddConversation() {
|
||||
...conversationsItems.value,
|
||||
{
|
||||
key: `${conversationsItems.value.length}`,
|
||||
label: `New Conversation ${conversationsItems.value.length}`,
|
||||
label: `会话 ${conversationsItems.value.length}`,
|
||||
group: 'history',
|
||||
},
|
||||
];
|
||||
activeKey.value = `${conversationsItems.value.length}`;
|
||||
@ -339,16 +375,16 @@ const placeholderNode = computed(() =>
|
||||
h(Welcome, {
|
||||
variant: 'borderless',
|
||||
icon: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*s5sNRo5LjfQAAAAAAAAAAAAADgCCAQ/fmt.webp',
|
||||
title: "Hello, I'm Ant Design X",
|
||||
title: '欢迎使用PPT自动生成',
|
||||
description:
|
||||
'Base on Ant Design, AGI product interface solution, create a better intelligent vision~',
|
||||
'基于Ant Design,提供AGI产品接口解决方案,打造更好的智能视觉~',
|
||||
extra: h(Space, {}, [
|
||||
h(Button, { icon: h(ShareAltOutlined) }),
|
||||
h(Button, { icon: h(EllipsisOutlined) }),
|
||||
]),
|
||||
}),
|
||||
h(Prompts, {
|
||||
title: 'Do you want?',
|
||||
title: '你想要?',
|
||||
items: placeholderPromptsItems,
|
||||
styles: {
|
||||
list: {
|
||||
@ -391,14 +427,15 @@ const getConversationList = async () => {
|
||||
limit: '5',
|
||||
},
|
||||
);
|
||||
if (res.status === 200) {
|
||||
if (res.data.length > 0) {
|
||||
conversationsItems.value = res.data.map((item: any) => {
|
||||
return {
|
||||
key: item.id,
|
||||
label: item.name,
|
||||
group: 'history',
|
||||
};
|
||||
});
|
||||
activeKey.value = res.data.data[0].id;
|
||||
activeKey.value = res.data[0].id;
|
||||
}
|
||||
};
|
||||
|
||||
@ -448,14 +485,14 @@ const pptStyle = ref({
|
||||
});
|
||||
|
||||
// 监听窗口大小变化
|
||||
const handleResize = () => {
|
||||
// 动态调整宽度和高度
|
||||
pptStyle.value = {
|
||||
height: 'calc(100vh - 150px)', // 保持高度不变
|
||||
width: '40%', // 宽度为窗口宽度的 40%
|
||||
margin: '30px 20px',
|
||||
};
|
||||
};
|
||||
// const handleResize = () => {
|
||||
// // 动态调整宽度和高度
|
||||
// pptStyle.value = {
|
||||
// height: 'calc(100vh - 150px)', // 保持高度不变
|
||||
// width: '40%', // 宽度为窗口宽度的 40%
|
||||
// margin: '30px 20px',
|
||||
// };
|
||||
// };
|
||||
|
||||
// 监听模板选择事件
|
||||
const onModeClick: ConversationsProps['onActiveChange'] = (key) => {
|
||||
@ -471,51 +508,57 @@ const errorHandler = () => {
|
||||
|
||||
onMounted(() => {
|
||||
getConversationList();
|
||||
window.addEventListener('resize', handleResize);
|
||||
// window.addEventListener('resize', ()=>{
|
||||
// handleResize(),
|
||||
// console.error('窗口大小变化')
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<contextHolder />
|
||||
<div :style="styles.layout" style="height: calc(100vh - 70px)">
|
||||
<contextHolder />
|
||||
<div :style="styles.menu">
|
||||
<!-- 🌟 Logo -->
|
||||
<div :style="styles.logo">
|
||||
<img
|
||||
src="https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*eco6RrQhxbMAAAAAAAAAAAAADgCCAQ/original"
|
||||
draggable="false"
|
||||
alt="logo"
|
||||
:style="styles['logo-img']"
|
||||
/>
|
||||
<span :style="styles['logo-span']">PPT模板生成</span>
|
||||
</div>
|
||||
|
||||
<!-- 🌟 添加会话 -->
|
||||
<Button type="link" :style="styles.addBtn" @click="onAddConversation">
|
||||
<Button
|
||||
type="link"
|
||||
:style="styles.addBtn"
|
||||
style="margin-top: 20px"
|
||||
@click="onAddConversation"
|
||||
>
|
||||
<PlusOutlined />
|
||||
新建会话
|
||||
</Button>
|
||||
|
||||
<!-- 🌟 会话管理 -->
|
||||
<Conversations
|
||||
:items="conversationsItems"
|
||||
:style="styles.conversations"
|
||||
:active-key="activeKey"
|
||||
:menu="menuConfig"
|
||||
@active-change="onConversationClick"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
height: 100%;
|
||||
"
|
||||
>
|
||||
<Conversations
|
||||
:items="conversationsItems"
|
||||
:style="styles.conversations"
|
||||
style="height: 50%"
|
||||
:active-key="activeKey"
|
||||
:menu="menuConfig"
|
||||
:groupable="groupable"
|
||||
@active-change="onConversationClick"
|
||||
/>
|
||||
|
||||
<!-- 🌟 会话管理 -->
|
||||
<Typography.Title :level="5" style="margin: 0 0 8px">
|
||||
选择模板
|
||||
</Typography.Title>
|
||||
<Conversations
|
||||
:items="templates"
|
||||
:style="styles.conversations"
|
||||
:active-key="acticeModeKey"
|
||||
:menu="menuConfig"
|
||||
@active-change="onModeClick"
|
||||
/>
|
||||
<!-- 🌟 会话管理 -->
|
||||
<Conversations
|
||||
:items="templates"
|
||||
:style="styles.conversations"
|
||||
:active-key="acticeModeKey"
|
||||
:menu="menuConfig"
|
||||
:groupable="groupable"
|
||||
@active-change="onModeClick"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div :style="styles.chat" style="margin-left: 20px">
|
||||
|
@ -1,27 +1,114 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SpiderItem } from '@vben/common-ui';
|
||||
|
||||
<script setup lang="js">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { SpiderListView, SpiderWorkView } from '@vben/common-ui';
|
||||
|
||||
import { getAppList, sendWorkflow } from '#/api';
|
||||
|
||||
const spiderList = ref<SpiderItem[]>([]);
|
||||
const loading = ref(true);
|
||||
const spider = ref<SpiderItem>();
|
||||
// 数据爬取工具列表
|
||||
const tools = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '工具一',
|
||||
description: '这是一个用于抓取网页数据的工具',
|
||||
content: '工具一的具体内容:支持多种网页抓取规则配置。',
|
||||
path: '/tools/tool1',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '工具二',
|
||||
description: '这是一个用于分析文本数据的工具',
|
||||
content: '工具二的具体内容:支持自然语言处理和文本分析功能。',
|
||||
path: '/tools/tool2',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '工具三',
|
||||
description: '这是一个用于数据清洗的工具',
|
||||
content: '工具三的具体内容:支持数据去重、格式化等操作。',
|
||||
path: '/tools/tool3',
|
||||
},
|
||||
]);
|
||||
|
||||
// 当前选中的工具
|
||||
const selectedTool = ref(null);
|
||||
|
||||
// 抓取状态相关变量
|
||||
const isFetching = ref(false);
|
||||
const fetchStatus = ref('idle'); // idle | fetching | completed
|
||||
|
||||
// 保存抓取结果
|
||||
const fetchResult = ref(null);
|
||||
|
||||
// 点击工具项时触发
|
||||
const selectTool = (tool) => {
|
||||
selectedTool.value = tool;
|
||||
fetchStatus.value = 'idle'; // 重置抓取状态
|
||||
};
|
||||
|
||||
const getChatflowList = async () => {
|
||||
const res = await getAppList({});
|
||||
if (res) {
|
||||
spiderList.value = res;
|
||||
loading.value = false;
|
||||
try {
|
||||
const res = await getAppList({
|
||||
mode: '',
|
||||
name: '',
|
||||
});
|
||||
tools.value = res;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
function handleClick(item: SpiderItem) {
|
||||
spider.value = item;
|
||||
}
|
||||
// 开始抓取逻辑
|
||||
const startFetching = async () => {
|
||||
if (!selectedTool.value) return;
|
||||
|
||||
// 更新状态为“抓取中”
|
||||
isFetching.value = true;
|
||||
fetchStatus.value = 'fetching';
|
||||
|
||||
try {
|
||||
const res = await sendWorkflow(
|
||||
{
|
||||
appid: 'c736edd0-925d-4877-9223-56aab7342311',
|
||||
},
|
||||
{
|
||||
userId: '1562',
|
||||
conversationId: '',
|
||||
files: [],
|
||||
inputs: {},
|
||||
},
|
||||
);
|
||||
// 保存抓取结果
|
||||
fetchResult.value = res.data.outputs.result;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
// 模拟抓取完成
|
||||
isFetching.value = false;
|
||||
fetchStatus.value = 'completed';
|
||||
};
|
||||
|
||||
// 下载文件逻辑
|
||||
const downloadFile = () => {
|
||||
if (!fetchResult.value) return;
|
||||
|
||||
// 使用抓取结果作为文件内容
|
||||
const fileName = `${selectedTool.value.name}.txt`;
|
||||
const fileContent = fetchResult.value;
|
||||
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([fileContent], { type: 'text/plain' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = fileName;
|
||||
|
||||
// 触发下载
|
||||
link.click();
|
||||
|
||||
// 释放 URL 对象
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getChatflowList();
|
||||
@ -29,23 +116,95 @@ onMounted(() => {
|
||||
</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">
|
||||
<SpiderListView
|
||||
:loading="loading"
|
||||
:items="spiderList"
|
||||
title="数据爬取工具"
|
||||
@click="handleClick"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-full lg:w-3/4">
|
||||
<SpiderWorkView
|
||||
:item="spider"
|
||||
:run-spider="sendWorkflow"
|
||||
title="目标网址:"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a-layout>
|
||||
<!-- 右侧部分开始 -->
|
||||
<a-layout :style="{ height: '100vh' }">
|
||||
<!-- 右侧页面主体开始 -->
|
||||
<a-layout-content
|
||||
:style="{
|
||||
margin: '12px 10px',
|
||||
padding: '18px',
|
||||
background: '#fff',
|
||||
minHeight: '280px',
|
||||
borderRadius: '4px',
|
||||
}"
|
||||
>
|
||||
<!-- 左右布局容器 -->
|
||||
<a-row
|
||||
:gutter="16"
|
||||
:style="{ height: 'calc(100vh - 100px)', overflow: 'hidden' }"
|
||||
>
|
||||
<!-- 左边:数据爬取工具列表 -->
|
||||
<a-col
|
||||
:span="6"
|
||||
:style="{
|
||||
height: '100%',
|
||||
overflowY: 'auto',
|
||||
borderRight: '1px solid #e8e8e8',
|
||||
}"
|
||||
>
|
||||
<a-card
|
||||
title="数据爬取工具列表"
|
||||
:bordered="false"
|
||||
:style="{ height: '100%' }"
|
||||
>
|
||||
<a-list item-layout="horizontal" :data-source="tools">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item @click="selectTool(item)">
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<span>{{ item.name }}</span>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<!-- 右边:所选工具的内容 -->
|
||||
<a-col
|
||||
:span="18"
|
||||
:style="{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
height: '100%',
|
||||
}"
|
||||
>
|
||||
<a-card
|
||||
v-if="selectedTool"
|
||||
title="工具"
|
||||
:bordered="false"
|
||||
:style="{ marginBottom: '20px' }"
|
||||
>
|
||||
<p>{{ selectedTool.name }}</p>
|
||||
|
||||
<!-- 抓取按钮和状态 -->
|
||||
<div style="float: right; margin-top: 20px">
|
||||
<a-button
|
||||
type="primary"
|
||||
style="margin-right: 12px"
|
||||
:loading="isFetching"
|
||||
@click="startFetching"
|
||||
>
|
||||
开始抓取
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="downloadFile"
|
||||
v-if="fetchStatus === 'completed'"
|
||||
>
|
||||
下载文件
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
<a-empty v-else description="请选择一个工具" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-layout-content>
|
||||
<!-- 右侧页面主体结束 -->
|
||||
</a-layout>
|
||||
<!-- 右侧部分结束 -->
|
||||
</a-layout>
|
||||
</template>
|
||||
|
@ -1,210 +0,0 @@
|
||||
<script setup lang="js">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { getAppList, sendWorkflow } from '#/api';
|
||||
|
||||
// 数据爬取工具列表
|
||||
const tools = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '工具一',
|
||||
description: '这是一个用于抓取网页数据的工具',
|
||||
content: '工具一的具体内容:支持多种网页抓取规则配置。',
|
||||
path: '/tools/tool1',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '工具二',
|
||||
description: '这是一个用于分析文本数据的工具',
|
||||
content: '工具二的具体内容:支持自然语言处理和文本分析功能。',
|
||||
path: '/tools/tool2',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '工具三',
|
||||
description: '这是一个用于数据清洗的工具',
|
||||
content: '工具三的具体内容:支持数据去重、格式化等操作。',
|
||||
path: '/tools/tool3',
|
||||
},
|
||||
]);
|
||||
|
||||
// 当前选中的工具
|
||||
const selectedTool = ref(null);
|
||||
|
||||
// 抓取状态相关变量
|
||||
const isFetching = ref(false);
|
||||
const fetchStatus = ref('idle'); // idle | fetching | completed
|
||||
|
||||
// 保存抓取结果
|
||||
const fetchResult = ref(null);
|
||||
|
||||
// 点击工具项时触发
|
||||
const selectTool = (tool) => {
|
||||
selectedTool.value = tool;
|
||||
fetchStatus.value = 'idle'; // 重置抓取状态
|
||||
};
|
||||
|
||||
const getChatflowList = async () => {
|
||||
try {
|
||||
const res = await getAppList({
|
||||
mode: '',
|
||||
name: '',
|
||||
});
|
||||
tools.value = res;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
// 开始抓取逻辑
|
||||
const startFetching = async () => {
|
||||
if (!selectedTool.value) return;
|
||||
|
||||
// 更新状态为“抓取中”
|
||||
isFetching.value = true;
|
||||
fetchStatus.value = 'fetching';
|
||||
|
||||
try {
|
||||
const res = await sendWorkflow(
|
||||
{
|
||||
appid: 'c736edd0-925d-4877-9223-56aab7342311',
|
||||
},
|
||||
{
|
||||
userId: '1562',
|
||||
conversationId: '',
|
||||
files: [],
|
||||
inputs: {},
|
||||
},
|
||||
);
|
||||
// 保存抓取结果
|
||||
fetchResult.value = res.data.outputs.result;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
// 模拟抓取完成
|
||||
isFetching.value = false;
|
||||
fetchStatus.value = 'completed';
|
||||
};
|
||||
|
||||
// 下载文件逻辑
|
||||
const downloadFile = () => {
|
||||
if (!fetchResult.value) return;
|
||||
|
||||
// 使用抓取结果作为文件内容
|
||||
const fileName = `${selectedTool.value.name}.txt`;
|
||||
const fileContent = fetchResult.value;
|
||||
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([fileContent], { type: 'text/plain' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = fileName;
|
||||
|
||||
// 触发下载
|
||||
link.click();
|
||||
|
||||
// 释放 URL 对象
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getChatflowList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-layout>
|
||||
<!-- 右侧部分开始 -->
|
||||
<a-layout :style="{ height: '100vh' }">
|
||||
<!-- 右侧页面主体开始 -->
|
||||
<a-layout-content
|
||||
:style="{
|
||||
margin: '12px 10px',
|
||||
padding: '18px',
|
||||
background: '#fff',
|
||||
minHeight: '280px',
|
||||
borderRadius: '4px',
|
||||
}"
|
||||
>
|
||||
<!-- 左右布局容器 -->
|
||||
<a-row
|
||||
:gutter="16"
|
||||
:style="{ height: 'calc(100vh - 100px)', overflow: 'hidden' }"
|
||||
>
|
||||
<!-- 左边:数据爬取工具列表 -->
|
||||
<a-col
|
||||
:span="6"
|
||||
:style="{
|
||||
height: '100%',
|
||||
overflowY: 'auto',
|
||||
borderRight: '1px solid #e8e8e8',
|
||||
}"
|
||||
>
|
||||
<a-card
|
||||
title="数据爬取工具列表"
|
||||
:bordered="false"
|
||||
:style="{ height: '100%' }"
|
||||
>
|
||||
<a-list item-layout="horizontal" :data-source="tools">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item @click="selectTool(item)">
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<span>{{ item.name }}</span>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<!-- 右边:所选工具的内容 -->
|
||||
<a-col
|
||||
:span="18"
|
||||
:style="{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
height: '100%',
|
||||
}"
|
||||
>
|
||||
<a-card
|
||||
v-if="selectedTool"
|
||||
title="工具"
|
||||
:bordered="false"
|
||||
:style="{ marginBottom: '20px' }"
|
||||
>
|
||||
<p>{{ selectedTool.name }}</p>
|
||||
|
||||
<!-- 抓取按钮和状态 -->
|
||||
<div style="float: right; margin-top: 20px">
|
||||
<a-button
|
||||
type="primary"
|
||||
style="margin-right: 12px"
|
||||
:loading="isFetching"
|
||||
@click="startFetching"
|
||||
>
|
||||
开始抓取
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="downloadFile"
|
||||
v-if="fetchStatus === 'completed'"
|
||||
>
|
||||
下载文件
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
<a-empty v-else description="请选择一个工具" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-layout-content>
|
||||
<!-- 右侧页面主体结束 -->
|
||||
</a-layout>
|
||||
<!-- 右侧部分结束 -->
|
||||
</a-layout>
|
||||
</template>
|
@ -14,6 +14,7 @@ import {
|
||||
CloudUploadOutlined,
|
||||
CommentOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
EllipsisOutlined,
|
||||
FireOutlined,
|
||||
HeartOutlined,
|
||||
@ -126,7 +127,7 @@ const styles = computed(() => {
|
||||
} as const;
|
||||
});
|
||||
|
||||
const pptx = ref<any>('/static/e5230571-ef0b-4fa0-a91d-f05313e15c3f.docx');
|
||||
const pptx = ref<any>('/static/9e1c421e-991c-411f-8176-6350a97e70f3.docx');
|
||||
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
@ -134,20 +135,14 @@ const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
const menuConfig: ConversationsProps['menu'] = (conversation) => ({
|
||||
items: [
|
||||
// {
|
||||
// label: 'Operation 1',
|
||||
// key: 'operation1',
|
||||
// icon: h(EditOutlined),
|
||||
// },
|
||||
// {
|
||||
// label: 'Operation 2',
|
||||
// key: 'operation2',
|
||||
// icon: h(StopOutlined),
|
||||
// disabled: true,
|
||||
// },
|
||||
{
|
||||
label: '重命名',
|
||||
key: 'operation1',
|
||||
icon: h(EditOutlined),
|
||||
},
|
||||
{
|
||||
label: '删除此对话',
|
||||
key: 'operation3',
|
||||
key: 'operation2',
|
||||
icon: h(DeleteOutlined),
|
||||
danger: true,
|
||||
},
|
||||
@ -495,8 +490,8 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<contextHolder />
|
||||
<div :style="styles.layout" style="height: calc(100vh - 70px)">
|
||||
<contextHolder />
|
||||
<div :style="styles.menu">
|
||||
<!-- 🌟 Logo -->
|
||||
<div :style="styles.logo">
|
||||
|
@ -13,18 +13,16 @@ export default defineConfig(async () => {
|
||||
target: 'http://localhost:8081/api',
|
||||
ws: true,
|
||||
},
|
||||
'/static': {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/static/, ''),
|
||||
target: 'http://47.112.173.8:6802',
|
||||
},
|
||||
'/static/*.docx': {
|
||||
'/static/**/*.docx': {
|
||||
changeOrigin: true,
|
||||
target: 'http://47.112.173.8:6805',
|
||||
},
|
||||
'/static': {
|
||||
changeOrigin: true,
|
||||
target: 'http://47.112.173.8:6802',
|
||||
},
|
||||
'/v1': {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/v1/, ''),
|
||||
target: 'http://localhost:8081/v1',
|
||||
},
|
||||
},
|
||||
|
@ -40,7 +40,6 @@
|
||||
"@vben/types": "workspace:*",
|
||||
"@vueuse/core": "catalog:",
|
||||
"@vueuse/integrations": "catalog:",
|
||||
"ant-design-vue": "catalog:",
|
||||
"qrcode": "catalog:",
|
||||
"tippy.js": "catalog:",
|
||||
"vue": "catalog:",
|
||||
|
@ -21,6 +21,7 @@ defineOptions({
|
||||
withDefaults(defineProps<Props>(), {
|
||||
items: () => [],
|
||||
});
|
||||
// const emit = defineEmits<{ (e: 'go', path: string): void }>();
|
||||
defineEmits(['click']);
|
||||
</script>
|
||||
|
||||
|
@ -3,4 +3,3 @@ export * from './authentication';
|
||||
export * from './dashboard';
|
||||
export * from './fallback';
|
||||
export * from './home';
|
||||
export * from './spider';
|
||||
|
@ -1,3 +0,0 @@
|
||||
export { default as SpiderListView } from './spider-list-view.vue';
|
||||
export { default as SpiderWorkView } from './spider-work-view.vue';
|
||||
export type * from './typing';
|
@ -1,49 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { SpiderItem } from './typing';
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@vben-core/shadcn-ui';
|
||||
|
||||
interface Props {
|
||||
items?: SpiderItem[];
|
||||
title: string;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
name: 'SpiderListView',
|
||||
});
|
||||
withDefaults(defineProps<Props>(), {
|
||||
items: () => [],
|
||||
});
|
||||
defineEmits(['click']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card
|
||||
v-loading="loading"
|
||||
style="height: calc(100vh - 120px); overflow-y: auto"
|
||||
>
|
||||
<CardHeader class="py-4">
|
||||
<CardTitle class="text-lg">{{ title }}</CardTitle>
|
||||
<CardDescription>请选择需要爬取的网站</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="flex flex-wrap p-5 pt-0">
|
||||
<ul class="divide-border w-full divide-y" role="list">
|
||||
<li
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
@click="$emit('click', item)"
|
||||
class="flex cursor-pointer justify-between gap-x-6 py-5"
|
||||
>
|
||||
{{ item.name }}
|
||||
</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
@ -1,139 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { SpiderItem } from './typing';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@vben-core/shadcn-ui';
|
||||
|
||||
interface SpiderParams {
|
||||
appid: string;
|
||||
}
|
||||
|
||||
interface SpiderContext {
|
||||
userId: string;
|
||||
conversationId: string;
|
||||
files: unknown[];
|
||||
inputs: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface SpiderResult {
|
||||
data: {
|
||||
outputs: {
|
||||
result: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface Props {
|
||||
item?: SpiderItem;
|
||||
title: string;
|
||||
runSpider?: (
|
||||
params: SpiderParams,
|
||||
context: SpiderContext,
|
||||
) => Promise<SpiderResult>;
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
name: 'SpiderWorkView',
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
item: () => {
|
||||
return null;
|
||||
},
|
||||
runSpider: () => async () => ({
|
||||
data: {
|
||||
outputs: {
|
||||
result: '',
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
const startFetching = async () => {
|
||||
// 更新状态为“抓取中”
|
||||
isFetching.value = true;
|
||||
fetchStatus.value = 'fetching';
|
||||
|
||||
try {
|
||||
const res = await props.runSpider(
|
||||
{
|
||||
appid: 'c736edd0-925d-4877-9223-56aab7342311',
|
||||
},
|
||||
{
|
||||
userId: '1562',
|
||||
conversationId: '',
|
||||
files: [],
|
||||
inputs: {},
|
||||
},
|
||||
);
|
||||
// 保存抓取结果
|
||||
fetchResult.value = res.data.outputs.result;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
// 模拟抓取完成
|
||||
isFetching.value = false;
|
||||
fetchStatus.value = 'completed';
|
||||
};
|
||||
|
||||
// 下载文件逻辑
|
||||
const downloadFile = () => {
|
||||
if (!fetchResult.value) return;
|
||||
|
||||
// 使用抓取结果作为文件内容
|
||||
const fileName = `${props.item.name}.txt`;
|
||||
const fileContent = fetchResult.value;
|
||||
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([fileContent], { type: 'text/plain' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = fileName;
|
||||
|
||||
// 触发下载
|
||||
link.click();
|
||||
|
||||
// 释放 URL 对象
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
const isFetching = ref(false);
|
||||
const fetchResult = ref('');
|
||||
const fetchStatus = ref('');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full">
|
||||
<Card class="w-full self-end" v-loading="isFetching">
|
||||
<CardHeader class="py-4">
|
||||
<CardTitle class="text-lg">{{ title }}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent class="flex flex-wrap pt-0">
|
||||
{{ item ? item.name : '请选择右侧爬虫' }}
|
||||
</CardContent>
|
||||
<CardFooter class="flex justify-end">
|
||||
<Button :disabled="!item" @click="startFetching">
|
||||
{{ isFetching ? '抓取中...' : '开始抓取' }}
|
||||
</Button>
|
||||
<Button
|
||||
class="mx-2"
|
||||
:disabled="fetchStatus !== 'completed'"
|
||||
@click="downloadFile"
|
||||
>
|
||||
下载文件
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
@ -1,9 +0,0 @@
|
||||
interface SpiderItem {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
content: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export type { SpiderItem };
|
@ -1329,9 +1329,6 @@ importers:
|
||||
'@vueuse/integrations':
|
||||
specifier: 'catalog:'
|
||||
version: 13.1.0(async-validator@4.2.5)(axios@1.9.0)(focus-trap@7.6.4)(jwt-decode@4.0.0)(nprogress@0.2.0)(qrcode@1.5.4)(sortablejs@1.15.6)(vue@3.5.13(typescript@5.8.3))
|
||||
ant-design-vue:
|
||||
specifier: 'catalog:'
|
||||
version: 4.2.6(vue@3.5.13(typescript@5.8.3))
|
||||
qrcode:
|
||||
specifier: 'catalog:'
|
||||
version: 1.5.4
|
||||
|
Loading…
Reference in New Issue
Block a user