diff --git a/frontend/src/views/BugTracker.vue b/frontend/src/views/BugTracker.vue
index 37050ff..464f20e 100644
--- a/frontend/src/views/BugTracker.vue
+++ b/frontend/src/views/BugTracker.vue
@@ -16,22 +16,21 @@
{{ statusLabel(bug.status) }}
{{ formatDate(bug.created_at) }}
-
{{ bug.title }}
- {{ bug.description }}
- 报告者: {{ bug.reporter }}
+ {{ bug.content }}
+ {{ bug.display_name || bug.username }}
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -40,10 +39,11 @@
@@ -92,12 +92,8 @@
-
-
-
-
-
-
+
+
@@ -113,7 +109,7 @@
@@ -137,38 +133,35 @@ const expandedBugId = ref(null)
const newComment = ref('')
const bugForm = reactive({
- title: '',
- description: '',
- priority: 'normal',
+ content: '',
+ priority: 2,
})
+// priority: 0=urgent, 1=high, 2=normal
const priorities = [
- { value: 'low', label: '低' },
- { value: 'normal', label: '中' },
- { value: 'high', label: '高' },
- { value: 'critical', label: '紧急' },
+ { value: 0, label: '紧急' },
+ { value: 1, label: '高' },
+ { value: 2, label: '中' },
]
+// is_resolved: 0=open, 1=testing, 2=fixed, 3=tested
const activeBugs = computed(() =>
- bugs.value.filter(b => b.status !== 'tested' && b.status !== 'closed')
- .sort((a, b) => {
- const order = { critical: 0, high: 1, normal: 2, low: 3 }
- return (order[a.priority] ?? 2) - (order[b.priority] ?? 2)
- })
+ bugs.value.filter(b => b.is_resolved !== 2 && b.is_resolved !== 3)
+ .sort((a, b) => (a.priority ?? 2) - (b.priority ?? 2))
)
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) {
- const map = { low: '低', normal: '中', high: '高', critical: '紧急' }
- return map[p] || '中'
+ const map = { 0: '紧急', 1: '高', 2: '中' }
+ return map[p] ?? '中'
}
function statusLabel(s) {
- const map = { open: '待处理', testing: '测试中', fixed: '已修复', tested: '已验证', closed: '已关闭' }
- return map[s] || s
+ const map = { 0: '待处理', 1: '待测试', 2: '已修复', 3: '已测试' }
+ return map[s] ?? '待处理'
}
function formatDate(d) {
@@ -198,20 +191,19 @@ async function loadBugs() {
}
async function createBug() {
- if (!bugForm.title.trim()) return
+ if (!bugForm.content.trim()) return
try {
const res = await api('/api/bug-report', {
method: 'POST',
body: JSON.stringify({
- content: bugForm.title.trim() + (bugForm.description.trim() ? '\n' + bugForm.description.trim() : ''),
- priority: bugForm.priority === 'urgent' ? 0 : bugForm.priority === 'high' ? 1 : 2,
+ content: bugForm.content.trim(),
+ priority: bugForm.priority,
}),
})
if (res.ok) {
showAddBug.value = false
- bugForm.title = ''
- bugForm.description = ''
- bugForm.priority = 'normal'
+ bugForm.content = ''
+ bugForm.priority = 2
await loadBugs()
ui.showToast('Bug已提交')
}
@@ -221,14 +213,14 @@ async function createBug() {
}
async function updateStatus(bug, newStatus) {
- const id = bug._id || bug.id
+ const id = bug.id
try {
const res = await api(`/api/bug-reports/${id}`, {
method: 'PUT',
body: JSON.stringify({ status: newStatus }),
})
if (res.ok) {
- bug.status = newStatus
+ bug.is_resolved = newStatus
ui.showToast(`状态已更新: ${statusLabel(newStatus)}`)
}
} catch {
@@ -237,7 +229,7 @@ async function updateStatus(bug, newStatus) {
}
async function removeBug(bug) {
- const ok = await showConfirm(`确定删除 "${bug.title}"?`)
+ const ok = await showConfirm(`确定删除 "${bug.content}"?`)
if (!ok) return
const id = bug._id || bug.id
try {
@@ -255,11 +247,10 @@ async function addComment(bug) {
if (!newComment.value.trim()) return
const id = bug._id || bug.id
try {
- const res = await api(`/api/bug-reports/${id}/comments`, {
+ const res = await api(`/api/bug-reports/${id}/comment`, {
method: 'POST',
body: JSON.stringify({
- text: newComment.value.trim(),
- author: auth.user.display_name || auth.user.username,
+ content: newComment.value.trim(),
}),
})
if (res.ok) {