init
This commit is contained in:
4
src/App.vue
Normal file
4
src/App.vue
Normal file
@@ -0,0 +1,4 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
98
src/api/session.js
Normal file
98
src/api/session.js
Normal 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
1
src/assets/vue.svg
Normal 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 |
43
src/components/HelloWorld.vue
Normal file
43
src/components/HelloWorld.vue
Normal 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
12
src/main.js
Normal 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
13
src/router/index.js
Normal 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
34
src/style.css
Normal 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
167
src/views/HomeView.vue
Normal 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
1473
src/views/SessionView.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user