Files
xfc_webview_V2/server/generate-seo-templates.cjs
2026-02-28 15:43:14 +08:00

256 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* SEO模板生成器
* 根据路由配置自动生成静态HTML模板
*/
const fs = require('fs')
const path = require('path')
// 页面SEO配置与useSEO.js保持一致
const pageSEOConfigs = {
'index.html': {
title: '幸福查官网_家庭生活安全评估_个人履约与情感互信平台',
description: '幸福查是您的智慧家庭安全管家。专注家政用工筛查与家庭财务健康。全方位核验保姆、月嫂、护工的司法背景与失信记录,同时提供个人经济履约分析。把好家庭进门关,守护家人安宁。',
keywords: '幸福查,家庭风险评估,生活隐患排查,情感互信报告,个人履约评估,家庭财务分析',
url: 'https://www.xingfucha.cn'
},
'agent.html': {
title: '幸福查代理 - 免费开通代理权限 | 大数据风险报告代理',
description: '幸福查代理平台,免费开通代理权限,享受大数据风险报告查询服务代理收益。专业的大数据风险报告、婚姻查询、个人信用评估等服务的代理合作。',
keywords: '幸福查代理, 免费代理, 大数据风险报告代理, 代理权限, 代理收益',
url: 'https://www.xingfucha.cn/agent'
},
'help.html': {
title: '幸福查帮助中心_合作伙伴操作指南_业务规则说明',
description: '幸福查官方服务支持中心。提供全方位的平台使用指引,涵盖合作伙伴注册流程、业务权益说明、成本核算规则及数据系统操作教程。助您快速掌握平台功能,高效开展服务。',
keywords: '幸福查使用教程,业务操作指南,合作伙伴权益,新手入门手册',
url: 'https://www.xingfucha.cn/help'
},
'help-guide.html': {
title: '使用指南 - 幸福查操作教程 | 功能说明',
description: '幸福查详细使用指南,包含各功能模块的操作教程、功能说明、注意事项等,让用户快速上手使用。',
keywords: '使用指南, 操作教程, 功能说明, 快速上手, 幸福查教程',
url: 'https://www.xingfucha.cn/help/guide'
},
'example.html': {
title: '示例报告 - 幸福查报告展示 | 大数据风险报告样例',
description: '幸福查示例报告展示,包含大数据风险报告、婚姻状况查询、个人信用评估等服务的报告样例,让用户了解报告内容和格式。',
keywords: '示例报告, 报告展示, 报告样例, 大数据风险报告, 婚姻查询报告',
url: 'https://www.xingfucha.cn/example'
},
'service.html': {
title: '客服中心 - 幸福查在线客服 | 技术支持',
description: '幸福查客服中心,提供在线客服支持、技术咨询、问题反馈等服务,确保用户获得及时有效的帮助。',
keywords: '客服中心, 在线客服, 技术支持, 问题反馈, 幸福查客服',
url: 'https://www.xingfucha.cn/service'
},
'inquire-personalData.html': {
title: '个人生活信用健康度_家庭经济履约画像_综合风险分析_幸福查',
description: '幸福查个人生活信用系统提供客观的健康指数分析。核心功能涵盖经济履约记录监测、生活消费稳定性预警及个人资质评分。通过多维数据排查潜在的信用盲点,辅助建立稳健的家庭财务档案。',
keywords: '个人履约评价检测,家庭经济画像,履约能力分析,生活履约评分,风险自查报告',
url: 'https://www.xingfucha.cn/inquire/personalData'
},
'inquire-companyinfo.html': {
title: '家庭经营性资产风险评估_企业工商信用透视_幸福查',
description: '幸福查深度透视家庭经营实体的工商信用状况。评估维度覆盖企业行政处罚、司法被执行信息及经营异常名录。客观评估商业合作伙伴实力,有效规避家庭资产的连带责任风险与合同陷阱。',
keywords: '企业风险评估,工商信用分析,商业合作评估,经营异常筛查,老板背景核实',
url: 'https://www.xingfucha.cn/inquire/companyinfo'
},
'inquire-preloanbackgroundcheck.html': {
title: '家庭财务健康度分析_个人经济履约压力检测_资金管理参考_幸福查',
description: '幸福查基于大数据算法对个人近期经济行为进行多维分析。精准检测资金流转稳定性、履约历史详情及生活消费压力指数。辅助用户掌握自身财务状况,科学规划家庭资金收支平衡度,提升抗风险能力。',
keywords: '财务健康检测,经济压力分析,履约能力评估,财务稳健度分析,生活消费指数',
url: 'https://www.xingfucha.cn/inquire/preloanbackgroundcheck'
},
'inquire-marriage.html': {
title: '婚前背景综合了解_涉婚风险筛查_情感互信报告_幸福查',
description: '幸福查婚恋评估系统致力于维护家庭情感基石。深度评估对象的涉婚法律诉讼、失信被执行记录及社会不良标签。消除交往中的信息不对称,辅助构建透明、坦诚<E59DA6>、安全的婚姻关系。',
keywords: '婚前背景核验,涉婚司法记录,情感互信分析,家庭安全报告,婚恋诚意度',
url: 'https://www.xingfucha.cn/inquire/marriage'
},
'inquire-backgroundcheck.html': {
title: '职业背景真实性核实_个人履约与职场信用分析_幸福查',
description: '幸福查针对求职与用工场景,提供客观的职业背景参考。核实学历背景、职业履历一致性及潜在的竞业限制风险。降低职场信任成本,助力构建诚实守信的职业发展环境。',
keywords: '入职背景核实,职业诚信档案,简历信息比对,职场风险评估,个人履历分析',
url: 'https://www.xingfucha.cn/inquire/backgroundcheck'
},
'inquire-homeservice.html': {
title: '家政人员背景核验_家庭用工司法安全评估_幸福查',
description: '幸福查专注家庭服务场景的安全用工工具。支持对保姆、月嫂及护工进行身份信息一致性核实与过往涉诉历史分析。科学识别服务人员的潜在风险标签,保障老人与儿童的居家生活安宁。',
keywords: '家政背景核实,家庭用工安全,保姆司法筛查,家政履约记录,居家安全评估',
url: 'https://www.xingfucha.cn/inquire/homeservice'
}
}
/**
* 规范化文案移除损坏字符U+FFFD统一为中文标点避免乱码
*/
function normalizeText(str) {
if (typeof str !== 'string') return str
return str
.replace(/\uFFFD/g, '') // 移除 UTF-8 替换符(乱码)
.replace(/。/g, '。')
.replace(/、/g, '、')
}
/**
* 生成HTML模板
*/
function generateHTMLTemplate(config) {
const title = normalizeText(config.title)
const description = normalizeText(config.description)
const keywords = normalizeText(config.keywords)
const structuredData = {
"@context": "https://schema.org",
"@type": "WebPage",
"name": title,
"description": description,
"url": config.url,
"mainEntity": {
"@type": "Organization",
"name": "幸福查",
"url": "https://www.xingfucha.cn/",
"description": "专业大数据风险报告查询与代理平台,支持个人和企业多场景风控应用"
}
}
return `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 页面标题 -->
<title>${title}</title>
<!-- SEO Meta标签 -->
<meta name="description" content="${description}">
<meta name="keywords" content="${keywords}">
<!-- Open Graph标签 -->
<meta property="og:title" content="${title}">
<meta property="og:description" content="${description}">
<meta property="og:url" content="${config.url}">
<meta property="og:type" content="website">
<meta property="og:site_name" content="幸福查">
<meta property="og:locale" content="zh_CN">
<!-- Twitter Cards -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="${title}">
<meta name="twitter:description" content="${description}">
<meta name="twitter:url" content="${config.url}">
<!-- Canonical URL -->
<link rel="canonical" href="${config.url}">
<!-- 结构化数据 -->
<script type="application/ld+json">
${JSON.stringify(structuredData, null, 8)}
</script>
<!-- 其他Meta标签 -->
<meta name="robots" content="index, follow">
<meta name="googlebot" content="index, follow">
<meta name="baiduspider" content="index, follow">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
margin: 0;
padding: 0;
line-height: 1.6;
}
.seo-content {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h1 { color: #333; }
p { color: #666; }
.redirect-notice {
background: #fff3cd;
border: 1px solid #ffc107;
color: #856404;
padding: 10px;
margin: 20px 0;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="seo-content">
<h1>${title}</h1>
<div class="redirect-notice">
<p>正在跳转到完整版网站...</p>
<p>如果浏览器没有自动跳转,请 <a href="${config.url}">点击这里</a></p>
</div>
<p>${description}</p>
<!-- 这里可以添加更多SEO友好的静态内容 -->
<section>
<h2>关于幸福查</h2>
<p>幸福查是专业的家庭生活安全评估平台,提供全方位的风险查询服务。我们的核心使命是帮助用户建立安全、可信赖的生活环境。</p>
</section>
<section>
<h2>核心服务</h2>
<ul>
<li>个人生活信用健康度评估</li>
<li>家庭经营性资产风险评估</li>
<li>家庭财务健康度分析</li>
<li>婚前背景综合了解</li>
<li>职业背景真实性核实</li>
<li>家政人员背景核验</li>
</ul>
</section>
<section>
<h2>为什么选择幸福查</h2>
<p>幸福查依托大数据技术,为用户提供准确、及时的风险评估报告,帮助您做出明智决策。</p>
</section>
</div>
<script>
// 可选自动跳转到SPA应用
// setTimeout(function() {
// window.location.href = '${config.url}';
// }, 2000);
</script>
</body>
</html>`
}
/**
* 主函数
*/
function main() {
const outputDir = path.join(__dirname, '../public/seo-templates')
// 创建输出目录
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true })
console.log(`✓ 创建模板目录: ${outputDir}`)
}
// 生成所有模板文件
let successCount = 0
Object.entries(pageSEOConfigs).forEach(([filename, config]) => {
const htmlContent = generateHTMLTemplate(config)
const filePath = path.join(outputDir, filename)
fs.writeFileSync(filePath, htmlContent, 'utf-8')
console.log(`✓ 生成模板: ${filename}`)
successCount++
})
console.log(`\n✓ 成功生成 ${successCount} 个SEO模板文件`)
console.log(`📁 模板目录: ${outputDir}`)
}
// 执行生成
main()