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 (