feat(site): integrate multilingual content management / 集成多语言内容管理
完善官网、管理后台与后端的多语言内容编辑和发布流程,调整站点页面及相关接口,并同步数据库脚本。 新增容器部署配置,改用环境变量注入数据库凭据;补充仓库忽略规则,并停止跟踪本地环境文件和 Maven 构建产物。
这个提交包含在:
1 父节点
4ee6e9ae83
当前提交
85083ab962
1056 个文件已更改
+15449
-132933
没有与搜索条件相匹配的文件
+23
-94
@@ -1,7 +1,13 @@
|
||||
/**
|
||||
* 门户客户服务(若依公开接口)- 在线留言、招商加盟、联系信息
|
||||
* 门户客户服务(若依公开接口)- 在线留言、联系信息
|
||||
*/
|
||||
import { nextTick } from 'vue'
|
||||
import i18n from '../i18n'
|
||||
|
||||
function ui(key, fallback = '') {
|
||||
const v = i18n.global.t(key)
|
||||
return v && v !== key ? v : fallback
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
if (text == null || text === '') {
|
||||
@@ -39,13 +45,19 @@ export async function fetchContactList() {
|
||||
*/
|
||||
export async function submitMessage(data) {
|
||||
const base = (import.meta.env.VITE_SITE_API_BASE || '/site').replace(/\/$/, '')
|
||||
const res = await fetch(`${base}/message/submit`, {
|
||||
const inquiryPayload = {
|
||||
inquiryName: data?.messageName || '',
|
||||
inquiryPhone: data?.messagePhone || '',
|
||||
inquiryProduct: data?.messageEmail || '',
|
||||
inquiryMessage: data?.messageContent || ''
|
||||
}
|
||||
const res = await fetch(`${base}/product/inquiry`, {
|
||||
method: 'POST',
|
||||
credentials: 'omit',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
body: JSON.stringify(inquiryPayload)
|
||||
})
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`)
|
||||
@@ -54,28 +66,12 @@ export async function submitMessage(data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交招商申请
|
||||
* @param {Object} data { applyName, applyPhone, applyCompany, applyIntent, applyArea }
|
||||
* @returns {Promise<Object>}
|
||||
* 注入联系信息并初始化留言表单
|
||||
*/
|
||||
export async function submitJoinApply(data) {
|
||||
const base = (import.meta.env.VITE_SITE_API_BASE || '/site').replace(/\/$/, '')
|
||||
const res = await fetch(`${base}/join/apply`, {
|
||||
method: 'POST',
|
||||
credentials: 'omit',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`)
|
||||
}
|
||||
return await res.json()
|
||||
export async function injectContactAndInitForms() {
|
||||
await injectContactInfo()
|
||||
initMessageForm()
|
||||
}
|
||||
|
||||
/**
|
||||
* 将联系信息注入到页面
|
||||
* 注入目标:联系我们页面的联系信息展示区域
|
||||
*/
|
||||
export async function injectContactInfo() {
|
||||
@@ -141,20 +137,20 @@ export function initMessageForm() {
|
||||
}
|
||||
|
||||
if (!data.messageName || !data.messagePhone || !data.messageContent) {
|
||||
alert('请填写姓名、联系电话和留言内容')
|
||||
alert(ui('ui.form.contact_required'))
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await submitMessage(data)
|
||||
if (result.code === 200) {
|
||||
alert('留言提交成功,我们会尽快与您联系!')
|
||||
alert(ui('ui.status.submit_ok_message'))
|
||||
form.reset()
|
||||
} else {
|
||||
alert(result.msg || '提交失败,请稍后重试')
|
||||
alert(result.msg || ui('ui.status.submit_fail_retry'))
|
||||
}
|
||||
} catch (error) {
|
||||
alert('提交失败,请稍后重试')
|
||||
alert(ui('ui.status.submit_fail_retry'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,64 +159,6 @@ export function initMessageForm() {
|
||||
submitBtn?.addEventListener('click', submitHandler)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化招商申请表单
|
||||
* 给招商表单绑定提交事件
|
||||
*/
|
||||
export function initJoinForm() {
|
||||
const form = resolveJoinForm()
|
||||
if (!form) {
|
||||
return
|
||||
}
|
||||
if (form.dataset.huayangBoundJoin === '1') {
|
||||
return
|
||||
}
|
||||
form.dataset.huayangBoundJoin = '1'
|
||||
|
||||
const submitHandler = async (event) => {
|
||||
event.preventDefault()
|
||||
|
||||
const data = {
|
||||
applyName: pickFormValue(form, ['name', 'applyName'], ['姓名', '联系人']),
|
||||
applyPhone: pickFormValue(form, ['phone', 'applyPhone'], ['电话', '手机', '联系方式']),
|
||||
applyCompany: pickFormValue(form, ['company', 'applyCompany'], ['公司', '企业']),
|
||||
applyIntent: pickFormValue(form, ['intent', 'applyIntent'], ['意向', '需求']),
|
||||
applyArea: pickFormValue(form, ['area', 'applyArea'], ['区域', '地区'])
|
||||
}
|
||||
|
||||
if (!data.applyName || !data.applyPhone) {
|
||||
alert('请填写姓名和联系电话')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await submitJoinApply(data)
|
||||
if (result.code === 200) {
|
||||
alert('申请提交成功,我们的招商经理会尽快与您联系!')
|
||||
form.reset()
|
||||
} else {
|
||||
alert(result.msg || '提交失败,请稍后重试')
|
||||
}
|
||||
} catch (error) {
|
||||
alert('提交失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
form.addEventListener('submit', submitHandler)
|
||||
const submitBtn = form.querySelector('.e_formBtn-16, .e_formBtn-96, .btn-primary')
|
||||
submitBtn?.addEventListener('click', submitHandler)
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入联系信息并初始化表单
|
||||
* 页面初始化时调用
|
||||
*/
|
||||
export async function injectContactAndInitForms() {
|
||||
await injectContactInfo()
|
||||
initMessageForm()
|
||||
initJoinForm()
|
||||
}
|
||||
|
||||
function resolveMessageForm() {
|
||||
const explicit = document.querySelector('.message-form, #messageForm')
|
||||
if (explicit) return explicit
|
||||
@@ -230,15 +168,6 @@ function resolveMessageForm() {
|
||||
return document.querySelector('.e_form-10, form.e_form-10, form.e_form-94')
|
||||
}
|
||||
|
||||
function resolveJoinForm() {
|
||||
const explicit = document.querySelector('.join-form, #joinForm')
|
||||
if (explicit) return explicit
|
||||
const isJoinPage =
|
||||
window.location.search.includes('page=join') || window.location.pathname.toLowerCase().includes('join')
|
||||
if (!isJoinPage) return null
|
||||
return document.querySelector('form.e_form-94, .e_form-94')
|
||||
}
|
||||
|
||||
function pickFormValue(form, nameCandidates, placeholderCandidates) {
|
||||
const byName = nameCandidates
|
||||
.map((name) => form.querySelector(`[name="${name}"]`))
|
||||
|
||||
在新工单中引用
屏蔽一个用户