From ca7af8baf9f1084fc897064be8af9555870879c7 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 21 Sep 2026 13:12:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(acc-support):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E5=B9=B6=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E8=81=94=E7=B3=BB=E6=88=91=E4=BB=AC=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增从后台获取管理员配置的联系我们数据的功能,支持邮箱和电话的跳转链接, fallback 到旧的固定链接配置 --- src/lib/im-api.js | 3 +++ src/views/acc-support-view.jsx | 41 +++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/lib/im-api.js b/src/lib/im-api.js index 6bc23ea6..150d277a 100644 --- a/src/lib/im-api.js +++ b/src/lib/im-api.js @@ -834,3 +834,6 @@ export const getAbuseReasons = (targetType = 'user') => imGet('/reports/abuse/re export const submitAbuseReport = body => imPost('/reports/abuse', body); export const getFeedbackConfig = () => imGet('/feedback/config'); export const submitFeedback = body => imPost('/feedback', {client_context: clientContext(), ...body}); + +// -- Contact us (admin 字典 im_contact_us 透传,含邮箱/电话条目;后台修改后经缓存失效近实时生效). -- +export const getContactUs = () => imGet('/contact-us'); diff --git a/src/views/acc-support-view.jsx b/src/views/acc-support-view.jsx index 0fcef1a8..546875b6 100644 --- a/src/views/acc-support-view.jsx +++ b/src/views/acc-support-view.jsx @@ -3,6 +3,12 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; import { APP_NAME, LINK_CONTACT_US, LINK_PRIVACY_POLICY, LINK_TERMS_OF_SERVICE } from '../config.js'; +import { getContactUs } from '../lib/im-api.js'; + +// Admin-managed "contact us" entries (dictionary type im_contact_us): emails get mailto:, phone +// numbers get tel:, anything else renders as plain (non-navigating) text. +const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; +const PHONE_PATTERN = /^\+?[0-9][0-9\- ]{4,}$/; // Renders as a real link when a destination is configured, or as inert (non-navigating) text // otherwise -- same treatment auth-onboarding-view.jsx already gives its own placeholder @@ -14,13 +20,42 @@ function FlatLink({href, icon, children}) { } export default class AccSupportView extends React.PureComponent { + constructor(props) { + super(props); + this.state = { + contactItems: [] + }; + } + + componentDidMount() { + // Entries come from the im-server /contact-us endpoint (admin dictionary im_contact_us). + // On failure the static config fallback below stays in place; no toast for a support page. + getContactUs().then(data => { + const items = (data && Array.isArray(data.items)) ? + data.items.filter(it => it && it.label && it.value) : []; + this.setState({contactItems: items}); + }).catch(() => {}); + } + render() { + const {contactItems} = this.state; return (
- - - + {contactItems.length > 0 ? + contactItems.map((item, idx) => { + const value = item.value; + const href = EMAIL_PATTERN.test(value) ? 'mailto:' + value : + (PHONE_PATTERN.test(value) ? 'tel:' + value.replace(/[^\d+]/g, '') : null); + return + {item.label} + ; + }) + : + + + + }