From 55b1111d96fdb7acbb354e8f8d67eedd468bee33 Mon Sep 17 00:00:00 2001 From: 3970260761 <3970260761@qq.com> Date: Thu, 12 Nov 2026 01:55:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(feedback):=20=E7=95=99=E8=A8=80=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E5=85=A8=E9=93=BE=E8=B7=AF=20=E2=80=94=20=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E5=BC=B9=E7=AA=97(=E9=AA=8C=E8=AF=81=E7=A0=81+IP?= =?UTF-8?q?=E9=99=90=E9=A2=91)=20+=20=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86(?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B5=81=E8=BD=AC/=E5=88=A0=E9=99=A4/?= =?UTF-8?q?=E8=A7=92=E6=A0=87)=20+=20nginx=20/admin/=20=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D502?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 + components.d.ts | 2 + nginx.conf | 15 ++ src/components/FeedbackModal.vue | 267 +++++++++++++++++++++++++++++++ src/layouts/base.layout.vue | 87 ++++++++++ src/pages/Admin.page.vue | 159 +++++++++++++++++- 6 files changed, 534 insertions(+), 2 deletions(-) create mode 100644 src/components/FeedbackModal.vue diff --git a/README.md b/README.md index 02ecd07..36e6a04 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,12 @@ - **生成记录**:翻译/OCR/修图/转换等 9 个工具自动留痕,数据存本地 - **体验优化**:全站中文默认、收藏与最近使用、菜单一键展开/收起、宽屏自适应、品牌页脚等数十项细节 +### 留言反馈(2026.11 新增) + +- **访客提交**:顶栏「留言反馈」按钮打开弹窗 —— 类型(功能建议/意见建议/Bug 反馈/其他)+ 内容(上限 1000 字)+ 联系方式(可选),图形验证码防刷,同一 IP 一小时内限提交 1 次 +- **管理后台**:`/admin` 切到「留言反馈」标签(`X-Admin-Token` 鉴权,令牌存本地 `it-tools-admin-token`),列出时间/类型/内容/联系方式/真实 IP,支持状态流转(未处理→已处理→已回复)与删除,导航标签带未处理数角标;窄屏下表格容器内横向滚动不撑破页面 +- **链路**:公开页 → relay `POST /feedback`(验证码校验 + IP 限频)落盘 `data/feedback.json`;管理接口经 nginx `location /admin/` 反代到 `it-tools-relay:8091`。公网入口 https://it.88531.cn/ + ## 优势 - **一次激活,全站通用**:输入一次卡密,全部授权功能解锁,无需逐个购买 diff --git a/components.d.ts b/components.d.ts index 14cc680..4c27a91 100644 --- a/components.d.ts +++ b/components.d.ts @@ -92,6 +92,7 @@ declare module '@vue/runtime-core' { Encryption: typeof import('./src/tools/encryption/encryption.vue')['default'] EtaCalculator: typeof import('./src/tools/eta-calculator/eta-calculator.vue')['default'] FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default'] + FeedbackModal: typeof import('./src/components/FeedbackModal.vue')['default'] FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default'] GenHistory: typeof import('./src/tools/gen-history/GenHistory.vue')['default'] GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default'] @@ -193,6 +194,7 @@ declare module '@vue/runtime-core' { NRadioButton: typeof import('naive-ui')['NRadioButton'] NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NScrollbar: typeof import('naive-ui')['NScrollbar'] + NSelect: typeof import('naive-ui')['NSelect'] NSlider: typeof import('naive-ui')['NSlider'] NSpace: typeof import('naive-ui')['NSpace'] NSpin: typeof import('naive-ui')['NSpin'] diff --git a/nginx.conf b/nginx.conf index 43d18d6..5dd12c5 100644 --- a/nginx.conf +++ b/nginx.conf @@ -17,6 +17,21 @@ server { proxy_read_timeout 10s; } + # admin console SPA route (exact match beats the /admin/ API prefix below, + # otherwise nginx 301s /admin -> /admin/ and the API proxy swallows the UI) + location = /admin { + try_files $uri /index.html; + } + + # admin console API (relay does its own Bearer auth; must beat SPA fallback) + location /admin/ { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://it-tools-relay:8091; + proxy_connect_timeout 5s; + proxy_read_timeout 30s; + } + # license relay (card activation etc; auth gate itself must stay open) location /relay/ { client_max_body_size 2g; diff --git a/src/components/FeedbackModal.vue b/src/components/FeedbackModal.vue new file mode 100644 index 0000000..5e2b2f5 --- /dev/null +++ b/src/components/FeedbackModal.vue @@ -0,0 +1,267 @@ + + + + + + diff --git a/src/layouts/base.layout.vue b/src/layouts/base.layout.vue index 28859c1..37b33a1 100644 --- a/src/layouts/base.layout.vue +++ b/src/layouts/base.layout.vue @@ -16,6 +16,7 @@ import { useToolStore } from '@/tools/tools.store'; import { useTracker } from '@/modules/tracker/tracker.services'; import CollapsibleToolMenu from '@/components/CollapsibleToolMenu.vue'; import UserMenu from '@/components/UserMenu.vue'; +import FeedbackModal from '@/components/FeedbackModal.vue'; const themeVars = useThemeVars(); const styleStore = useStyleStore(); @@ -31,6 +32,42 @@ if (isLoggedIn.value) { const version = config.app.version; const commitSha = config.app.lastCommitSha.slice(0, 7); +// ---- 站内留言反馈(右上角入口,弹窗提交,与授权系统无关) ---- +const showFeedback = ref(false); + +// ---- 页脚售后微信:点击复制 ---- +const WECHAT_ID = 'q3970260761'; +const wechatCopied = ref(false); +async function copyWechat() { + let ok = false; + try { + await navigator.clipboard.writeText(WECHAT_ID); + ok = true; + } + catch { + // 剪贴板 API 不可用(非 https / 老浏览器)时退回 execCommand + try { + const ta = document.createElement('textarea'); + ta.value = WECHAT_ID; + ta.style.position = 'fixed'; + ta.style.opacity = '0'; + document.body.appendChild(ta); + ta.select(); + ok = document.execCommand('copy'); + document.body.removeChild(ta); + } + catch { + ok = false; + } + } + if (ok) { + wechatCopied.value = true; + setTimeout(() => { + wechatCopied.value = false; + }, 2000); + } +} + const { tracker } = useTracker(); const { t } = useI18n(); @@ -193,6 +230,18 @@ onBeforeUnmount(() => { + + + + + { title="https://gitea.88531.cn/jinghui/it-tools-pro" >🐙 开源 gitea.88531.cn + · + + 💬 售后微信 {{ wechatCopied ? '已复制 ✓' : 'q3970260761' }} + + + + @@ -321,6 +384,16 @@ onBeforeUnmount(() => { opacity: 0.55; } + // 售后微信:点击复制(固定底栏下 pointer-events:none,这里单独放行) + .footer-wechat { + cursor: pointer; + pointer-events: auto; + + &:hover { + color: #0e9384; + } + } + :deep(a) { color: #838587; text-decoration: none; @@ -363,6 +436,13 @@ onBeforeUnmount(() => { flex-shrink: 0; } +// 右上角「留言反馈」入口:与顶栏其它文字按钮同规格 +.feedback-btn { + font-size: 13px; + white-space: nowrap; + flex-shrink: 0; +} + @media (max-width: 900px) { // 窄屏顶栏放不下完整文字时收缩为纯图标,并收紧间距,避免溢出右边缘 .top-nav { @@ -375,6 +455,13 @@ onBeforeUnmount(() => { padding-left: 8px; padding-right: 8px; } + .feedback-btn { + .feedback-btn-text { + display: none; + } + padding-left: 8px; + padding-right: 8px; + } } .top-nav { diff --git a/src/pages/Admin.page.vue b/src/pages/Admin.page.vue index f99e651..5a1d8a1 100644 --- a/src/pages/Admin.page.vue +++ b/src/pages/Admin.page.vue @@ -19,7 +19,10 @@ const loginPass = ref(''); function authHeaders(): Record { const h: Record = {}; if (token.value) { + // Bearer = logged-in admin session (channel 2); X-Admin-Token = bootstrap + // ADMIN_TOKEN paste flow (channel 1). Send both so either kind works. h['Authorization'] = `Bearer ${token.value}`; + h['X-Admin-Token'] = token.value; } return h; } @@ -61,6 +64,7 @@ async function login() { authed.value = true; localStorage.setItem(TOKEN_KEY, token.value); loadOverview(); + loadFeedback(); } } catch (e: any) { @@ -372,6 +376,55 @@ async function saveReco() { } } +// ============ 留言反馈(网站访客提交,与授权系统无关) ============ +const feedback = ref([]); + +async function loadFeedback() { + try { + const b = await api('/admin/feedback'); + feedback.value = b.data ?? []; + } catch (e: any) { + setMsg(`留言加载失败:${e.message}`); + } +} + +async function fbSetStatus(f: any, status: string) { + try { + const b = await api('/admin/feedback', { method: 'POST', body: JSON.stringify({ id: f.id, status }) }); + setMsg(b.code === 200 ? '已更新留言状态' : (b.message || '状态更新失败')); + if (b.code === 200) f.status = status; + } catch (e: any) { + setMsg(`状态更新失败:${e.message}`); + } +} + +function fbOnStatus(f: any, e: Event) { + fbSetStatus(f, (e.target as HTMLSelectElement).value); +} + +async function fbDelete(f: any) { + if (!window.confirm('确定删除这条留言?删除后无法恢复。')) return; + try { + const b = await api('/admin/feedback', { method: 'POST', body: JSON.stringify({ id: f.id, action: 'delete' }) }); + setMsg(b.code === 200 ? '已删除' : (b.message || '删除失败')); + if (b.code === 200) feedback.value = feedback.value.filter(x => x.id !== f.id); + } catch (e: any) { + setMsg(`删除失败:${e.message}`); + } +} + +function fbTime(ts: any) { + try { + const d = new Date(Number(ts) * 1000); + const p = (n: number) => String(n).padStart(2, '0'); + return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`; + } catch { + return String(ts ?? ''); + } +} + +const fbNewCount = computed(() => feedback.value.filter(f => f.status === 'new').length); + function recoAdd() { reco.value.unshift({ path: '', icon: '🧰', name: '', desc: '', enabled: true }); } @@ -389,9 +442,9 @@ function recoMove(i: number, d: -1 | 1) { reco.value.splice(j, 0, it); } -const tab = ref<'overview' | 'files' | 'usage' | 'storage' | 'reco'>('overview'); +const tab = ref<'overview' | 'files' | 'usage' | 'storage' | 'reco' | 'feedback'>('overview'); -function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') { +function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco' | 'feedback') { tab.value = id; if (id === 'overview') { loadOverview(); @@ -405,6 +458,9 @@ function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') { if (id === 'storage') { loadStorage(); } + if (id === 'feedback') { + loadFeedback(); + } } @@ -436,6 +492,10 @@ function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') {
📈 使用统计
💾 存储设置
🏠 首页推荐
+
+ 💬 留言反馈 + {{ fbNewCount }} +
退出 @@ -642,6 +702,55 @@ function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') { + + + @@ -751,6 +860,33 @@ function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') { gap: 7px; } +// ---- 留言反馈列表 ---- +.adm-fb-time { + white-space: nowrap; + font-variant-numeric: tabular-nums; +} + +.adm-fb-content { + max-width: 460px; + white-space: pre-wrap; + word-break: break-word; + line-height: 1.6; +} + +.adm-fb-contact, +.adm-fb-ip { + white-space: nowrap; +} + +.adm-fb-ip { + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 12px; +} + +.adm-fb-ops { + white-space: nowrap; +} + .adm-reco-row { display: flex; align-items: center; @@ -972,6 +1108,25 @@ function switchTab(id: 'overview' | 'files' | 'usage' | 'storage' | 'reco') { } } +/* 留言反馈表:窄视口容器内横向滚动,表头保持横排不被挤成竖列 */ +.adm-fb-scroll { + overflow-x: auto; + -webkit-overflow-scrolling: touch; + + .adm-table { + min-width: 820px; + + th { + white-space: nowrap; + } + + td { + word-break: break-word; + max-width: 360px; + } + } +} + .adm-badge { font-size: 11px; padding: 1px 8px;