feat(ai): 添加 AI 写作、知识库、思维导图和工作流功能

- 新增 AI 写作功能,包括示例点击、重置和停止流等功能
- 实现 AI 知识库管理,支持创建、编辑和删除知识库
- 添加 AI 思维导图功能,支持预览和管理思维导图
- 实现 AI 工作流管理,支持创建、编辑和删除工作流
- 优化 API 调用,使用 Vben 组件库和 Vue 3 相关特性
This commit is contained in:
gjd
2025-06-10 18:03:16 +08:00
parent 54066859c5
commit a4e44379e8
29 changed files with 20774 additions and 76 deletions

View File

@@ -0,0 +1,73 @@
<script setup lang="ts">
import type { Item } from './ui';
import { onMounted, onUnmounted, ref } from 'vue';
import { Tinyflow as TinyflowNative } from './ui';
import './ui/index.css';
const props = defineProps<{
className?: string;
data?: Record<string, any>;
provider?: {
internal?: () => Item[] | Promise<Item[]>;
knowledge?: () => Item[] | Promise<Item[]>;
llm?: () => Item[] | Promise<Item[]>;
};
style?: Record<string, string>;
}>();
const divRef = ref<HTMLDivElement | null>(null);
let tinyflow: null | TinyflowNative = null;
// 定义默认的 provider 方法
const defaultProvider = {
llm: () => [] as Item[],
knowledge: () => [] as Item[],
internal: () => [] as Item[],
};
onMounted(() => {
if (divRef.value) {
// 合并默认 provider 和传入的 props.provider
const mergedProvider = {
...defaultProvider,
...props.provider,
};
tinyflow = new TinyflowNative({
element: divRef.value as Element,
data: props.data || {},
provider: mergedProvider,
});
}
});
onUnmounted(() => {
if (tinyflow) {
tinyflow.destroy();
tinyflow = null;
}
});
const getData = () => {
if (tinyflow) {
return tinyflow.getData();
}
console.warn('Tinyflow instance is not initialized');
return null;
};
defineExpose({
getData,
});
</script>
<template>
<div
ref="divRef"
class="tinyflow"
:class="[className]"
:style="style"
style="height: 100%"
></div>
</template>