2025-05-05 16:33:06 +08:00
|
|
|
<script lang="ts" setup>
|
2025-05-06 01:46:24 +08:00
|
|
|
import { ref } from 'vue';
|
2025-05-04 18:45:03 +08:00
|
|
|
|
2025-05-05 16:33:06 +08:00
|
|
|
import { SpiderListView, SpiderWorkView } from '@vben/common-ui';
|
2025-05-04 18:45:03 +08:00
|
|
|
|
2025-05-16 17:44:56 +08:00
|
|
|
import { notification } from 'ant-design-vue';
|
|
|
|
|
2025-05-17 22:07:52 +08:00
|
|
|
import {
|
|
|
|
getSpiderStatus,
|
|
|
|
getWorkflowInfo,
|
|
|
|
getWorkflowList,
|
|
|
|
runSpider,
|
|
|
|
sendWorkflow,
|
|
|
|
stopSpider,
|
|
|
|
} from '#/api';
|
2025-05-16 23:02:11 +08:00
|
|
|
// sendWorkflow
|
2025-05-17 17:34:27 +08:00
|
|
|
interface TempItem {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
url: string;
|
|
|
|
}
|
|
|
|
|
2025-05-16 17:44:56 +08:00
|
|
|
interface ResultItem {
|
|
|
|
key: number;
|
|
|
|
role: 'ai' | 'user';
|
|
|
|
content: string;
|
|
|
|
footer?: any;
|
|
|
|
}
|
|
|
|
interface WordFlowItem {
|
|
|
|
id: string;
|
|
|
|
workflowRunId: string;
|
|
|
|
taskId: string;
|
|
|
|
userId: string;
|
|
|
|
appId: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const hitsory = ref([]);
|
|
|
|
const loading = ref(true);
|
|
|
|
const temp = ref();
|
|
|
|
const itemMessage = ref<ResultItem[]>([]);
|
|
|
|
|
|
|
|
const getLogs = async (appid: string) => {
|
|
|
|
loading.value = true;
|
|
|
|
const res = await getWorkflowList({
|
|
|
|
appid,
|
|
|
|
limit: 5,
|
|
|
|
});
|
|
|
|
hitsory.value = res;
|
|
|
|
loading.value = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
async function handleClick(item: WordFlowItem) {
|
|
|
|
const res = await getWorkflowInfo({
|
|
|
|
appid: item.appId,
|
|
|
|
workflowRunId: item.workflowRunId,
|
|
|
|
});
|
|
|
|
itemMessage.value = [];
|
|
|
|
if (res.outputs) {
|
|
|
|
itemMessage.value.push({
|
|
|
|
key: itemMessage.value.length + 1,
|
|
|
|
role: 'ai',
|
|
|
|
content: res.outputs.result,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-05-17 17:34:27 +08:00
|
|
|
async function handleClickMode(item: TempItem) {
|
2025-05-16 17:44:56 +08:00
|
|
|
notification.success({
|
|
|
|
message: `${item.name}`,
|
|
|
|
description: '已选取',
|
|
|
|
duration: 3,
|
|
|
|
});
|
|
|
|
temp.value = item;
|
|
|
|
getLogs(item.id);
|
2025-05-05 16:33:06 +08:00
|
|
|
}
|
2025-05-04 18:45:03 +08:00
|
|
|
|
2025-05-06 01:46:24 +08:00
|
|
|
// onMounted(() => {
|
2025-05-16 17:44:56 +08:00
|
|
|
// getLogs(spiderList.value[0].id);
|
2025-05-06 01:46:24 +08:00
|
|
|
// });
|
2025-05-02 22:08:36 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-05-16 17:44:56 +08:00
|
|
|
<div class="layout">
|
|
|
|
<div class="lg:w-1/5">
|
|
|
|
<SpiderListView
|
|
|
|
title="选择模板"
|
|
|
|
:items="hitsory"
|
|
|
|
:loading="loading"
|
|
|
|
@click-mode="handleClickMode"
|
|
|
|
@click="handleClick"
|
|
|
|
/>
|
2025-05-05 16:33:06 +08:00
|
|
|
</div>
|
2025-05-16 17:44:56 +08:00
|
|
|
<SpiderWorkView
|
|
|
|
title="目标网址:"
|
|
|
|
:item="temp"
|
2025-05-16 23:02:11 +08:00
|
|
|
:run-spider="runSpider"
|
2025-05-17 22:07:52 +08:00
|
|
|
:stop-spider="stopSpider"
|
|
|
|
:get-spider-status="getSpiderStatus"
|
|
|
|
:send-workflow="sendWorkflow"
|
2025-05-16 17:44:56 +08:00
|
|
|
:item-message="itemMessage"
|
|
|
|
/>
|
2025-05-05 16:33:06 +08:00
|
|
|
</div>
|
2025-05-02 22:08:36 +08:00
|
|
|
</template>
|
2025-05-16 17:44:56 +08:00
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
|
.layout {
|
|
|
|
width: 100%;
|
|
|
|
min-width: 1400px;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
background: hsl(216deg 21.74% 95.49%);
|
|
|
|
font-family: AlibabaPuHuiTi, v-deep(var(--ant-font-family)), sans-serif;
|
|
|
|
border-radius: v-deep(var(--ant-border-radius));
|
|
|
|
}
|
|
|
|
</style>
|