From 3b476a29d427152aa17ade2661cc3550ccc78bc3 Mon Sep 17 00:00:00 2001 From: zjb <2152698745@qq.com> Date: Thu, 29 May 2025 15:56:24 +0800 Subject: [PATCH] feedback --- docusaurus.config.js | 12 +++ src/css/custom.css | 64 ++++++++++++ src/pages/feedback.js | 182 ++++++++++++++++++++++++++++++++++ src/pages/feedback.module.css | 160 ++++++++++++++++++++++++++++++ 4 files changed, 418 insertions(+) create mode 100644 src/pages/feedback.js create mode 100644 src/pages/feedback.module.css diff --git a/docusaurus.config.js b/docusaurus.config.js index a809001..811bc7b 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -70,6 +70,11 @@ module.exports = { position: 'left', dropdownActiveClassDisabled: true }, + { + to: '/feedback', + position: 'right', + label: '问题反馈' + }, // { // href: 'https://github.com/boxyhq', // position: 'right', @@ -173,6 +178,13 @@ module.exports = { highlightSearchTermsOnTargetPage: true, blogRouteBasePath: "/", explicitSearchResultPath: true, + indexDocs: true, + indexBlog: false, + indexPages: true, + docsRouteBasePath: "/", + searchResultLimits: 8, + searchBarPosition: "right", + searchBarShortcutHint: true, // For Docs using Chinese, The `language` is recommended to set to: // ``` // language: ["en", "zh"], diff --git a/src/css/custom.css b/src/css/custom.css index f0b0f1a..c651310 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -16,6 +16,10 @@ --ifm-color-primary-lightest: rgb(146, 224, 208); --ifm-code-font-size: 95%; --search-local-modal-background:#1b2440; + --search-local-highlight-color: #466aff; + --search-local-hit-background: #f0f4ff; + --search-local-hit-shadow: 0 1px 3px 0 #d4e0ee; + --search-local-hit-active-color: #fff; } .navbar{ background-color: rgba(27, 36, 64, 1); @@ -149,4 +153,64 @@ html[data-theme='dark'] .docusaurus-highlight-code-line { .widget{ display: none!important; opacity: 0; +} + +/* 优化搜索框样式 */ +.navbar__search-input { + border-radius: 4px; + transition: width 0.2s ease-in-out; + border: 1px solid transparent; +} + +.navbar__search-input:focus { + width: 260px; + border-color: var(--ifm-color-primary); +} + +/* 搜索结果样式 */ +.search-result-match { + color: var(--search-local-highlight-color); + font-weight: bold; +} + +.search-result-item { + padding: 1rem; + margin-bottom: 0.5rem; + border-radius: 8px; + background-color: var(--search-local-hit-background); + box-shadow: var(--search-local-hit-shadow); + transition: all 0.2s ease; +} + +.search-result-item:hover { + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +/* 问题反馈导航按钮样式 */ +.navbar__items a[href="/feedback"] { + background-color: rgba(70, 106, 255, 0.1); + color: var(--ifm-color-primary) !important; + padding: 0.5rem 1rem; + border-radius: 4px; + font-weight: 500; + transition: all 0.2s ease; +} + +.navbar__items a[href="/feedback"]:hover { + background-color: rgba(70, 106, 255, 0.2); +} + +/* 暗黑模式适配 */ +html[data-theme='dark'] { + --search-local-hit-background: #2a2a3c; + --search-local-hit-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4); +} + +html[data-theme='dark'] .navbar__items a[href="/feedback"] { + background-color: rgba(70, 106, 255, 0.2); +} + +html[data-theme='dark'] .navbar__items a[href="/feedback"]:hover { + background-color: rgba(70, 106, 255, 0.3); } \ No newline at end of file diff --git a/src/pages/feedback.js b/src/pages/feedback.js new file mode 100644 index 0000000..9fd0e20 --- /dev/null +++ b/src/pages/feedback.js @@ -0,0 +1,182 @@ +const React = require('react'); +const { useState } = React; +const Layout = require('@theme/Layout').default; +const styles = require('./feedback.module.css'); + +function Feedback() { + const [formData, setFormData] = useState({ + name: '', + email: '', + type: '功能建议', + content: '', + }); + + const [submitted, setSubmitted] = useState(false); + const [error, setError] = useState(''); + const [isSubmitting, setIsSubmitting] = useState(false); + + const validateEmail = (email) => { + const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return re.test(email); + }; + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData(prevData => ({ + ...prevData, + [name]: value + })); + setError(''); + }; + + const handleSubmit = async (e) => { + e.preventDefault(); + + if (!formData.name.trim()) { + setError('请输入您的姓名'); + return; + } + + if (!formData.email.trim()) { + setError('请输入您的邮箱地址'); + return; + } + + if (!validateEmail(formData.email)) { + setError('请输入有效的邮箱地址'); + return; + } + + if (!formData.content.trim()) { + setError('请输入反馈内容'); + return; + } + + setIsSubmitting(true); + + try { + // 模拟API调用 + await new Promise(resolve => setTimeout(resolve, 1000)); + console.log('表单提交:', formData); + setSubmitted(true); + setError(''); + } catch (err) { + setError('提交失败,请稍后重试'); + } finally { + setIsSubmitting(false); + } + }; + + if (submitted) { + return ( + + + + 感谢您的反馈! + 我们已收到您的反馈意见,将认真处理每一条建议。您的支持是我们不断进步的动力。 + + { + setSubmitted(false); + setFormData({ + name: '', + email: '', + type: '功能建议', + content: '', + }); + }} + > + 继续提交反馈 + + 返回首页 + + + + + ); + } + + return ( + + + 问题反馈 + + 欢迎提供您的宝贵意见,帮助我们做得更好 + + + {error && {error}} + + + + 姓名 * + + + + + 邮箱 * + + + + + 反馈类型 + + 功能建议 + 问题报告 + 使用咨询 + 其他 + + + + + 反馈内容 * + + + + + {isSubmitting ? '提交中...' : '提交反馈'} + + + + + ); +} + +module.exports = Feedback; \ No newline at end of file diff --git a/src/pages/feedback.module.css b/src/pages/feedback.module.css new file mode 100644 index 0000000..d90f631 --- /dev/null +++ b/src/pages/feedback.module.css @@ -0,0 +1,160 @@ +.feedbackContainer { + max-width: 800px; + margin: 2rem auto; + padding: 2.5rem; + background: #ffffff; + border-radius: 8px; + box-shadow: 8px 6px 18px rgba(171, 202, 255, 0.24); +} + +.subtitle { + color: #666; + margin-bottom: 2rem; + text-align: center; + font-size: 1rem; + line-height: 1.5; +} + +h1 { + text-align: center; + color: #1b2440; + margin-bottom: 1rem; + font-size: 2rem; + font-weight: 600; +} + +.feedbackForm { + display: flex; + flex-direction: column; + gap: 1.25rem; +} + +.formGroup { + display: flex; + flex-direction: column; + gap: 0.5rem; +} + +.formGroup label { + font-weight: 500; + color: #1b2440; + font-size: 0.95rem; +} + +.required { + color: #e53e3e; + margin-left: 4px; +} + +.formGroup input, +.formGroup select, +.formGroup textarea { + padding: 0.75rem; + border: 1px solid #d4e0ee; + border-radius: 4px; + font-size: 0.95rem; + transition: all 0.2s ease; + background-color: #fff; +} + +.formGroup input:focus, +.formGroup select:focus, +.formGroup textarea:focus { + outline: none; + border-color: #466aff; + box-shadow: 0 0 0 3px rgba(70, 106, 255, 0.1); +} + +.formGroup input:hover, +.formGroup select:hover, +.formGroup textarea:hover { + border-color: #466aff; +} + +.formGroup input::placeholder, +.formGroup textarea::placeholder { + color: #94a3b8; +} + +.button { + background-color: #466aff; + color: white; + padding: 0.75rem 1.5rem; + border: none; + border-radius: 4px; + font-size: 1rem; + font-weight: 500; + cursor: pointer; + transition: all 0.2s ease; + margin-top: 0.5rem; +} + +.button:hover { + background-color: #3451cc; + transform: translateY(-1px); +} + +.button:disabled { + background-color: #94a3b8; + cursor: not-allowed; + transform: none; +} + +.errorMessage { + background-color: #fff5f5; + border: 1px solid #feb2b2; + color: #e53e3e; + padding: 0.75rem; + border-radius: 4px; + margin-bottom: 1rem; + text-align: center; + font-size: 0.95rem; +} + +.successMessage { + text-align: center; + padding: 2rem; +} + +.successMessage h1 { + color: #466aff; + margin-bottom: 1rem; + font-size: 1.75rem; +} + +.successMessage p { + color: #1b2440; + margin-bottom: 2rem; + font-size: 1rem; + line-height: 1.5; +} + +.homeLink { + display: inline-block; + margin-top: 1rem; + color: #466aff; + text-decoration: none; + font-weight: 500; + margin-left: 1rem; + transition: all 0.2s ease; +} + +.homeLink:hover { + color: #3451cc; + text-decoration: none; +} + +@media (max-width: 768px) { + .feedbackContainer { + margin: 1rem; + padding: 1.5rem; + } + + h1 { + font-size: 1.75rem; + } + + .button { + width: 100%; + } +} \ No newline at end of file
我们已收到您的反馈意见,将认真处理每一条建议。您的支持是我们不断进步的动力。
+ 欢迎提供您的宝贵意见,帮助我们做得更好 +