Fix BugTracker: match actual API data model
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 23s
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 23s
- is_resolved (0/1/2/3) instead of string status
- priority (0/1/2 numbers) instead of strings
- content field instead of title/description
- display_name/username for reporter
- comment endpoint /comment (singular), body: {content}
- Fix duplicate content display in template
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,22 +16,21 @@
|
|||||||
<span class="bug-status" :class="'s-' + (bug.status || 'open')">{{ statusLabel(bug.status) }}</span>
|
<span class="bug-status" :class="'s-' + (bug.status || 'open')">{{ statusLabel(bug.status) }}</span>
|
||||||
<span class="bug-date">{{ formatDate(bug.created_at) }}</span>
|
<span class="bug-date">{{ formatDate(bug.created_at) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bug-title">{{ bug.title }}</div>
|
<div class="bug-title">{{ bug.content }}</div>
|
||||||
<div v-if="bug.description" class="bug-desc">{{ bug.description }}</div>
|
<div v-if="bug.display_name" class="bug-reporter">{{ bug.display_name || bug.username }}</div>
|
||||||
<div v-if="bug.reporter" class="bug-reporter">报告者: {{ bug.reporter }}</div>
|
|
||||||
|
|
||||||
<!-- Status workflow -->
|
<!-- Status workflow: is_resolved: 0=open, 1=testing, 2=fixed, 3=tested -->
|
||||||
<div class="bug-actions">
|
<div class="bug-actions">
|
||||||
<template v-if="bug.status === 'open'">
|
<template v-if="bug.is_resolved === 0">
|
||||||
<button class="btn-sm btn-status" @click="updateStatus(bug, 'testing')">开始测试</button>
|
<button class="btn-sm btn-status" @click="updateStatus(bug, 1)">待测试</button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="bug.status === 'testing'">
|
<template v-else-if="bug.is_resolved === 1">
|
||||||
<button class="btn-sm btn-status" @click="updateStatus(bug, 'fixed')">标记修复</button>
|
<button class="btn-sm btn-status" @click="updateStatus(bug, 2)">已修复</button>
|
||||||
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 'open')">重新打开</button>
|
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 0)">重新打开</button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="bug.status === 'fixed'">
|
<template v-else-if="bug.is_resolved === 2">
|
||||||
<button class="btn-sm btn-status" @click="updateStatus(bug, 'tested')">验证通过</button>
|
<button class="btn-sm btn-status" @click="updateStatus(bug, 3)">已测试</button>
|
||||||
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 'open')">重新打开</button>
|
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 0)">重新打开</button>
|
||||||
</template>
|
</template>
|
||||||
<button class="btn-sm btn-delete" @click="removeBug(bug)">删除</button>
|
<button class="btn-sm btn-delete" @click="removeBug(bug)">删除</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -40,10 +39,11 @@
|
|||||||
<div class="comments-section" v-if="expandedBugId === (bug._id || bug.id)">
|
<div class="comments-section" v-if="expandedBugId === (bug._id || bug.id)">
|
||||||
<div v-for="comment in (bug.comments || [])" :key="comment._id || comment.id" class="comment-item">
|
<div v-for="comment in (bug.comments || [])" :key="comment._id || comment.id" class="comment-item">
|
||||||
<div class="comment-meta">
|
<div class="comment-meta">
|
||||||
<span class="comment-author">{{ comment.author || comment.user_name || '匿名' }}</span>
|
<span class="comment-author">{{ comment.display_name || comment.username || '系统' }}</span>
|
||||||
|
<span class="comment-action" v-if="comment.action">{{ comment.action }}</span>
|
||||||
<span class="comment-time">{{ formatDate(comment.created_at) }}</span>
|
<span class="comment-time">{{ formatDate(comment.created_at) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-text">{{ comment.text || comment.content }}</div>
|
<div class="comment-text">{{ comment.content }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-add">
|
<div class="comment-add">
|
||||||
<input
|
<input
|
||||||
@@ -75,9 +75,9 @@
|
|||||||
<span class="bug-status s-tested">已解决</span>
|
<span class="bug-status s-tested">已解决</span>
|
||||||
<span class="bug-date">{{ formatDate(bug.created_at) }}</span>
|
<span class="bug-date">{{ formatDate(bug.created_at) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bug-title">{{ bug.title }}</div>
|
<div class="bug-title">{{ bug.content }}</div>
|
||||||
<div class="bug-actions">
|
<div class="bug-actions">
|
||||||
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 'open')">重新打开</button>
|
<button class="btn-sm btn-reopen" @click="updateStatus(bug, 0)">重新打开</button>
|
||||||
<button class="btn-sm btn-delete" @click="removeBug(bug)">删除</button>
|
<button class="btn-sm btn-delete" @click="removeBug(bug)">删除</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -92,12 +92,8 @@
|
|||||||
<button class="btn-close" @click="showAddBug = false">✕</button>
|
<button class="btn-close" @click="showAddBug = false">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>标题</label>
|
<label>Bug 内容</label>
|
||||||
<input v-model="bugForm.title" class="form-input" placeholder="Bug标题" />
|
<textarea v-model="bugForm.content" class="form-textarea" rows="4" placeholder="描述问题、复现步骤等..."></textarea>
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>描述</label>
|
|
||||||
<textarea v-model="bugForm.description" class="form-textarea" rows="4" placeholder="Bug描述,复现步骤等..."></textarea>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>优先级</label>
|
<label>优先级</label>
|
||||||
@@ -113,7 +109,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="overlay-footer">
|
<div class="overlay-footer">
|
||||||
<button class="btn-outline" @click="showAddBug = false">取消</button>
|
<button class="btn-outline" @click="showAddBug = false">取消</button>
|
||||||
<button class="btn-primary" @click="createBug" :disabled="!bugForm.title.trim()">提交</button>
|
<button class="btn-primary" @click="createBug" :disabled="!bugForm.content.trim()">提交</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -137,38 +133,35 @@ const expandedBugId = ref(null)
|
|||||||
const newComment = ref('')
|
const newComment = ref('')
|
||||||
|
|
||||||
const bugForm = reactive({
|
const bugForm = reactive({
|
||||||
title: '',
|
content: '',
|
||||||
description: '',
|
priority: 2,
|
||||||
priority: 'normal',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// priority: 0=urgent, 1=high, 2=normal
|
||||||
const priorities = [
|
const priorities = [
|
||||||
{ value: 'low', label: '低' },
|
{ value: 0, label: '紧急' },
|
||||||
{ value: 'normal', label: '中' },
|
{ value: 1, label: '高' },
|
||||||
{ value: 'high', label: '高' },
|
{ value: 2, label: '中' },
|
||||||
{ value: 'critical', label: '紧急' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// is_resolved: 0=open, 1=testing, 2=fixed, 3=tested
|
||||||
const activeBugs = computed(() =>
|
const activeBugs = computed(() =>
|
||||||
bugs.value.filter(b => b.status !== 'tested' && b.status !== 'closed')
|
bugs.value.filter(b => b.is_resolved !== 2 && b.is_resolved !== 3)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => (a.priority ?? 2) - (b.priority ?? 2))
|
||||||
const order = { critical: 0, high: 1, normal: 2, low: 3 }
|
|
||||||
return (order[a.priority] ?? 2) - (order[b.priority] ?? 2)
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const resolvedBugs = computed(() =>
|
const resolvedBugs = computed(() =>
|
||||||
bugs.value.filter(b => b.status === 'tested' || b.status === 'closed')
|
bugs.value.filter(b => b.is_resolved === 2 || b.is_resolved === 3)
|
||||||
)
|
)
|
||||||
|
|
||||||
function priorityLabel(p) {
|
function priorityLabel(p) {
|
||||||
const map = { low: '低', normal: '中', high: '高', critical: '紧急' }
|
const map = { 0: '紧急', 1: '高', 2: '中' }
|
||||||
return map[p] || '中'
|
return map[p] ?? '中'
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusLabel(s) {
|
function statusLabel(s) {
|
||||||
const map = { open: '待处理', testing: '测试中', fixed: '已修复', tested: '已验证', closed: '已关闭' }
|
const map = { 0: '待处理', 1: '待测试', 2: '已修复', 3: '已测试' }
|
||||||
return map[s] || s
|
return map[s] ?? '待处理'
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(d) {
|
function formatDate(d) {
|
||||||
@@ -198,20 +191,19 @@ async function loadBugs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createBug() {
|
async function createBug() {
|
||||||
if (!bugForm.title.trim()) return
|
if (!bugForm.content.trim()) return
|
||||||
try {
|
try {
|
||||||
const res = await api('/api/bug-report', {
|
const res = await api('/api/bug-report', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
content: bugForm.title.trim() + (bugForm.description.trim() ? '\n' + bugForm.description.trim() : ''),
|
content: bugForm.content.trim(),
|
||||||
priority: bugForm.priority === 'urgent' ? 0 : bugForm.priority === 'high' ? 1 : 2,
|
priority: bugForm.priority,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
showAddBug.value = false
|
showAddBug.value = false
|
||||||
bugForm.title = ''
|
bugForm.content = ''
|
||||||
bugForm.description = ''
|
bugForm.priority = 2
|
||||||
bugForm.priority = 'normal'
|
|
||||||
await loadBugs()
|
await loadBugs()
|
||||||
ui.showToast('Bug已提交')
|
ui.showToast('Bug已提交')
|
||||||
}
|
}
|
||||||
@@ -221,14 +213,14 @@ async function createBug() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateStatus(bug, newStatus) {
|
async function updateStatus(bug, newStatus) {
|
||||||
const id = bug._id || bug.id
|
const id = bug.id
|
||||||
try {
|
try {
|
||||||
const res = await api(`/api/bug-reports/${id}`, {
|
const res = await api(`/api/bug-reports/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({ status: newStatus }),
|
body: JSON.stringify({ status: newStatus }),
|
||||||
})
|
})
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
bug.status = newStatus
|
bug.is_resolved = newStatus
|
||||||
ui.showToast(`状态已更新: ${statusLabel(newStatus)}`)
|
ui.showToast(`状态已更新: ${statusLabel(newStatus)}`)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -237,7 +229,7 @@ async function updateStatus(bug, newStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function removeBug(bug) {
|
async function removeBug(bug) {
|
||||||
const ok = await showConfirm(`确定删除 "${bug.title}"?`)
|
const ok = await showConfirm(`确定删除 "${bug.content}"?`)
|
||||||
if (!ok) return
|
if (!ok) return
|
||||||
const id = bug._id || bug.id
|
const id = bug._id || bug.id
|
||||||
try {
|
try {
|
||||||
@@ -255,11 +247,10 @@ async function addComment(bug) {
|
|||||||
if (!newComment.value.trim()) return
|
if (!newComment.value.trim()) return
|
||||||
const id = bug._id || bug.id
|
const id = bug._id || bug.id
|
||||||
try {
|
try {
|
||||||
const res = await api(`/api/bug-reports/${id}/comments`, {
|
const res = await api(`/api/bug-reports/${id}/comment`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
text: newComment.value.trim(),
|
content: newComment.value.trim(),
|
||||||
author: auth.user.display_name || auth.user.username,
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user