Skip to content

Commit 4fa9bee

Browse files
author
yqz
committed
顶部栏问题
1 parent fc4a329 commit 4fa9bee

3 files changed

Lines changed: 95 additions & 4 deletions

File tree

frontend/src/components/BlogHeader.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
全部文章
3131
</router-link>
3232

33-
<router-link to="/about" class="site-nav-link" active-class="active">
33+
<router-link to="/feedback" class="site-nav-link" active-class="active">
3434
<span class="site-nav-ico" aria-hidden="true">
3535
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
36-
<circle cx="12" cy="12" r="10" />
37-
<path d="M12 16v-4M12 8h.01" />
36+
<path d="M4 6h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z" />
37+
<path d="M22 8l-10 7L2 8" />
3838
</svg>
3939
</span>
40-
关于
40+
问题反馈
4141
</router-link>
4242

4343
<button type="button" class="site-nav-link site-nav-link-btn site-nav-widgets-btn" @click="$emit('toggle-widgets')">

frontend/src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AdminLoginView from '../views/AdminLoginView.vue'
99
import ChangelogListView from '../views/ChangelogListView.vue'
1010
import ChangelogDetailView from '../views/ChangelogDetailView.vue'
1111
import AboutView from '../views/AboutView.vue'
12+
import FeedbackView from '../views/FeedbackView.vue'
1213
import ConsoleLayout from '../layouts/ConsoleLayout.vue'
1314
import ConsoleDashboardView from '../views/ConsoleDashboardView.vue'
1415
import ConsoleProfileView from '../views/ConsoleProfileView.vue'
@@ -36,6 +37,11 @@ const routes = [
3637
name: 'about',
3738
component: AboutView
3839
},
40+
{
41+
path: '/feedback',
42+
name: 'feedback',
43+
component: FeedbackView
44+
},
3945
{
4046
path: '/console/login',
4147
name: 'consoleLogin',
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<template>
2+
<div class="blog-container">
3+
<main>
4+
<div class="card">
5+
<div class="card-body" style="padding: 22px">
6+
<h1 style="margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -0.02em">问题反馈</h1>
7+
<p style="margin: 12px 0 0; color: var(--muted); line-height: 1.8">
8+
欢迎提交使用中的问题/建议(同一 IP 每天仅可提交一次)。
9+
</p>
10+
11+
<div style="margin-top: 18px">
12+
<div class="field">
13+
<div class="label">姓名</div>
14+
<input v-model.trim="name" class="input" type="text" maxlength="50" placeholder="请输入姓名" />
15+
</div>
16+
17+
<div class="field">
18+
<div class="label">问题</div>
19+
<textarea
20+
v-model.trim="content"
21+
class="textarea"
22+
rows="6"
23+
maxlength="2000"
24+
placeholder="请尽量描述清楚:发生了什么、期望什么、复现步骤(如有)"
25+
/>
26+
</div>
27+
28+
<div style="display: flex; justify-content: flex-end; margin-top: 14px">
29+
<button class="btn primary" :disabled="submitting" @click="submit">
30+
{{ submitting ? '提交中...' : '提交反馈' }}
31+
</button>
32+
</div>
33+
34+
<div v-if="error" class="error" style="margin-top: 12px">{{ error }}</div>
35+
</div>
36+
</div>
37+
</div>
38+
</main>
39+
</div>
40+
</template>
41+
42+
<script setup>
43+
import { ref } from 'vue'
44+
import { createFeedback } from '../api/feedback'
45+
import { showMessage } from '../utils/message'
46+
47+
const name = ref('')
48+
const content = ref('')
49+
const submitting = ref(false)
50+
const error = ref('')
51+
52+
async function submit() {
53+
if (submitting.value) return
54+
error.value = ''
55+
56+
if (!name.value || name.value.trim().length < 1) {
57+
error.value = '请填写姓名'
58+
return
59+
}
60+
61+
if (!content.value || content.value.trim().length < 2) {
62+
error.value = '请填写问题内容(至少 2 个字符)'
63+
return
64+
}
65+
66+
submitting.value = true
67+
try {
68+
await createFeedback({
69+
submitterName: name.value.trim(),
70+
content: content.value.trim()
71+
})
72+
showMessage('已收到你的反馈,感谢!')
73+
name.value = ''
74+
content.value = ''
75+
} catch (e) {
76+
const traceId = e?.traceId ? `traceId ${e.traceId}` : ''
77+
const prefix = e?.code ? `错误码 ${e.code}` : e?.httpStatus ? `HTTP ${e.httpStatus}` : ''
78+
const head = [prefix, traceId].filter(Boolean).join('')
79+
error.value = head ? `${head}${e?.message || '提交失败'}` : e?.message || '提交失败'
80+
} finally {
81+
submitting.value = false
82+
}
83+
}
84+
</script>
85+

0 commit comments

Comments
 (0)