feat(@vben/web-antd): 重构PPT生成页面并调整

This commit is contained in:
Kven 2025-05-05 18:00:00 +08:00
parent 83953c07c4
commit 53a0137cb4
16 changed files with 339 additions and 554 deletions

View File

@ -24,15 +24,21 @@ export namespace ChatflowApi {
} }
export interface ChatListResult { export interface ChatListResult {
data: [
{
createAt: string;
id: string; id: string;
name: string;
inputs: { inputs: {
[key: string]: any; [key: string]: any;
}; };
status: string;
introduction: string; introduction: string;
createAt: string; name: string;
status: string;
updatedAt: string; updatedAt: string;
},
];
hasMore: boolean;
limit: number;
} }
} }
@ -51,7 +57,7 @@ export async function getChatList(
const url = params.appid const url = params.appid
? `/v1/chat/conversations/${params.appid}` ? `/v1/chat/conversations/${params.appid}`
: '/v1/chat/conversations/'; : '/v1/chat/conversations/';
return requestClient.request<ChatflowApi.ChatListResult[]>(url, { return requestClient.request<ChatflowApi.ChatListResult>(url, {
data, data,
method: 'POST', method: 'POST',
}); });

View File

@ -1,5 +1,3 @@
import type { SpiderItem } from '@vben/common-ui';
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
export namespace RepositoryApi { export namespace RepositoryApi {
@ -9,9 +7,9 @@ export namespace RepositoryApi {
} }
} }
export async function getAppList(params: RepositoryApi.AppListParams) { export const getAppList = (params: RepositoryApi.AppListParams) => {
return requestClient.get<SpiderItem[]>(`/v1/server/apps`, { params }); return requestClient.get(`/v1/server/apps`, { params });
} };
// export const getAppDetail = (id) => { // export const getAppDetail = (id) => {
// return requestClient.get(`/v1/server/${id}`) // return requestClient.get(`/v1/server/${id}`)

View File

@ -51,7 +51,7 @@ export const useAuthStore = defineStore('auth', () => {
realName: user.username, realName: user.username,
username: user.username, username: user.username,
roles: [user.role.name], roles: [user.role.name],
homePath: '/home', homePath: '/analytics',
token: csrf.token, token: csrf.token,
}; };
accessStore.setAccessToken(csrf.token); accessStore.setAccessToken(csrf.token);
@ -114,7 +114,7 @@ export const useAuthStore = defineStore('auth', () => {
realName: user.username, realName: user.username,
username: user.username, username: user.username,
roles: [user.role.name], roles: [user.role.name],
homePath: '/home', homePath: '/analytics',
token: csrf.token, token: csrf.token,
}; };
userStore.setUserInfo(userInfo); userStore.setUserInfo(userInfo);

View File

@ -1,4 +1,4 @@
<script setup lang="ts"> <script setup lang="tsx">
import type { import type {
AttachmentsProps, AttachmentsProps,
BubbleListProps, BubbleListProps,
@ -15,6 +15,7 @@ import {
CommentOutlined, CommentOutlined,
CopyOutlined, CopyOutlined,
DeleteOutlined, DeleteOutlined,
EditOutlined,
EllipsisOutlined, EllipsisOutlined,
FireOutlined, FireOutlined,
HeartOutlined, HeartOutlined,
@ -48,6 +49,8 @@ import {
import { getChatList, sendWorkflow } from '#/api'; import { getChatList, sendWorkflow } from '#/api';
import '@vue-office/pptx/lib/index.css';
defineOptions({ name: 'PlaygroundIndependentSetup' }); defineOptions({ name: 'PlaygroundIndependentSetup' });
const { token } = theme.useToken(); const { token } = theme.useToken();
@ -132,6 +135,11 @@ const [messageApi, contextHolder] = message.useMessage();
const menuConfig: ConversationsProps['menu'] = (conversation) => ({ const menuConfig: ConversationsProps['menu'] = (conversation) => ({
items: [ items: [
{
label: '重命名',
key: 'operation1',
icon: h(EditOutlined),
},
{ {
label: '删除此对话', label: '删除此对话',
key: 'operation3', key: 'operation3',
@ -148,16 +156,43 @@ const acticeModeKey = ref('1');
// //
const templates = ref([ const templates = ref([
{ label: '模板1', key: '1' }, { label: '模板1', key: '333', group: 'model' },
{ label: '模板2', key: '2' }, { label: '模板2', key: '334', group: 'model' },
{ label: '模板3', key: '3' }, { label: '模板3', key: '335', group: 'model' },
{ label: '模板34', key: '4' }, { label: '模板34', key: '336', group: 'model' },
{ label: '模板35', key: '5' }, { label: '模板35', key: '337', group: 'model' },
{ label: '模板36', key: '7' }, { label: '模板36', key: '338', group: 'model' },
{ label: '模板37', key: '8' }, { label: '模板37', key: '339', group: 'model' },
{ label: '模板38', key: '9' }, { 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)) // const sleep = () => new Promise(resolve => setTimeout(resolve, 500))
function renderTitle(icon: VNode, title: string) { function renderTitle(icon: VNode, title: string) {
@ -176,21 +211,21 @@ const placeholderPromptsItems: PromptsProps['items'] = [
key: '1', key: '1',
label: renderTitle( label: renderTitle(
h(FireOutlined, { style: { color: '#FF4D4F' } }), h(FireOutlined, { style: { color: '#FF4D4F' } }),
'Hot Topics', '热门话题',
), ),
description: 'What are you interested in?', description: '你对什么感兴趣?',
children: [ children: [
{ {
key: '1-1', key: '1-1',
description: `What's new in X?`, description: `X有什么新功能?`,
}, },
{ {
key: '1-2', key: '1-2',
description: `What's AGI?`, description: `AGI是什么?`,
}, },
{ {
key: '1-3', key: '1-3',
description: `Where is the doc?`, description: `医生在哪里?`,
}, },
], ],
}, },
@ -198,24 +233,24 @@ const placeholderPromptsItems: PromptsProps['items'] = [
key: '2', key: '2',
label: renderTitle( label: renderTitle(
h(ReadOutlined, { style: { color: '#1890FF' } }), h(ReadOutlined, { style: { color: '#1890FF' } }),
'Design Guide', '设计指导',
), ),
description: 'How to design a good product?', description: '如何设计一个好的产品?',
children: [ children: [
{ {
key: '2-1', key: '2-1',
icon: h(HeartOutlined), icon: h(HeartOutlined),
description: `Know the well`, description: `了解情况`,
}, },
{ {
key: '2-2', key: '2-2',
icon: h(SmileOutlined), icon: h(SmileOutlined),
description: `Set the AI role`, description: `设置AI角色`,
}, },
{ {
key: '2-3', key: '2-3',
icon: h(CommentOutlined), icon: h(CommentOutlined),
description: `Express the feeling`, description: `表达感受`,
}, },
], ],
}, },
@ -224,12 +259,12 @@ const placeholderPromptsItems: PromptsProps['items'] = [
const senderPromptsItems: PromptsProps['items'] = [ const senderPromptsItems: PromptsProps['items'] = [
{ {
key: '1', key: '1',
description: 'Hot Topics', description: '热门话题',
icon: h(FireOutlined, { style: { color: '#FF4D4F' } }), icon: h(FireOutlined, { style: { color: '#FF4D4F' } }),
}, },
{ {
key: '2', key: '2',
description: 'Design Guide', description: '设计指导',
icon: h(ReadOutlined, { style: { color: '#1890FF' } }), icon: h(ReadOutlined, { style: { color: '#1890FF' } }),
}, },
]; ];
@ -317,7 +352,8 @@ function onAddConversation() {
...conversationsItems.value, ...conversationsItems.value,
{ {
key: `${conversationsItems.value.length}`, key: `${conversationsItems.value.length}`,
label: `New Conversation ${conversationsItems.value.length}`, label: `会话 ${conversationsItems.value.length}`,
group: 'history',
}, },
]; ];
activeKey.value = `${conversationsItems.value.length}`; activeKey.value = `${conversationsItems.value.length}`;
@ -339,16 +375,16 @@ const placeholderNode = computed(() =>
h(Welcome, { h(Welcome, {
variant: 'borderless', variant: 'borderless',
icon: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*s5sNRo5LjfQAAAAAAAAAAAAADgCCAQ/fmt.webp', icon: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*s5sNRo5LjfQAAAAAAAAAAAAADgCCAQ/fmt.webp',
title: "Hello, I'm Ant Design X", title: '欢迎使用PPT自动生成',
description: description:
'Base on Ant Design, AGI product interface solution, create a better intelligent vision~', '基于Ant Design提供AGI产品接口解决方案打造更好的智能视觉~',
extra: h(Space, {}, [ extra: h(Space, {}, [
h(Button, { icon: h(ShareAltOutlined) }), h(Button, { icon: h(ShareAltOutlined) }),
h(Button, { icon: h(EllipsisOutlined) }), h(Button, { icon: h(EllipsisOutlined) }),
]), ]),
}), }),
h(Prompts, { h(Prompts, {
title: 'Do you want?', title: '你想要?',
items: placeholderPromptsItems, items: placeholderPromptsItems,
styles: { styles: {
list: { list: {
@ -391,14 +427,15 @@ const getConversationList = async () => {
limit: '5', limit: '5',
}, },
); );
if (res.status === 200) { if (res.data.length > 0) {
conversationsItems.value = res.data.map((item: any) => { conversationsItems.value = res.data.map((item: any) => {
return { return {
key: item.id, key: item.id,
label: item.name, 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 = () => { // const handleResize = () => {
// // //
pptStyle.value = { // pptStyle.value = {
height: 'calc(100vh - 150px)', // // height: 'calc(100vh - 150px)', //
width: '40%', // 40% // width: '40%', // 40%
margin: '30px 20px', // margin: '30px 20px',
}; // };
}; // };
// //
const onModeClick: ConversationsProps['onActiveChange'] = (key) => { const onModeClick: ConversationsProps['onActiveChange'] = (key) => {
@ -471,52 +508,58 @@ const errorHandler = () => {
onMounted(() => { onMounted(() => {
getConversationList(); getConversationList();
window.addEventListener('resize', handleResize); // window.addEventListener('resize', ()=>{
// handleResize(),
// console.error('')
// });
}); });
</script> </script>
<template> <template>
<contextHolder />
<div :style="styles.layout" style="height: calc(100vh - 70px)"> <div :style="styles.layout" style="height: calc(100vh - 70px)">
<contextHolder />
<div :style="styles.menu"> <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 /> <PlusOutlined />
新建会话 新建会话
</Button> </Button>
<!-- 🌟 会话管理 --> <!-- 🌟 会话管理 -->
<div
style="
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
"
>
<Conversations <Conversations
:items="conversationsItems" :items="conversationsItems"
:style="styles.conversations" :style="styles.conversations"
style="height: 50%"
:active-key="activeKey" :active-key="activeKey"
:menu="menuConfig" :menu="menuConfig"
:groupable="groupable"
@active-change="onConversationClick" @active-change="onConversationClick"
/> />
<!-- 🌟 会话管理 --> <!-- 🌟 会话管理 -->
<Typography.Title :level="5" style="margin: 0 0 8px">
选择模板
</Typography.Title>
<Conversations <Conversations
:items="templates" :items="templates"
:style="styles.conversations" :style="styles.conversations"
:active-key="acticeModeKey" :active-key="acticeModeKey"
:menu="menuConfig" :menu="menuConfig"
:groupable="groupable"
@active-change="onModeClick" @active-change="onModeClick"
/> />
</div> </div>
</div>
<div :style="styles.chat" style="margin-left: 20px"> <div :style="styles.chat" style="margin-left: 20px">
<!-- 🌟 消息列表 --> <!-- 🌟 消息列表 -->

View File

@ -1,27 +1,114 @@
<script lang="ts" setup> <script setup lang="js">
import type { SpiderItem } from '@vben/common-ui';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { SpiderListView, SpiderWorkView } from '@vben/common-ui';
import { getAppList, sendWorkflow } from '#/api'; import { getAppList, sendWorkflow } from '#/api';
const spiderList = ref<SpiderItem[]>([]); //
const loading = ref(true); const tools = ref([
const spider = ref<SpiderItem>(); {
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 getChatflowList = async () => {
const res = await getAppList({}); try {
if (res) { const res = await getAppList({
spiderList.value = res; mode: '',
loading.value = false; 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(() => { onMounted(() => {
getChatflowList(); getChatflowList();
@ -29,23 +116,95 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="px-5"> <a-layout>
<div class="mt-5 flex flex-col lg:flex-row"> <!-- 右侧部分开始 -->
<div class="mr-4 w-full lg:w-1/4"> <a-layout :style="{ height: '100vh' }">
<SpiderListView <!-- 右侧页面主体开始 -->
:loading="loading" <a-layout-content
:items="spiderList" :style="{
title="数据爬取工具" margin: '12px 10px',
@click="handleClick" padding: '18px',
/> background: '#fff',
</div> minHeight: '280px',
<div class="w-full lg:w-3/4"> borderRadius: '4px',
<SpiderWorkView }"
:item="spider" >
:run-spider="sendWorkflow" <!-- 左右布局容器 -->
title="目标网址:" <a-row
/> :gutter="16"
</div> :style="{ height: 'calc(100vh - 100px)', overflow: 'hidden' }"
</div> >
<!-- 左边数据爬取工具列表 -->
<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> </div>
</a-card>
<a-empty v-else description="请选择一个工具" />
</a-col>
</a-row>
</a-layout-content>
<!-- 右侧页面主体结束 -->
</a-layout>
<!-- 右侧部分结束 -->
</a-layout>
</template> </template>

View File

@ -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>

View File

@ -14,6 +14,7 @@ import {
CloudUploadOutlined, CloudUploadOutlined,
CommentOutlined, CommentOutlined,
DeleteOutlined, DeleteOutlined,
EditOutlined,
EllipsisOutlined, EllipsisOutlined,
FireOutlined, FireOutlined,
HeartOutlined, HeartOutlined,
@ -126,7 +127,7 @@ const styles = computed(() => {
} as const; } 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(); const [messageApi, contextHolder] = message.useMessage();
@ -134,20 +135,14 @@ const [messageApi, contextHolder] = message.useMessage();
const menuConfig: ConversationsProps['menu'] = (conversation) => ({ const menuConfig: ConversationsProps['menu'] = (conversation) => ({
items: [ items: [
// { {
// label: 'Operation 1', label: '重命名',
// key: 'operation1', key: 'operation1',
// icon: h(EditOutlined), icon: h(EditOutlined),
// }, },
// {
// label: 'Operation 2',
// key: 'operation2',
// icon: h(StopOutlined),
// disabled: true,
// },
{ {
label: '删除此对话', label: '删除此对话',
key: 'operation3', key: 'operation2',
icon: h(DeleteOutlined), icon: h(DeleteOutlined),
danger: true, danger: true,
}, },
@ -495,8 +490,8 @@ onMounted(() => {
</script> </script>
<template> <template>
<contextHolder />
<div :style="styles.layout" style="height: calc(100vh - 70px)"> <div :style="styles.layout" style="height: calc(100vh - 70px)">
<contextHolder />
<div :style="styles.menu"> <div :style="styles.menu">
<!-- 🌟 Logo --> <!-- 🌟 Logo -->
<div :style="styles.logo"> <div :style="styles.logo">

View File

@ -13,18 +13,16 @@ export default defineConfig(async () => {
target: 'http://localhost:8081/api', target: 'http://localhost:8081/api',
ws: true, ws: true,
}, },
'/static': { '/static/**/*.docx': {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/static/, ''),
target: 'http://47.112.173.8:6802',
},
'/static/*.docx': {
changeOrigin: true, changeOrigin: true,
target: 'http://47.112.173.8:6805', target: 'http://47.112.173.8:6805',
}, },
'/static': {
changeOrigin: true,
target: 'http://47.112.173.8:6802',
},
'/v1': { '/v1': {
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/v1/, ''),
target: 'http://localhost:8081/v1', target: 'http://localhost:8081/v1',
}, },
}, },

View File

@ -40,7 +40,6 @@
"@vben/types": "workspace:*", "@vben/types": "workspace:*",
"@vueuse/core": "catalog:", "@vueuse/core": "catalog:",
"@vueuse/integrations": "catalog:", "@vueuse/integrations": "catalog:",
"ant-design-vue": "catalog:",
"qrcode": "catalog:", "qrcode": "catalog:",
"tippy.js": "catalog:", "tippy.js": "catalog:",
"vue": "catalog:", "vue": "catalog:",

View File

@ -21,6 +21,7 @@ defineOptions({
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
items: () => [], items: () => [],
}); });
// const emit = defineEmits<{ (e: 'go', path: string): void }>();
defineEmits(['click']); defineEmits(['click']);
</script> </script>

View File

@ -3,4 +3,3 @@ export * from './authentication';
export * from './dashboard'; export * from './dashboard';
export * from './fallback'; export * from './fallback';
export * from './home'; export * from './home';
export * from './spider';

View File

@ -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';

View File

@ -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>

View File

@ -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>

View File

@ -1,9 +0,0 @@
interface SpiderItem {
id: number;
name: string;
description: string;
content: string;
path: string;
}
export type { SpiderItem };

View File

@ -1329,9 +1329,6 @@ importers:
'@vueuse/integrations': '@vueuse/integrations':
specifier: 'catalog:' 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)) 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: qrcode:
specifier: 'catalog:' specifier: 'catalog:'
version: 1.5.4 version: 1.5.4