Add project status report and frontend documentation
- Introduced `PROJECT_STATUS.md` to provide a comprehensive overview of the MiroFish project, detailing the current status, completed features, and future development plans. - Added multiple documentation files in the frontend directory, including detailed descriptions of the homepage functionality, startup guide, and project completion summary. - Implemented a structured approach to document the project's architecture, API integration, and user interaction processes, enhancing clarity for developers and users alike. - Included a `.gitignore` file to manage ignored files and directories in the frontend project, improving project organization and cleanliness.
This commit is contained in:
48
frontend/src/App.vue
Normal file
48
frontend/src/App.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 使用 Vue Router 来管理页面
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 全局样式重置 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#app {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* 滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #000000;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #333333;
|
||||
}
|
||||
|
||||
/* 全局按钮样式 */
|
||||
button {
|
||||
font-family: inherit;
|
||||
}
|
||||
</style>
|
||||
70
frontend/src/api/graph.js
Normal file
70
frontend/src/api/graph.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import service, { requestWithRetry } from './index'
|
||||
|
||||
/**
|
||||
* 生成本体(上传文档和模拟需求)
|
||||
* @param {Object} data - 包含files, simulation_requirement, project_name等
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function generateOntology(formData) {
|
||||
return requestWithRetry(() =>
|
||||
service({
|
||||
url: '/api/graph/ontology/generate',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建图谱
|
||||
* @param {Object} data - 包含project_id, graph_name等
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function buildGraph(data) {
|
||||
return requestWithRetry(() =>
|
||||
service({
|
||||
url: '/api/graph/build',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务状态
|
||||
* @param {String} taskId - 任务ID
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function getTaskStatus(taskId) {
|
||||
return service({
|
||||
url: `/api/graph/task/${taskId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图谱数据
|
||||
* @param {String} graphId - 图谱ID
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function getGraphData(graphId) {
|
||||
return service({
|
||||
url: `/api/graph/data/${graphId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目信息
|
||||
* @param {String} projectId - 项目ID
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function getProject(projectId) {
|
||||
return service({
|
||||
url: `/api/graph/project/${projectId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
67
frontend/src/api/index.js
Normal file
67
frontend/src/api/index.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import axios from 'axios'
|
||||
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5001',
|
||||
timeout: 300000, // 5分钟超时(本体生成可能需要较长时间)
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
console.error('Request error:', error)
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
// 响应拦截器(容错重试机制)
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
const res = response.data
|
||||
|
||||
// 如果返回的状态码不是success,则抛出错误
|
||||
if (!res.success && res.success !== undefined) {
|
||||
console.error('API Error:', res.error || res.message || 'Unknown error')
|
||||
return Promise.reject(new Error(res.error || res.message || 'Error'))
|
||||
}
|
||||
|
||||
return res
|
||||
},
|
||||
error => {
|
||||
console.error('Response error:', error)
|
||||
|
||||
// 处理超时
|
||||
if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) {
|
||||
console.error('Request timeout')
|
||||
}
|
||||
|
||||
// 处理网络错误
|
||||
if (error.message === 'Network Error') {
|
||||
console.error('Network error - please check your connection')
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
// 带重试的请求函数
|
||||
export const requestWithRetry = async (requestFn, maxRetries = 3, delay = 1000) => {
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
try {
|
||||
return await requestFn()
|
||||
} catch (error) {
|
||||
if (i === maxRetries - 1) throw error
|
||||
|
||||
console.warn(`Request failed, retrying (${i + 1}/${maxRetries})...`)
|
||||
await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default service
|
||||
BIN
frontend/src/assets/logo/MiroFish_logo_compressed.jpeg
Normal file
BIN
frontend/src/assets/logo/MiroFish_logo_compressed.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 KiB |
9
frontend/src/main.js
Normal file
9
frontend/src/main.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(router)
|
||||
|
||||
app.mount('#app')
|
||||
24
frontend/src/router/index.js
Normal file
24
frontend/src/router/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Home from '../views/Home.vue'
|
||||
import Process from '../views/Process.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/process/:projectId',
|
||||
name: 'Process',
|
||||
component: Process,
|
||||
props: true
|
||||
}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
726
frontend/src/views/Home.vue
Normal file
726
frontend/src/views/Home.vue
Normal file
@@ -0,0 +1,726 @@
|
||||
<template>
|
||||
<div class="home-container">
|
||||
<div class="content-wrapper">
|
||||
<!-- Logo -->
|
||||
<div class="logo-section">
|
||||
<img src="../assets/logo/MiroFish_logo_compressed.jpeg" alt="MiroFish" class="logo" />
|
||||
</div>
|
||||
|
||||
<!-- 标语 + 装饰线 -->
|
||||
<div class="slogan-section">
|
||||
<div class="decorative-line"></div>
|
||||
<h1 class="slogan">上传任意报告,即刻推演未来</h1>
|
||||
<div class="decorative-line"></div>
|
||||
</div>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<div class="form-section">
|
||||
<!-- 模拟需求输入框 -->
|
||||
<div class="input-group">
|
||||
<label for="requirement" class="input-label">模拟需求</label>
|
||||
<textarea
|
||||
id="requirement"
|
||||
v-model="formData.simulationRequirement"
|
||||
placeholder="请详细描述您的模拟需求..."
|
||||
rows="6"
|
||||
:disabled="loading"
|
||||
class="requirement-input"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 文件上传区域 -->
|
||||
<div class="input-group">
|
||||
<label class="input-label">上传文档</label>
|
||||
<div
|
||||
class="upload-area"
|
||||
:class="{ 'drag-over': isDragOver, 'disabled': loading, 'has-files': files.length > 0 }"
|
||||
@dragover.prevent="handleDragOver"
|
||||
@dragleave.prevent="handleDragLeave"
|
||||
@drop.prevent="handleDrop"
|
||||
@click="triggerFileInput"
|
||||
>
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
multiple
|
||||
accept=".pdf,.md,.txt"
|
||||
@change="handleFileSelect"
|
||||
style="display: none"
|
||||
:disabled="loading"
|
||||
/>
|
||||
<div v-if="files.length === 0" class="upload-placeholder">
|
||||
<svg class="upload-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
|
||||
</svg>
|
||||
<p class="upload-text">拖拽文件至此或点击上传</p>
|
||||
<span class="upload-hint">支持 PDF / Markdown / TXT</span>
|
||||
</div>
|
||||
<div v-else class="file-list">
|
||||
<div v-for="(file, index) in files" :key="index" class="file-item">
|
||||
<div class="file-info">
|
||||
<svg class="file-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
||||
</svg>
|
||||
<div class="file-details">
|
||||
<span class="file-name">{{ file.name }}</span>
|
||||
<span class="file-size">{{ formatFileSize(file.size) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="remove-btn"
|
||||
@click.stop="removeFile(index)"
|
||||
:disabled="loading"
|
||||
aria-label="删除文件"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 开始模拟按钮 -->
|
||||
<button
|
||||
class="start-btn"
|
||||
@click="startSimulation"
|
||||
:disabled="!canSubmit || loading"
|
||||
>
|
||||
<span v-if="!loading">开 始 模 拟</span>
|
||||
<span v-else class="loading-text">
|
||||
<span class="loading-spinner"></span>
|
||||
处理中
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- 错误提示 -->
|
||||
<transition name="fade">
|
||||
<div v-if="error" class="error-message">
|
||||
<svg class="error-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
{{ error }}
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { generateOntology } from '../api/graph'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
simulationRequirement: ''
|
||||
})
|
||||
|
||||
// 文件列表
|
||||
const files = ref([])
|
||||
|
||||
// 状态
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const isDragOver = ref(false)
|
||||
|
||||
// 文件输入引用
|
||||
const fileInput = ref(null)
|
||||
|
||||
// 计算属性:是否可以提交
|
||||
const canSubmit = computed(() => {
|
||||
return formData.value.simulationRequirement.trim() !== '' && files.value.length > 0
|
||||
})
|
||||
|
||||
// 触发文件选择
|
||||
const triggerFileInput = () => {
|
||||
if (!loading.value && files.value.length === 0) {
|
||||
fileInput.value?.click()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理文件选择
|
||||
const handleFileSelect = (event) => {
|
||||
const selectedFiles = Array.from(event.target.files)
|
||||
addFiles(selectedFiles)
|
||||
}
|
||||
|
||||
// 处理拖拽相关
|
||||
const handleDragOver = (e) => {
|
||||
if (!loading.value) {
|
||||
isDragOver.value = true
|
||||
}
|
||||
}
|
||||
|
||||
const handleDragLeave = (e) => {
|
||||
isDragOver.value = false
|
||||
}
|
||||
|
||||
const handleDrop = (e) => {
|
||||
isDragOver.value = false
|
||||
if (loading.value) return
|
||||
|
||||
const droppedFiles = Array.from(e.dataTransfer.files)
|
||||
addFiles(droppedFiles)
|
||||
}
|
||||
|
||||
// 添加文件
|
||||
const addFiles = (newFiles) => {
|
||||
// 过滤支持的文件类型
|
||||
const validFiles = newFiles.filter(file => {
|
||||
const ext = file.name.split('.').pop().toLowerCase()
|
||||
return ['pdf', 'md', 'txt'].includes(ext)
|
||||
})
|
||||
|
||||
if (validFiles.length !== newFiles.length) {
|
||||
error.value = '部分文件格式不支持,已自动过滤'
|
||||
setTimeout(() => { error.value = '' }, 3000)
|
||||
}
|
||||
|
||||
files.value.push(...validFiles)
|
||||
}
|
||||
|
||||
// 移除文件
|
||||
const removeFile = (index) => {
|
||||
files.value.splice(index, 1)
|
||||
}
|
||||
|
||||
// 格式化文件大小
|
||||
const formatFileSize = (bytes) => {
|
||||
if (bytes === 0) return '0 B'
|
||||
const k = 1024
|
||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
||||
}
|
||||
|
||||
// 开始模拟
|
||||
const startSimulation = async () => {
|
||||
if (!canSubmit.value || loading.value) return
|
||||
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
// 构建FormData
|
||||
const formDataObj = new FormData()
|
||||
|
||||
// 添加文件
|
||||
files.value.forEach(file => {
|
||||
formDataObj.append('files', file)
|
||||
})
|
||||
|
||||
// 添加必填字段
|
||||
formDataObj.append('simulation_requirement', formData.value.simulationRequirement)
|
||||
|
||||
// 调用API
|
||||
const response = await generateOntology(formDataObj)
|
||||
|
||||
if (response.success) {
|
||||
// 跳转到处理页面
|
||||
router.push({
|
||||
name: 'Process',
|
||||
params: { projectId: response.data.project_id }
|
||||
})
|
||||
} else {
|
||||
error.value = response.error || '生成本体失败,请重试'
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Start simulation error:', err)
|
||||
error.value = err.message || '提交失败,请检查网络连接或稍后重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载后的处理
|
||||
onMounted(() => {
|
||||
// 动画已经在CSS中定义,这里可以做其他初始化工作
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* ==================== 基础布局 ==================== */
|
||||
.home-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #ffffff;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
width: 100%;
|
||||
max-width: 900px;
|
||||
}
|
||||
|
||||
/* ==================== Logo区域 ==================== */
|
||||
.logo-section {
|
||||
text-align: center;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.logo {
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* ==================== 标语区域 ==================== */
|
||||
.slogan-section {
|
||||
text-align: center;
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.decorative-line {
|
||||
width: 200px;
|
||||
height: 1px;
|
||||
background-color: #000000;
|
||||
margin: 1.5rem auto;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 200;
|
||||
color: #000000;
|
||||
letter-spacing: 0.15em;
|
||||
line-height: 1.8;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.slogan div {
|
||||
margin: 0.3rem 0;
|
||||
}
|
||||
|
||||
/* ==================== 表单区域 ==================== */
|
||||
.form-section {
|
||||
/* 移除动画,确保立即可见 */
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.input-label {
|
||||
display: block;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
color: #000000;
|
||||
margin-bottom: 1rem;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* ==================== 输入框样式 ==================== */
|
||||
.requirement-input {
|
||||
width: 100%;
|
||||
min-height: 150px;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid #000000;
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
line-height: 1.6;
|
||||
transition: all 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.requirement-input::placeholder {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.requirement-input:focus {
|
||||
outline: none;
|
||||
border-width: 2px;
|
||||
padding: calc(1.5rem - 1px);
|
||||
}
|
||||
|
||||
.requirement-input:disabled {
|
||||
background-color: #f8f8f8;
|
||||
color: #999999;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ==================== 上传区域 ==================== */
|
||||
.upload-area {
|
||||
min-height: 200px;
|
||||
border: 2px dashed #000000;
|
||||
padding: 3rem 2rem;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.upload-area:hover:not(.disabled):not(.has-files) {
|
||||
border-style: solid;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.upload-area.drag-over:not(.disabled) {
|
||||
border-width: 3px;
|
||||
border-style: solid;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.upload-area.disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.upload-area.has-files {
|
||||
cursor: default;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.upload-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.upload-icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
stroke-width: 1.5;
|
||||
animation: float 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 1.1rem;
|
||||
color: #000000;
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
font-size: 0.9rem;
|
||||
color: #666666;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* ==================== 文件列表 ==================== */
|
||||
.file-list {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.file-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.file-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.file-item:hover {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.file-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.file-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex-shrink: 0;
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.file-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
font-size: 1rem;
|
||||
color: #000000;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.file-size {
|
||||
font-size: 0.85rem;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #000000;
|
||||
background-color: #ffffff;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.remove-btn svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
.remove-btn:hover:not(:disabled) {
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
.remove-btn:hover:not(:disabled) svg {
|
||||
stroke: #ffffff;
|
||||
}
|
||||
|
||||
.remove-btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ==================== 开始模拟按钮 ==================== */
|
||||
.start-btn {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 1.5rem 4rem;
|
||||
border: 2px solid #000000;
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
font-size: 1.3rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.2em;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.start-btn:hover:not(:disabled) {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.start-btn:active:not(:disabled) {
|
||||
transform: translateY(0);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.start-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 2px solid #ffffff;
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
/* ==================== 错误提示 ==================== */
|
||||
.error-message {
|
||||
margin-top: 2rem;
|
||||
padding: 1.25rem 1.5rem;
|
||||
border: 1px solid #ff0000;
|
||||
background-color: #fff5f5;
|
||||
color: #ff0000;
|
||||
font-size: 0.95rem;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.error-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
/* ==================== 动画定义 ==================== */
|
||||
@keyframes fadeInDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 过渡效果 ==================== */
|
||||
.fade-enter-active, .fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from, .fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* ==================== 响应式设计 ==================== */
|
||||
@media (max-width: 1024px) {
|
||||
.content-wrapper {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.decorative-line {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.home-container {
|
||||
padding: 1.5rem 1rem;
|
||||
}
|
||||
|
||||
.logo {
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 1.5rem;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.decorative-line {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.slogan-section {
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.requirement-input {
|
||||
min-height: 120px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
min-height: 160px;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
.upload-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.start-btn {
|
||||
padding: 1.25rem 3rem;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.file-item {
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.logo {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.start-btn {
|
||||
max-width: 100%;
|
||||
font-size: 1rem;
|
||||
letter-spacing: 0.15em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
453
frontend/src/views/Process.vue
Normal file
453
frontend/src/views/Process.vue
Normal file
@@ -0,0 +1,453 @@
|
||||
<template>
|
||||
<div class="process-container">
|
||||
<!-- 左侧:实时图谱展示区 -->
|
||||
<div class="left-panel">
|
||||
<div class="panel-header">
|
||||
<h2>实时图谱</h2>
|
||||
</div>
|
||||
<div class="graph-container">
|
||||
<div v-if="loading" class="loading-state">
|
||||
<div class="loading-spinner-large"></div>
|
||||
<p>加载图谱中...</p>
|
||||
</div>
|
||||
<div v-else-if="error" class="error-state">
|
||||
<p>{{ error }}</p>
|
||||
</div>
|
||||
<div v-else-if="graphData" class="graph-view">
|
||||
<!-- 图谱可视化将在这里实现 -->
|
||||
<div class="graph-placeholder">
|
||||
<p>图谱节点数: {{ graphData.node_count }}</p>
|
||||
<p>关系数: {{ graphData.edge_count }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p>暂无图谱数据</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:流程展示区 -->
|
||||
<div class="right-panel">
|
||||
<div class="panel-header">
|
||||
<h2>Step 1 - 现实种子构建</h2>
|
||||
</div>
|
||||
<div class="process-content">
|
||||
<!-- 流程步骤 -->
|
||||
<div class="steps">
|
||||
<div
|
||||
v-for="(step, index) in steps"
|
||||
:key="index"
|
||||
class="step-item"
|
||||
:class="{
|
||||
'active': currentStep === index,
|
||||
'completed': currentStep > index
|
||||
}"
|
||||
>
|
||||
<div class="step-indicator">
|
||||
<div class="step-number">{{ index + 1 }}</div>
|
||||
</div>
|
||||
<div class="step-content">
|
||||
<h3>{{ step.title }}</h3>
|
||||
<p>{{ step.description }}</p>
|
||||
<div v-if="step.status" class="step-status">
|
||||
{{ step.status }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 项目信息 -->
|
||||
<div v-if="projectData" class="project-info">
|
||||
<h3>项目信息</h3>
|
||||
<div class="info-item">
|
||||
<span class="label">项目名称:</span>
|
||||
<span class="value">{{ projectData.name }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">项目ID:</span>
|
||||
<span class="value">{{ projectData.project_id }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">状态:</span>
|
||||
<span class="value">{{ projectData.status }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { getProject, buildGraph, getTaskStatus, getGraphData } from '../api/graph'
|
||||
|
||||
const route = useRoute()
|
||||
const projectId = route.params.projectId
|
||||
|
||||
// 状态
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
const projectData = ref(null)
|
||||
const graphData = ref(null)
|
||||
const currentStep = ref(0)
|
||||
|
||||
// 流程步骤
|
||||
const steps = ref([
|
||||
{
|
||||
title: '文档分析',
|
||||
description: '正在分析上传的文档内容',
|
||||
status: ''
|
||||
},
|
||||
{
|
||||
title: '本体生成',
|
||||
description: '使用LLM生成知识图谱本体',
|
||||
status: ''
|
||||
},
|
||||
{
|
||||
title: '图谱构建',
|
||||
description: '基于本体构建知识图谱',
|
||||
status: ''
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: '现实种子构建完成',
|
||||
status: ''
|
||||
}
|
||||
])
|
||||
|
||||
// 轮询定时器
|
||||
let pollTimer = null
|
||||
|
||||
// 加载项目数据
|
||||
const loadProject = async () => {
|
||||
try {
|
||||
const response = await getProject(projectId)
|
||||
if (response.success) {
|
||||
projectData.value = response.data
|
||||
|
||||
// 根据项目状态更新步骤
|
||||
updateStepsByProjectStatus(response.data.status)
|
||||
|
||||
// 如果本体已生成,自动开始构建图谱
|
||||
if (response.data.status === 'ontology_generated' && !response.data.graph_id) {
|
||||
await startBuildGraph()
|
||||
}
|
||||
|
||||
// 如果图谱正在构建,开始轮询任务状态
|
||||
if (response.data.status === 'graph_building' && response.data.graph_build_task_id) {
|
||||
startPollingTask(response.data.graph_build_task_id)
|
||||
}
|
||||
|
||||
// 如果图谱已完成,加载图谱数据
|
||||
if (response.data.status === 'graph_completed' && response.data.graph_id) {
|
||||
await loadGraphData(response.data.graph_id)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Load project error:', err)
|
||||
error.value = '加载项目失败: ' + (err.message || '未知错误')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 根据项目状态更新步骤
|
||||
const updateStepsByProjectStatus = (status) => {
|
||||
switch (status) {
|
||||
case 'created':
|
||||
currentStep.value = 0
|
||||
steps.value[0].status = '进行中...'
|
||||
break
|
||||
case 'ontology_generated':
|
||||
currentStep.value = 1
|
||||
steps.value[0].status = '已完成'
|
||||
steps.value[1].status = '已完成'
|
||||
break
|
||||
case 'graph_building':
|
||||
currentStep.value = 2
|
||||
steps.value[0].status = '已完成'
|
||||
steps.value[1].status = '已完成'
|
||||
steps.value[2].status = '进行中...'
|
||||
break
|
||||
case 'graph_completed':
|
||||
currentStep.value = 3
|
||||
steps.value[0].status = '已完成'
|
||||
steps.value[1].status = '已完成'
|
||||
steps.value[2].status = '已完成'
|
||||
steps.value[3].status = '已完成'
|
||||
break
|
||||
case 'failed':
|
||||
error.value = projectData.value?.error || '项目处理失败'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 开始构建图谱
|
||||
const startBuildGraph = async () => {
|
||||
try {
|
||||
const response = await buildGraph({
|
||||
project_id: projectId
|
||||
})
|
||||
|
||||
if (response.success) {
|
||||
const taskId = response.data.task_id
|
||||
startPollingTask(taskId)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Build graph error:', err)
|
||||
error.value = '启动图谱构建失败: ' + (err.message || '未知错误')
|
||||
}
|
||||
}
|
||||
|
||||
// 开始轮询任务状态
|
||||
const startPollingTask = (taskId) => {
|
||||
pollTimer = setInterval(async () => {
|
||||
try {
|
||||
const response = await getTaskStatus(taskId)
|
||||
if (response.success) {
|
||||
const task = response.data
|
||||
|
||||
// 更新步骤状态
|
||||
if (task.status === 'processing') {
|
||||
steps.value[2].status = `${task.message} (${task.progress}%)`
|
||||
} else if (task.status === 'completed') {
|
||||
steps.value[2].status = '已完成'
|
||||
currentStep.value = 3
|
||||
|
||||
// 停止轮询
|
||||
stopPolling()
|
||||
|
||||
// 重新加载项目数据
|
||||
await loadProject()
|
||||
} else if (task.status === 'failed') {
|
||||
error.value = '图谱构建失败: ' + (task.error || '未知错误')
|
||||
stopPolling()
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Poll task status error:', err)
|
||||
}
|
||||
}, 2000) // 每2秒轮询一次
|
||||
}
|
||||
|
||||
// 停止轮询
|
||||
const stopPolling = () => {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
// 加载图谱数据
|
||||
const loadGraphData = async (graphId) => {
|
||||
try {
|
||||
const response = await getGraphData(graphId)
|
||||
if (response.success) {
|
||||
graphData.value = response.data
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Load graph data error:', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
loadProject()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.process-container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* 左侧面板 */
|
||||
.left-panel {
|
||||
flex: 1;
|
||||
border-right: 1px solid #000000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 右侧面板 */
|
||||
.right-panel {
|
||||
width: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 面板标题 */
|
||||
.panel-header {
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid #000000;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.panel-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* 图谱容器 */
|
||||
.graph-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.loading-state,
|
||||
.error-state,
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.loading-spinner-large {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid #000000;
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.graph-placeholder {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
|
||||
/* 流程内容 */
|
||||
.process-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
/* 步骤列表 */
|
||||
.steps {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.step-item {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
opacity: 0.4;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.step-item.active,
|
||||
.step-item.completed {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.step-indicator {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-number {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 2px solid #000000;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 500;
|
||||
background-color: #ffffff;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.step-item.active .step-number {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.step-item.completed .step-number {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.step-content h3 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.step-content p {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.step-status {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.85rem;
|
||||
color: #000000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 项目信息 */
|
||||
.project-info {
|
||||
margin-top: 2rem;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
|
||||
.project-info h3 {
|
||||
margin: 0 0 1rem 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.info-item .label {
|
||||
font-weight: 500;
|
||||
margin-right: 0.5rem;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.info-item .value {
|
||||
color: #666666;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 1024px) {
|
||||
.process-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #000000;
|
||||
height: 50vh;
|
||||
}
|
||||
|
||||
.right-panel {
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user