This commit is contained in:
2026-03-10 10:37:05 +08:00
commit 8ac6e443fc
17 changed files with 3063 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

3
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).

13
index.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>bosch-frontend</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

22
package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "bosch-frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
"axios": "^1.13.6",
"element-plus": "^2.13.5",
"vue": "^3.5.25",
"vue-router": "4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.4",
"vite": "^5.4.21"
}
}

1125
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
public/vite.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

4
src/App.vue Normal file
View File

@@ -0,0 +1,4 @@
<template>
<router-view />
</template>

98
src/api/session.js Normal file
View File

@@ -0,0 +1,98 @@
import axios from 'axios'
const http = axios.create({ timeout: 120000 })
http.interceptors.response.use(
(res) => res.data,
(err) => {
const msg = err.response?.data?.detail || err.message || '请求失败'
return Promise.reject(new Error(msg))
}
)
export const sessionApi = {
/** 创建会话,发送初始需求 */
start(requirement) {
return http.post('/session/start', { requirement })
},
/** 用户补充回答继续追问 */
clarify(sessionId, message) {
return http.post(`/session/${sessionId}/clarify`, { message })
},
/** PM Agent 分析需求 */
pmRun(sessionId) {
return http.post(`/session/${sessionId}/pm/run`)
},
/** 对 PM 产出提反馈 */
pmRefine(sessionId, feedback) {
return http.post(`/session/${sessionId}/pm/refine`, { feedback })
},
/** QA Agent 生成测试用例 */
qaRun(sessionId) {
return http.post(`/session/${sessionId}/qa/run`)
},
/** 对 QA 产出提反馈 */
qaRefine(sessionId, feedback) {
return http.post(`/session/${sessionId}/qa/refine`, { feedback })
},
/** Dev Agent 生成代码 */
devRun(sessionId) {
return http.post(`/session/${sessionId}/dev/run`)
},
/** 对 Dev 产出提反馈 */
devRefine(sessionId, feedback) {
return http.post(`/session/${sessionId}/dev/refine`, { feedback })
},
/** 流式修改 PM 产出 */
pmRefineStream(sessionId, feedback) {
return fetch(`/session/${sessionId}/pm/refine/stream?feedback=${encodeURIComponent(feedback)}`)
},
/** 流式修改 QA 产出 */
qaRefineStream(sessionId, feedback) {
return fetch(`/session/${sessionId}/qa/refine/stream?feedback=${encodeURIComponent(feedback)}`)
},
/** 流式执行 PM Agent返回 fetch Response用于 SSE 读取) */
pmStream(sessionId) {
return fetch(`/session/${sessionId}/pm/stream`)
},
/** 流式执行 QA Agent返回 fetch Response用于 SSE 读取) */
qaStream(sessionId) {
return fetch(`/session/${sessionId}/qa/stream`)
},
/** 流式执行 Dev Agent返回 fetch Response用于 SSE 读取) */
devStream(sessionId) {
return fetch(`/session/${sessionId}/dev/stream`)
},
/** 执行单元测试(真实 pytest */
testRun(sessionId) {
return http.post(`/session/${sessionId}/test/run`)
},
/** AI 自动修复失败的测试 */
testFix(sessionId) {
return http.post(`/session/${sessionId}/test/fix`)
},
/** AI 自动修复失败的测试(流式 SSE */
testFixStream(sessionId) {
return fetch(`/session/${sessionId}/test/fix/stream`)
},
/** 获取会话完整状态 */
getSession(sessionId) {
return http.get(`/session/${sessionId}`)
},
}

1
src/assets/vue.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

View File

@@ -0,0 +1,43 @@
<script setup>
import { ref } from 'vue'
defineProps({
msg: String,
})
const count = ref(0)
</script>
<template>
<h1>{{ msg }}</h1>
<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>
<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Learn more about IDE Support for Vue in the
<a
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
target="_blank"
>Vue Docs Scaling up Guide</a
>.
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>
<style scoped>
.read-the-docs {
color: #888;
}
</style>

12
src/main.js Normal file
View File

@@ -0,0 +1,12 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import './style.css'
import App from './App.vue'
import router from './router'
createApp(App)
.use(ElementPlus, { locale: zhCn })
.use(router)
.mount('#app')

13
src/router/index.js Normal file
View File

@@ -0,0 +1,13 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SessionView from '@/views/SessionView.vue'
const routes = [
{ path: '/', component: HomeView },
{ path: '/session/:id', component: SessionView },
]
export default createRouter({
history: createWebHistory(),
routes,
})

34
src/style.css Normal file
View File

@@ -0,0 +1,34 @@
*, *::before, *::after {
box-sizing: border-box;
}
html, body, #app {
margin: 0;
padding: 0;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
-webkit-font-smoothing: antialiased;
color: #303133;
}
a {
text-decoration: none;
color: inherit;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #c0c4cc;
border-radius: 3px;
}

167
src/views/HomeView.vue Normal file
View File

@@ -0,0 +1,167 @@
<template>
<div class="home-wrap">
<div class="home-card">
<div class="logo-row">
<span class="logo-badge">Bosch</span>
<span class="title-text">AI 研发效能助手</span>
</div>
<p class="subtitle">输入产品需求 AI 完成需求分析 测试用例 代码生成的全流程</p>
<el-input
v-model="requirement"
type="textarea"
:rows="6"
placeholder="请输入您的产品需求,例如:实现一个用户登录功能,支持用户名密码方式,需要记录登录日志……"
class="req-input"
:disabled="loading"
/>
<div class="action-row">
<el-button
type="primary"
size="large"
:loading="loading"
:disabled="!requirement.trim()"
@click="handleStart"
>
<el-icon v-if="!loading"><Promotion /></el-icon>
{{ loading ? '正在分析需求…' : '开始 AI 分析' }}
</el-button>
</div>
<div v-if="errorMsg" style="margin-top:16px">
<el-alert :title="errorMsg" type="error" show-icon :closable="false" />
</div>
</div>
<div class="flow-hint">
<div class="flow-step" v-for="(step, i) in steps" :key="i">
<span>{{ step.label }}</span>
<el-icon v-if="i < steps.length - 1" class="arrow"><ArrowRight /></el-icon>
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { Promotion, ArrowRight } from '@element-plus/icons-vue'
import { sessionApi } from '@/api/session'
const router = useRouter()
const requirement = ref('')
const loading = ref(false)
const errorMsg = ref('')
const steps = [
{ label: '需求澄清' },
{ label: 'PM 需求分析' },
{ label: 'QA 测试用例' },
{ label: 'Dev 代码生成' },
{ label: '运行测试' },
]
async function handleStart() {
if (!requirement.value.trim()) return
loading.value = true
errorMsg.value = ''
try {
const res = await sessionApi.start(requirement.value.trim())
router.push(`/session/${res.session_id}`)
} catch (e) {
errorMsg.value = e.message
ElMessage.error(e.message)
} finally {
loading.value = false
}
}
</script>
<style scoped>
.home-wrap {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 32px;
padding: 40px 20px;
background: linear-gradient(135deg, #f0f4ff 0%, #fafafa 100%);
}
.home-card {
background: #fff;
border-radius: 16px;
padding: 48px 56px;
width: 100%;
max-width: 720px;
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}
.logo-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 8px;
}
.logo-badge {
background: #e30613;
color: #fff;
font-size: 13px;
font-weight: 700;
padding: 4px 10px;
border-radius: 4px;
letter-spacing: 1px;
}
.title-text {
font-size: 24px;
font-weight: 700;
color: #1a1a1a;
letter-spacing: 0.5px;
}
.subtitle {
color: #666;
font-size: 14px;
margin-bottom: 28px;
line-height: 1.6;
}
.req-input {
margin-bottom: 20px;
}
.action-row {
display: flex;
justify-content: flex-end;
}
.flow-hint {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
justify-content: center;
}
.flow-step {
display: flex;
align-items: center;
gap: 6px;
font-size: 14px;
color: #555;
background: #fff;
border-radius: 24px;
padding: 8px 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.arrow {
color: #c0c4cc;
margin-left: 4px;
}
</style>

1473
src/views/SessionView.vue Normal file

File diff suppressed because it is too large Load Diff

25
vite.config.js Normal file
View File

@@ -0,0 +1,25 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 3000,
proxy: {
'/session': {
target: 'http://localhost:8000',
changeOrigin: true,
},
'/workflow': {
target: 'http://localhost:8000',
changeOrigin: true,
},
},
},
})