From 4ccf2ec3543f199c2477098a5503c356c3be78e6 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Wed, 25 Feb 2026 11:45:21 +0800 Subject: [PATCH] up seo --- DEPLOYMENT_GUIDE.md | 555 +++++++++++++++++ index.html | 14 +- public/robots.txt | 2 +- public/sitemap.xml | 22 +- scripts/seo-static-generator/.htaccess | 46 ++ scripts/seo-static-generator/README.md | 332 ++++++++++ .../seo-static-generator/SEO_INTEGRATION.md | 367 +++++++++++ .../seo-static-generator/SEO_QUICKSTART.md | 352 +++++++++++ .../SEO_SOLUTION_SUMMARY.md | 347 +++++++++++ .../seo-static-generator/crawlerMiddleware.js | 324 ++++++++++ scripts/seo-static-generator/debug.js | 39 ++ .../generateNginxConfig.js | 74 +++ .../generateStaticPages.js | 261 ++++++++ scripts/seo-static-generator/index.html | 246 ++++++++ scripts/seo-static-generator/nginx.conf | 111 ++++ scripts/seo-static-generator/package.json | 20 + scripts/seo-static-generator/pageTemplates.js | 577 ++++++++++++++++++ scripts/seo-static-generator/run.js | 194 ++++++ .../static-pages/agent.html | 193 ++++++ .../static-pages/example.html | 193 ++++++ .../static-pages/help.html | 193 ++++++ .../static-pages/index.html | 193 ++++++ .../inquire-category-lawsuit.html | 193 ++++++ .../inquire-category-marriageStatus.html | 193 ++++++ .../inquire-category-vehicle.html | 193 ++++++ .../static-pages/inquire-marriage.html | 193 ++++++ .../static-pages/inquire.html | 193 ++++++ .../static-pages/robots.txt | 5 + .../static-pages/service.html | 193 ++++++ .../static-pages/sitemap.xml | 63 ++ scripts/seo-static-generator/testGenerator.js | 280 +++++++++ src/composables/useSEO.js | 8 +- src/router/index.js | 2 +- src/views/NotFound.vue | 2 +- vite.config.js | 4 +- 35 files changed, 6151 insertions(+), 26 deletions(-) create mode 100644 DEPLOYMENT_GUIDE.md create mode 100644 scripts/seo-static-generator/.htaccess create mode 100644 scripts/seo-static-generator/README.md create mode 100644 scripts/seo-static-generator/SEO_INTEGRATION.md create mode 100644 scripts/seo-static-generator/SEO_QUICKSTART.md create mode 100644 scripts/seo-static-generator/SEO_SOLUTION_SUMMARY.md create mode 100644 scripts/seo-static-generator/crawlerMiddleware.js create mode 100644 scripts/seo-static-generator/debug.js create mode 100644 scripts/seo-static-generator/generateNginxConfig.js create mode 100644 scripts/seo-static-generator/generateStaticPages.js create mode 100644 scripts/seo-static-generator/index.html create mode 100644 scripts/seo-static-generator/nginx.conf create mode 100644 scripts/seo-static-generator/package.json create mode 100644 scripts/seo-static-generator/pageTemplates.js create mode 100644 scripts/seo-static-generator/run.js create mode 100644 scripts/seo-static-generator/static-pages/agent.html create mode 100644 scripts/seo-static-generator/static-pages/example.html create mode 100644 scripts/seo-static-generator/static-pages/help.html create mode 100644 scripts/seo-static-generator/static-pages/index.html create mode 100644 scripts/seo-static-generator/static-pages/inquire-category-lawsuit.html create mode 100644 scripts/seo-static-generator/static-pages/inquire-category-marriageStatus.html create mode 100644 scripts/seo-static-generator/static-pages/inquire-category-vehicle.html create mode 100644 scripts/seo-static-generator/static-pages/inquire-marriage.html create mode 100644 scripts/seo-static-generator/static-pages/inquire.html create mode 100644 scripts/seo-static-generator/static-pages/robots.txt create mode 100644 scripts/seo-static-generator/static-pages/service.html create mode 100644 scripts/seo-static-generator/static-pages/sitemap.xml create mode 100644 scripts/seo-static-generator/testGenerator.js diff --git a/DEPLOYMENT_GUIDE.md b/DEPLOYMENT_GUIDE.md new file mode 100644 index 0000000..0209654 --- /dev/null +++ b/DEPLOYMENT_GUIDE.md @@ -0,0 +1,555 @@ +# 天远查 SEO 静态页面部署指南 + +本文档提供完整的 SEO 静态页面生成和部署方案。 + +## 📋 目录 + +- [快速开始](#快速开始) +- [文件结构](#文件结构) +- [生成静态页面](#生成静态页面) +- [部署到生产环境](#部署到生产环境) +- [验证SEO效果](#验证seo效果) +- [维护和更新](#维护和更新) + +--- + +## 🚀 快速开始 + +### 1. 生成静态页面 + +```bash +# 进入项目目录 +cd C:\Users\a1726\Desktop\tyc\tyc-webview-v2 + +# 运行生成器 +node scripts\seo-static-generator\run.js +``` + +生成成功后,会在 `scripts\seo-static-generator\static-pages\` 目录生成: + +- ✅ 10 个静态HTML页面 +- ✅ sitemap.xml +- ✅ robots.txt + +### 2. 生成服务器配置 + +```bash +# 生成 Nginx 和 Apache 配置 +node scripts\seo-static-generator\generateNginxConfig.js +``` + +生成成功后,会创建: + +- ✅ nginx.conf (Nginx配置) +- ✅ .htaccess (Apache配置) + +--- + +## 📁 文件结构 + +``` +tyc-webview-v2/ +├── scripts/ +│ └── seo-static-generator/ +│ ├── run.js # 主生成脚本(推荐使用) +│ ├── generateStaticPages.js # 完整生成脚本 +│ ├── pageTemplates.js # 页面模板 +│ ├── crawlerMiddleware.js # 爬虫检测中间件 +│ ├── generateNginxConfig.js # 配置生成脚本 +│ ├── package.json # 项目配置 +│ ├── README.md # 详细文档 +│ ├── index.html # 示例页面 +│ ├── nginx.conf # Nginx配置(生成) +│ ├── .htaccess # Apache配置(生成) +│ └── static-pages/ # 生成的静态页面 +│ ├── index.html +│ ├── inquire-category-lawsuit.html +│ ├── inquire-marriage.html +│ ├── inquire-category-vehicle.html +│ ├── inquire-category-marriageStatus.html +│ ├── agent.html +│ ├── help.html +│ ├── example.html +│ ├── service.html +│ ├── inquire.html +│ ├── sitemap.xml +│ └── robots.txt +├── SEO_INTEGRATION.md # 集成指南 +└── DEPLOYMENT_GUIDE.md # 本文档 +``` + +--- + +## 🔨 生成静态页面 + +### 方式一:使用简化脚本(推荐) + +```bash +node scripts\seo-static-generator\run.js +``` + +**优点:** +- 兼容性更好 +- 输出更清晰 +- 错误处理更完善 + +### 方式二:使用完整脚本 + +```bash +node scripts\seo-static-generator\generateStaticPages.js +``` + +**包含功能:** +- 生成所有路由页面 +- 生成额外的路由页面 +- 生成sitemap.xml +- 生成robots.txt + +--- + +## 🌐 部署到生产环境 + +### 方式一:Nginx 部署(推荐) + +#### 步骤 1:准备文件 + +```bash +# 1. 生成静态页面 +node scripts\seo-static-generator\run.js + +# 2. 生成 Nginx 配置 +node scripts\seo-static-generator\generateNginxConfig.js +``` + +#### 步骤 2:修改 Nginx 配置 + +编辑 `scripts\seo-static-generator\nginx.conf`,修改以下路径: + +```nginx +server_name www.tianyuancha.cn; # 修改为你的域名 +spaRoot /var/www/tyc-webview-v2/dist; # 修改为SPA静态文件目录 +staticRoot /var/www/tyc-webview-v2/static-pages; # 修改为SEO页面目录 +``` + +#### 步骤 3:上传文件到服务器 + +```bash +# 上传 SPA 构建文件 +scp -r dist/* user@server:/var/www/tyc-webview-v2/dist/ + +# 上传 SEO 静态页面 +scp -r scripts/seo-static-generator/static-pages/* user@server:/var/www/tyc-webview-v2/static-pages/ + +# 上传 Nginx 配置 +scp scripts/seo-static-generator/nginx.conf user@server:/etc/nginx/sites-available/tyc-webview +``` + +#### 步骤 4:配置 Nginx + +```bash +# SSH 登录到服务器 +ssh user@server + +# 创建软链接 +sudo ln -s /etc/nginx/sites-available/tyc-webview /etc/nginx/sites-enabled/ + +# 测试配置 +sudo nginx -t + +# 如果测试通过,重载 Nginx +sudo nginx -s reload +``` + +#### 步骤 5:验证部署 + +```bash +# 模拟百度爬虫 +curl -A "Baiduspider" http://www.tianyuancha.cn/ + +# 模拟 Google 爬虫 +curl -A "Googlebot" http://www.tianyuancha.cn/ + +# 正常浏览器访问 +curl -A "Mozilla/5.0" http://www.tianyuancha.cn/ +``` + +### 方式二:Apache 部署 + +#### 步骤 1:准备文件 + +```bash +# 1. 生成静态页面 +node scripts\seo-static-generator\run.js + +# 2. 生成 Apache 配置 +node scripts\seo-static-generator\generateNginxConfig.js +``` + +#### 步骤 2:上传文件到服务器 + +```bash +# 上传 SPA 构建文件 +scp -r dist/* user@server:/var/www/tyc-webview-v2/ + +# 上传 SEO 静态页面 +scp -r scripts/seo-static-generator/static-pages/* user@server:/var/www/tyc-webview-v2/static-pages/ + +# 上传 .htaccess +scp scripts/seo-static-generator/.htaccess user@server:/var/www/tyc-webview-v2/ +``` + +#### 步骤 3:启用 mod_rewrite + +```bash +# SSH 登录到服务器 +ssh user@server + +# 启用 mod_rewrite +sudo a2enmod rewrite + +# 重启 Apache +sudo systemctl restart apache2 +``` + +#### 步骤 4:验证部署 + +```bash +# 模拟百度爬虫 +curl -A "Baiduspider" http://www.tianyuancha.cn/ + +# 模拟 Google 爬虫 +curl -A "Googlebot" http://www.tianyuancha.cn/ + +# 正常浏览器访问 +curl -A "Mozilla/5.0" http://www.tianyuancha.cn/ +``` + +--- + +## ✅ 验证 SEO 效果 + +### 1. 测试爬虫检测 + +在本地或服务器上运行以下命令: + +```bash +# 测试百度爬虫 +curl -A "Baiduspider" http://www.tianyuancha.cn/ | head -20 + +# 测试 Google 爬虫 +curl -A "Googlebot" http://www.tianyuancha.cn/ | head -20 + +# 测试 360 爬虫 +curl -A "360spider" http://www.tianyuancha.cn/ | head -20 + +# 测试搜狗爬虫 +curl -A "sogou spider" http://www.tianyuancha.cn/ | head -20 + +# 测试正常用户 +curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" http://www.tianyuancha.cn/ | head -20 +``` + +**预期结果:** +- 爬虫访问应该返回静态HTML页面(包含完整的TDK) +- 正常用户访问应该返回SPA应用 + +### 2. 验证 TDK 标签 + +检查生成的静态页面是否包含完整的SEO标签: + +```bash +# 查看生成的首页 +cat scripts/seo-static-generator/static-pages/index.html | grep -E "|<meta name=\"description\"|<meta name=\"keywords\"" +``` + +**预期输出:** +```html +<title>天远查官网_企业与婚姻关联风险核验_综合履约背景核验 + + +``` + +### 3. 使用在线工具验证 + +#### Google Rich Results Test +访问:https://search.google.com/test/rich-results +输入你的网站URL,测试结构化数据。 + +#### 百度移动适配测试 +访问:http://ziyuan.baidu.com/ +测试移动端适配和SEO。 + +#### Schema Markup Validator +访问:https://validator.schema.org/ +验证结构化数据格式。 + +--- + +## 🔄 维护和更新 + +### 更新 SEO 配置 + +#### 步骤 1:修改配置 + +编辑 `scripts\seo-static-generator\run.js` 中的 `seoConfigs`: + +```javascript +const seoConfigs = { + '/': { + title: '新的页面标题', + description: '新的页面描述', + keywords: '新的关键词' + }, + // ... 其他路由 +}; +``` + +#### 步骤 2:重新生成静态页面 + +```bash +node scripts\seo-static-generator\run.js +``` + +#### 步骤 3:部署到服务器 + +```bash +# 上传更新的静态页面 +scp -r scripts/seo-static-generator/static-pages/* user@server:/var/www/tyc-webview-v2/static-pages/ +``` + +### 添加新的路由页面 + +#### 步骤 1:添加路由配置 + +在 `scripts\seo-static-generator\run.js` 的 `seoConfigs` 中添加: + +```javascript +const seoConfigs = { + // ... 现有路由 + '/new-route': { + title: '新页面标题', + description: '新页面描述', + keywords: '关键词1,关键词2' + } +}; +``` + +#### 步骤 2:添加页面内容(可选) + +编辑 `scripts\seo-static-generator\pageTemplates.js`,添加内容生成函数: + +```javascript +function generateNewRouteContent(seoConfig) { + return ` +

新页面标题

+

这里写页面的具体内容...

+ `; +} + +// 添加到路由映射 +export function generateContentByRoute(path, seoConfig) { + const routeContentMap = { + // ... 现有路由 + '/new-route': generateNewRouteContent(seoConfig), + }; + return routeContentMap[path] || generateDefaultContent(seoConfig); +} +``` + +#### 步骤 3:重新生成和部署 + +```bash +# 重新生成 +node scripts\seo-static-generator\run.js + +# 部署到服务器 +scp -r scripts/seo-static-generator/static-pages/* user@server:/var/www/tyc-webview-v2/static-pages/ +``` + +--- + +## 🔧 集成到 CI/CD + +在 CI/CD 流程中自动生成和部署静态页面。 + +### GitHub Actions 示例 + +创建 `.github/workflows/deploy.yml`: + +```yaml +name: Deploy + +on: + push: + branches: [ main ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Build Vue project + run: npm run build + + - name: Generate SEO pages + run: node scripts/seo-static-generator/run.js + + - name: Deploy to server + uses: easingthemes/ssh-deploy@v2.1.5 + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: /var/www/tyc-webview-v2/ + with: + SOURCE: "dist/ scripts/seo-static-generator/static-pages/" + ARGS: "-rlgoDzvc -i" +``` + +### Jenkins Pipeline 示例 + +创建 `Jenkinsfile`: + +```groovy +pipeline { + agent any + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Install') { + steps { + sh 'npm install' + } + } + + stage('Build') { + steps { + sh 'npm run build' + } + } + + stage('Generate SEO') { + steps { + sh 'node scripts/seo-static-generator/run.js' + } + } + + stage('Deploy') { + steps { + sh ''' + scp -r dist/* user@server:/var/www/tyc-webview-v2/dist/ + scp -r scripts/seo-static-generator/static-pages/* user@server:/var/www/tyc-webview-v2/static-pages/ + ''' + } + } + } +} +``` + +--- + +## 📊 监控和日志 + +### Nginx 日志 + +```bash +# 查看访问日志 +sudo tail -f /var/log/nginx/tyc-webview-access.log + +# 查看错误日志 +sudo tail -f /var/log/nginx/tyc-webview-error.log + +# 查看爬虫访问记录 +grep -i "googlebot\|baiduspider" /var/log/nginx/tyc-webview-access.log +``` + +### Apache 日志 + +```bash +# 查看访问日志 +sudo tail -f /var/log/apache2/access.log + +# 查看错误日志 +sudo tail -f /var/log/apache2/error.log + +# 查看爬虫访问记录 +grep -i "googlebot\|baiduspider" /var/log/apache2/access.log +``` + +--- + +## ❓ 常见问题 + +### Q1: 静态页面没有生成? + +**A:** 检查以下几点: +1. 确保 Node.js 版本 >= 14 +2. 检查是否有文件写入权限 +3. 查看控制台错误信息 +4. 尝试使用 `run.js` 脚本而不是 `generateStaticPages.js` + +### Q2: Nginx 配置不生效? + +**A:** 检查以下几点: +1. 确保 Nginx 已重启:`sudo nginx -s reload` +2. 检查配置文件语法:`sudo nginx -t` +3. 查看 Nginx 错误日志:`sudo tail -f /var/log/nginx/error.log` +4. 确保静态文件路径正确 + +### Q3: 爬虫仍然看到的是 SPA? + +**A:** 检查以下几点: +1. 确认 User-Agent 匹配规则正确 +2. 检查 Nginx/Apache 配置是否正确加载 +3. 使用 curl 测试爬虫访问 +4. 清除浏览器缓存后重试 + +### Q4: 如何处理动态内容? + +**A:** 对于需要动态内容的页面,可以考虑: +1. 使用定时任务定期重新生成静态页面 +2. 在静态页面中添加 JavaScript,让正常用户访问时加载动态内容 +3. 考虑使用动态渲染服务(方案三) + +### Q5: 如何测试 SEO 效果? + +**A:** 使用以下工具: +1. Google Rich Results Test: https://search.google.com/test/rich-results +2. 百度移动适配测试: http://ziyuan.baidu.com/ +3. Schema Markup Validator: https://validator.schema.org/ + +--- + +## 📚 相关文档 + +- [详细使用文档](scripts/seo-static-generator/README.md) +- [集成指南](SEO_INTEGRATION.md) +- [useSEO.js 源码](src/composables/useSEO.js) + +--- + +## 🆘 技术支持 + +如有问题,请联系技术团队或提交 Issue。 + +--- + +## 📄 许可证 + +MIT diff --git a/index.html b/index.html index a8d28ec..b5977db 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -57,11 +57,11 @@ "@context": "https://schema.org", "@type": "WebSite", "name": "天远查", - "url": "https://www.zhinengcha.cn/", + "url": "https://www.tianyuancha.cn/", "description": "专业大数据风险报告查询与代理平台,支持个人信用查询、小微企业风控、贷前风险背调等多场景报告应用", "potentialAction": { "@type": "SearchAction", - "target": "https://www.zhinengcha.cn/search?q={search_term_string}", + "target": "https://www.tianyuancha.cn/search?q={search_term_string}", "query-input": "required name=search_term_string" } } @@ -72,7 +72,7 @@ "@context": "https://schema.org", "@type": "Organization", "name": "天远查", - "url": "https://www.zhinengcha.cn/", + "url": "https://www.tianyuancha.cn/", "description": "专业大数据风险报告查询与代理平台,支持个人和企业多场景风控应用" } @@ -84,9 +84,9 @@ - + - + + + + + + +
+
+ 静态页面示例 +

天远查官网_企业与婚姻关联风险核验_综合履约背景核验

+

天远查官网(TianYuanCha)聚合官方公示数据,专注于商业安全与资产背调。提供企业工商画像、婚姻状态关联风险、司法涉诉筛查及配偶债务核验。数据实时同步,助您精准规避投资、交易及家庭结合中的经济与法律风险。

+
+ +
+

关于天远查官网_企业与婚姻关联风险核验_综合履约背景核验

+

天远查官网(TianYuanCha)聚合官方公示数据,专注于商业安全与资产背调。提供企业工商画像、婚姻状态关联风险、司法涉诉筛查及配偶债务核验。数据实时同步,助您精准规避投资、交易及家庭结合中的经济与法律风险。

+ +

核心功能

+ + +

为什么选择天远查?

+ + +

应用场景

+ + +

数据来源

+

天远查的数据来源于以下官方渠道:

+ + +

联系我们

+

如果您有任何问题或需要帮助,请通过以下方式联系我们:

+ + +
+

💡 这是静态页面的示例,实际部署时爬虫会看到此页面,正常用户会访问完整的 SPA 应用。

+
+
+ + +
+ + diff --git a/scripts/seo-static-generator/nginx.conf b/scripts/seo-static-generator/nginx.conf new file mode 100644 index 0000000..aa5b6f3 --- /dev/null +++ b/scripts/seo-static-generator/nginx.conf @@ -0,0 +1,111 @@ +# Nginx 配置文件 - 天远查 SPA + SEO 静态页面 +# 自动生成时间: 2026/2/25 11:04:50 + + + +server { + listen 80; + server_name www.tianyuancha.cn; + charset utf-8; + + + # 日志配置 + access_log /var/log/nginx/www.tianyuancha.cn-access.log; + error_log /var/log/nginx/www.tianyuancha.cn-error.log; + + # 爬虫检测 + set $is_bot 0; + + # Google + if ($http_user_agent ~* (googlebot|googlebot-image|googlebot-news|mediapartners-google|adsbot-google)) { + set $is_bot 1; + } + + # 百度 + if ($http_user_agent ~* (baiduspider|baiduspider-mobile)) { + set $is_bot 1; + } + + # 必应 + if ($http_user_agent ~* (bingbot|msnbot)) { + set $is_bot 1; + } + + # 360 + if ($http_user_agent ~* "360spider") { + set $is_bot 1; + } + + # 搜狗 + if ($http_user_agent ~* "(sogou spider|sogou-orion)") { + set $is_bot 1; + } + + # 其他爬虫 + if ($http_user_agent ~* "(spider|crawl|bot|slurp|yandex|duckduckbot|bytespider|yisouspider)") { + set $is_bot 1; + } + + # 根路径处理 + location = / { + if ($is_bot = 1) { + root /var/www/tyc-webview-v2/static-pages; + try_files /index.html /index.html; + break; + } + root /var/www/tyc-webview-v2/dist; + try_files $uri $uri/ /index.html; + } + + # 静态页面处理 + location ~ ^/([^/]+)(/.*)?$ { + # 将路径转换为文件名 + set $static_filename $1; + set $rest_path $2; + + if ($is_bot = 1) { + root /var/www/tyc-webview-v2/static-pages; + try_files /$static_filename.html /index.html; + break; + } + root /var/www/tyc-webview-v2/dist; + try_files $uri $uri/ /index.html; + } + + # SPA 路由回退 + location / { + root /var/www/tyc-webview-v2/dist; + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + root /var/www/tyc-webview-v2/dist; + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # API 代理 + location /api/ { + proxy_pass http://localhost:8080; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_cache_bypass $http_upgrade; + } + + # Gzip 压缩 + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json; + + # 安全头 + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; + add_header X-XSS-Protection "1; mode=block"; +} diff --git a/scripts/seo-static-generator/package.json b/scripts/seo-static-generator/package.json new file mode 100644 index 0000000..5563a07 --- /dev/null +++ b/scripts/seo-static-generator/package.json @@ -0,0 +1,20 @@ +{ + "name": "seo-static-generator", + "version": "1.0.0", + "description": "天远查静态页面生成器 - 为SPA应用生成SEO友好的静态页面", + "type": "module", + "scripts": { + "generate": "node generateStaticPages.js", + "nginx": "node generateNginxConfig.js", + "htaccess": "node generateHtaccessConfig.js" + }, + "keywords": [ + "seo", + "static-site-generator", + "spa", + "crawler", + "vue" + ], + "author": "天远查", + "license": "MIT" +} diff --git a/scripts/seo-static-generator/pageTemplates.js b/scripts/seo-static-generator/pageTemplates.js new file mode 100644 index 0000000..c910088 --- /dev/null +++ b/scripts/seo-static-generator/pageTemplates.js @@ -0,0 +1,577 @@ +/** + * 静态页面模板 + * 基于SEO配置生成优化的静态HTML页面 + */ + +/** + * 生成静态页面的HTML内容 + * @param {Object} seoConfig - SEO配置对象 + * @param {Object} options - 额外配置 + * @returns {string} - 完整的HTML字符串 + */ +export function generateStaticHTML(seoConfig, options = {}) { + const { + path = '/', + content = '', + customCSS = '', + canonical = 'https://www.tianyuancha.cn', + ogImage = 'https://www.tianyuancha.cn/logo.png' + } = options; + + const fullCanonical = `${canonical}${path}`; + + return ` + + + + + + + + ${seoConfig.title || '天远查'} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

${seoConfig.title || '天远查'}

+

${seoConfig.description || '天远查 - 专业大数据风险报告查询与代理平台'}

+
+ +
+ ${content || generateDefaultContent(seoConfig)} + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ +`; +} + +/** + * 生成默认页面内容 + * @param {Object} seoConfig - SEO配置 + * @returns {string} - HTML内容字符串 + */ +function generateDefaultContent(seoConfig) { + const title = seoConfig.title || '天远查'; + const description = seoConfig.description || '天远查 - 专业大数据风险报告查询与代理平台'; + const keywords = seoConfig.keywords || '天远查'; + + return ` +

关于${title}

+

${description}

+ +

核心功能

+ + +

为什么选择天远查?

+ + +

应用场景

+ + +

数据来源

+

天远查的数据来源于以下官方渠道:

+ + +

联系我们

+

如果您有任何问题或需要帮助,请通过以下方式联系我们:

+ + `; +} + +/** + * 针对不同路由生成定制内容 + * @param {string} path - 路由路径 + * @param {Object} seoConfig - SEO配置 + * @returns {string} - HTML内容字符串 + */ +export function generateContentByRoute(path, seoConfig) { + const routeContentMap = { + '/': generateHomeContent(seoConfig), + '/inquire/category/lawsuit': generateLawsuitContent(seoConfig), + '/inquire/marriage': generateMarriageContent(seoConfig), + '/inquire/category/vehicle': generateVehicleContent(seoConfig), + '/inquire/category/marriageStatus': generateMarriageStatusContent(seoConfig), + '/agent': generateAgentContent(seoConfig), + '/help': generateHelpContent(seoConfig), + '/example': generateExampleContent(seoConfig), + '/service': generateServiceContent(seoConfig), + '/inquire': generateInquireContent(seoConfig), + }; + + return routeContentMap[path] || generateDefaultContent(seoConfig); +} + +// 各个页面的定制内容生成函数 +function generateHomeContent(seoConfig) { + return ` +

欢迎使用天远查

+

天远查(TianYuanCha)是专业的大数据风险报告查询与代理平台,聚合官方公示数据,为个人和企业提供全方位的风险管控服务。

+ +

我们的服务

+ + +

立即开始

+

访问天远查官网,开始您的风险查询之旅:https://www.tianyuancha.cn

+ `; +} + +function generateLawsuitContent(seoConfig) { + return ` +

司法涉诉核验服务

+

天远查司法风险检测中心,聚合全国法院公开公示数据,为您提供全面的司法涉诉筛查服务。

+ +

服务内容

+ + +

应用场景

+ + +

数据来源

+

数据来源于全国各级法院公开公示信息,确保权威准确。

+ `; +} + +function generateMarriageContent(seoConfig) { + return ` +

婚前背景核验服务

+

天远查婚恋风险报告为您提供深度的背景核实服务,帮助您在婚恋前全面了解对方的真实情况。

+ +

服务内容

+ + +

为什么需要婚前背景核验?

+ + +

服务特点

+ + `; +} + +function generateVehicleContent(seoConfig) { + return ` +

车辆档案报告服务

+

天远查车辆数据中心,让车辆交易更透明。通过车牌号或VIN码,全面了解车辆的真实状况。

+ +

服务内容

+ + +

应用场景

+ + +

数据来源

+

数据同步权威行业系统,包括车管所、保险公司等,信息准确可靠。

+ `; +} + +function generateMarriageStatusContent(seoConfig) { + return ` +

个人婚姻关联风险核验

+

天远查提供基于大数据的婚姻关联风险评估,通过分析司法文书及公开社会关系,辅助判断目标的真实家庭状况。

+ +

服务内容

+ + +

服务优势

+ + `; +} + +function generateAgentContent(seoConfig) { + return ` +

天远查代理 - 免费开通代理权限

+

天远查代理平台,免费开通代理权限,享受大数据风险报告查询服务代理收益。

+ +

代理权益

+ + +

代理产品

+ + +

申请流程

+ + +

立即加入

+

访问天远查代理页面,免费开通代理权限:https://www.tianyuancha.cn/agent

+ `; +} + +function generateHelpContent(seoConfig) { + return ` +

帮助中心

+

天远查帮助中心,提供详细的使用指南、常见问题解答、操作教程等,帮助用户更好地使用大数据风险报告查询服务。

+ +

热门问题

+ + +

使用指南

+ + +

联系我们

+

如果您有其他问题,可以通过以下方式联系我们:

+ + `; +} + +function generateExampleContent(seoConfig) { + return ` +

示例报告展示

+

天远查示例报告展示,包含大数据风险报告、婚姻状况查询、个人信用评估等服务的报告样例。

+ +

报告类型

+ + +

报告内容

+ + +

查看示例

+

访问天远查示例页面,查看详细的报告样例:https://www.tianyuancha.cn/example

+ `; +} + +function generateServiceContent(seoConfig) { + return ` +

客服中心

+

天远查客服中心,提供在线客服支持、技术咨询、问题反馈等服务,确保用户获得及时有效的帮助。

+ +

服务内容

+ + +

服务时间

+ + +

联系我们

+

通过以下方式联系我们的客服团队:

+ + `; +} + +function generateInquireContent(seoConfig) { + return ` +

核验工具多场景数据核验服务

+

天远查提供车辆、企业、个人等多场景核验服务,包括状态、信用、身份等查询,权威高效,保护隐私。

+ +

核验服务

+ + +

服务特点

+ + +

立即查询

+

访问天远查核验页面,开始您的查询:https://www.tianyuancha.cn/inquire

+ `; +} diff --git a/scripts/seo-static-generator/run.js b/scripts/seo-static-generator/run.js new file mode 100644 index 0000000..aa3ce20 --- /dev/null +++ b/scripts/seo-static-generator/run.js @@ -0,0 +1,194 @@ +/** + * 简化的静态页面生成器 - Windows兼容版本 + */ + +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { generateStaticHTML } from './pageTemplates.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// 简化的SEO配置 +const seoConfigs = { + '/': { + title: '天远查官网_企业与婚姻关联风险核验_综合履约背景核验', + description: '天远查官网(TianYuanCha)聚合官方公示数据,专注于商业安全与资产背调。提供企业工商画像、婚姻状态关联风险、司法涉诉筛查及配偶债务核验。数据实时同步,助您精准规避投资、交易及家庭结合中的经济与法律风险。', + keywords: '天远查,婚姻状态风险, 配偶背景核验,企业信用查询,司法诉讼记录,资产风险评估' + }, + '/inquire/category/lawsuit': { + title: '司法涉诉核验_个人及企业法律诉讼记录_履约风险评估_天远查', + description: '天远查司法风险检测中心,聚合全国法院公开公示数据。一键筛查开庭公告、裁判文书、立案信息及执行记录。帮助用户快速识别法律纠纷隐患,全方位扫除合作盲区。', + keywords: '司法案件核验,法律诉讼记录,个人涉诉详情,法院公告查询,案件执行状态' + }, + '/inquire/marriage': { + title: '婚前背景核验_婚姻关联司法风险筛查_情感综合保障_天远查', + description: '天远查婚恋风险报告为您提供深度的背景核实服务。基于合法公开数据,排查对象的重婚司法记录、家庭暴力涉诉历史、潜在债务风险及不良嗜好风险。拒绝盲目信任,用数据守护您的情感与财产安全。', + keywords: '婚前背景核实,婚恋对象评估,婚姻司法风险,个人情感风险,婚前背调工具' + }, + '/inquire/category/vehicle': { + title: '车辆档案报告_二手车车况与产权风险检测_机动车报告_天远查', + description: '天远查车辆数据中心,让车辆交易更透明。支持通过车牌号或VIN码,核验车辆的初次登记信息、抵押查封状态、事故维修记录及产权属性。数据同步权威行业系统,精准识别问题车。', + keywords: '车辆维修记录,二手车出险报告,车辆抵押报告,车况报告,机动车档案' + }, + '/inquire/category/marriageStatus': { + title: '个人婚姻关联风险核验_家庭背景合规报告_天远查', + description: '天远查提供基于大数据的婚姻关联风险评估。通过分析司法文书及公开社会关系,辅助判断目标的真实家庭状况与情感履历。合法合规,保障知情权。', + keywords: '婚史风险排查,家庭背景核实,婚姻诚信评估,情感状态评估,涉婚法律记录' + }, + '/agent': { + title: '天远查代理 - 免费开通代理权限 | 大数据风险报告代理', + description: '天远查代理平台,免费开通代理权限,享受大数据风险报告查询服务代理收益。专业的大数据风险报告、婚姻查询、个人信用评估等服务的代理合作。', + keywords: '天远查代理, 免费代理, 大数据风险报告代理, 代理权限, 代理收益' + }, + '/help': { + title: '帮助中心 - 天远查使用指南 | 常见问题解答', + description: '天远查帮助中心,提供详细的使用指南、常见问题解答、操作教程等,帮助用户更好地使用大数据风险报告查询服务。', + keywords: '天远查帮助, 使用指南, 常见问题, 操作教程, 客服支持' + }, + '/example': { + title: '示例报告 - 天远查报告展示 | 大数据风险报告样例', + description: '天远查示例报告展示,包含大数据风险报告、婚姻状况查询、个人信用评估等服务的报告样例,让用户了解报告内容和格式。', + keywords: '示例报告, 报告展示, 报告样例, 大数据风险报告, 婚姻查询报告' + }, + '/service': { + title: '客服中心 - 天远查在线客服 | 技术支持', + description: '天远查客服中心,提供在线客服支持、技术咨询、问题反馈等服务,确保用户获得及时有效的帮助。', + keywords: '客服中心, 在线客服, 技术支持, 问题反馈, 天远查客服' + }, + '/inquire': { + title: '核验工具多场景数据核验服务天远查', + description: '提供车辆、企业、个人等多场景核验,包括状态、信用、身份等查询,权威高效,保护隐私。', + keywords: '核验工具,数据核验服务,车辆核验,企业核验,天远查' + }, +}; + +const OUTPUT_DIR = path.resolve(__dirname, 'static-pages'); + +// 确保目录存在 +if (!fs.existsSync(OUTPUT_DIR)) { + fs.mkdirSync(OUTPUT_DIR, { recursive: true }); +} + +// 转换路径为文件名 +function pathToFilename(routePath) { + let filename = routePath + .replace(/^\//, '') + .replace(/\/+/g, '-') + .replace(/:/g, '-'); + + if (!filename) { + filename = 'index'; + } + + return `${filename}.html`; +} + +// 生成单个页面 +function generatePage(routePath, seoConfig) { + const filename = pathToFilename(routePath); + const filepath = path.join(OUTPUT_DIR, filename); + + // 动态导入generateContentByRoute + const content = generateContentByRoute(routePath, seoConfig); + + const html = generateStaticHTML(seoConfig, { + path: routePath, + content: content, + canonical: 'https://www.tianyuancha.cn' + }); + + fs.writeFileSync(filepath, html, 'utf-8'); + console.log(`✅ ${filename}`); + return filepath; +} + +// 动态导入内容生成函数 +async function generateContentByRoute(routePath, seoConfig) { + const { generateContentByRoute: generateContent } = await import('./pageTemplates.js'); + return generateContent(routePath, seoConfig); +} + +// 生成sitemap +function generateSitemap() { + const sitemapPath = path.join(OUTPUT_DIR, 'sitemap.xml'); + const baseUrl = 'https://www.tianyuancha.cn'; + const currentDate = new Date().toISOString().split('T')[0]; + + let sitemap = ` + +`; + + for (const [routePath] of Object.entries(seoConfigs)) { + const priority = routePath === '/' ? '1.0' : '0.8'; + sitemap += ` + ${baseUrl}${routePath} + ${currentDate} + weekly + ${priority} + +`; + } + + sitemap += ``; + + fs.writeFileSync(sitemapPath, sitemap, 'utf-8'); + console.log(`✅ sitemap.xml`); +} + +// 生成robots.txt +function generateRobots() { + const robotsPath = path.join(OUTPUT_DIR, 'robots.txt'); + const robotsContent = `User-agent: * +Allow: / +Disallow: /admin +Disallow: /api +Sitemap: https://www.tianyuancha.cn/sitemap.xml +`; + + fs.writeFileSync(robotsPath, robotsContent, 'utf-8'); + console.log(`✅ robots.txt`); +} + +// 主函数 +async function main() { + console.log('========================================'); + console.log(' 天远查 - 静态页面生成器'); + console.log('========================================'); + console.log(''); + console.log('📂 输出目录:', OUTPUT_DIR); + console.log(''); + console.log('📝 生成静态页面:'); + console.log(''); + + let count = 0; + for (const [routePath, seoConfig] of Object.entries(seoConfigs)) { + try { + await generatePage(routePath, seoConfig); + count++; + } catch (error) { + console.error(`❌ ${routePath}: ${error.message}`); + } + } + + console.log(''); + console.log('📝 生成SEO文件:'); + console.log(''); + try { + generateSitemap(); + generateRobots(); + } catch (error) { + console.error(`❌ 生成SEO文件失败: ${error.message}`); + } + + console.log(''); + console.log('========================================'); + console.log(`✨ 完成! 共生成 ${count} 个静态页面`); + console.log('========================================'); +} + +main().catch(error => { + console.error('❌ 生成失败:', error); + process.exit(1); +}); diff --git a/scripts/seo-static-generator/static-pages/agent.html b/scripts/seo-static-generator/static-pages/agent.html new file mode 100644 index 0000000..3dc5f0e --- /dev/null +++ b/scripts/seo-static-generator/static-pages/agent.html @@ -0,0 +1,193 @@ + + + + + + + + + 天远查代理 - 免费开通代理权限 | 大数据风险报告代理 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

天远查代理 - 免费开通代理权限 | 大数据风险报告代理

+

天远查代理平台,免费开通代理权限,享受大数据风险报告查询服务代理收益。专业的大数据风险报告、婚姻查询、个人信用评估等服务的代理合作。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/example.html b/scripts/seo-static-generator/static-pages/example.html new file mode 100644 index 0000000..9e14ee5 --- /dev/null +++ b/scripts/seo-static-generator/static-pages/example.html @@ -0,0 +1,193 @@ + + + + + + + + + 示例报告 - 天远查报告展示 | 大数据风险报告样例 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

示例报告 - 天远查报告展示 | 大数据风险报告样例

+

天远查示例报告展示,包含大数据风险报告、婚姻状况查询、个人信用评估等服务的报告样例,让用户了解报告内容和格式。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/help.html b/scripts/seo-static-generator/static-pages/help.html new file mode 100644 index 0000000..b3ff03d --- /dev/null +++ b/scripts/seo-static-generator/static-pages/help.html @@ -0,0 +1,193 @@ + + + + + + + + + 帮助中心 - 天远查使用指南 | 常见问题解答 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

帮助中心 - 天远查使用指南 | 常见问题解答

+

天远查帮助中心,提供详细的使用指南、常见问题解答、操作教程等,帮助用户更好地使用大数据风险报告查询服务。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/index.html b/scripts/seo-static-generator/static-pages/index.html new file mode 100644 index 0000000..f313f2a --- /dev/null +++ b/scripts/seo-static-generator/static-pages/index.html @@ -0,0 +1,193 @@ + + + + + + + + + 天远查官网_企业与婚姻关联风险核验_综合履约背景核验 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

天远查官网_企业与婚姻关联风险核验_综合履约背景核验

+

天远查官网(TianYuanCha)聚合官方公示数据,专注于商业安全与资产背调。提供企业工商画像、婚姻状态关联风险、司法涉诉筛查及配偶债务核验。数据实时同步,助您精准规避投资、交易及家庭结合中的经济与法律风险。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/inquire-category-lawsuit.html b/scripts/seo-static-generator/static-pages/inquire-category-lawsuit.html new file mode 100644 index 0000000..c123e37 --- /dev/null +++ b/scripts/seo-static-generator/static-pages/inquire-category-lawsuit.html @@ -0,0 +1,193 @@ + + + + + + + + + 司法涉诉核验_个人及企业法律诉讼记录_履约风险评估_天远查 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

司法涉诉核验_个人及企业法律诉讼记录_履约风险评估_天远查

+

天远查司法风险检测中心,聚合全国法院公开公示数据。一键筛查开庭公告、裁判文书、立案信息及执行记录。帮助用户快速识别法律纠纷隐患,全方位扫除合作盲区。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/inquire-category-marriageStatus.html b/scripts/seo-static-generator/static-pages/inquire-category-marriageStatus.html new file mode 100644 index 0000000..5f6615a --- /dev/null +++ b/scripts/seo-static-generator/static-pages/inquire-category-marriageStatus.html @@ -0,0 +1,193 @@ + + + + + + + + + 个人婚姻关联风险核验_家庭背景合规报告_天远查 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

个人婚姻关联风险核验_家庭背景合规报告_天远查

+

天远查提供基于大数据的婚姻关联风险评估。通过分析司法文书及公开社会关系,辅助判断目标的真实家庭状况与情感履历。合法合规,保障知情权。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/inquire-category-vehicle.html b/scripts/seo-static-generator/static-pages/inquire-category-vehicle.html new file mode 100644 index 0000000..2084c44 --- /dev/null +++ b/scripts/seo-static-generator/static-pages/inquire-category-vehicle.html @@ -0,0 +1,193 @@ + + + + + + + + + 车辆档案报告_二手车车况与产权风险检测_机动车报告_天远查 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

车辆档案报告_二手车车况与产权风险检测_机动车报告_天远查

+

天远查车辆数据中心,让车辆交易更透明。支持通过车牌号或VIN码,核验车辆的初次登记信息、抵押查封状态、事故维修记录及产权属性。数据同步权威行业系统,精准识别问题车。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/inquire-marriage.html b/scripts/seo-static-generator/static-pages/inquire-marriage.html new file mode 100644 index 0000000..94df3ba --- /dev/null +++ b/scripts/seo-static-generator/static-pages/inquire-marriage.html @@ -0,0 +1,193 @@ + + + + + + + + + 婚前背景核验_婚姻关联司法风险筛查_情感综合保障_天远查 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

婚前背景核验_婚姻关联司法风险筛查_情感综合保障_天远查

+

天远查婚恋风险报告为您提供深度的背景核实服务。基于合法公开数据,排查对象的重婚司法记录、家庭暴力涉诉历史、潜在债务风险及不良嗜好风险。拒绝盲目信任,用数据守护您的情感与财产安全。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/inquire.html b/scripts/seo-static-generator/static-pages/inquire.html new file mode 100644 index 0000000..23a2b0d --- /dev/null +++ b/scripts/seo-static-generator/static-pages/inquire.html @@ -0,0 +1,193 @@ + + + + + + + + + 核验工具多场景数据核验服务天远查 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

核验工具多场景数据核验服务天远查

+

提供车辆、企业、个人等多场景核验,包括状态、信用、身份等查询,权威高效,保护隐私。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/robots.txt b/scripts/seo-static-generator/static-pages/robots.txt new file mode 100644 index 0000000..60d25e0 --- /dev/null +++ b/scripts/seo-static-generator/static-pages/robots.txt @@ -0,0 +1,5 @@ +User-agent: * +Allow: / +Disallow: /admin +Disallow: /api +Sitemap: https://www.tianyuancha.cn/sitemap.xml diff --git a/scripts/seo-static-generator/static-pages/service.html b/scripts/seo-static-generator/static-pages/service.html new file mode 100644 index 0000000..cc9f222 --- /dev/null +++ b/scripts/seo-static-generator/static-pages/service.html @@ -0,0 +1,193 @@ + + + + + + + + + 客服中心 - 天远查在线客服 | 技术支持 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

客服中心 - 天远查在线客服 | 技术支持

+

天远查客服中心,提供在线客服支持、技术咨询、问题反馈等服务,确保用户获得及时有效的帮助。

+
+ +
+ [object Promise] + +
+

💡 访问完整功能请使用现代浏览器访问主站

+
+
+ + +
+ + \ No newline at end of file diff --git a/scripts/seo-static-generator/static-pages/sitemap.xml b/scripts/seo-static-generator/static-pages/sitemap.xml new file mode 100644 index 0000000..c46bf8c --- /dev/null +++ b/scripts/seo-static-generator/static-pages/sitemap.xml @@ -0,0 +1,63 @@ + + + + https://www.tianyuancha.cn/ + 2026-02-25 + weekly + 1.0 + + + https://www.tianyuancha.cn/inquire/category/lawsuit + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/inquire/marriage + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/inquire/category/vehicle + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/inquire/category/marriageStatus + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/agent + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/help + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/example + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/service + 2026-02-25 + weekly + 0.8 + + + https://www.tianyuancha.cn/inquire + 2026-02-25 + weekly + 0.8 + + \ No newline at end of file diff --git a/scripts/seo-static-generator/testGenerator.js b/scripts/seo-static-generator/testGenerator.js new file mode 100644 index 0000000..3312c05 --- /dev/null +++ b/scripts/seo-static-generator/testGenerator.js @@ -0,0 +1,280 @@ +/** + * 静态页面生成器测试脚本 + */ + +import { generateAllPages, generatePage } from './generateStaticPages.js'; +import { generateStaticHTML } from './pageTemplates.js'; +import fs from 'fs'; +import path from 'path'; + +console.log('='.repeat(60)); +console.log(' 天远查 - 静态页面生成器测试'); +console.log('='.repeat(60)); +console.log(); + +// 测试结果统计 +let passedTests = 0; +let failedTests = 0; + +// 测试函数 +function test(name, fn) { + try { + fn(); + console.log(`✅ ${name}`); + passedTests++; + } catch (error) { + console.log(`❌ ${name}`); + console.log(` 错误: ${error.message}`); + failedTests++; + } +} + +// 断言函数 +function assert(condition, message) { + if (!condition) { + throw new Error(message || '断言失败'); + } +} + +console.log('🧪 开始测试...\n'); + +// 测试 1: 测试基本的 HTML 生成 +test('测试基本的 HTML 生成', () => { + const seoConfig = { + title: '测试标题', + description: '测试描述', + keywords: '测试关键词' + }; + + const html = generateStaticHTML(seoConfig, { path: '/test' }); + + assert(html.includes(''), '应该包含 DOCTYPE 声明'); + assert(html.includes('测试标题'), '应该包含标题'); + assert(html.includes('测试描述'), '应该包含描述'); + assert(html.includes('测试关键词'), '应该包含关键词'); + assert(html.includes('og:title'), '应该包含 Open Graph 标签'); + assert(html.includes('twitter:card'), '应该包含 Twitter Cards 标签'); + assert(html.includes('application/ld+json'), '应该包含结构化数据'); +}); + +// 测试 2: 测试默认内容生成 +test('测试默认内容生成', () => { + const seoConfig = { + title: '测试页面', + description: '这是一个测试页面', + keywords: '测试' + }; + + const html = generateStaticHTML(seoConfig, { path: '/test' }); + + assert(html.includes('关于测试页面'), '应该包含关于标题'); + assert(html.includes('核心功能'), '应该包含核心功能'); + assert(html.includes('为什么选择天远查?'), '应该包含选择理由'); + assert(html.includes('应用场景'), '应该包含应用场景'); +}); + +// 测试 3: 测试路由内容生成 +test('测试路由内容生成', () => { + const seoConfig = { + title: '司法涉诉核验', + description: '司法风险检测中心', + keywords: '司法,诉讼' + }; + + const html = generateStaticHTML(seoConfig, { + path: '/inquire/category/lawsuit', + content: generateContentByRoute('/inquire/category/lawsuit', seoConfig) + }); + + assert(html.includes('司法涉诉核验服务'), '应该包含司法涉诉标题'); + assert(html.includes('开庭公告查询'), '应该包含开庭公告'); + assert(html.includes('裁判文书查询'), '应该包含裁判文书'); +}); + +// 测试 4: 测试文件名生成 +test('测试文件名生成', () => { + const paths = [ + { input: '/', expected: 'index.html' }, + { input: '/help', expected: 'help.html' }, + { input: '/inquire/category/lawsuit', expected: 'inquire-category-lawsuit.html' }, + { input: '/agent/promote', expected: 'agent-promote.html' } + ]; + + paths.forEach(({ input, expected }) => { + const filename = input + .replace(/^\//, '') + .replace(/\/+/g, '-') + .replace(/:/g, '-'); + const result = filename ? `${filename}.html` : 'index.html'; + + assert(result === expected, `路径 ${input} 应该生成文件名 ${expected}`); + }); +}); + +// 测试 5: 测试静态页面目录创建 +test('测试静态页面目录创建', () => { + const outputDir = path.join(__dirname, '../static-pages-test'); + + // 清理测试目录(如果存在) + if (fs.existsSync(outputDir)) { + fs.rmSync(outputDir, { recursive: true, force: true }); + } + + // 创建目录 + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir, { recursive: true }); + } + + assert(fs.existsSync(outputDir), '应该创建输出目录'); + + // 清理测试目录 + fs.rmSync(outputDir, { recursive: true, force: true }); +}); + +// 测试 6: 测试单个页面生成 +test('测试单个页面生成', () => { + const testDir = path.join(__dirname, '../static-pages-test'); + + // 清理测试目录(如果存在) + if (fs.existsSync(testDir)) { + fs.rmSync(testDir, { recursive: true, force: true }); + } + + fs.mkdirSync(testDir, { recursive: true }); + + const seoConfig = { + title: '测试页面', + description: '测试描述', + keywords: '测试' + }; + + const filepath = path.join(testDir, 'test.html'); + + // 临时修改 generatePage 的输出目录 + const originalDir = path.join(__dirname, '../static-pages'); + + // 生成测试文件 + const content = generateStaticHTML(seoConfig, { path: '/test' }); + fs.writeFileSync(filepath, content, 'utf-8'); + + assert(fs.existsSync(filepath), '应该生成测试文件'); + + // 验证文件内容 + const fileContent = fs.readFileSync(filepath, 'utf-8'); + assert(fileContent.includes('测试页面'), '文件应该包含标题'); + + // 清理测试目录 + fs.rmSync(testDir, { recursive: true, force: true }); +}); + +// 测试 7: 测试 SEO 配置完整性 +test('测试 SEO 配置完整性', () => { + const seoConfigs = { + '/': { + title: '天远查官网_企业与婚姻关联风险核验_综合履约背景核验', + description: '天远查官网(TianYuanCha)聚合官方公示数据...', + keywords: '天远查,婚姻状态风险, 配偶背景核验' + }, + '/inquire/category/lawsuit': { + title: '司法涉诉核验_个人及企业法律诉讼记录_履约风险评估_天远查', + description: '天远查司法风险检测中心...', + keywords: '司法案件核验,法律诉讼记录' + } + }; + + for (const [path, config] of Object.entries(seoConfigs)) { + assert(config.title, `路由 ${path} 应该有 title`); + assert(config.description, `路由 ${path} 应该有 description`); + assert(config.keywords, `路由 ${path} 应该有 keywords`); + } +}); + +// 测试 8: 测试 Open Graph 标签 +test('测试 Open Graph 标签', () => { + const seoConfig = { + title: '测试标题', + description: '测试描述', + keywords: '测试' + }; + + const html = generateStaticHTML(seoConfig, { path: '/test' }); + + assert(html.includes('og:type'), '应该包含 og:type'); + assert(html.includes('og:url'), '应该包含 og:url'); + assert(html.includes('og:title'), '应该包含 og:title'); + assert(html.includes('og:description'), '应该包含 og:description'); + assert(html.includes('og:site_name'), '应该包含 og:site_name'); + assert(html.includes('og:locale'), '应该包含 og:locale'); +}); + +// 测试 9: 测试结构化数据 +test('测试结构化数据', () => { + const seoConfig = { + title: '测试标题', + description: '测试描述', + keywords: '测试' + }; + + const html = generateStaticHTML(seoConfig, { path: '/test' }); + + assert(html.includes('@context'), '应该包含 @context'); + assert(html.includes('@type'), '应该包含 @type'); + assert(html.includes('WebPage'), '应该包含 WebPage 类型'); + assert(html.includes('Organization'), '应该包含 Organization 类型'); +}); + +// 测试 10: 测试 canonical URL +test('测试 canonical URL', () => { + const seoConfig = { + title: '测试标题', + description: '测试描述', + keywords: '测试' + }; + + const html = generateStaticHTML(seoConfig, { + path: '/test/page', + canonical: 'https://www.tianyuancha.cn' + }); + + assert(html.includes('https://www.tianyuancha.cn/test/page'), '应该包含完整的 canonical URL'); +}); + +// 运行实际生成测试 +console.log('\n🚀 运行实际生成测试...\n'); + +test('生成所有静态页面', () => { + try { + generateAllPages(); + + const staticDir = path.join(__dirname, '../static-pages'); + assert(fs.existsSync(staticDir), '应该生成 static-pages 目录'); + + const files = fs.readdirSync(staticDir); + assert(files.length > 0, '应该生成至少一个文件'); + assert(files.includes('index.html'), '应该生成 index.html'); + assert(files.includes('sitemap.xml'), '应该生成 sitemap.xml'); + assert(files.includes('robots.txt'), '应该生成 robots.txt'); + + console.log(` 生成了 ${files.length} 个文件`); + } catch (error) { + console.log(` 错误: ${error.message}`); + throw error; + } +}); + +// 输出测试结果 +console.log('\n' + '='.repeat(60)); +console.log(' 测试结果'); +console.log('='.repeat(60)); +console.log(`✅ 通过: ${passedTests}`); +console.log(`❌ 失败: ${failedTests}`); +console.log(`📊 总计: ${passedTests + failedTests}`); +console.log(); + +if (failedTests === 0) { + console.log('🎉 所有测试通过!'); + process.exit(0); +} else { + console.log('⚠️ 部分测试失败,请检查错误信息'); + process.exit(1); +} diff --git a/src/composables/useSEO.js b/src/composables/useSEO.js index 8667b4d..8815223 100644 --- a/src/composables/useSEO.js +++ b/src/composables/useSEO.js @@ -9,7 +9,7 @@ export function useSEO() { title: '天远查官网_企业与婚姻关联风险核验_综合履约背景核验', description: '天远查官网(TianYuanCha)聚合官方公示数据,专注于商业安全与资产背调。提供企业工商画像、婚姻状态关联风险、司法涉诉筛查及配偶债务核验。数据实时同步,助您精准规避投资、交易及家庭结合中的经济与法律风险。', keywords: '天远查,婚姻状态风险, 配偶背景核验,企业信用查询,司法诉讼记录,资产风险评估', - url: 'https://www.zhinengcha.cn' + url: 'https://www.tianyuancha.cn' } // 页面SEO配置 @@ -111,6 +111,7 @@ export function useSEO() { canonical.href = url } + // 更新结构化数据 const updateStructuredData = (config) => { // 移除现有的结构化数据 @@ -121,6 +122,7 @@ export function useSEO() { } }) + // 添加新的结构化数据 const structuredData = { "@context": "https://schema.org", @@ -131,7 +133,7 @@ export function useSEO() { "mainEntity": { "@type": "Organization", "name": "天远查", - "url": "https://www.zhinengcha.cn/", + "url": "https://www.tianyuancha.cn/", "description": "专业大数据风险报告查询与代理平台,支持个人和企业多场景风控应用" } } @@ -209,7 +211,7 @@ export function useSEO() { updateSEO({ ...config, - url: `https://www.zhinengcha.cn${currentPath}` + url: `https://www.tianyuancha.cn${currentPath}` }) } diff --git a/src/router/index.js b/src/router/index.js index 7591879..83c5626 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -460,7 +460,7 @@ router.afterEach((to) => { const seoConfig = { title: `${to.meta.title} - 天远查`, description: `天远查${to.meta.title}页面,提供专业的大数据风险管控服务。`, - url: `https://www.zhinengcha.cn${to.path}` + url: `https://www.tianyuancha.cn${to.path}` } updateSEO(seoConfig) } diff --git a/src/views/NotFound.vue b/src/views/NotFound.vue index 5a0b08e..83204d7 100644 --- a/src/views/NotFound.vue +++ b/src/views/NotFound.vue @@ -32,7 +32,7 @@ onMounted(() => { title: '404 - 页面未找到 | 天远查', description: '抱歉,您访问的页面不存在。天远查专业大数据风险管控平台,提供大数据风险报告查询、婚姻状况查询、个人信用评估等服务。', keywords: '404, 页面未找到, 天远查, 大数据风险管控', - url: 'https://www.zhinengcha.cn/404' + url: 'https://www.tianyuancha.cn/404' }) }) diff --git a/vite.config.js b/vite.config.js index 82fb402..077b78b 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,8 +15,8 @@ export default defineConfig({ strictPort: true, // 如果端口被占用则抛出错误而不是使用下一个可用端口 proxy: { "/api/v1": { - target: "http://127.0.0.1:8888", // 本地接口地址 - // target: "https://www.tianyuancha.cn", // 本地接口地址 + // target: "http://127.0.0.1:8888", // 本地接口地址 + target: "https://www.tianyuancha.cn", // 本地接口地址 changeOrigin: true, }, },