Commit da00dc22 authored by xuchentao's avatar xuchentao

feat: build Zhiyin Future corporate website

parents
# 复制为 .env 后使用。生产环境请生成独立密钥。
CMS_PORT=8792
# 后台主密码始终有效,用于登录和找回;在后台修改的用户密码会另存于 CMS_DATA_DIR。
CMS_PASSWORD=replace-with-a-strong-password
CMS_SECRET=replace-with-openssl-rand-hex-32
CMS_API_KEY=replace-with-openssl-rand-hex-32
# 本地默认放入已忽略的 .runtime;生产环境请改为 /root/zhiyinweilai/shared/ 下的绝对路径。
CMS_DATA_DIR=.runtime/cms-data
CMS_BUILD_LOCK=.runtime/site-build.lock
node_modules/
dist/
.astro/
.codex-tmp/
.runtime/
.env
!.env.example
public/uploads/
.DS_Store
# 智引未来官网 · GitLab CI/CD 单目录覆盖部署
# 流程:停止应用 → 覆盖 current → 安装与构建 → 启动并检查 → 更新 Nginx
# 触发:push 到 main 分支
#
# GitLab 版本:11.7
# 仅使用 stages、only、script 等基础语法;服务器部署锁用于拒绝并发部署。
variables:
DEPLOY_ROOT: "/root/zhiyinweilai"
CURRENT_DIR: "/root/zhiyinweilai/current"
SHARED_DIR: "/root/zhiyinweilai/shared"
SHARED_ENV: "/root/zhiyinweilai/shared/.env"
DEPLOY_LOCK: "/root/zhiyinweilai/shared/deploy.lock"
APP_NAME: "zhiyinweilai"
SITE_URL: "http://127.0.0.1:8792/"
PM2_BIN: "/usr/bin/pm2"
PM2_HOME_DIR: "/root/.pm2"
PM2_USE_SUDO: "1"
PUBLIC_HOST: "www.zhiyintec.com"
stages:
- deploy
deploy:
stage: deploy
tags:
- zhiyinweilai-prod
only:
- main
script:
- |
set -Eeuo pipefail
echo "[deploy] 提交:$CI_COMMIT_SHA"
case "$DEPLOY_ROOT" in
/*) ;;
*) echo "DEPLOY_ROOT 必须是绝对路径" >&2; exit 2 ;;
esac
case "$PM2_BIN" in
/*) ;;
*) echo "PM2_BIN 必须是绝对路径" >&2; exit 2 ;;
esac
case "$PM2_HOME_DIR" in
/*) ;;
*) echo "PM2_HOME_DIR 必须是绝对路径" >&2; exit 2 ;;
esac
if [ "$CURRENT_DIR" != "$DEPLOY_ROOT/current" ] || [ "$SHARED_DIR" != "$DEPLOY_ROOT/shared" ]; then
echo "current 或 shared 目录不属于部署根目录" >&2
exit 2
fi
if [ "$SHARED_ENV" != "$SHARED_DIR/.env" ] || [ "$DEPLOY_LOCK" != "$SHARED_DIR/deploy.lock" ]; then
echo "生产配置或部署锁路径不属于 shared 目录" >&2
exit 2
fi
case "$APP_NAME" in
*[!A-Za-z0-9_.-]*|'') echo "PM2 应用名包含不安全字符" >&2; exit 2 ;;
esac
case "$PM2_USE_SUDO" in
0|1) ;;
*) echo "PM2_USE_SUDO 只能是 0 或 1" >&2; exit 2 ;;
esac
test -n "$CI_COMMIT_SHA" || (echo "CI_COMMIT_SHA 缺失" >&2 && exit 2)
test -x "$PM2_BIN" || (echo "PM2 不存在或不可执行:$PM2_BIN" >&2 && exit 2)
command -v flock >/dev/null || (echo "服务器缺少 flock" >&2 && exit 2)
command -v curl >/dev/null || (echo "服务器缺少 curl" >&2 && exit 2)
command -v node >/dev/null || (echo "服务器缺少 Node.js" >&2 && exit 2)
if [ -L "$DEPLOY_ROOT" ] || { [ -e "$DEPLOY_ROOT" ] && [ ! -d "$DEPLOY_ROOT" ]; }; then
echo "DEPLOY_ROOT 必须是非软链接实体目录:$DEPLOY_ROOT" >&2
exit 2
fi
mkdir -p "$DEPLOY_ROOT"
if [ "$(readlink -f "$DEPLOY_ROOT")" != "$DEPLOY_ROOT" ] || [ -L "$DEPLOY_ROOT" ]; then
echo "DEPLOY_ROOT 必须是非软链接实体目录:$DEPLOY_ROOT" >&2
exit 2
fi
if [ -L "$SHARED_DIR" ] || { [ -e "$SHARED_DIR" ] && [ ! -d "$SHARED_DIR" ]; }; then
echo "shared 必须是非软链接实体目录:$SHARED_DIR" >&2
exit 2
fi
mkdir -p "$SHARED_DIR"
if [ "$(readlink -f "$SHARED_DIR")" != "$SHARED_DIR" ]; then
echo "shared 必须位于指定部署目录:$SHARED_DIR" >&2
exit 2
fi
test -f "$SHARED_ENV" || (echo "缺少生产配置:$SHARED_ENV" >&2 && exit 2)
# GitLab 11.7 没有 resource_group。非阻塞锁让并发 pipeline 直接失败,
# 避免较早的 pipeline 排队后覆盖较新的提交。
exec 9>"$DEPLOY_LOCK"
if ! flock -n 9; then
echo "已有部署正在进行,本次 pipeline 不进入等待队列" >&2
exit 3
fi
pm2_command() {
if [ "$PM2_USE_SUDO" = "1" ]; then
sudo -n env PM2_HOME="$PM2_HOME_DIR" "$PM2_BIN" "$@"
else
env PM2_HOME="$PM2_HOME_DIR" "$PM2_BIN" "$@"
fi
}
# 先停止且只停止本项目进程。单目录部署失败时不会自动回滚。
if pm2_command describe "$APP_NAME" >/dev/null 2>&1; then
echo "[deploy] 停止本项目 PM2 进程:$APP_NAME"
pm2_command delete "$APP_NAME"
fi
# 首次迁移时只移除 current 软链接本身,不触碰它原来指向的 release。
if [ -L "$CURRENT_DIR" ]; then
old_current_target=$(readlink -f "$CURRENT_DIR" 2>/dev/null || true)
echo "[deploy] 移除旧 current 软链接(原目标保留):${old_current_target:-未知}"
unlink "$CURRENT_DIR"
elif [ -e "$CURRENT_DIR" ] && [ ! -d "$CURRENT_DIR" ]; then
echo "current 存在但不是目录,拒绝覆盖:$CURRENT_DIR" >&2
exit 2
fi
mkdir -p "$CURRENT_DIR"
if [ -L "$CURRENT_DIR" ] || [ "$(readlink -f "$CURRENT_DIR")" != "$CURRENT_DIR" ]; then
echo "current 必须是指定位置的实体目录:$CURRENT_DIR" >&2
exit 2
fi
echo "[deploy] 清空 current"
find "$CURRENT_DIR" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
echo "[deploy] 导出提交到 current"
git -c safe.directory="$CI_PROJECT_DIR" -C "$CI_PROJECT_DIR" cat-file -e "$CI_COMMIT_SHA^{commit}"
git -c safe.directory="$CI_PROJECT_DIR" -C "$CI_PROJECT_DIR" archive "$CI_COMMIT_SHA" | tar -x -C "$CURRENT_DIR"
ln -s "$SHARED_ENV" "$CURRENT_DIR/.env"
cd "$CURRENT_DIR"
echo "[deploy] 安装依赖"
npm ci
echo "[deploy] 使用 shared 中的 CMS 数据和构建锁进行构建"
node --env-file="$SHARED_ENV" -e '
const path = require("node:path");
const shared = path.resolve(process.argv[1]);
for (const name of ["CMS_DATA_DIR", "CMS_BUILD_LOCK"]) {
const value = process.env[name];
if (!value) throw new Error(`${name} 未配置`);
const resolved = path.resolve(value);
if (resolved === shared || !resolved.startsWith(`${shared}${path.sep}`)) {
throw new Error(`${name} 必须位于 ${shared}/ 下`);
}
}
' "$SHARED_DIR"
node --env-file="$SHARED_ENV" scripts/run-with-site-lock.mjs -- npm run build:inside-lock
echo "[deploy] 启动本项目 PM2 进程"
pm2_command start "$CURRENT_DIR/server.mjs" \
--name "$APP_NAME" \
--cwd "$CURRENT_DIR" \
--node-args="--env-file=$SHARED_ENV"
healthy=0
for attempt in $(seq 1 30); do
if curl --fail --silent --show-error --max-time 3 "$SITE_URL" >/dev/null; then
healthy=1
break
fi
echo "[deploy] 等待服务启动... ($attempt/30)"
sleep 1
done
if [ "$healthy" != "1" ]; then
echo "健康检查失败:$SITE_URL" >&2
pm2_command logs "$APP_NAME" --lines 30 --nostream || true
exit 1
fi
echo "[deploy] 更新并验证 Nginx"
test -f "$CURRENT_DIR/deploy/nginx/zhiyinweilai.conf" || (echo "缺少 Nginx 配置" >&2 && exit 2)
sudo -n /usr/bin/install -o root -g root -m 0644 "$CURRENT_DIR/deploy/nginx/zhiyinweilai.conf" /etc/nginx/conf.d/zhiyinweilai.conf
sudo -n /usr/sbin/nginx -t
sudo -n /usr/bin/systemctl reload nginx
curl --fail --silent --show-error --max-time 5 \
--noproxy "*" \
--resolve "$PUBLIC_HOST:443:127.0.0.1" \
"https://$PUBLIC_HOST/" >/dev/null
echo "[deploy] 部署完成:$CURRENT_DIR"
echo "[deploy] 旧 releases 目录未被读取或清理;确认无用后请人工删除"
# 智引未来洞察内容后台
项目采用与官网同端口的 Astro 内容后台:Markdown 文件负责内容存储,Astro 同时提供管理 API 和静态页面生成。文章列表、分类页和详情页均预渲染为 HTML,便于 SEO 与 GEO 发现。
## 启动
```bash
cp .env.example .env
npm install
npm run dev
```
- 开发官网:`http://localhost:4321/`
- 开发后台:`http://localhost:4321/admin/`
生产模式:
```bash
npm run build
npm start
```
- 官网:`http://localhost:8792/`
- 后台:`http://localhost:8792/admin/`
- 洞察中心:`http://localhost:8792/articles/`
## 环境变量
- `CMS_PORT`:官网与后台共用端口,默认 `8792`
- `CMS_PASSWORD`:后台主密码,也用于密码找回
- `CMS_SECRET`:会话签名密钥
- `CMS_API_KEY`:外部管理 API 的 Bearer Token
- `CMS_DATA_DIR`:仓库外持久化内容目录
- `CMS_BUILD_LOCK`:代码部署与内容发布共用的构建锁
生产建议:
```env
CMS_PORT=8792
CMS_DATA_DIR=/root/zhiyinweilai/shared/cms-data
CMS_BUILD_LOCK=/root/zhiyinweilai/shared/site-build.lock
```
## 内容目录与版本
- `src/content/articles/`:工作稿,包括新草稿和已发布文章的未发布修改
- `src/content/published/`:官网构建使用的线上稿
- `src/content/categories.json`:后台维护的分类
- `public/uploads/`:本地开发的上传图片
配置 `CMS_DATA_DIR` 后,上述用户数据改存到该持久化目录。保存草稿不会改动线上稿;点击发布后,编辑稿才覆盖线上稿并触发静态构建。下架会移除线上稿但保留编辑稿;删除同时移除两版,构建失败时自动恢复。
## 管理 API
所有接口使用 `/api/cms` 前缀:
| 分组 | 方法与地址 | 用途 |
| --- | --- | --- |
| 验证 | `GET /api/cms/captcha` | 获取验证码 |
| 会话 | `GET/POST/DELETE /api/cms/session` | 状态、登录、退出 |
| 账号 | `PUT /api/cms/account/password` | 修改密码并注销已有会话 |
| 分类 | `GET/POST/PATCH/DELETE /api/cms/categories` | 分类管理 |
| 文章 | `GET/POST /api/cms/articles` | 列表与新建草稿 |
| 文章 | `GET/PUT/DELETE /api/cms/articles/:slug` | 读取、保存、删除 |
| 草稿 | `DELETE /api/cms/articles/:slug/draft` | 放弃未发布修改 |
| 发布 | `POST /api/cms/articles/:slug/publish` | 发布并构建 |
| 下架 | `POST /api/cms/articles/:slug/unpublish` | 下架并构建 |
| 工具 | `POST /api/cms/preview` | Markdown 预览 |
| 上传 | `POST /api/cms/uploads` | 上传文章图片 |
| 导入 | `POST /api/cms/imports/word` | 导入 `.docx` 草稿与内嵌图片 |
| 构建 | `GET /api/cms/build` | 查询静态构建状态 |
浏览器后台通过会话 Cookie 鉴权;外部程序可使用 `Authorization: Bearer <CMS_API_KEY>`
## Word 与 Markdown 导入
后台支持 `.md` 和不超过 20MB 的 `.docx`,不支持旧版 `.doc`。第一个一级标题会作为文章标题并从正文移除;Word 内嵌 PNG、JPG、WEBP、GIF 会保存到上传目录并转成 Markdown 图片。导入只创建草稿,不会自动发布;失败时会清理本次已提取图片。
```http
POST /api/cms/imports/word
Authorization: Bearer <CMS_API_KEY>
Content-Type: application/json
```
```json
{
"fileName": "GEO洞察文章.docx",
"dataUrl": "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,...",
"category": "GEO洞察",
"title": "可选的自定义标题"
}
```
## 构建一致性
发布、下架、删除文章或修改已使用分类时,后台先获取共享构建锁。若代码部署或其他构建已持锁,本次操作返回冲突,不进入等待队列。后台在临时目录执行 Astro 构建,成功后原子替换 `dist/`;失败则恢复内容并保留旧站点。
生产数据必须位于:
```text
/root/zhiyinweilai/
├── current/ # 当前代码和构建产物,部署时覆盖
└── shared/ # .env、CMS 数据、上传文件和锁
```
## GitLab、PM2 与 Nginx
`.gitlab-ci.yml` 使用单目录覆盖部署:停止指定的 `zhiyinweilai` PM2 进程,清空 `current/`,导出当前提交,关联 `shared/.env`,安装依赖并构建,重新启动并进行本机健康检查,最后安装和验证 Nginx 配置。
默认参数:
- 部署根目录:`/root/zhiyinweilai`
- PM2 应用名:`zhiyinweilai`
- 服务端口:`8792`
- Nginx 配置:`/etc/nginx/conf.d/zhiyinweilai.conf`
- 公网域名:`www.zhiyintec.com`
Runner 需要被授权执行固定的配置安装、`nginx -t` 和 reload 命令。建议建立 `/etc/sudoers.d/zhiyinweilai-runner`
```sudoers
Cmnd_Alias ZHIYIN_NGINX = \
/usr/bin/install -o root -g root -m 0644 /root/zhiyinweilai/current/deploy/nginx/zhiyinweilai.conf /etc/nginx/conf.d/zhiyinweilai.conf, \
/usr/sbin/nginx -t, \
/usr/bin/systemctl reload nginx
gitlab-runner ALL=(root) NOPASSWD: ZHIYIN_NGINX
```
完成后使用 `sudo visudo -cf /etc/sudoers.d/zhiyinweilai-runner` 校验语法。
# 智引未来企业官网
西安智引未来人工智能科技有限公司官网。项目基于 Astro 5 + Node standalone adapter,包含品牌官网、GEO/SMO 服务页、响应式适配、搜索增长洞察 CMS、SEO/GEO 基础、原子构建与 GitLab/Nginx 部署配置。
## 本地运行
```bash
npm install
npm run dev
```
- 官网开发地址:`http://localhost:4321/`
- 内容后台:`http://localhost:4321/admin/`
生产构建与本地服务:
```bash
npm run build
npm start
```
生产模式默认监听 `http://127.0.0.1:8792/`
## 常用命令
```bash
npm run check # Astro / TypeScript 检查
npm test # CMS 认证与导入测试
npm run build # 带共享锁的原子生产构建
npm start # 启动 standalone 服务
```
## 内容管理
洞察文章使用 Markdown 存储,并由同端口 `/admin/` 后台管理。工作稿位于 `src/content/articles/`,线上稿位于 `src/content/published/`;生产环境通过 `CMS_DATA_DIR` 将内容持久化到仓库外。发布、下架、删除和分类修改会触发带共享锁的静态页面重建。
后台支持:
- 草稿、发布、下架、删除与未发布修改回退
- 分类新增、重命名、删除与文章迁移
- Markdown 和 Word `.docx` 导入
- 文章图片上传、Markdown 预览和修改密码
- Bearer API 调用与发布构建状态查询
完整说明见 [CMS_README.md](./CMS_README.md)
## SEO 与 AI 可发现性
- 页面级标题、描述、关键词、canonical、Open Graph 和 Twitter Card
- Organization、WebSite、WebPage、Service、FAQ、Article 和 Breadcrumb 结构化数据
- sitemap、robots.txt、语义化页面、静态文章与分类分页
- `/llms.txt``/llms-full.txt` 提供结构化站点摘要与完整内容入口
- Astro 图片优化、移动端适配、减少动态效果偏好与原生懒加载
## 部署
- Astro standalone 输出:`dist/server/``dist/client/`
- GitLab CI:`.gitlab-ci.yml`
- Nginx 配置:`deploy/nginx/zhiyinweilai.conf`
- 生产端口:`8792`
- 站点域名:`www.zhiyintec.com`
- 服务器目录:`/root/zhiyinweilai/current``/root/zhiyinweilai/shared`
生产部署前需在 `/root/zhiyinweilai/shared/.env` 配置独立的 `CMS_PASSWORD``CMS_SECRET``CMS_API_KEY``CMS_DATA_DIR``CMS_BUILD_LOCK`。上传文件、CMS 数据与构建锁必须位于 `shared/`,不能放入部署时会覆盖的 `current/`
import { defineConfig } from "astro/config";
import sitemap from "@astrojs/sitemap";
import node from "@astrojs/node";
import path from "node:path";
const customOutDir = process.env.ZHIYIN_BUILD_OUT_DIR;
export default defineConfig({
site: "https://www.zhiyintec.com",
integrations: [sitemap({
filter: (page) => {
const pathname = new URL(page).pathname;
return pathname !== "/404/"
&& pathname !== "/admin/"
&& !pathname.startsWith("/api/")
&& !pathname.startsWith("/uploads/")
&& !pathname.endsWith(".txt");
},
})],
adapter: node({ mode: "standalone" }),
...(customOutDir ? { outDir: path.resolve(customOutDir) } : {}),
build: { format: "directory" },
trailingSlash: "ignore",
});
# 智引未来官网正式域名:HTTP 统一跳转到 HTTPS 和 www 主域名。
server {
listen 80;
server_name zhiyintec.com www.zhiyintec.com;
return 301 https://www.zhiyintec.com$request_uri;
}
server {
listen 443 ssl http2;
server_name zhiyintec.com;
ssl_certificate /etc/nginx/certs/zhiyintec.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/zhiyintec.com.certkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
return 301 https://www.zhiyintec.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.zhiyintec.com;
ssl_certificate /etc/nginx/certs/zhiyintec.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/zhiyintec.com.certkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:ZHIYIN:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
client_max_body_size 28m;
location / {
proxy_pass http://127.0.0.1:8792;
proxy_http_version 1.1;
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_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "zhiyinweilai-official-site",
"type": "module",
"version": "1.0.0",
"private": true,
"engines": {
"node": ">=20.20.0 <21"
},
"scripts": {
"dev": "node --env-file=.env ./node_modules/astro/astro.js dev",
"build": "node scripts/build-site.mjs",
"build:inside-lock": "node scripts/build-site.mjs --inside-lock",
"build:astro": "astro check && astro build",
"preview": "astro preview",
"check": "astro check",
"test": "node --import tsx/esm --test tests/*.test.ts",
"start": "node --env-file=.env server.mjs",
"admin": "npm start",
"serve": "npm run build && npm start"
},
"dependencies": {
"@astrojs/node": "9.5.5",
"@astrojs/sitemap": "^3.7.3",
"astro": "5.18.2",
"gray-matter": "^4.0.3",
"mammoth": "^1.12.0",
"marked": "^14.1.4",
"turndown": "^7.2.4",
"turndown-plugin-gfm": "^1.0.2"
},
"devDependencies": {
"@astrojs/check": "^0.9.6",
"@types/turndown": "^5.0.6",
"docx": "^9.7.1",
"tsx": "^4.23.1",
"typescript": "^5.9.3"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="775" height="199" viewBox="0 0 775 199" fill="none">
<defs>
<linearGradient id="bottomGrad" x1="0" y1="0" x2="775" y2="0" gradientUnits="userSpaceOnUse">
<stop offset="0%" stop-color="#3dd6fe"/>
<stop offset="50%" stop-color="#25a4fe"/>
<stop offset="100%" stop-color="#1178fe"/>
</linearGradient>
</defs>
<path d="M 124.0 59.0 L 123.0 63.0 L 123.0 81.0 L 124.0 85.0 L 128.0 89.0 L 177.0 89.0 L 181.0 88.0 L 186.0 81.0 L 186.0 76.0 L 182.0 77.0 L 181.0 79.0 L 179.0 79.0 L 175.0 82.0 L 174.0 81.0 L 133.0 81.0 L 131.0 79.0 L 131.0 64.0 L 132.0 63.0 L 176.0 63.0 L 177.0 62.0 L 179.0 64.0 L 177.0 68.0 L 140.0 68.0 L 139.0 69.0 L 139.0 75.0 L 140.0 76.0 L 174.0 76.0 L 175.0 75.0 L 180.0 75.0 L 186.0 69.0 L 186.0 58.0 L 181.0 55.0 L 130.0 55.0 Z M 547.0 45.0 L 547.0 53.0 L 579.0 53.0 L 579.0 44.0 L 548.0 44.0 Z M 159.0 34.0 L 176.0 52.0 L 178.0 52.0 L 194.0 36.0 L 194.0 34.0 L 185.0 34.0 L 176.0 42.0 L 169.0 34.0 Z M 416.0 30.0 L 407.0 30.0 L 405.0 37.0 L 402.0 41.0 L 402.0 44.0 L 410.0 44.0 L 414.0 37.0 L 414.0 34.0 L 416.0 32.0 Z M 362.0 30.0 L 368.0 44.0 L 376.0 44.0 L 371.0 30.0 Z M 530.0 22.0 L 524.0 28.0 L 521.0 33.0 L 517.0 46.0 L 517.0 53.0 L 519.0 57.0 L 519.0 61.0 L 524.0 70.0 L 530.0 76.0 L 545.0 82.0 L 554.0 82.0 L 555.0 83.0 L 580.0 82.0 L 580.0 70.0 L 547.0 70.0 L 540.0 67.0 L 535.0 62.0 L 531.0 55.0 L 532.0 40.0 L 539.0 32.0 L 547.0 28.0 L 580.0 28.0 L 580.0 16.0 L 546.0 16.0 L 537.0 18.0 Z M 458.0 19.0 L 452.0 23.0 L 448.0 27.0 L 447.0 30.0 L 445.0 31.0 L 440.0 47.0 L 441.0 57.0 L 447.0 70.0 L 453.0 76.0 L 460.0 80.0 L 474.0 83.0 L 490.0 82.0 L 497.0 78.0 L 499.0 78.0 L 505.0 72.0 L 508.0 63.0 L 508.0 44.0 L 474.0 44.0 L 474.0 54.0 L 494.0 54.0 L 496.0 56.0 L 495.0 63.0 L 491.0 68.0 L 489.0 68.0 L 487.0 70.0 L 472.0 70.0 L 463.0 66.0 L 455.0 56.0 L 454.0 45.0 L 459.0 35.0 L 471.0 28.0 L 506.0 28.0 L 506.0 16.0 L 469.0 16.0 Z M 610.0 17.0 L 600.0 23.0 L 591.0 35.0 L 589.0 44.0 L 589.0 55.0 L 591.0 63.0 L 595.0 68.0 L 595.0 70.0 L 602.0 77.0 L 607.0 80.0 L 610.0 80.0 L 616.0 83.0 L 618.0 82.0 L 619.0 83.0 L 628.0 83.0 L 637.0 81.0 L 648.0 74.0 L 651.0 69.0 L 653.0 68.0 L 653.0 66.0 L 656.0 62.0 L 658.0 53.0 L 658.0 45.0 L 657.0 44.0 L 658.0 42.0 L 651.0 27.0 L 639.0 18.0 L 636.0 18.0 L 633.0 16.0 L 620.0 16.0 L 619.0 15.0 L 614.0 17.0 Z M 617.0 28.0 L 630.0 28.0 L 639.0 34.0 L 645.0 46.0 L 644.0 55.0 L 640.0 63.0 L 633.0 69.0 L 628.0 71.0 L 619.0 71.0 L 612.0 68.0 L 605.0 61.0 L 602.0 54.0 L 603.0 53.0 L 602.0 47.0 L 604.0 39.0 L 609.0 33.0 Z M 198.0 15.0 L 198.0 22.0 L 229.0 22.0 L 230.0 23.0 L 230.0 32.0 L 229.0 33.0 L 205.0 33.0 L 200.0 37.0 L 199.0 40.0 L 200.0 43.0 L 199.0 53.0 L 200.0 56.0 L 204.0 59.0 L 207.0 60.0 L 232.0 60.0 L 233.0 61.0 L 231.0 70.0 L 226.0 77.0 L 218.0 81.0 L 211.0 81.0 L 210.0 82.0 L 203.0 81.0 L 203.0 89.0 L 214.0 89.0 L 215.0 88.0 L 225.0 87.0 L 234.0 81.0 L 240.0 69.0 L 240.0 56.0 L 235.0 52.0 L 209.0 51.0 L 208.0 50.0 L 208.0 42.0 L 209.0 41.0 L 233.0 41.0 L 236.0 40.0 L 239.0 36.0 L 239.0 15.0 L 236.0 14.0 L 204.0 14.0 L 203.0 15.0 Z M 356.0 19.0 L 356.0 26.0 L 383.0 26.0 L 384.0 27.0 L 384.0 47.0 L 383.0 48.0 L 352.0 48.0 L 352.0 55.0 L 373.0 55.0 L 374.0 56.0 L 368.0 66.0 L 359.0 75.0 L 352.0 78.0 L 354.0 87.0 L 359.0 85.0 L 360.0 83.0 L 362.0 83.0 L 374.0 72.0 L 375.0 69.0 L 378.0 66.0 L 380.0 60.0 L 384.0 56.0 L 385.0 57.0 L 385.0 89.0 L 393.0 89.0 L 393.0 56.0 L 394.0 55.0 L 396.0 56.0 L 396.0 59.0 L 403.0 71.0 L 414.0 82.0 L 416.0 82.0 L 417.0 84.0 L 424.0 87.0 L 426.0 78.0 L 420.0 76.0 L 419.0 74.0 L 416.0 73.0 L 410.0 67.0 L 403.0 56.0 L 404.0 55.0 L 425.0 55.0 L 425.0 48.0 L 394.0 48.0 L 393.0 47.0 L 393.0 27.0 L 394.0 26.0 L 421.0 26.0 L 421.0 19.0 L 394.0 19.0 L 393.0 18.0 L 393.0 10.0 L 385.0 10.0 L 385.0 17.0 L 383.0 19.0 Z M 254.0 10.0 L 254.0 89.0 L 261.0 89.0 L 261.0 10.0 Z M 277.0 21.0 L 277.0 28.0 L 303.0 28.0 L 304.0 29.0 L 304.0 40.0 L 303.0 41.0 L 273.0 41.0 L 273.0 49.0 L 290.0 49.0 L 291.0 50.0 L 291.0 52.0 L 289.0 54.0 L 289.0 57.0 L 283.0 67.0 L 276.0 74.0 L 271.0 77.0 L 274.0 85.0 L 279.0 83.0 L 289.0 73.0 L 289.0 71.0 L 291.0 70.0 L 291.0 68.0 L 295.0 63.0 L 298.0 52.0 L 300.0 49.0 L 304.0 50.0 L 304.0 88.0 L 312.0 88.0 L 312.0 51.0 L 314.0 49.0 L 318.0 52.0 L 319.0 58.0 L 329.0 75.0 L 336.0 82.0 L 339.0 83.0 L 340.0 85.0 L 343.0 84.0 L 343.0 81.0 L 345.0 79.0 L 344.0 76.0 L 341.0 75.0 L 334.0 68.0 L 333.0 65.0 L 331.0 64.0 L 331.0 62.0 L 328.0 59.0 L 325.0 51.0 L 326.0 49.0 L 343.0 49.0 L 343.0 42.0 L 342.0 41.0 L 316.0 42.0 L 312.0 40.0 L 312.0 30.0 L 314.0 28.0 L 339.0 28.0 L 339.0 21.0 L 313.0 21.0 L 312.0 20.0 L 312.0 10.0 L 307.0 10.0 L 306.0 9.0 L 304.0 9.0 L 304.0 20.0 L 303.0 21.0 Z M 127.0 9.0 L 126.0 13.0 L 122.0 18.0 L 118.0 20.0 L 118.0 27.0 L 122.0 27.0 L 128.0 23.0 L 136.0 23.0 L 137.0 27.0 L 135.0 30.0 L 118.0 30.0 L 118.0 37.0 L 119.0 38.0 L 131.0 38.0 L 132.0 37.0 L 133.0 38.0 L 127.0 44.0 L 119.0 46.0 L 118.0 47.0 L 118.0 53.0 L 123.0 53.0 L 127.0 51.0 L 130.0 51.0 L 137.0 46.0 L 140.0 42.0 L 145.0 48.0 L 149.0 49.0 L 151.0 51.0 L 157.0 52.0 L 157.0 45.0 L 151.0 43.0 L 145.0 38.0 L 146.0 37.0 L 156.0 37.0 L 156.0 30.0 L 145.0 30.0 L 144.0 29.0 L 145.0 27.0 L 144.0 25.0 L 146.0 23.0 L 157.0 23.0 L 157.0 16.0 L 135.0 16.0 L 133.0 17.0 L 132.0 16.0 L 134.0 12.0 L 134.0 9.0 Z" fill="#172e87" fill-rule="evenodd"/>
<path d="M 157.0 31.0 L 157.0 33.0 L 168.0 33.0 L 177.0 24.0 L 186.0 33.0 L 196.0 33.0 L 195.0 30.0 L 178.0 13.0 L 176.0 13.0 Z" fill="#3bccf7" fill-rule="evenodd"/>
<path d="M 423.0 154.0 L 423.0 167.0 L 452.0 167.0 L 452.0 154.0 Z M 736.0 153.0 L 736.0 165.0 L 767.0 165.0 L 767.0 153.0 Z M 197.0 153.0 L 197.0 165.0 L 228.0 165.0 L 228.0 153.0 Z M 722.0 134.0 L 714.0 143.0 L 710.0 155.0 L 711.0 168.0 L 718.0 181.0 L 726.0 187.0 L 735.0 190.0 L 766.0 191.0 L 767.0 190.0 L 767.0 175.0 L 738.0 175.0 L 734.0 173.0 L 728.0 167.0 L 726.0 158.0 L 729.0 150.0 L 736.0 144.0 L 740.0 143.0 L 767.0 143.0 L 767.0 128.0 L 739.0 128.0 L 727.0 131.0 Z M 650.0 128.0 L 650.0 190.0 L 666.0 190.0 L 666.0 144.0 L 667.0 143.0 L 683.0 143.0 L 689.0 148.0 L 689.0 152.0 L 685.0 157.0 L 673.0 157.0 L 672.0 158.0 L 672.0 166.0 L 689.0 190.0 L 707.0 190.0 L 705.0 185.0 L 692.0 168.0 L 699.0 164.0 L 704.0 156.0 L 705.0 146.0 L 701.0 137.0 L 696.0 132.0 L 685.0 128.0 Z M 586.0 128.0 L 586.0 170.0 L 588.0 176.0 L 592.0 182.0 L 598.0 187.0 L 609.0 191.0 L 619.0 191.0 L 626.0 189.0 L 631.0 186.0 L 638.0 178.0 L 641.0 170.0 L 641.0 128.0 L 626.0 128.0 L 626.0 165.0 L 623.0 172.0 L 617.0 176.0 L 608.0 175.0 L 602.0 168.0 L 602.0 162.0 L 601.0 161.0 L 601.0 128.0 Z M 579.0 128.0 L 560.0 129.0 L 554.0 132.0 L 548.0 138.0 L 544.0 148.0 L 544.0 190.0 L 560.0 190.0 L 560.0 144.0 L 561.0 143.0 L 579.0 143.0 Z M 524.0 143.0 L 540.0 143.0 L 543.0 135.0 L 549.0 128.0 L 524.0 128.0 Z M 462.0 128.0 L 461.0 129.0 L 461.0 165.0 L 462.0 166.0 L 462.0 171.0 L 466.0 180.0 L 474.0 187.0 L 485.0 191.0 L 494.0 191.0 L 505.0 187.0 L 513.0 179.0 L 517.0 170.0 L 517.0 165.0 L 518.0 164.0 L 518.0 129.0 L 517.0 128.0 L 502.0 128.0 L 502.0 166.0 L 500.0 171.0 L 497.0 174.0 L 493.0 176.0 L 486.0 176.0 L 482.0 174.0 L 477.0 167.0 L 477.0 128.0 Z M 453.0 128.0 L 424.0 128.0 L 419.0 129.0 L 410.0 134.0 L 406.0 138.0 L 401.0 148.0 L 401.0 156.0 L 400.0 157.0 L 400.0 166.0 L 401.0 167.0 L 400.0 171.0 L 400.0 189.0 L 401.0 190.0 L 416.0 190.0 L 416.0 153.0 L 417.0 150.0 L 422.0 145.0 L 426.0 143.0 L 454.0 143.0 L 454.0 129.0 Z M 312.0 128.0 L 311.0 130.0 L 312.0 131.0 L 312.0 166.0 L 313.0 167.0 L 326.0 167.0 L 328.0 166.0 L 328.0 147.0 L 327.0 145.0 L 329.0 143.0 L 343.0 144.0 L 348.0 148.0 L 352.0 156.0 L 351.0 165.0 L 346.0 172.0 L 340.0 175.0 L 312.0 176.0 L 311.0 177.0 L 312.0 190.0 L 343.0 190.0 L 355.0 185.0 L 363.0 177.0 L 368.0 165.0 L 368.0 152.0 L 363.0 141.0 L 355.0 133.0 L 346.0 129.0 L 341.0 129.0 L 340.0 128.0 Z M 173.0 148.0 L 172.0 167.0 L 175.0 174.0 L 182.0 183.0 L 186.0 186.0 L 196.0 190.0 L 241.0 190.0 L 248.0 187.0 L 253.0 182.0 L 268.0 151.0 L 272.0 157.0 L 272.0 159.0 L 287.0 190.0 L 304.0 190.0 L 302.0 183.0 L 279.0 133.0 L 272.0 128.0 L 265.0 128.0 L 258.0 133.0 L 241.0 169.0 L 234.0 175.0 L 199.0 175.0 L 195.0 173.0 L 190.0 168.0 L 188.0 164.0 L 188.0 154.0 L 190.0 150.0 L 195.0 145.0 L 200.0 143.0 L 228.0 143.0 L 228.0 128.0 L 200.0 128.0 L 188.0 131.0 L 179.0 138.0 Z M 115.0 128.0 L 115.0 170.0 L 119.0 179.0 L 126.0 186.0 L 135.0 190.0 L 167.0 190.0 L 167.0 174.0 L 132.0 174.0 L 131.0 173.0 L 131.0 129.0 L 130.0 128.0 Z M 89.0 128.0 L 89.0 190.0 L 104.0 190.0 L 105.0 189.0 L 105.0 129.0 L 104.0 128.0 Z M 38.0 130.0 L 35.0 133.0 L 30.0 143.0 L 30.0 145.0 L 10.0 187.0 L 10.0 190.0 L 27.0 190.0 L 32.0 180.0 L 52.0 180.0 L 47.0 166.0 L 39.0 164.0 L 45.0 151.0 L 47.0 152.0 L 47.0 154.0 L 64.0 190.0 L 82.0 190.0 L 57.0 134.0 L 52.0 129.0 L 49.0 128.0 L 42.0 128.0 Z" fill="url(#bottomGrad)" fill-rule="evenodd"/>
</svg>
const $ = (selector) => document.querySelector(selector);
const API_BASE = "/api/cms";
const MAX_UPLOAD_SIZE = 20 * 1024 * 1024;
const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
let categories = [];
let editingSlug = null;
let editingStatus = "new-unsaved";
let dirty = false;
let previewTimer = null;
let previewRequest = 0;
async function api(path, options = {}) {
const endpoint = path.startsWith("/") ? path : `/${path}`;
const response = await fetch(`${API_BASE}${endpoint}`, {
headers: { "Content-Type": "application/json" },
...options,
body: options.body ? JSON.stringify(options.body) : undefined,
});
let data = {};
try { data = await response.json(); } catch {}
if (!response.ok) throw new Error(data.error || `请求失败(${response.status})`);
return data;
}
const show = (selector) => $(selector).classList.remove("hidden");
const hide = (selector) => $(selector).classList.add("hidden");
const refreshCaptcha = () => {
$("#captcha-image").src = `${API_BASE}/captcha?t=${Date.now()}`;
$("#captcha").value = "";
};
function showLogin() {
show("#login");
hide("#app");
refreshCaptcha();
$("#password").focus();
}
async function boot() {
const session = await api("/session").catch(() => ({ authed: false }));
if (session.authed) {
hide("#login"); show("#app");
await loadCategories();
loadArticles();
}
else showLogin();
}
$("#captcha-image").addEventListener("click", refreshCaptcha);
$("#login-form").addEventListener("submit", async (event) => {
event.preventDefault();
$("#login-error").textContent = "";
try {
await api("/session", { method: "POST", body: { password: $("#password").value, captcha: $("#captcha").value } });
$("#password").value = "";
$("#captcha").value = "";
hide("#login"); show("#app");
await loadCategories();
loadArticles();
} catch (error) {
$("#login-error").textContent = error.message;
refreshCaptcha();
}
});
$("#logout").addEventListener("click", async () => { await api("/session", { method: "DELETE" }); location.reload(); });
function closePasswordModal() {
hide("#password-modal");
$("#password-form").reset();
$("#password-error").textContent = "";
}
$("#change-password").addEventListener("click", () => {
$("#password-form").reset();
$("#password-error").textContent = "";
show("#password-modal");
$("#current-password").focus();
});
$("#close-password-modal").addEventListener("click", closePasswordModal);
$("#cancel-password").addEventListener("click", closePasswordModal);
$("#password-form").addEventListener("submit", async (event) => {
event.preventDefault();
const currentPassword = $("#current-password").value;
const newPassword = $("#new-password").value;
const confirmPassword = $("#confirm-password").value;
const submit = event.submitter;
$("#password-error").textContent = "";
if (newPassword !== confirmPassword) {
$("#password-error").textContent = "两次输入的新密码不一致";
return;
}
if (submit) submit.disabled = true;
try {
await api("/account/password", { method: "PUT", body: { currentPassword, newPassword } });
closePasswordModal();
alert("密码修改成功,请重新登录后台");
showLogin();
} catch (error) {
$("#password-error").textContent = error.message;
} finally {
if (submit) submit.disabled = false;
}
});
const statusMap = {
"new-unsaved": ["尚未保存", "new-draft", "填写完成后先保存草稿,线上网站不会发生变化。"],
"new-draft": ["新建未发布", "new-draft", "这篇文章目前只有草稿版本,发布后才会出现在官网。"],
"edited-draft": ["修改未发布", "edited-draft", "草稿已经保存,官网仍在展示上一次发布的版本。"],
live: ["已上线", "live", "当前编辑内容与官网展示的版本一致。"],
};
function applyStatus(element, status) {
const [label, className] = statusMap[status] || statusMap["new-draft"];
element.className = `status ${className}`;
element.textContent = label;
}
async function loadArticles() {
const articles = await api("/articles").catch((error) => { alert(error.message); return []; });
const list = $("#article-list");
list.innerHTML = "";
const pending = articles.filter((item) => item.publishStatus !== "live").length;
$("#pending-badge").textContent = `${pending} 篇草稿待发布`;
$("#pending-badge").classList.toggle("hidden", pending === 0);
if (!articles.length) { list.innerHTML = '<div class="empty">还没有文章,点击“新建文章”开始。</div>'; return; }
for (const article of articles) {
const card = document.createElement("article");
card.className = "article-row";
card.innerHTML = '<div class="article-summary"><h2></h2><p><span class="category"></span><span class="updated"></span><span class="status"></span></p></div><div class="row-actions"></div>';
card.querySelector("h2").textContent = article.title;
card.querySelector(".category").textContent = article.category;
card.querySelector(".updated").textContent = `更新于 ${article.updated}`;
applyStatus(card.querySelector(".status"), article.publishStatus);
const actions = card.querySelector(".row-actions");
const edit = listAction("编辑", "ghost small", () => openEditor(article.slug));
const publish = listAction("发布", "primary small", () => publishFromList(article));
publish.disabled = article.publishStatus === "live";
publish.title = publish.disabled ? "文章当前已上线" : "发布到官网";
actions.append(edit, publish, listMoreActions(article));
list.append(card);
}
}
function listAction(label, className, action) {
const button = document.createElement("button");
button.type = "button";
button.className = className;
button.textContent = label;
button.onclick = action;
return button;
}
function listMenuAction(label, className, action) {
return listAction(label, `menu-action ${className}`.trim(), async (event) => {
event.currentTarget.closest("details").open = false;
await action();
});
}
function listMoreActions(article) {
const details = document.createElement("details");
details.className = "more-actions row-more-actions";
const summary = document.createElement("summary");
summary.textContent = "更多";
summary.setAttribute("aria-label", `${article.title}的更多操作`);
const menu = document.createElement("div");
menu.className = "action-menu";
if (article.publishStatus === "edited-draft") {
menu.append(listMenuAction("放弃未发布修改", "", () => discardFromList(article)));
}
if (["live", "edited-draft"].includes(article.publishStatus)) {
menu.append(listMenuAction("下架文章", "danger", () => unpublishFromList(article)));
}
menu.append(listMenuAction("删除文章", "danger", () => deleteFromList(article)));
details.append(summary, menu);
details.addEventListener("toggle", () => {
if (!details.open) return;
document.querySelectorAll(".row-more-actions[open]").forEach((item) => {
if (item !== details) item.open = false;
});
});
return details;
}
async function publishFromList(article) {
try {
await triggerBuild(`/articles/${article.slug}/publish`);
await loadArticles();
} catch {}
}
async function discardFromList(article) {
if (!confirm(`确定放弃《${article.title}》未发布的修改,恢复为当前线上版本吗?`)) return;
try {
await api(`/articles/${article.slug}/draft`, { method: "DELETE" });
await loadArticles();
} catch (error) { alert(error.message); }
}
async function unpublishFromList(article) {
const detail = article.publishStatus === "edited-draft" ? "未发布的修改会继续保留为草稿。" : "文章内容会继续保留为草稿。";
if (!confirm(`确定将《${article.title}》从官网下架吗?${detail}`)) return;
try {
await triggerBuild(`/articles/${article.slug}/unpublish`, { action: "下架" });
await loadArticles();
} catch {}
}
async function deleteFromList(article) {
const prompt = article.publishStatus === "new-draft"
? `确定彻底删除草稿《${article.title}》吗?删除后无法恢复。`
: `确定彻底删除《${article.title}》吗?线上版本和草稿都会删除,且无法恢复。`;
if (!confirm(prompt)) return;
try {
await triggerBuild(`/articles/${article.slug}`, { action: "删除", method: "DELETE" });
await loadArticles();
} catch {}
}
function fillCategories(selected) {
const current = selected || $("#category").value || categories[0] || "";
const options = $("#category-options");
options.innerHTML = "";
categories.forEach((name) => {
const option = document.createElement("button");
option.type = "button";
option.className = "select-option";
option.dataset.value = name;
option.setAttribute("role", "option");
option.setAttribute("aria-selected", String(name === current));
option.innerHTML = '<span></span><span class="option-check" aria-hidden="true">✓</span>';
option.querySelector("span").textContent = name;
option.addEventListener("click", () => {
selectCategory(name, true);
closeCategoryMenu();
});
options.append(option);
});
selectCategory(categories.includes(current) ? current : categories[0] || "", false);
}
function selectCategory(name, markDirty) {
$("#category").value = name;
$("#category-value").textContent = name || "请选择分类";
$("#category-options").querySelectorAll(".select-option").forEach((option) => {
option.setAttribute("aria-selected", String(option.dataset.value === name));
});
if (markDirty) dirty = true;
}
function closeCategoryMenu() {
$("#category-menu").classList.add("hidden");
$("#category-trigger").setAttribute("aria-expanded", "false");
$("#category-select").classList.remove("open");
}
function toggleCategoryMenu() {
const opening = $("#category-menu").classList.contains("hidden");
if (!opening) return closeCategoryMenu();
$("#category-menu").classList.remove("hidden");
$("#category-trigger").setAttribute("aria-expanded", "true");
$("#category-select").classList.add("open");
$("#category-error").textContent = "";
}
$("#category-trigger").addEventListener("click", (event) => { event.stopPropagation(); toggleCategoryMenu(); });
$("#category-menu").addEventListener("click", (event) => event.stopPropagation());
document.addEventListener("click", closeCategoryMenu);
document.addEventListener("click", (event) => {
document.querySelectorAll(".row-more-actions[open]").forEach((details) => {
if (!details.contains(event.target)) details.open = false;
});
});
document.addEventListener("keydown", (event) => { if (event.key === "Escape") closeCategoryMenu(); });
async function createCategory() {
const input = $("#new-category");
const name = input.value.trim();
$("#category-error").textContent = "";
try {
await triggerBuild("/categories", { action: "添加分类", body: { name } });
await loadCategories();
input.value = "";
fillCategories(name);
dirty = true;
closeCategoryMenu();
if (!$("#category-modal").classList.contains("hidden")) await loadCategoryManager();
} catch (error) { $("#category-error").textContent = error.message; }
}
$("#add-category").addEventListener("click", createCategory);
$("#new-category").addEventListener("keydown", (event) => {
if (event.key !== "Enter") return;
event.preventDefault();
createCategory();
});
async function loadCategories() {
const result = await api("/categories");
categories = result.categories;
fillCategories($("#category").value);
return result;
}
async function loadCategoryManager() {
const result = await loadCategories();
renderCategoryManager(result.stats || []);
}
function clearCategoryPanels() {
$("#category-manager-list").querySelectorAll(".category-inline-panel").forEach((panel) => panel.remove());
}
function categoryPanel(row, text) {
clearCategoryPanels();
const panel = document.createElement("div");
panel.className = "category-inline-panel";
const note = document.createElement("p");
note.textContent = text;
panel.append(note);
row.append(panel);
return panel;
}
async function runCategoryBuild(action, method, body) {
$("#manager-category-error").textContent = "";
try {
await triggerBuild("/categories", { action, method, body });
await loadCategoryManager();
await loadArticles();
} catch (error) {
$("#manager-category-error").textContent = error.message;
await loadCategoryManager().catch(() => {});
}
}
function showRenameCategory(row, stat) {
const panel = categoryPanel(row, `重命名后,${stat.count} 篇文章会同步更新分类。`);
const form = document.createElement("div");
form.className = "category-rename-form";
const input = document.createElement("input");
input.maxLength = 20;
input.value = stat.name;
input.setAttribute("aria-label", `重命名 ${stat.name}`);
const save = document.createElement("button");
save.type = "button";
save.className = "primary";
save.textContent = "保存名称";
const cancel = document.createElement("button");
cancel.type = "button";
cancel.className = "ghost";
cancel.textContent = "取消";
save.onclick = () => {
const name = input.value.trim();
if (!name || name === stat.name) return clearCategoryPanels();
runCategoryBuild("更新分类", "PATCH", { current: stat.name, name });
};
cancel.onclick = clearCategoryPanels;
input.addEventListener("keydown", (event) => {
if (event.key === "Enter") { event.preventDefault(); save.click(); }
if (event.key === "Escape") clearCategoryPanels();
});
form.append(input, save, cancel);
panel.append(form);
input.focus();
input.select();
}
function showDeleteCategory(row, stat) {
const panel = categoryPanel(
row,
stat.count ? `该分类下有 ${stat.count} 篇文章,请选择删除后要迁移到的分类。` : "该分类下没有文章,可以直接删除。",
);
const actions = document.createElement("div");
actions.className = stat.count ? "replacement-options" : "category-inline-actions";
const choices = stat.count ? categories.filter((name) => name !== stat.name) : [""];
choices.forEach((replacement) => {
const button = document.createElement("button");
button.type = "button";
button.className = stat.count ? "" : "confirm-danger";
button.textContent = stat.count ? `迁移到“${replacement}”并删除` : "确认删除分类";
button.onclick = () => runCategoryBuild("删除分类", "DELETE", { name: stat.name, replacement });
actions.append(button);
});
const cancel = document.createElement("button");
cancel.type = "button";
cancel.className = "ghost";
cancel.textContent = "取消";
cancel.onclick = clearCategoryPanels;
actions.append(cancel);
panel.append(actions);
}
function renderCategoryManager(stats) {
const list = $("#category-manager-list");
list.innerHTML = "";
stats.forEach((stat) => {
const row = document.createElement("div");
row.className = "category-manager-row";
const main = document.createElement("div");
main.className = "category-row-main";
const name = document.createElement("div");
name.className = "category-row-name";
const strong = document.createElement("strong");
strong.textContent = stat.name;
const count = document.createElement("span");
count.textContent = stat.count ? `${stat.count} 篇文章` : "暂无文章";
name.append(strong, count);
const actions = document.createElement("div");
actions.className = "category-row-actions";
const rename = document.createElement("button");
rename.type = "button";
rename.className = "ghost";
rename.textContent = "重命名";
rename.onclick = () => showRenameCategory(row, stat);
const remove = document.createElement("button");
remove.type = "button";
remove.className = "ghost danger";
remove.textContent = "删除";
remove.disabled = categories.length <= 1;
remove.title = remove.disabled ? "至少需要保留一个分类" : "删除分类";
remove.onclick = () => showDeleteCategory(row, stat);
actions.append(rename, remove);
main.append(name, actions);
row.append(main);
list.append(row);
});
}
async function openCategoryManager() {
$("#manager-category-error").textContent = "";
show("#category-modal");
try { await loadCategoryManager(); }
catch (error) { $("#manager-category-error").textContent = error.message; }
}
$("#manage-categories").addEventListener("click", openCategoryManager);
$("#close-category-modal").addEventListener("click", () => hide("#category-modal"));
$("#manager-add-category").addEventListener("click", async () => {
const input = $("#manager-new-category");
const name = input.value.trim();
$("#manager-category-error").textContent = "";
try {
await triggerBuild("/categories", { action: "添加分类", body: { name } });
input.value = "";
await loadCategoryManager();
} catch (error) { $("#manager-category-error").textContent = error.message; }
});
$("#manager-new-category").addEventListener("keydown", (event) => {
if (event.key === "Enter") { event.preventDefault(); $("#manager-add-category").click(); }
});
function setView(editing) {
$("#list-view").classList.toggle("hidden", editing);
$("#edit-view").classList.toggle("hidden", !editing);
}
function setEditorStatus(status) {
editingStatus = status;
applyStatus($("#editor-status"), status);
$("#version-note").textContent = statusMap[status]?.[2] || "";
const persisted = status !== "new-unsaved";
$("#more-actions").classList.toggle("hidden", !persisted);
$("#more-actions").open = false;
$("#discard").classList.toggle("hidden", status !== "edited-draft");
$("#unpublish").classList.toggle("hidden", !["live", "edited-draft"].includes(status));
$("#delete-article").classList.toggle("hidden", !persisted);
}
async function openEditor(slug) {
editingSlug = slug;
dirty = false;
fillCategories();
$("#preview").innerHTML = "";
$("#message").textContent = "";
$("#upload-status").textContent = "";
if (slug) {
const article = await api(`/articles/${slug}`);
$("#edit-heading").textContent = "编辑文章";
$("#title").value = article.title;
fillCategories(article.category);
$("#body").value = article.body;
setEditorStatus(article.publishStatus);
} else {
$("#edit-heading").textContent = "新建文章";
$("#title").value = "";
$("#body").value = "";
setEditorStatus("new-unsaved");
}
setView(true);
schedulePreview(0);
$("#title").focus();
}
$("#new-article").addEventListener("click", () => openEditor(null));
$("#import-article").addEventListener("click", () => $("#article-file").click());
$("#article-file").addEventListener("change", async (event) => {
const file = event.target.files?.[0];
event.target.value = "";
if (!file) return;
if (file.size > MAX_UPLOAD_SIZE) {
$("#import-status").textContent = "文件不能超过 20MB";
return;
}
const extension = file.name.toLowerCase().match(/\.[^.]+$/)?.[0];
if (![".md", ".docx"].includes(extension)) {
$("#import-status").textContent = "仅支持 Markdown(.md)或 Word(.docx)文件";
return;
}
$("#import-status").textContent = `正在导入 ${file.name}…`;
try {
let result;
if (extension === ".md") {
let body = await file.text();
const heading = body.match(/^#\s+(.+)$/m);
const title = heading?.[1].trim() || file.name.replace(/\.md$/i, "");
if (heading?.index !== undefined) {
body = `${body.slice(0, heading.index)}${body.slice(heading.index + heading[0].length)}`
.trim()
.replace(/\n{3,}/g, "\n\n");
}
if (!body) throw new Error("Markdown 文件中没有可导入的正文内容");
result = await api("/articles", { method: "POST", body: { title, category: categories[0], body } });
} else {
const dataUrl = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(file);
});
result = await api("/imports/word", {
method: "POST",
body: { fileName: file.name, category: categories[0], dataUrl: String(dataUrl).replace(/^data:[^;,]*;/, `data:${DOCX_MIME};`) },
});
}
const successMessage = extension === ".docx"
? `导入成功:已创建草稿并提取 ${result.imageCount} 张图片`
: "导入成功:已创建 Markdown 草稿";
$("#import-status").textContent = successMessage;
await openEditor(result.slug);
$("#message").textContent = successMessage;
} catch (error) {
$("#import-status").textContent = error.message;
}
});
$("#back").addEventListener("click", () => {
if (dirty && !confirm("还有未保存的内容,确定返回文章列表吗?")) return;
setView(false);
loadArticles();
});
function payload() {
return {
title: $("#title").value.trim(),
category: $("#category").value,
body: $("#body").value,
};
}
async function save() {
const result = editingSlug
? await api(`/articles/${editingSlug}`, { method: "PUT", body: payload() })
: await api("/articles", { method: "POST", body: payload() });
editingSlug = result.slug;
dirty = false;
setEditorStatus(result.publishStatus);
return result.slug;
}
$("#edit-form").addEventListener("submit", async (event) => {
event.preventDefault();
$("#message").textContent = "正在保存…";
try {
await save();
$("#message").textContent = editingStatus === "live" ? "内容与线上版本一致。" : "草稿已保存,线上版本没有改变。";
} catch (error) { $("#message").textContent = error.message; }
});
$("#publish").addEventListener("click", async () => {
$("#message").textContent = "正在保存草稿…";
try {
const slug = await save();
await triggerBuild(`/articles/${slug}/publish`);
setEditorStatus("live");
$("#message").textContent = "发布成功,官网已更新。";
} catch (error) { $("#message").textContent = error.message; }
});
$("#discard").addEventListener("click", async () => {
if (!editingSlug) return;
if (!confirm("确定放弃未发布的修改,恢复为当前线上版本吗?")) return;
try {
const result = await api(`/articles/${editingSlug}/draft`, { method: "DELETE" });
dirty = false;
if (result.removed) { setView(false); loadArticles(); }
else await openEditor(editingSlug);
} catch (error) { $("#message").textContent = error.message; }
});
$("#unpublish").addEventListener("click", async () => {
if (!editingSlug) return;
const detail = editingStatus === "edited-draft" ? "未发布的修改会继续保留为草稿。" : "文章内容会继续保留为草稿。";
if (!confirm(`确定将这篇文章从官网下架吗?${detail}`)) return;
$("#more-actions").open = false;
$("#message").textContent = "正在下架文章…";
try {
await triggerBuild(`/articles/${editingSlug}/unpublish`, { action: "下架" });
setEditorStatus("new-draft");
$("#message").textContent = "文章已下架,内容已保留为草稿。";
} catch (error) { $("#message").textContent = error.message; }
});
$("#delete-article").addEventListener("click", async () => {
if (!editingSlug) return;
const prompt = editingStatus === "new-draft"
? "确定彻底删除这篇草稿吗?删除后无法恢复。"
: "确定彻底删除这篇文章吗?线上版本和草稿都会删除,且无法恢复。";
if (!confirm(prompt)) return;
$("#more-actions").open = false;
$("#message").textContent = "正在删除文章…";
try {
await triggerBuild(`/articles/${editingSlug}`, { action: "删除", method: "DELETE" });
dirty = false;
editingSlug = null;
setView(false);
await loadArticles();
} catch (error) { $("#message").textContent = error.message; }
});
async function renderPreview() {
const body = $("#body").value.trim();
if (!body) { $("#preview").innerHTML = ""; return; }
const request = ++previewRequest;
try {
const result = await api("/preview", { method: "POST", body: { body } });
if (request === previewRequest) $("#preview").innerHTML = result.html;
} catch {
if (request === previewRequest) $("#preview").textContent = "预览暂时不可用";
}
}
function schedulePreview(delay = 350) {
clearTimeout(previewTimer);
previewTimer = setTimeout(renderPreview, delay);
}
$("#title").addEventListener("input", () => { dirty = true; });
$("#body").addEventListener("input", () => { dirty = true; schedulePreview(); });
$("#upload-button").addEventListener("click", () => $("#file").click());
$("#file").addEventListener("change", async (event) => {
const file = event.target.files?.[0];
event.target.value = "";
if (!file) return;
if (file.size > MAX_UPLOAD_SIZE) {
$("#upload-status").textContent = "图片不能超过 20MB";
return;
}
$("#upload-status").textContent = "上传中…";
try {
const dataUrl = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(file);
});
const result = await api("/uploads", { method: "POST", body: { dataUrl } });
const textarea = $("#body");
const start = textarea.selectionStart;
const markdown = `\n![${file.name}](${result.url})\n`;
textarea.value = textarea.value.slice(0, start) + markdown + textarea.value.slice(textarea.selectionEnd);
textarea.dispatchEvent(new Event("input"));
$("#upload-status").textContent = "图片已插入";
} catch (error) { $("#upload-status").textContent = error.message; }
});
async function triggerBuild(endpoint, { action = "发布", method = "POST", body } = {}) {
show("#build-modal");
hide("#close-modal");
$("#build-title").textContent = `正在${action}…`;
$("#build-log").textContent = "系统正在更新官网,请稍候。";
try {
await api(endpoint, { method, body });
} catch (error) {
$("#build-title").textContent = `${action}失败`;
$("#build-log").textContent = error.message;
show("#close-modal");
throw error;
}
while (true) {
await new Promise((resolve) => setTimeout(resolve, 1000));
const state = await api("/build");
if (state.status === "building") continue;
if (state.ok) { hide("#build-modal"); return; }
$("#build-title").textContent = `${action}失败`;
$("#build-log").textContent = state.log || `${action}失败,请联系技术人员。`;
show("#close-modal");
throw new Error(`${action}失败,原文章已恢复,请检查操作日志。`);
}
}
$("#close-modal").addEventListener("click", () => hide("#build-modal"));
boot();
:root {
--primary: #1473E6;
--primary-dark: #073B83;
--deep: #071D3B;
--light: #EAF3FF;
--bg: #F7F9FC;
--surface: #fff;
--text: #142033;
--muted: #6b7280;
--border: #E2E8F0;
--danger: #c04444;
font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; }
button, .button { min-height: 40px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; transition: .18s ease; }
.primary { color: white; background: var(--primary-dark); }
.primary:hover { background: var(--deep); transform: translateY(-1px); }
.ghost { color: var(--primary-dark); background: transparent; border: 1px solid var(--border); }
.ghost:hover { border-color: var(--primary); }
.small { min-height: 34px; padding-inline: 13px; font-size: 12px; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; }
.login { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: linear-gradient(135deg, #faf8f4, var(--light)); }
.login-card { width: min(420px, 100%); padding: 42px; display: grid; gap: 16px; background: white; border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 24px 60px rgba(15,35,60,.12); }
.brand-mark { color: var(--primary); font-size: 14px; font-weight: 700; letter-spacing: .18em; }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card p { margin: -8px 0 4px; color: var(--muted); }
.login-card label, .field-panel label, .field-label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.captcha-row { display: flex; align-items: stretch; gap: 10px; }
.captcha-row input { min-width: 0; flex: 1; text-transform: uppercase; }
#captcha-image { width: 132px; height: 46px; flex: 0 0 auto; cursor: pointer; background: var(--light); border: 1px solid var(--border); border-radius: 9px; }
input, textarea, select { width: 100%; padding: 11px 13px; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 9px; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(20,115,230,.14); border-color: var(--primary); }
.topbar { min-height: 68px; padding: 12px 28px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 22px; color: white; background: #071D3B; }
.topbar > div:first-child { display: flex; align-items: center; gap: 13px; }
.topbar strong { color: var(--primary); font-size: 19px; }
.topbar span { font-size: 13px; opacity: .76; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.topbar .ghost { color: white; border-color: rgba(255,255,255,.24); }
.pending-badge { padding: 5px 10px; color: #ffe49b; background: rgba(255,206,94,.12); border: 1px solid rgba(255,206,94,.3); border-radius: 999px; }
.view { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 70px; }
.view-head { margin-bottom: 26px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.view-head p { margin: 0 0 5px; color: var(--primary-dark); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.view-head h1 { margin: 0; font-size: 30px; }
.view-actions { display: flex; gap: 9px; }
.import-status { min-height: 20px; margin: -16px 0 12px; color: var(--muted); font-size: 13px; text-align: right; }
.article-list { display: grid; gap: 10px; }
.article-row { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: white; border: 1px solid var(--border); border-radius: 14px; }
.article-summary { min-width: 0; flex: 1; }
.article-row h2 { margin: 0 0 8px; font-size: 17px; }
.article-row p { margin: 0; display: flex; flex-wrap: wrap; gap: 8px 13px; align-items: center; color: var(--muted); font-size: 12px; }
.article-row code { color: #9a8d7e; }
.status { padding: 2px 8px; border-radius: 999px; }
.status.live { color: #0D966A; background: #DFF8EE; }
.status.new-draft { color: #916300; background: #fff2c7; }
.status.edited-draft { color: #9c4c22; background: #ffeadc; }
.row-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.row-actions button:disabled { cursor: default; opacity: .48; transform: none; }
.row-more-actions summary { min-height: 34px; padding-inline: 13px; font-size: 12px; }
.row-more-actions .action-menu { top: calc(100% + 8px); bottom: auto; z-index: 12; }
.empty { padding: 70px; color: var(--muted); text-align: center; background: white; border: 1px dashed var(--border); border-radius: 14px; }
#edit-form { display: grid; gap: 18px; }
.field-panel, .editor-panel { padding: 24px; background: white; border: 1px solid var(--border); border-radius: 16px; }
.field-panel { display: grid; gap: 15px; }
.field-panel small { font-weight: 400; opacity: .8; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.custom-select { position: relative; }
.select-trigger { width: 100%; padding: 0 13px; justify-content: space-between; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 9px; text-align: left; }
.select-trigger:hover, .custom-select.open .select-trigger { border-color: var(--primary); }
.custom-select.open .select-trigger { outline: 2px solid rgba(20,115,230,.14); }
.select-chevron { color: var(--muted); transition: transform .18s ease; }
.custom-select.open .select-chevron { transform: rotate(180deg); }
.select-menu { width: 100%; margin-top: 7px; position: absolute; z-index: 20; overflow: hidden; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 45px rgba(15,35,60,.16); }
.select-options { max-height: 220px; padding: 7px; display: grid; gap: 2px; overflow-y: auto; }
.select-option { width: 100%; min-height: 40px; padding: 0 11px; justify-content: space-between; color: var(--text); background: transparent; border-radius: 8px; }
.select-option:hover { background: #F1F7FF; }
.select-option[aria-selected="true"] { color: var(--primary-dark); background: #EAF3FF; font-weight: 600; }
.option-check { opacity: 0; color: var(--primary-dark); }
.select-option[aria-selected="true"] .option-check { opacity: 1; }
.category-create { padding: 12px; background: #F7F9FC; border-top: 1px solid var(--border); }
.category-create > span { display: block; margin-bottom: 8px; color: var(--text); font-weight: 600; }
.category-create > div { display: flex; gap: 8px; }
.category-create input { min-width: 0; }
.category-create button { min-width: 68px; flex: 0 0 auto; white-space: nowrap; }
.category-create .error { min-height: 0; margin: 6px 2px 0; }
.editor-titlebar { align-items: flex-end; }
.editor-titlebar > div { display: grid; gap: 12px; }
.editor-titlebar > .status { margin-bottom: 4px; padding: 6px 12px; font-size: 13px; }
.back-button { min-height: auto; width: max-content; padding: 0; color: var(--muted); background: transparent; border-radius: 0; }
.back-button:hover { color: var(--primary-dark); }
.version-note { margin: -12px 0 18px; padding: 13px 16px; color: #6b5a4f; background: #F8EEE6; border: 1px solid var(--border); border-radius: 11px; font-size: 13px; }
.auto-meta { margin: 0; padding: 11px 13px; color: var(--muted); background: #F7F9FC; border-radius: 9px; font-size: 12px; }
.editor-head { margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.editor-head > div { display: flex; align-items: center; gap: 9px; }
.editor-head small { color: var(--muted); font-size: 12px; font-weight: 400; }
#upload-status { color: var(--muted); font-size: 12px; }
.editor-grid { min-height: 480px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#body { min-height: 480px; resize: vertical; font-family: inherit; font-size: 15px; line-height: 1.8; }
.preview { padding: 22px; overflow: auto; background: #F9FCFF; border: 1px solid var(--border); border-radius: 9px; line-height: 1.8; }
.preview:empty::before { content: "文章预览会显示在这里"; color: var(--muted); }
.preview h1, .preview h2, .preview h3 { color: var(--primary-dark); }
.preview img { max-width: 100%; }
.edit-actions { padding: 15px 18px; position: sticky; bottom: 14px; z-index: 5; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(75,34,26,.1); backdrop-filter: blur(10px); }
.save-button { background: white; }
.more-actions { position: relative; }
.more-actions summary { min-height: 40px; padding: 0 15px; display: flex; align-items: center; color: var(--muted); background: white; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; list-style: none; }
.more-actions summary::-webkit-details-marker { display: none; }
.more-actions summary::after { content: "⌄"; margin-left: 7px; transition: transform .18s ease; }
.more-actions[open] summary::after { transform: rotate(180deg); }
.more-actions[open] summary { color: var(--primary-dark); border-color: var(--primary); }
.action-menu { min-width: 180px; padding: 7px; position: absolute; right: 0; bottom: calc(100% + 8px); display: grid; gap: 2px; background: white; border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 14px 36px rgba(75,34,26,.16); }
.menu-action { width: 100%; min-height: 38px; padding: 0 11px; justify-content: flex-start; color: var(--text); background: transparent; border-radius: 7px; font-size: 13px; }
.menu-action:hover { background: #FAF1EA; }
.menu-action.danger { color: var(--danger); }
.menu-action.danger:hover { background: #fff0f0; }
#message { margin-left: 8px; color: var(--muted); font-size: 13px; }
.modal { position: fixed; inset: 0; z-index: 30; padding: 20px; display: grid; place-items: center; background: rgba(0,0,0,.6); }
.modal-card { width: min(780px, 100%); max-height: 82vh; background: white; border-radius: 16px; overflow: hidden; }
.modal-card > div { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.category-manager { width: min(680px, 100%); }
.modal-card > .modal-head { padding: 18px 20px; }
.modal-head > div { display: grid; gap: 4px; }
.modal-head small { color: var(--muted); font-size: 12px; font-weight: 400; }
.password-card { width: min(500px, 100%); }
.modal-card > .password-form { padding: 20px; display: grid; gap: 14px; border: 0; }
.password-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.password-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.password-form .error { margin: -4px 0 0; }
.password-actions { display: flex; justify-content: flex-end; gap: 9px; }
.modal-card > .category-manager-body { max-height: 68vh; padding: 20px; display: block; overflow-y: auto; border: 0; }
.manager-create { display: flex; gap: 9px; }
.manager-create input { min-width: 0; }
.manager-create button { flex: 0 0 auto; white-space: nowrap; }
.category-manager-list { margin-top: 8px; display: grid; gap: 8px; }
.category-manager-row { padding: 13px 14px; background: #FAF7F1; border: 1px solid var(--border); border-radius: 11px; }
.category-row-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.category-row-name { min-width: 0; display: grid; gap: 3px; }
.category-row-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-row-name span { color: var(--muted); font-size: 12px; }
.category-row-actions { display: flex; gap: 5px; }
.category-row-actions button { min-height: 32px; padding-inline: 10px; font-size: 12px; }
.category-row-actions .danger { color: var(--danger); }
.category-row-actions button:disabled { cursor: not-allowed; opacity: .45; }
.category-inline-panel { margin-top: 11px; padding-top: 11px; display: grid; gap: 9px; border-top: 1px solid var(--border); }
.category-inline-panel p { margin: 0; color: var(--muted); font-size: 12px; }
.category-rename-form { display: flex; gap: 8px; }
.category-rename-form input { min-width: 0; }
.category-inline-actions, .replacement-options { display: flex; flex-wrap: wrap; gap: 7px; }
.category-inline-actions button, .replacement-options button { min-height: 32px; padding-inline: 11px; font-size: 12px; }
.confirm-danger { color: white; background: var(--danger); }
.replacement-options button { color: var(--primary-dark); background: white; border: 1px solid var(--border); }
.replacement-options button:hover { border-color: var(--primary); background: #FBEAE6; }
.build-card { width: min(780px, 100%); }
#build-log { max-height: 62vh; margin: 0; padding: 18px; overflow: auto; color: var(--muted); background: #faf7f1; white-space: pre-wrap; font-size: 12px; }
@media (max-width: 760px) {
.topbar, .view-head, .article-row { align-items: flex-start; flex-direction: column; }
.top-actions { width: 100%; flex-wrap: wrap; }
.view-actions { width: 100%; }
.view-actions button { flex: 1; }
.field-row, .editor-grid { grid-template-columns: 1fr; }
.view { width: min(100% - 28px, 1120px); padding-top: 28px; }
.row-actions { width: 100%; }
.row-actions > button, .row-more-actions { flex: 1; }
.row-more-actions summary { width: 100%; justify-content: center; }
.edit-actions { flex-wrap: wrap; }
#message { width: 100%; margin: 4px 0 0; }
.login-card { padding: 30px 24px; }
.manager-create, .category-row-main, .category-rename-form { align-items: stretch; flex-direction: column; }
}
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
<defs>
<radialGradient id="blue" cx="0" cy="0" r="1" gradientTransform="translate(170 90) rotate(45) scale(530)"><stop stop-color="#DCEEFF"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient>
<radialGradient id="green" cx="0" cy="0" r="1" gradientTransform="translate(1060 500) rotate(210) scale(480)"><stop stop-color="#DDF9F0"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient>
<linearGradient id="brand" x1="0" x2="1"><stop stop-color="#1473E6"/><stop offset=".55" stop-color="#19C7C4"/><stop offset="1" stop-color="#10B981"/></linearGradient>
</defs>
<rect width="1200" height="630" fill="#fff"/><rect width="1200" height="630" fill="url(#blue)"/><rect width="1200" height="630" fill="url(#green)"/>
<path d="M0 100H1200M0 200H1200M0 300H1200M0 400H1200M0 500H1200M200 0V630M400 0V630M600 0V630M800 0V630M1000 0V630" stroke="#1473E6" stroke-opacity=".055"/>
<rect x="82" y="74" width="210" height="44" rx="22" fill="#F1F7FF" stroke="#CFE3FB"/><circle cx="108" cy="96" r="6" fill="#10B981"/><text x="126" y="103" fill="#073B83" font-family="sans-serif" font-size="18" font-weight="600">GEO + SMO 双引擎</text>
<text x="82" y="266" fill="#142033" font-family="sans-serif" font-size="76" font-weight="700">智引未来,让品牌</text>
<text x="82" y="363" fill="url(#brand)" font-family="sans-serif" font-size="76" font-weight="700">被每一个搜索看见</text>
<text x="86" y="430" fill="#526070" font-family="sans-serif" font-size="26">全域搜索优化与大数据分析服务商</text>
<g transform="translate(850 160)"><circle cx="130" cy="130" r="125" fill="#fff" stroke="#DCEAF8"/><circle cx="130" cy="130" r="84" fill="none" stroke="#19C7C4" stroke-opacity=".4"/><circle cx="130" cy="130" r="44" fill="url(#brand)"/><text x="104" y="141" fill="#fff" font-family="sans-serif" font-size="30" font-weight="700">AI</text><circle cx="25" cy="75" r="12" fill="#1473E6"/><circle cx="238" cy="78" r="12" fill="#10B981"/><circle cx="192" cy="240" r="9" fill="#19C7C4"/></g>
<rect x="82" y="520" width="1036" height="2" fill="url(#brand)"/><text x="82" y="567" fill="#073B83" font-family="sans-serif" font-size="20" font-weight="600">AILEAD FUTURE</text><text x="1118" y="567" fill="#8491A3" font-family="sans-serif" font-size="18" text-anchor="end">www.zhiyintec.com</text>
</svg>
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /api/
Sitemap: https://www.zhiyintec.com/sitemap-index.xml
{
"name": "智引未来",
"short_name": "智引未来",
"description": "GEO与SMO全域搜索优化服务商",
"start_url": "/",
"display": "standalone",
"background_color": "#FFFFFF",
"theme_color": "#1473E6",
"lang": "zh-CN",
"icons": [
{
"src": "/favicon.png",
"sizes": "955x955",
"type": "image/png",
"purpose": "any maskable"
}
]
}
import { buildSiteAtomic, withSiteBuildLock } from "./site-build.mjs";
try {
const build = () => buildSiteAtomic({ onOutput: (text) => process.stdout.write(text) });
if (process.argv.includes("--inside-lock")) {
if (process.env.ZHIYIN_SITE_LOCK_HELD !== "1") throw new Error("build:inside-lock 只能在共享构建锁中运行");
await build();
} else {
await withSiteBuildLock(build);
}
} catch (error) {
console.error(error instanceof Error ? error.message : error);
process.exitCode = 1;
}
import fs from "node:fs/promises";
import path from "node:path";
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, TextRun } from "docx";
const root = process.cwd();
const outputDirectory = path.join(root, "tests", "fixtures");
const imageFile = path.join(root, "pic", "智引未来GEO_原始版本_渐变背景.png");
const marker = "ZHIYIN-PRODUCTION-IMPORT-20260811";
await fs.mkdir(outputDirectory, { recursive: true });
await fs.writeFile(path.join(outputDirectory, "import-test.md"), [
"# 企业开始GEO诊断前,建议先准备这五类信息",
"",
"一次有效的GEO诊断,需要把品牌事实、用户问题和当前AI可见结果放在同一个框架中观察。准备资料不必复杂,但应尽量准确。",
"",
"![智引未来品牌示意图]({{TEST_IMAGE_URL}})",
"",
"## 一、品牌与业务简介",
"",
"用简洁语言说明企业是谁、服务谁、解决什么问题,以及当前最重要的产品与市场。",
"",
"## 二、核心品牌与品类关键词",
"",
"整理用户可能主动搜索的品牌词、品类词、场景词和问题词,作为诊断范围的初始输入。",
"",
"## 三、重点竞品与替代方案",
"",
"列出用户在比较阶段可能同时考虑的品牌或方案,便于观察AI回答中的推荐结构。",
"",
"## 四、现有官方内容",
"",
"准备官网、公众号、产品资料和权威报道等内容入口,确认品牌事实是否统一。",
"",
"## 五、当前最关心的问题",
"",
"说明品牌是完全没有被提及、描述不准确,还是在关键问题中被竞品压制。",
"",
"智引未来会基于真实可见结果建立诊断基线,让后续优化有明确方向和可追溯依据。",
"",
`测试标记:${marker}-MARKDOWN`,
"",
].join("\n"));
const image = await fs.readFile(imageFile);
const heading = (text) => new Paragraph({ text, heading: HeadingLevel.HEADING_2 });
const body = (text) => new Paragraph({ children: [new TextRun(text)] });
const document = new Document({
sections: [{
children: [
new Paragraph({ text: "企业如何开始一次AI搜索可见度诊断", heading: HeadingLevel.HEADING_1 }),
body("AI搜索可见度诊断的目标,是确认品牌在哪些问题中出现、如何被描述,以及信息来自哪些引用来源。"),
new Paragraph({ children: [new ImageRun({ data: image, transformation: { width: 320, height: 320 }, type: "png", altText: { title: "智引未来测试图片", description: "用于验证Word导入图片提取", name: "test.png" } })] }),
heading("建立品牌事实基线"),
body("先确认企业名称、业务定位、产品服务、联系方式和官方表达,避免不同内容入口相互矛盾。"),
heading("定义用户问题集合"),
body("围绕认知、比较、验证和决策阶段整理问题,观察品牌和竞品在回答中的真实位置。"),
heading("记录引用与推荐语境"),
body("不仅记录是否被提及,还要确认引用来源、描述准确性和推荐理由。"),
heading("形成可持续监测范围"),
body("平台和回答会持续变化,因此诊断基线应能进入后续监测、优化与复盘。"),
body(`测试标记:${marker}-WORD`),
],
}],
});
await fs.writeFile(path.join(outputDirectory, "import-test.docx"), await Packer.toBuffer(document));
console.log(`Created fixtures in ${outputDirectory}`);
import { spawn } from "node:child_process";
import { withSiteBuildLock } from "./site-build.mjs";
const separator = process.argv.indexOf("--");
const command = separator >= 0 ? process.argv.slice(separator + 1) : [];
if (!command.length) {
console.error("用法:node scripts/run-with-site-lock.mjs -- <部署命令> [参数]");
process.exit(2);
}
await withSiteBuildLock(() => new Promise((resolve, reject) => {
const child = spawn(command[0], command.slice(1), {
stdio: "inherit",
env: { ...process.env, ZHIYIN_SITE_LOCK_HELD: "1" },
});
child.on("error", reject);
child.on("exit", (code, signal) => {
if (code === 0) resolve();
else reject(new Error(signal ? `部署命令被信号 ${signal} 终止` : `部署命令退出码:${code}`));
});
})).catch((error) => {
console.error(error instanceof Error ? error.message : error);
process.exitCode = 1;
});
export interface BuildOptions {
onOutput?: (text: string) => void;
}
export class SiteBuildLockBusyError extends Error {}
export function tryAcquireSiteBuildLock(): Promise<(() => Promise<void>) | null>;
export function withSiteBuildLock<T>(task: () => Promise<T>, options?: { timeoutMs?: number }): Promise<T>;
export function buildSiteAtomic(options?: BuildOptions): Promise<string>;
import crypto from "node:crypto";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { spawn } from "node:child_process";
const ROOT = process.cwd();
const RUNTIME_DIR = path.join(ROOT, ".runtime");
const DEFAULT_LOCK = process.env.CMS_DATA_DIR
? path.join(path.resolve(process.env.CMS_DATA_DIR), ".site-build.lock")
: path.join(RUNTIME_DIR, "site-build.lock");
const LOCK_FILE = path.resolve(process.env.CMS_BUILD_LOCK || DEFAULT_LOCK);
const RECOVERY_LOCK_FILE = `${LOCK_FILE}.recovery`;
const ASTRO_BIN = path.join(ROOT, "node_modules", "astro", "astro.js");
const DIST_DIR = path.join(ROOT, "dist");
const MAX_LOG_LENGTH = 2 * 1024 * 1024;
export class SiteBuildLockBusyError extends Error {
constructor() {
super("网站正在部署或生成静态页面,请稍后重试");
this.name = "SiteBuildLockBusyError";
}
}
const delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
async function fileExists(file) {
try { await fs.access(file); return true; } catch { return false; }
}
function processIsAlive(pid) {
if (!Number.isInteger(pid) || pid <= 0) return false;
try { process.kill(pid, 0); return true; } catch { return false; }
}
async function removeStaleLock() {
let recoveryHandle;
try {
recoveryHandle = await fs.open(RECOVERY_LOCK_FILE, "wx");
const raw = await fs.readFile(LOCK_FILE, "utf8");
const lock = JSON.parse(raw);
const sameHost = lock.hostname === os.hostname();
if (sameHost && !processIsAlive(Number(lock.pid))) {
await fs.unlink(LOCK_FILE);
return true;
}
} catch (error) {
if (error.code === "ENOENT") return true;
if (error.code === "EEXIST") return false;
} finally {
if (recoveryHandle) {
await recoveryHandle.close().catch(() => {});
await fs.unlink(RECOVERY_LOCK_FILE).catch(() => {});
}
}
return false;
}
async function acquireSiteBuildLock(timeoutMs = 15 * 60 * 1000) {
await fs.mkdir(path.dirname(LOCK_FILE), { recursive: true });
const started = Date.now();
const token = crypto.randomBytes(12).toString("hex");
while (true) {
try {
const handle = await fs.open(LOCK_FILE, "wx");
await handle.writeFile(JSON.stringify({ token, pid: process.pid, hostname: os.hostname(), startedAt: new Date().toISOString() }));
await handle.close();
return async () => {
try {
const current = JSON.parse(await fs.readFile(LOCK_FILE, "utf8"));
if (current.token === token) await fs.unlink(LOCK_FILE);
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
};
} catch (error) {
if (error.code !== "EEXIST") throw error;
if (await removeStaleLock()) continue;
if (Date.now() - started >= timeoutMs) throw new SiteBuildLockBusyError();
await delay(300);
}
}
}
export async function tryAcquireSiteBuildLock() {
try {
return await acquireSiteBuildLock(0);
} catch (error) {
if (error instanceof SiteBuildLockBusyError) return null;
throw error;
}
}
export async function withSiteBuildLock(task, options = {}) {
const release = await acquireSiteBuildLock(options.timeoutMs);
try { return await task(); } finally { await release(); }
}
function runAstro(command, env, onOutput) {
return new Promise((resolve, reject) => {
const child = spawn(process.execPath, [ASTRO_BIN, command], { cwd: ROOT, env: { ...process.env, ...env } });
let log = "";
const append = (chunk) => {
const text = chunk.toString();
log = `${log}${text}`.slice(-MAX_LOG_LENGTH);
onOutput?.(text);
};
child.stdout.on("data", append);
child.stderr.on("data", append);
child.on("error", reject);
child.on("exit", (code) => code === 0 ? resolve(log) : reject(Object.assign(new Error(`astro ${command} 执行失败`), { log })));
});
}
export async function buildSiteAtomic(options = {}) {
await fs.mkdir(RUNTIME_DIR, { recursive: true });
const id = `${Date.now()}-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
const temporary = path.join(RUNTIME_DIR, `dist-${id}`);
const backup = path.join(RUNTIME_DIR, `dist-backup-${id}`);
let movedCurrent = false;
let log = "";
try {
log += await runAstro("check", {}, options.onOutput);
log += await runAstro("build", { ZHIYIN_BUILD_OUT_DIR: temporary }, options.onOutput);
if (await fileExists(DIST_DIR)) {
await fs.rename(DIST_DIR, backup);
movedCurrent = true;
}
try {
await fs.rename(temporary, DIST_DIR);
} catch (error) {
if (movedCurrent) await fs.rename(backup, DIST_DIR);
throw error;
}
if (movedCurrent) {
await fs.rm(backup, { recursive: true, force: true }).catch((error) => {
options.onOutput?.(`\n旧构建目录清理失败,可稍后手动清理:${error.message}\n`);
});
}
return log;
} catch (error) {
await fs.rm(temporary, { recursive: true, force: true });
if (movedCurrent && !await fileExists(DIST_DIR) && await fileExists(backup)) await fs.rename(backup, DIST_DIR);
if (error.log) error.log = `${log}${error.log}`.slice(-MAX_LOG_LENGTH);
else error.log = log;
throw error;
}
}
import assert from "node:assert/strict";
import fs from "node:fs/promises";
import path from "node:path";
const baseUrl = process.env.CMS_BASE_URL || "http://127.0.0.1:8792";
const apiKey = process.env.CMS_API_KEY;
if (!apiKey) throw new Error("CMS_API_KEY 未配置");
const headers = { Authorization: `Bearer ${apiKey}` };
const jsonHeaders = { ...headers, "Content-Type": "application/json" };
async function request(route, options = {}) {
const response = await fetch(`${baseUrl}/api/cms${route}`, {
...options,
headers: { ...headers, ...options.headers },
});
const payload = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(`${options.method || "GET"} ${route} 返回 ${response.status}${payload.error || "未知错误"}`);
return payload;
}
const categories = await request("/categories");
for (const required of ["GEO洞察", "AI搜索"]) assert.ok(categories.categories.includes(required));
const image = await fs.readFile(path.resolve("pic/智引未来GEO_原始版本_渐变背景.png"));
const uploadedImage = await request("/uploads", {
method: "POST",
headers: jsonHeaders,
body: JSON.stringify({ dataUrl: `data:image/png;base64,${image.toString("base64")}` }),
});
const markdownFile = path.resolve("tests/fixtures/import-test.md");
let markdown = await fs.readFile(markdownFile, "utf8");
const heading = markdown.match(/^#\s+(.+)$/m);
assert.ok(heading?.index !== undefined);
const markdownTitle = heading[1].trim();
markdown = `${markdown.slice(0, heading.index)}${markdown.slice(heading.index + heading[0].length)}`
.trim()
.replace("{{TEST_IMAGE_URL}}", uploadedImage.url);
const markdownImport = await request("/articles", {
method: "POST",
headers: jsonHeaders,
body: JSON.stringify({ title: markdownTitle, category: "GEO洞察", body: markdown }),
});
const docxFile = path.resolve("tests/fixtures/import-test.docx");
const docx = await fs.readFile(docxFile);
const wordImport = await request("/imports/word", {
method: "POST",
headers: jsonHeaders,
body: JSON.stringify({
fileName: path.basename(docxFile),
category: "AI搜索",
dataUrl: `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,${docx.toString("base64")}`,
}),
});
const markdownArticle = await request(`/articles/${markdownImport.slug}`);
const wordArticle = await request(`/articles/${wordImport.slug}`);
assert.equal(markdownImport.publishStatus, "new-draft");
assert.equal(markdownArticle.title, markdownTitle);
assert.equal(markdownArticle.category, "GEO洞察");
assert.match(markdownArticle.body, /ZHIYIN-PRODUCTION-IMPORT-20260811-MARKDOWN/);
assert.match(markdownArticle.body, new RegExp(uploadedImage.url.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
assert.equal(wordImport.publishStatus, "new-draft");
assert.equal(wordImport.title, "企业如何开始一次AI搜索可见度诊断");
assert.equal(wordImport.imageCount, 1);
assert.equal(wordArticle.category, "AI搜索");
assert.match(wordArticle.body, /ZHIYIN-PRODUCTION-IMPORT-20260811-WORD/);
assert.doesNotMatch(wordArticle.body, /^#\s+企业如何开始一次AI搜索可见度诊断/m);
const wordImageUrl = wordArticle.body.match(/!\[[^\]]*\]\((\/uploads\/[^)]+)\)/)?.[1];
assert.ok(wordImageUrl);
for (const imageUrl of [uploadedImage.url, wordImageUrl]) {
const response = await fetch(`${baseUrl}${imageUrl}`);
assert.equal(response.status, 200);
assert.equal(response.headers.get("content-type"), "image/png");
assert.deepEqual(Buffer.from(await response.arrayBuffer()), image);
}
console.log(JSON.stringify({
markdown: { slug: markdownImport.slug, title: markdownArticle.title, imageUrl: uploadedImage.url, publishStatus: markdownImport.publishStatus },
word: { slug: wordImport.slug, title: wordImport.title, imageUrl: wordImageUrl, imageCount: wordImport.imageCount, publishStatus: wordImport.publishStatus, warnings: wordImport.warnings },
}, null, 2));
process.env.PORT ||= process.env.CMS_PORT || "8792";
process.env.HOST ||= "127.0.0.1";
await import("./dist/server/entry.mjs");
---
import { fmtDate, paginationWindow, type Article, type CategoryInfo } from "../lib/articles";
interface Props {
items: Article[];
categories: CategoryInfo[];
totalCount: number;
activeSlug: string | null;
currentPage: number;
lastPage: number;
basePath: string;
}
const { items, categories, totalCount, activeSlug, currentPage, lastPage, basePath } = Astro.props as Props;
const pageHref = (page: number) => page <= 1 ? `${basePath}/` : `${basePath}/page/${page}/`;
const pages = paginationWindow(currentPage, lastPage);
---
<nav class="article-tabs" aria-label="搜索增长洞察分类">
<a class:list={["article-tab", { active: activeSlug === null }]} href="/articles/">全部 <span>{totalCount}</span></a>
{categories.map((category) => (
<a class:list={["article-tab", { active: activeSlug === category.slug }]} href={`/articles/topic/${category.slug}/`}>
{category.name} <span>{category.count}</span>
</a>
))}
</nav>
{items.length ? (
<div class="article-grid">
{items.map((item, index) => (
<article class="article-card" data-reveal>
<a href={`/articles/${item.id}/`} aria-label={`阅读:${item.data.title}`}>
<div class="article-card__meta">
<span>{item.data.category}</span><time datetime={fmtDate(item.data.date)}>{fmtDate(item.data.date)}</time>
</div>
<div class="article-card__index">{String((currentPage - 1) * 9 + index + 1).padStart(2, "0")}</div>
<h2>{item.data.title}</h2>
<p>{item.data.excerpt}</p>
<strong>阅读全文 <span>↗</span></strong>
</a>
</article>
))}
</div>
) : <p class="article-empty">该分类暂时还没有文章。</p>}
{lastPage > 1 && (
<nav class="article-pagination" aria-label="资讯分页">
{currentPage > 1 ? <a href={pageHref(currentPage - 1)} rel="prev">←</a> : <span aria-hidden="true">←</span>}
{pages.map((page) => page === 0
? <span class="gap">…</span>
: page === currentPage
? <span class="active" aria-current="page">{page}</span>
: <a href={pageHref(page)}>{page}</a>
)}
{currentPage < lastPage ? <a href={pageHref(currentPage + 1)} rel="next">→</a> : <span aria-hidden="true">→</span>}
</nav>
)}
---
import Base from "../layouts/Base.astro";
import Header from "./Header.astro";
import Footer from "./Footer.astro";
import ArticleListing from "./ArticleListing.astro";
import { site } from "../data/site";
import { PAGE_SIZE, type Article, type CategoryInfo } from "../lib/articles";
interface Props { items: Article[]; categories: CategoryInfo[]; totalCount: number; activeSlug: string | null; activeName: string | null; currentPage: number; lastPage: number; basePath: string; }
const { items, categories, totalCount, activeSlug, activeName, currentPage, lastPage, basePath } = Astro.props as Props;
const heading = activeName ?? "洞察中心";
const pageSuffix = currentPage > 1 ? `|第${currentPage}页` : "";
const title = `${heading}${pageSuffix}|${site.brand.name}`;
const description = activeName ? `智引未来${activeName}分类文章,分享GEO、SMO、AI搜索与品牌内容建设的实用洞察。` : "智引未来洞察中心:关于GEO、SMO、AI搜索可见度与品牌内容资产的持续观察。";
const keywords = [heading, "GEO洞察", "SMO增长", "AI搜索", "品牌内容", site.brand.name];
const pageUrl = new URL(`${basePath}${currentPage > 1 ? `/page/${currentPage}` : ""}/`, Astro.site).href;
const jsonLd = [{ "@context": "https://schema.org", "@type": "CollectionPage", name: heading, description, url: pageUrl, inLanguage: "zh-CN", mainEntity: { "@type": "ItemList", itemListElement: items.map((item, index) => ({ "@type": "ListItem", position: (currentPage - 1) * PAGE_SIZE + index + 1, name: item.data.title, url: new URL(`/articles/${item.id}/`, Astro.site).href })) } }, { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [{ "@type": "ListItem", position: 1, name: "首页", item: Astro.site?.href }, { "@type": "ListItem", position: 2, name: "洞察中心", item: new URL("/articles/", Astro.site).href }, ...(activeName ? [{ "@type": "ListItem", position: 3, name: activeName, item: pageUrl }] : [])] }];
---
<Base {title} {description} {keywords} {jsonLd}><Header /><main id="main-content"><section class="page-hero article-hero"><div class="page-hero__mesh"></div><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / <a href="/articles/">洞察中心</a>{activeName && ` / ${activeName}`}</div><div class="eyebrow"><span></span>AILEAD INSIGHTS</div><h1>{heading}</h1><p>{description}</p></div></section><section class="section-pad section-muted"><div class="container"><ArticleListing {items} {categories} {totalCount} {activeSlug} {currentPage} {lastPage} {basePath} /></div></section></main><Footer /></Base>
---
import { site } from "../data/site";
interface Props { title?: string; text?: string; }
const { title = "让品牌在下一次搜索中,被准确看见", text = "告诉我们品牌、品类与关注的问题,先用一次全搜索诊断看清GEO与SMO的优先级。" } = Astro.props;
---
<section class="cta-band"><div class="container cta-band__inner" data-reveal>
<div><div class="eyebrow eyebrow--light"><span></span>START WITH A DIAGNOSIS</div><h2>{title}</h2><p>{text}</p></div>
<div class="cta-band__actions"><a class="button button--white" href="/contact/">预约品牌诊断 <span>↗</span></a><a class="text-link text-link--light" href={`tel:${site.contact.phone}`}>电话 {site.contact.phoneDisplay}</a></div>
</div></section>
---
import { site } from "../data/site";
---
<dialog class="contact-dialog" data-contact-dialog aria-labelledby="contact-dialog-title">
<div class="contact-dialog__panel">
<button class="contact-dialog__close" type="button" data-contact-dialog-close aria-label="关闭联系方式弹窗">×</button>
<div class="contact-dialog__heading">
<div class="eyebrow"><span></span>CONTACT AILEAD</div>
<h2 id="contact-dialog-title">从一次品牌诊断开始</h2>
<p>告诉我们品牌与关注的品类关键词,先看清AI搜索和社媒搜索中的真实现状。</p>
</div>
<div class="contact-dialog__grid">
<article><span>01</span><h3>电话咨询</h3><a class="contact-dialog__primary" href={`tel:${site.contact.phone}`}>{site.contact.phoneDisplay}</a><p>工作沟通与项目咨询</p></article>
<article><span>02</span><h3>联系邮箱</h3><a class="contact-dialog__primary contact-dialog__email" href={`mailto:${site.contact.email}`}>{site.contact.email}</a><p>发送品牌资料与需求说明</p></article>
<article><span>03</span><h3>公司地址</h3><address>{site.contact.address}</address></article>
<article><span>04</span><h3>官方网站</h3><a class="contact-dialog__primary contact-dialog__website" href={`https://${site.contact.website}/`}>{site.contact.website}</a><p>智引未来官方信息窗口</p></article>
</div>
</div>
</dialog>
---
import logo from "../../pic/智引未来GEO_透明背景_矢量版.svg";
import { site } from "../data/site";
---
<footer class="site-footer">
<div class="footer-glow"></div>
<div class="container footer-grid">
<div class="footer-brand">
<a href="/" class="footer-logo" aria-label="智引未来首页"><img src={logo.src} width="775" height="199" loading="lazy" alt="智引未来" /></a>
<p>科技蓝为品牌基底,增长绿为业务引擎。让企业在AI与社媒搜索中持续被看见、被理解、被推荐。</p>
<div class="footer-tags"><span>GEO</span><span>SMO</span><span>AI全域优化</span></div>
</div>
<div><h2>探索智引</h2><a href="/about/">关于我们</a><a href="/methodology/">服务方法</a><a href="/articles/">洞察中心</a><a href="/faq/">常见问题</a></div>
<div><h2>产品服务</h2>{site.services.map((item) => <a href={`/services/${item.slug}/`}>{item.name}</a>)}</div>
<div class="footer-contact"><h2>联系咨询</h2><a class="footer-phone" href={`tel:${site.contact.phone}`}>{site.contact.phoneDisplay}</a><a href={`mailto:${site.contact.email}`}>{site.contact.email}</a><address>{site.contact.address}</address><a class="footer-arrow" href="/contact/">预约品牌诊断 <span>↗</span></a></div>
</div>
<div class="container footer-bottom">
<p>© {new Date().getFullYear()} {site.brand.legalName}</p>
<p>以真实数据驱动可持续的搜索增长</p>
</div>
</footer>
---
import logo from "../../pic/智引未来GEO_透明背景_矢量版.svg";
import { site } from "../data/site";
import { categoryToSlug, getCategoryNames } from "../lib/articles";
const path = Astro.url.pathname;
const isActive = (href: string) => href === "/" ? path === "/" : path.startsWith(href);
const categoryChildren = (await getCategoryNames()).map((label) => ({ href: `/articles/topic/${categoryToSlug(label)}/`, label }));
const nav = site.nav.map((item) => item.href === "/articles/" ? { ...item, children: [{ href: "/articles/", label: "全部文章" }, ...categoryChildren] } : item);
---
<header class="site-header" data-header>
<div class="container site-header__inner">
<a class="brand" href="/" aria-label="智引未来首页"><img src={logo.src} width="775" height="199" alt="智引未来 AILEAD FUTURE" /></a>
<nav class="desktop-nav" aria-label="主导航">
<ul>{nav.map((item) => <li class="nav-item">
<a class="nav-link" href={item.href} aria-current={isActive(item.href) ? "page" : undefined}>{item.label}</a>
<div class="nav-dropdown"><ul>{item.children.map((child) => <li><a href={child.href}>{child.label}<span aria-hidden="true">↗</span></a></li>)}</ul></div>
</li>)}</ul>
</nav>
<a class="button button--small header-cta" href="/contact/">预约诊断 <span>↗</span></a>
<details class="mobile-nav">
<summary aria-label="打开导航菜单"><span></span><span></span><span></span></summary>
<nav data-mobile-nav aria-label="移动端导航">{nav.map((item) => <div class="mobile-nav__group">
<a class="mobile-nav__primary" href={item.href} aria-current={isActive(item.href) ? "page" : undefined}>{item.label}</a>
<div class="mobile-subnav">{item.children.map((child) => <a href={child.href}>{child.label}</a>)}</div>
</div>)}<a class="button" href="/contact/">预约品牌诊断</a></nav>
</details>
</div>
</header>
---
const items = ["豆包", "通义千问", "DeepSeek", "百度AI", "文心一言", "Kimi", "腾讯元宝", "抖音搜索", "小红书搜索"];
---
<div class="platform-strip" aria-label="覆盖平台">
<div class="platform-strip__track">{[...items, ...items].map((item) => <span><i></i>{item}</span>)}</div>
</div>
---
interface Props { eyebrow: string; title: string; description?: string; align?: "left" | "center"; light?: boolean; }
const { eyebrow, title, description, align = "left", light = false } = Astro.props;
---
<div class:list={["section-heading", `section-heading--${align}`, { "section-heading--light": light }]} data-reveal>
<div class="eyebrow"><span></span>{eyebrow}</div><h2>{title}</h2>{description && <p>{description}</p>}
</div>
import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";
const articleSchema = z.object({
title: z.string(),
slug: z.string(),
date: z.coerce.date(),
updated: z.coerce.date(),
category: z.string(),
author: z.string(),
excerpt: z.string(),
status: z.enum(["draft", "published"]),
});
const articles = defineCollection({
loader: glob({ pattern: "**/*.md", base: "./src/content/articles" }),
schema: articleSchema,
});
const published = defineCollection({
loader: glob({ pattern: "**/*.md", base: "./src/content/published" }),
schema: articleSchema,
});
export const collections = { articles, published };
---
title: "AI友好型官网,应当先把品牌事实讲清楚"
slug: "ai-ready-website"
date: 2026-08-04
updated: 2026-08-04
category: "品牌内容"
author: "智引未来"
excerpt: "官网不仅面向访客,也承担官方信源角色。清晰的信息架构、语义结构与持续内容,比堆叠技术术语更重要。"
status: "published"
---
# AI友好型官网,应当先把品牌事实讲清楚
企业官网是品牌最稳定、最可控的信息源之一。对用户来说,它需要快速说明企业是谁、提供什么服务、如何联系;对搜索引擎与AI来说,这些信息还需要结构清晰、彼此一致。
## 先建立可靠的信息架构
品牌、服务、公司介绍、常见问题、联系方式和持续更新的文章中心,是多数企业官网的基础模块。每个模块应有明确主题,并通过合理链接形成完整关系。
## 再考虑可发现与可理解
语义化HTML、清晰标题层级、页面描述、结构化数据、站点地图与移动端性能,都会影响内容被发现和理解的效率。
真正的AI友好,不是给页面贴上“AI”标签,而是让品牌事实长期保持准确、完整、可验证。
---
title: "SMO不是泛投流:先理解社媒搜索意图"
slug: "smo-search-intent"
date: 2026-08-06
updated: 2026-08-06
category: "SMO增长"
author: "智引未来"
excerpt: "抖音和小红书搜索承接着明确的比较与决策需求。SMO的关键,是让内容真正回答用户正在搜索的问题。"
status: "published"
---
# SMO不是泛投流:先理解社媒搜索意图
推荐流解决“用户可能感兴趣什么”,搜索解决“用户此刻明确想知道什么”。两类流量的内容逻辑并不相同。
## 搜索内容要匹配决策阶段
同一个品类下,用户可能在寻找基础知识、比较方案、验证口碑或确认购买。内容若只重复品牌口号,很难承接这些具体需求。
SMO需要先识别品类词、场景词、问题词和品牌词,再判断每类搜索背后的决策阶段,规划对应的内容形式和信息深度。
## 排名只是结果之一
有效的社媒搜索优化还要关注点击后的承接:标题是否准确、内容是否可信、品牌信息是否完整、用户能否顺利进入下一步。
因此,排名、点击、内容表现与转化线索需要放在同一个复盘框架中观察。
---
title: "GEO是什么:品牌为什么需要面向AI回答做优化"
slug: "what-is-geo"
date: 2026-08-08
updated: 2026-08-08
category: "GEO洞察"
author: "智引未来"
excerpt: "从网页排名到AI回答,品牌可见度的判断方式正在改变。本文说明GEO解决什么问题,以及企业应从哪里开始。"
status: "published"
---
# GEO是什么:品牌为什么需要面向AI回答做优化
过去,用户通常从搜索结果列表中寻找网页;现在,越来越多问题会先得到一段由AI组织的回答。品牌是否被提及、被如何描述、引用了哪些来源,都会影响用户接下来的判断。
## GEO关注的不是单一排名
GEO是生成式引擎优化。它关注品牌能否进入AI回答、信息是否准确、被推荐时处于什么语境,以及相关结论能否回到可信来源。
这意味着企业不能只优化某一个页面,而要同时建设清晰的品牌知识、覆盖用户真实问题,并让官方信息保持一致、可理解和可验证。
## 从一次可见度诊断开始
适合的第一步不是立刻大量生产内容,而是先回答三个问题:
1. 用户会在哪些问题中寻找你的品类?
2. 当前AI回答里出现了谁,引用了什么?
3. 品牌缺少的是事实、内容,还是可信来源?
有了基线,后续的知识建设、内容发布与效果监测才有明确方向。
[
"GEO洞察",
"SMO增长",
"AI搜索",
"品牌内容"
]
---
title: "AI友好型官网,应当先把品牌事实讲清楚"
slug: "ai-ready-website"
date: 2026-08-04
updated: 2026-08-04
category: "品牌内容"
author: "智引未来"
excerpt: "官网不仅面向访客,也承担官方信源角色。清晰的信息架构、语义结构与持续内容,比堆叠技术术语更重要。"
status: "published"
---
# AI友好型官网,应当先把品牌事实讲清楚
企业官网是品牌最稳定、最可控的信息源之一。对用户来说,它需要快速说明企业是谁、提供什么服务、如何联系;对搜索引擎与AI来说,这些信息还需要结构清晰、彼此一致。
## 先建立可靠的信息架构
品牌、服务、公司介绍、常见问题、联系方式和持续更新的文章中心,是多数企业官网的基础模块。每个模块应有明确主题,并通过合理链接形成完整关系。
## 再考虑可发现与可理解
语义化HTML、清晰标题层级、页面描述、结构化数据、站点地图与移动端性能,都会影响内容被发现和理解的效率。
真正的AI友好,不是给页面贴上“AI”标签,而是让品牌事实长期保持准确、完整、可验证。
---
title: "SMO不是泛投流:先理解社媒搜索意图"
slug: "smo-search-intent"
date: 2026-08-06
updated: 2026-08-06
category: "SMO增长"
author: "智引未来"
excerpt: "抖音和小红书搜索承接着明确的比较与决策需求。SMO的关键,是让内容真正回答用户正在搜索的问题。"
status: "published"
---
# SMO不是泛投流:先理解社媒搜索意图
推荐流解决“用户可能感兴趣什么”,搜索解决“用户此刻明确想知道什么”。两类流量的内容逻辑并不相同。
## 搜索内容要匹配决策阶段
同一个品类下,用户可能在寻找基础知识、比较方案、验证口碑或确认购买。内容若只重复品牌口号,很难承接这些具体需求。
SMO需要先识别品类词、场景词、问题词和品牌词,再判断每类搜索背后的决策阶段,规划对应的内容形式和信息深度。
## 排名只是结果之一
有效的社媒搜索优化还要关注点击后的承接:标题是否准确、内容是否可信、品牌信息是否完整、用户能否顺利进入下一步。
因此,排名、点击、内容表现与转化线索需要放在同一个复盘框架中观察。
---
title: "GEO是什么:品牌为什么需要面向AI回答做优化"
slug: "what-is-geo"
date: 2026-08-08
updated: 2026-08-08
category: "GEO洞察"
author: "智引未来"
excerpt: "从网页排名到AI回答,品牌可见度的判断方式正在改变。本文说明GEO解决什么问题,以及企业应从哪里开始。"
status: "published"
---
# GEO是什么:品牌为什么需要面向AI回答做优化
过去,用户通常从搜索结果列表中寻找网页;现在,越来越多问题会先得到一段由AI组织的回答。品牌是否被提及、被如何描述、引用了哪些来源,都会影响用户接下来的判断。
## GEO关注的不是单一排名
GEO是生成式引擎优化。它关注品牌能否进入AI回答、信息是否准确、被推荐时处于什么语境,以及相关结论能否回到可信来源。
这意味着企业不能只优化某一个页面,而要同时建设清晰的品牌知识、覆盖用户真实问题,并让官方信息保持一致、可理解和可验证。
## 从一次可见度诊断开始
适合的第一步不是立刻大量生产内容,而是先回答三个问题:
1. 用户会在哪些问题中寻找你的品类?
2. 当前AI回答里出现了谁,引用了什么?
3. 品牌缺少的是事实、内容,还是可信来源?
有了基线,后续的知识建设、内容发布与效果监测才有明确方向。
export const site = {
seo: {
title: "智引未来|GEO与SMO全域搜索优化服务商",
description:
"西安智引未来提供GEO生成式引擎优化、SMO社媒搜索优化、AI友好型官网搭建与内容运营服务,帮助企业在AI搜索与社媒搜索中被看见、被理解、被推荐。",
keywords: ["智引未来", "GEO优化", "生成式引擎优化", "SMO优化", "社媒搜索优化", "AI搜索优化", "全域搜索获客"],
imageAlt: "智引未来GEO与SMO全域搜索优化品牌",
},
brand: {
name: "智引未来",
shortName: "智引未来",
englishName: "AILEAD FUTURE",
legalName: "西安智引未来人工智能科技有限公司",
tagline: "智引未来,让品牌被每一个搜索看见",
industry: "GEO · SMO · AI 全域搜索优化",
},
home: {
eyebrow: "GEO + SMO 双引擎",
headline: "让品牌被每一个搜索看见",
subhead:
"全栈自研技术的全域搜索优化与大数据分析服务商。以智引未来GEO与智引未来SMO为双引擎,帮助企业建立从品牌诊断、策略制定到持续增长的搜索获客闭环。",
stats: [
{ value: "8+", label: "主流AI平台覆盖" },
{ value: "12", label: "移动与网页终端" },
{ value: "2", label: "社媒搜索场景" },
{ value: "5", label: "自研核心技术" },
],
},
services: [
{
slug: "geo-optimization",
index: "01",
type: "geo",
name: "智引未来GEO",
kicker: "AI SEARCH VISIBILITY",
seoTitle: "GEO生成式引擎优化服务|智引未来",
seoDescription: "智引未来GEO通过AI提及监测、引用溯源、用户意图分析与内容优化,提升品牌在主流AI回答中的可见度与推荐机会。",
seoKeywords: ["GEO优化", "生成式引擎优化", "AI搜索优化", "AI品牌可见度", "AI引用优化"],
intro: "提升品牌在AI回答中的提及率与推荐机会,让企业信息更容易被AI理解、引用和信任。",
features: [
"跨平台监测品牌提及、引用来源与推荐语境,定位AI搜索中的真实缺口",
"基于问题场景与用户意图制定内容策略,不押注单一平台或一次性投放",
"从品牌知识库、内容生产到全域发布和持续复盘,形成可追踪的优化闭环",
],
capabilities: [
{ label: "诊断", value: "AI提及现状与竞品差距" },
{ label: "分析", value: "决策路径与引用来源溯源" },
{ label: "优化", value: "问题覆盖与品牌知识建设" },
{ label: "监测", value: "跨平台效果趋势与证据留存" },
],
process: ["品牌可见度诊断", "情报与引用分析", "用户意图建模", "内容发布与监测"],
},
{
slug: "smo-optimization",
index: "02",
type: "smo",
name: "智引未来SMO",
kicker: "SOCIAL SEARCH GROWTH",
seoTitle: "SMO社媒搜索优化服务|智引未来",
seoDescription: "智引未来SMO面向抖音与小红书搜索场景,通过真实搜索数据、内容意图匹配和持续优化,提升品牌内容排名与点击转化。",
seoKeywords: ["SMO优化", "社媒搜索优化", "抖音搜索优化", "小红书搜索优化", "内容搜索排名"],
intro: "提升品牌在抖音与小红书搜索结果中的排名、内容可见度与点击转化。",
features: [
"以平台后台真实搜索数据识别品类需求、品牌词和高价值问题,策略依据可追溯",
"围绕搜索意图规划内容矩阵,使选题、表达与用户决策阶段精准匹配",
"持续跟踪排名、点击与内容表现,让有效内容沉淀为长期搜索资产",
],
capabilities: [
{ label: "数据", value: "抖音与小红书真实搜索信号" },
{ label: "策略", value: "品类词、场景词与品牌词规划" },
{ label: "内容", value: "搜索友好型内容矩阵" },
{ label: "增长", value: "排名、点击与转化持续复盘" },
],
process: ["搜索需求盘点", "关键词与场景分层", "内容矩阵执行", "排名转化复盘"],
},
{
slug: "ai-website",
index: "03",
type: "platform",
name: "AI官网搭建",
kicker: "AI-READY WEBSITE",
seoTitle: "AI友好型企业官网搭建|智引未来",
seoDescription: "智引未来提供兼顾用户体验、SEO与AI抓取理解的企业官网搭建和持续运营服务,帮助品牌建立可信的官方信息源。",
seoKeywords: ["AI官网搭建", "企业官网建设", "AI友好网站", "GEO官网", "品牌官网运营"],
intro: "搭建兼顾用户体验、传统SEO与AI理解能力的官网,建立稳定可信的品牌信息源。",
features: [
"清晰的信息架构、语义化页面与结构化数据,帮助搜索引擎和AI准确理解品牌",
"响应式体验、性能优化、站点地图与内容管理能力一次搭建,便于长期运营",
"围绕品牌业务持续完善服务页、问答与行业内容,积累可被引用的官方资产",
],
capabilities: [
{ label: "架构", value: "语义清晰的品牌与服务页面" },
{ label: "发现", value: "SEO、GEO与站点地图配置" },
{ label: "内容", value: "可持续发布的知识内容中心" },
{ label: "体验", value: "移动端适配与性能优化" },
],
process: ["品牌资料梳理", "信息架构设计", "网站开发上线", "内容持续运营"],
},
{
slug: "content-operations",
index: "04",
type: "platform",
name: "公众号内容运营",
kicker: "TRUSTED CONTENT HUB",
seoTitle: "公众号内容运营服务|智引未来",
seoDescription: "智引未来围绕品牌知识、行业问题和搜索需求规划公众号内容,提升品牌可信度并沉淀可持续复用的内容资产。",
seoKeywords: ["公众号运营", "企业内容运营", "品牌内容建设", "搜索友好内容", "内容资产"],
intro: "以搜索需求和品牌知识为线索运营公众号内容,持续沉淀可信、可复用的品牌资产。",
features: [
"围绕用户问题、产品能力与行业认知建立长期选题地图,避免内容随机化",
"统一品牌事实、表达口径与证据来源,增强内容的可信度与可引用性",
"与官网、GEO和SMO策略协同,让一次内容生产服务多个搜索与传播场景",
],
capabilities: [
{ label: "规划", value: "年度主题与月度选题地图" },
{ label: "生产", value: "品牌一致的专业内容" },
{ label: "协同", value: "官网、AI与社媒多端复用" },
{ label: "沉淀", value: "持续扩展品牌知识资产" },
],
process: ["品牌知识盘点", "选题与栏目规划", "内容生产发布", "数据复盘迭代"],
},
],
about: {
heading: "用真实数据,让搜索增长有据可依",
position:
"智引未来是一家全栈自研技术的全域搜索优化与大数据分析服务商,以GEO与SMO双产品线帮助企业应对AI搜索和社媒搜索带来的入口重构。",
story: [
"当消费者开始向AI提问、在抖音和小红书搜索,品牌是否被提及、如何被描述、排在什么位置,正在直接影响信任与决策。智引未来聚焦企业在这些新搜索入口中的“不可见”问题,从品牌诊断开始,逐步建立可被理解、可被检索、可被推荐的内容资产。",
"智引未来GEO与智引未来SMO可以独立交付,也可以组合形成全搜索覆盖。两条产品线共享数据底座,贯通策略分析、内容生产、全域分发和效果监测,以更高效率形成跨平台协同。",
"我们坚持策略依据可追溯、效果数据白盒化。每一条结论都尽量回到真实搜索数据、引用来源和用户可见结果,让企业清楚知道问题在哪里、为什么这样优化、下一步如何改进。",
],
advantages: [
{ title: "自建数据底座", desc: "真实采集并还原用户所见,策略不依赖模糊估算。" },
{ title: "移动端全面覆盖", desc: "支持APP与网页多端监测,8+平台、12个终端一键全览。" },
{ title: "电商决策洞察", desc: "识别购物相关回答与推荐理由,理解品牌进入决策的方式。" },
{ title: "全链路闭环", desc: "监测、诊断、优化、复盘贯通,每条结论可回溯到证据。" },
{ title: "双引擎协同", desc: "GEO与SMO共享数据和内容资产,覆盖AI与社媒两类搜索入口。" },
{ title: "白盒效果看板", desc: "过程、排名与趋势持续呈现,让团队自主掌握优化进度。" },
],
technologies: [
"分布式实时多端监测引擎",
"LLM语义溯源与引用解析技术",
"GEO + SMO双频共振算法模型",
"多Agent集群合规数据采集技术",
"时序大数据分析引擎",
],
vision: "让品牌在每一个搜索入口被看见、被信任,成为全搜索优化领域的基础设施级服务商。",
},
workflow: [
{ number: "01", title: "监测", desc: "跨平台还原品牌、竞品与用户问题的真实可见结果。" },
{ number: "02", title: "诊断", desc: "定位内容缺口、引用来源、排名障碍与增长机会。" },
{ number: "03", title: "优化", desc: "建立品牌知识、内容矩阵与多端协同发布策略。" },
{ number: "04", title: "复盘", desc: "以透明看板持续追踪趋势,让策略随数据迭代。" },
],
faq: [
{ q: "西安智引未来是做什么的?", a: "西安智引未来是全栈自研技术的全域搜索优化与大数据分析服务商,总部位于西安。旗下智引未来GEO专注AI搜索优化,智引未来SMO专注社媒搜索优化,帮助品牌在用户所有“搜”的入口被看见和推荐。" },
{ q: "智引未来GEO和智引未来SMO有什么区别?", a: "GEO面向AI搜索场景,优化品牌在主流AI平台中被提及、引用和推荐的机会;SMO面向社媒搜索场景,优化品牌在抖音与小红书搜索中的排名和内容可见度。两项服务可以单独采购,也可以组合形成全搜索覆盖。" },
{ q: "智引未来GEO覆盖哪些AI平台?", a: "服务覆盖豆包、通义千问、DeepSeek、百度AI、文心一言、Kimi、腾讯元宝等主流AI平台,并会根据平台发展持续调整监测范围。具体覆盖清单以项目诊断阶段确认为准。" },
{ q: "智引未来SMO覆盖哪些平台?", a: "目前重点覆盖抖音搜索与小红书搜索两大社媒搜索场景。" },
{ q: "我应该选GEO还是SMO?", a: "如果品牌在AI回答中搜不到、被描述不准确或被竞品压制,可优先考虑GEO;如果抖音或小红书的自然搜索排名靠后、内容承接不足,可优先考虑SMO。不确定时,建议先做一次全搜索品牌诊断。" },
{ q: "智引未来和普通SEO公司有什么不同?", a: "传统SEO主要面向网页搜索结果。智引未来同时覆盖AI搜索与社媒搜索两个新场景,并以真实搜索数据、引用来源和用户可见结果驱动策略,服务重点也从网页排名扩展到品牌被理解、引用和推荐的全过程。" },
{ q: "GEO优化的效果能保证吗?", a: "我们通过数据诊断、内容优化和持续监测提升品牌可见度,但AI平台算法持续迭代,无法承诺固定排名。项目会提供白盒化数据和阶段性复盘,让客户持续看到过程、变化与证据。" },
{ q: "品牌在AI搜索中不可见会有什么影响?", a: "当消费者在决策前先向AI提问,品牌若没有进入回答、被错误理解或缺少可信引用,就可能错过认知、比较和选择环节。GEO的目标是尽早发现这些缺口并持续补齐品牌信息。" },
{ q: "智引未来的核心技术能力是什么?", a: "核心能力覆盖多端监测、LLM语义溯源与引用解析、GEO与SMO协同分析、多Agent合规数据采集以及时序大数据分析,贯穿数据采集、策略分析到效果监测。" },
{ q: "智引未来GEO的服务流程是怎样的?", a: "标准流程包括品牌可见度诊断、情报与引用分析、用户意图建模、内容发布与持续监测。每个阶段均形成透明的数据或内容交付,便于客户理解过程和效果。" },
{ q: "如何联系智引未来?", a: "可拨打17391783779,发送邮件至Zhiyin_Tech@163.com,或前往陕西省西安市曲江新区金辉环球中心A座沟通。" },
],
contact: {
website: "www.zhiyintec.com",
phone: "17391783779",
phoneDisplay: "173 9178 3779",
email: "Zhiyin_Tech@163.com",
address: "陕西省西安市曲江新区金辉环球中心A座",
locality: "曲江新区",
region: "陕西省西安市",
heading: "聊聊你的品牌,先看清搜索现状",
intro: "告诉我们品牌、品类与最关心的搜索问题。我们将从AI与社媒两个入口出发,协助你判断优先级和可执行的优化路径。",
socials: ["抖音", "微信公众号", "小红书"],
},
nav: [
{ href: "/", label: "首页", children: [{ href: "/#solutions", label: "双引擎方案" }, { href: "/#technology", label: "技术能力" }, { href: "/#workflow", label: "服务闭环" }] },
{ href: "/services/", label: "产品服务", children: [
{ href: "/services/geo-optimization/", label: "智引未来GEO" },
{ href: "/services/smo-optimization/", label: "智引未来SMO" },
{ href: "/services/ai-website/", label: "AI官网搭建" },
{ href: "/services/content-operations/", label: "公众号内容运营" },
] },
{ href: "/about/", label: "关于我们", children: [{ href: "/about/#position", label: "公司定位" }, { href: "/about/#advantages", label: "核心优势" }, { href: "/about/#technology", label: "自研技术" }] },
{ href: "/articles/", label: "洞察中心", children: [{ href: "/articles/", label: "全部文章" }] },
{ href: "/methodology/", label: "服务方法", children: [{ href: "/methodology/#workflow", label: "服务闭环" }, { href: "/methodology/#delivery", label: "交付方式" }] },
{ href: "/faq/", label: "常见问题", children: [{ href: "/faq/", label: "GEO与SMO FAQ" }] },
{ href: "/contact/", label: "联系我们", children: [{ href: "/contact/", label: "联系方式" }, { href: "tel:17391783779", label: "电话咨询" }] },
],
} as const;
---
import "../styles/global.css";
import logo from "../../pic/智引未来GEO_透明背景_矢量版.svg";
import favicon from "../../pic/智引未来GEO_原始版本_渐变背景.png";
import { getImage } from "astro:assets";
import { site } from "../data/site";
import ContactDialog from "../components/ContactDialog.astro";
interface Props {
title: string;
description?: string;
keywords?: string | readonly string[];
image?: string;
imageAlt?: string;
ogType?: "website" | "article";
noindex?: boolean;
publishedTime?: string;
modifiedTime?: string;
articleSection?: string;
articleAuthor?: string;
jsonLd?: Record<string, unknown> | Record<string, unknown>[];
}
const {
title,
description = site.seo.description,
keywords = site.seo.keywords,
image = "/og-cover.svg",
imageAlt = site.seo.imageAlt,
ogType = "website",
noindex = false,
publishedTime,
modifiedTime,
articleSection,
articleAuthor,
jsonLd = [],
} = Astro.props;
const cleanMeta = (value: string) => value.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
const metaTitle = cleanMeta(title);
const metaDescription = cleanMeta(description);
const metaKeywords = (typeof keywords === "string" ? keywords.split(",") : keywords)
.map((keyword) => cleanMeta(keyword))
.filter(Boolean)
.join(",");
const optimizedLogo = await getImage({ src: logo, width: 420, format: "png" });
const optimizedFavicon = await getImage({ src: favicon, width: 128, height: 128, format: "png" });
const canonical = new URL(Astro.url.pathname, Astro.site).href;
const ogImage = new URL(image, Astro.site).href;
const organizationLd = {
"@context": "https://schema.org",
"@type": ["ProfessionalService", "Organization"],
"@id": new URL("/#organization", Astro.site).href,
name: site.brand.name,
alternateName: [site.brand.englishName],
legalName: site.brand.legalName,
url: new URL("/", Astro.site).href,
logo: new URL(optimizedLogo.src, Astro.site).href,
slogan: site.brand.tagline,
description: site.home.subhead,
telephone: site.contact.phone,
email: site.contact.email,
address: {
"@type": "PostalAddress",
streetAddress: site.contact.address,
addressLocality: site.contact.locality,
addressRegion: site.contact.region,
addressCountry: "CN",
},
};
const websiteLd = {
"@context": "https://schema.org",
"@type": "WebSite",
"@id": new URL("/#website", Astro.site).href,
url: new URL("/", Astro.site).href,
name: site.brand.name,
alternateName: site.brand.englishName,
inLanguage: "zh-CN",
publisher: { "@id": new URL("/#organization", Astro.site).href },
};
const webPageLd = {
"@context": "https://schema.org",
"@type": "WebPage",
"@id": `${canonical}#webpage`,
url: canonical,
name: metaTitle,
description: metaDescription,
inLanguage: "zh-CN",
isPartOf: { "@id": new URL("/#website", Astro.site).href },
about: { "@id": new URL("/#organization", Astro.site).href },
primaryImageOfPage: { "@type": "ImageObject", url: ogImage, caption: imageAlt },
};
const pageLd = Array.isArray(jsonLd) ? jsonLd : [jsonLd];
const allLd = [organizationLd, websiteLd, webPageLd, ...pageLd.filter((item) => Object.keys(item).length > 0)];
const serializedLd = JSON.stringify(allLd).replace(/</g, "\\u003c");
---
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#FFFFFF" />
<meta name="color-scheme" content="light" />
<title>{metaTitle}</title>
<meta name="description" content={metaDescription} />
<meta name="keywords" content={metaKeywords} />
<meta name="robots" content={noindex ? "noindex,nofollow" : "index,follow,max-image-preview:large,max-snippet:-1,max-video-preview:-1"} />
<link rel="canonical" href={canonical} />
<link rel="icon" href={optimizedFavicon.src} type="image/png" sizes="128x128" />
<link rel="apple-touch-icon" href={optimizedFavicon.src} />
<link rel="manifest" href="/site.webmanifest" />
<link rel="alternate" hreflang="zh-CN" href={canonical} />
<link rel="alternate" hreflang="x-default" href={canonical} />
<meta property="og:type" content={ogType} />
<meta property="og:title" content={metaTitle} />
<meta property="og:description" content={metaDescription} />
<meta property="og:url" content={canonical} />
<meta property="og:image" content={ogImage} />
<meta property="og:image:alt" content={imageAlt} />
<meta property="og:site_name" content={site.brand.name} />
<meta property="og:locale" content="zh_CN" />
{publishedTime && <meta property="article:published_time" content={publishedTime} />}
{modifiedTime && <meta property="article:modified_time" content={modifiedTime} />}
{articleSection && <meta property="article:section" content={articleSection} />}
{articleAuthor && <meta property="article:author" content={articleAuthor} />}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={metaTitle} />
<meta name="twitter:description" content={metaDescription} />
<meta name="twitter:image" content={ogImage} />
<script type="application/ld+json" set:html={serializedLd} is:inline></script>
</head>
<body>
<a class="skip-link" href="#main-content">跳到主要内容</a>
<slot />
<ContactDialog />
<script is:inline>
const header = document.querySelector('[data-header]');
const syncHeader = () => header?.classList.toggle('is-scrolled', window.scrollY > 12);
addEventListener('scroll', syncHeader, { passive: true }); syncHeader();
const observer = 'IntersectionObserver' in window ? new IntersectionObserver((entries) => entries.forEach((entry) => {
if (entry.isIntersecting) { entry.target.classList.add('is-visible'); observer.unobserve(entry.target); }
}), { threshold: 0.08 }) : null;
document.querySelectorAll('[data-reveal]').forEach((el) => observer ? observer.observe(el) : el.classList.add('is-visible'));
document.querySelectorAll('[data-mobile-nav] a').forEach((link) => link.addEventListener('click', () => link.closest('details')?.removeAttribute('open')));
const contactDialog = document.querySelector('[data-contact-dialog]');
const isMobileDevice = () => matchMedia('(max-width: 760px), (hover: none) and (pointer: coarse)').matches;
document.addEventListener('click', (event) => {
const trigger = event.target.closest('[data-open-contact]');
const phoneLink = event.target.closest('a[href^="tel:"]');
if (!contactDialog || (!trigger && (!phoneLink || isMobileDevice()))) return;
event.preventDefault();
contactDialog.showModal();
});
contactDialog?.querySelector('[data-contact-dialog-close]')?.addEventListener('click', () => contactDialog.close());
contactDialog?.addEventListener('click', (event) => { if (event.target === contactDialog) contactDialog.close(); });
</script>
</body>
</html>
import crypto from "node:crypto";
import path from "node:path";
import fs from "node:fs/promises";
import matter from "gray-matter";
import { marked } from "marked";
const ROOT = process.cwd();
const DATA_ROOT = process.env.CMS_DATA_DIR ? path.resolve(process.env.CMS_DATA_DIR) : null;
const SOURCE_ARTICLES_DIR = path.join(ROOT, "src", "content", "articles");
const SOURCE_PUBLISHED_DIR = path.join(ROOT, "src", "content", "published");
export const ARTICLES_DIR = DATA_ROOT ? path.join(DATA_ROOT, "articles") : path.join(ROOT, "src", "content", "articles");
export const PUBLISHED_DIR = DATA_ROOT ? path.join(DATA_ROOT, "published") : path.join(ROOT, "src", "content", "published");
export const CATEGORIES_FILE = DATA_ROOT ? path.join(DATA_ROOT, "categories.json") : path.join(ROOT, "src", "content", "categories.json");
export const UPLOADS_DIR = DATA_ROOT ? path.join(DATA_ROOT, "uploads") : path.join(ROOT, "public", "uploads");
const DEFAULT_CATEGORIES = ["GEO洞察", "SMO增长", "AI搜索", "品牌内容"];
const DEFAULT_AUTHOR = "智引未来";
const CATEGORY_SLUGS: Record<string, string> = {
GEO洞察: "geo-insights",
SMO增长: "smo-growth",
AI搜索: "ai-search",
品牌内容: "brand-content",
};
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
export type PublishStatus = "new-draft" | "edited-draft" | "live";
export interface StoredArticle {
slug: string;
title: string;
date: string;
updated: string;
category: string;
author: string;
excerpt: string;
status: "draft" | "published";
body: string;
}
export interface Article {
id: string;
data: {
title: string;
slug: string;
date: Date;
updated: Date;
category: string;
author: string;
excerpt: string;
status: "published";
};
body: string;
}
export interface CategoryStat {
name: string;
count: number;
}
export interface ContentSnapshot {
restore: () => Promise<void>;
}
export class StoreError extends Error {
status: number;
details?: Record<string, unknown>;
constructor(message: string, status = 400, details?: Record<string, unknown>) {
super(message);
this.status = status;
this.details = details;
}
}
export const safeSlug = (slug: unknown): string | null => typeof slug === "string" && SLUG_RE.test(slug) ? slug : null;
export const fmtDate = (value?: string | Date): string => {
const date = value instanceof Date ? value : new Date(value || Date.now());
return Number.isNaN(date.valueOf()) ? new Date().toISOString().slice(0, 10) : date.toISOString().slice(0, 10);
};
const autoExcerpt = (body: string, fallback: string): string => {
const plain = String(body || "")
.replace(/!\[[^\]]*\]\([^)]*\)/g, " ")
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
.replace(/<[^>]+>/g, " ")
.replace(/[`*_>#~|\-]+/g, " ")
.replace(/\s+/g, " ")
.trim();
const text = plain || String(fallback || "").trim();
return text.length > 120 ? `${text.slice(0, 120).trim()}…` : text;
};
function serialize(data: StoredArticle, body: string): string {
const quote = (value: unknown) => JSON.stringify(value == null ? "" : String(value));
return [
"---",
`title: ${quote(data.title)}`,
`slug: ${quote(data.slug)}`,
`date: ${fmtDate(data.date)}`,
`updated: ${fmtDate(data.updated || data.date)}`,
`category: ${quote(data.category)}`,
`author: ${quote(data.author || DEFAULT_AUTHOR)}`,
`excerpt: ${quote(data.excerpt)}`,
`status: ${quote(data.status || "draft")}`,
"---",
"",
String(body || "").trim(),
"",
].join("\n");
}
async function fileExists(file: string): Promise<boolean> {
try { await fs.access(file); return true; } catch { return false; }
}
async function writeAtomic(file: string, content: string | Buffer): Promise<void> {
await fs.mkdir(path.dirname(file), { recursive: true });
const temporary = `${file}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
try {
await fs.writeFile(temporary, content);
await fs.rename(temporary, file);
} catch (error) {
await fs.unlink(temporary).catch(() => {});
throw error;
}
}
async function ensureStore(): Promise<void> {
await Promise.all([
fs.mkdir(ARTICLES_DIR, { recursive: true }),
fs.mkdir(PUBLISHED_DIR, { recursive: true }),
fs.mkdir(UPLOADS_DIR, { recursive: true }),
]);
if (DATA_ROOT) {
const seedDirectory = async (source: string, target: string) => {
const current = await fs.readdir(target);
if (current.some((file) => file.endsWith(".md"))) return;
const seeds = await fs.readdir(source).catch(() => [] as string[]);
await Promise.all(seeds.filter((file) => file.endsWith(".md")).map((file) => fs.copyFile(path.join(source, file), path.join(target, file))));
};
await Promise.all([
seedDirectory(SOURCE_ARTICLES_DIR, ARTICLES_DIR),
seedDirectory(SOURCE_PUBLISHED_DIR, PUBLISHED_DIR),
]);
}
if (!await fileExists(CATEGORIES_FILE)) {
await writeAtomic(CATEGORIES_FILE, `${JSON.stringify(DEFAULT_CATEGORIES, null, 2)}\n`);
}
}
export async function getCategoryNames(): Promise<string[]> {
await ensureStore();
try {
const parsed: unknown = JSON.parse(await fs.readFile(CATEGORIES_FILE, "utf8"));
const names = Array.isArray(parsed)
? parsed.map((value) => String(value).replace(/\s+/g, " ").trim()).filter(Boolean)
: [];
return [...new Set(names)].length ? [...new Set(names)] : [...DEFAULT_CATEGORIES];
} catch {
return [...DEFAULT_CATEGORIES];
}
}
async function saveCategories(categories: string[]): Promise<void> {
await writeAtomic(CATEGORIES_FILE, `${JSON.stringify(categories, null, 2)}\n`);
}
function normalizeCategoryName(value: unknown): string {
const name = String(value || "").replace(/\s+/g, " ").trim();
if (!name) throw new StoreError("请输入分类名称");
if (name.length > 20) throw new StoreError("分类名称不能超过 20 个字");
return name;
}
export async function addCategory(value: unknown): Promise<string[]> {
const name = normalizeCategoryName(value);
const categories = await getCategoryNames();
if (categories.includes(name)) throw new StoreError("该分类已经存在", 409);
const next = [...categories, name];
await saveCategories(next);
return next;
}
export async function readArticleFrom(directory: string, slug: string): Promise<StoredArticle> {
const raw = await fs.readFile(path.join(directory, `${slug}.md`), "utf8");
const { data, content } = matter(raw);
return {
slug,
title: String(data.title || ""),
date: fmtDate(data.date),
updated: fmtDate(data.updated || data.date),
category: String(data.category || ""),
author: String(data.author || DEFAULT_AUTHOR),
excerpt: String(data.excerpt || ""),
status: data.status === "draft" ? "draft" : "published",
body: content.trim(),
};
}
export const readWorkingArticle = (slug: string) => readArticleFrom(ARTICLES_DIR, slug);
async function markdownFiles(directory: string): Promise<string[]> {
await ensureStore();
return (await fs.readdir(directory)).filter((file) => file.endsWith(".md"));
}
async function snapshotDirectory(directory: string): Promise<Map<string, string>> {
const snapshot = new Map<string, string>();
for (const filename of await markdownFiles(directory)) {
snapshot.set(filename, await fs.readFile(path.join(directory, filename), "utf8"));
}
return snapshot;
}
async function restoreDirectory(directory: string, snapshot: Map<string, string>): Promise<void> {
for (const filename of await markdownFiles(directory)) {
if (!snapshot.has(filename)) await fs.unlink(path.join(directory, filename));
}
for (const [filename, content] of snapshot) await writeAtomic(path.join(directory, filename), content);
}
export async function createContentSnapshot(): Promise<ContentSnapshot> {
await ensureStore();
const articles = await snapshotDirectory(ARTICLES_DIR);
const published = await snapshotDirectory(PUBLISHED_DIR);
const categories = await fs.readFile(CATEGORIES_FILE, "utf8");
return {
restore: async () => {
await restoreDirectory(ARTICLES_DIR, articles);
await restoreDirectory(PUBLISHED_DIR, published);
await writeAtomic(CATEGORIES_FILE, categories);
},
};
}
const sameArticleContent = (left: StoredArticle, right: StoredArticle): boolean =>
["slug", "title", "date", "category", "author", "excerpt", "body"]
.every((key) => String(left[key as keyof StoredArticle] ?? "") === String(right[key as keyof StoredArticle] ?? ""));
export async function getPublishStatus(article: StoredArticle): Promise<PublishStatus> {
const liveFile = path.join(PUBLISHED_DIR, `${article.slug}.md`);
if (!await fileExists(liveFile)) return "new-draft";
const liveArticle = await readArticleFrom(PUBLISHED_DIR, article.slug);
return sameArticleContent(article, liveArticle) ? "live" : "edited-draft";
}
export async function listWorkingArticles(): Promise<Array<Omit<StoredArticle, "body"> & { publishStatus: PublishStatus }>> {
const articles = await Promise.all((await markdownFiles(ARTICLES_DIR)).map(async (file) => {
const article = await readWorkingArticle(file.replace(/\.md$/, ""));
const { body: _body, ...meta } = article;
return { ...meta, publishStatus: await getPublishStatus(article) };
}));
return articles.sort((a, b) => b.updated.localeCompare(a.updated) || b.date.localeCompare(a.date));
}
export async function writeArticle(slug: string, input: Record<string, unknown>, isNew = false): Promise<StoredArticle> {
await ensureStore();
const file = path.join(ARTICLES_DIR, `${slug}.md`);
if (isNew && await fileExists(file)) throw new StoreError("该网址标识已存在", 409);
const existing = !isNew && await fileExists(file) ? await readWorkingArticle(slug) : null;
const categories = await getCategoryNames();
const body = String(input.body || "").trim();
const normalized: StoredArticle = {
title: String(input.title || "").trim(),
slug,
date: existing?.date || fmtDate(),
updated: fmtDate(),
category: categories.includes(String(input.category)) ? String(input.category) : categories[0],
author: DEFAULT_AUTHOR,
excerpt: autoExcerpt(body, String(input.title || "")),
status: "draft",
body,
};
const liveFile = path.join(PUBLISHED_DIR, `${slug}.md`);
if (await fileExists(liveFile)) {
const liveArticle = await readArticleFrom(PUBLISHED_DIR, slug);
if (sameArticleContent(normalized, liveArticle)) {
normalized.status = "published";
normalized.updated = liveArticle.updated;
}
}
await writeAtomic(file, serialize(normalized, body));
return normalized;
}
export async function generateSlug(category: unknown, date = fmtDate()): Promise<string> {
await ensureStore();
const prefix = CATEGORY_SLUGS[String(category)] || "silver-journal";
const base = `${prefix}-${date.replaceAll("-", "")}`;
let slug = base;
let suffix = 2;
while (await fileExists(path.join(ARTICLES_DIR, `${slug}.md`)) || await fileExists(path.join(PUBLISHED_DIR, `${slug}.md`))) {
slug = `${base}-${suffix++}`;
}
return slug;
}
async function restoreFile(file: string, content: string | null): Promise<void> {
if (content === null) await fs.unlink(file).catch(() => {});
else await writeAtomic(file, content);
}
export async function publishArticle(slug: string): Promise<void> {
const article = await readWorkingArticle(slug);
const published: StoredArticle = { ...article, status: "published", updated: fmtDate() };
const text = serialize(published, article.body);
const draftFile = path.join(ARTICLES_DIR, `${slug}.md`);
const liveFile = path.join(PUBLISHED_DIR, `${slug}.md`);
const previousDraft = await fs.readFile(draftFile, "utf8");
const previousLive = await fileExists(liveFile) ? await fs.readFile(liveFile, "utf8") : null;
try {
await writeAtomic(liveFile, text);
await writeAtomic(draftFile, text);
} catch (error) {
await restoreFile(draftFile, previousDraft);
await restoreFile(liveFile, previousLive);
throw error;
}
}
export async function unpublishArticle(slug: string): Promise<void> {
const draftFile = path.join(ARTICLES_DIR, `${slug}.md`);
const liveFile = path.join(PUBLISHED_DIR, `${slug}.md`);
const previousDraft = await fs.readFile(draftFile, "utf8");
const previousLive = await fs.readFile(liveFile, "utf8");
const article = await readWorkingArticle(slug);
try {
await writeAtomic(draftFile, serialize({ ...article, status: "draft" }, article.body));
await fs.unlink(liveFile);
} catch (error) {
await restoreFile(draftFile, previousDraft);
await restoreFile(liveFile, previousLive);
throw error;
}
}
export async function deleteArticle(slug: string): Promise<void> {
const files = [path.join(ARTICLES_DIR, `${slug}.md`), path.join(PUBLISHED_DIR, `${slug}.md`)];
const backups: Array<{ file: string; content: string }> = [];
for (const file of files) if (await fileExists(file)) backups.push({ file, content: await fs.readFile(file, "utf8") });
if (!backups.length) throw new StoreError("文章不存在", 404);
try {
for (const { file } of backups) await fs.unlink(file);
} catch (error) {
for (const { file, content } of backups) await writeAtomic(file, content);
throw error;
}
}
export async function discardDraft(slug: string): Promise<{ removed: boolean; publishStatus: PublishStatus | null }> {
const liveFile = path.join(PUBLISHED_DIR, `${slug}.md`);
const draftFile = path.join(ARTICLES_DIR, `${slug}.md`);
if (await fileExists(liveFile)) {
await fs.copyFile(liveFile, draftFile);
return { removed: false, publishStatus: "live" };
}
await fs.unlink(draftFile);
return { removed: true, publishStatus: null };
}
async function categoryArticleFiles(category: string): Promise<Array<{ file: string; article: StoredArticle; raw: string }>> {
const results: Array<{ file: string; article: StoredArticle; raw: string }> = [];
for (const directory of [ARTICLES_DIR, PUBLISHED_DIR]) {
for (const filename of await markdownFiles(directory)) {
const slug = filename.replace(/\.md$/, "");
const article = await readArticleFrom(directory, slug);
if (article.category === category) {
const file = path.join(directory, filename);
results.push({ file, article, raw: await fs.readFile(file, "utf8") });
}
}
}
return results;
}
export async function getCategoryStats(): Promise<CategoryStat[]> {
const categories = await getCategoryNames();
const seen = new Map<string, Set<string>>(categories.map((name) => [name, new Set()]));
for (const directory of [ARTICLES_DIR, PUBLISHED_DIR]) {
for (const filename of await markdownFiles(directory)) {
const slug = filename.replace(/\.md$/, "");
const article = await readArticleFrom(directory, slug);
if (!seen.has(article.category)) seen.set(article.category, new Set());
seen.get(article.category)?.add(slug);
}
}
return categories.map((name) => ({ name, count: seen.get(name)?.size || 0 }));
}
async function updateCategoryArticles(current: string, replacement: string, nextCategories: string[]): Promise<void> {
const affected = await categoryArticleFiles(current);
const previousCategories = await fs.readFile(CATEGORIES_FILE, "utf8");
try {
for (const item of affected) {
const updated = { ...item.article, category: replacement };
await writeAtomic(item.file, serialize(updated, updated.body));
}
await saveCategories(nextCategories);
} catch (error) {
for (const item of affected) await writeAtomic(item.file, item.raw);
await writeAtomic(CATEGORIES_FILE, previousCategories);
throw error;
}
}
export async function renameCategory(currentValue: unknown, nextValue: unknown): Promise<string[]> {
const current = normalizeCategoryName(currentValue);
const nextName = normalizeCategoryName(nextValue);
const categories = await getCategoryNames();
if (!categories.includes(current)) throw new StoreError("分类不存在", 404);
if (current !== nextName && categories.includes(nextName)) throw new StoreError("该分类已经存在", 409);
if (current === nextName) return categories;
const next = categories.map((name) => name === current ? nextName : name);
await updateCategoryArticles(current, nextName, next);
return next;
}
export async function removeCategory(value: unknown, replacementValue: unknown): Promise<string[]> {
const name = normalizeCategoryName(value);
const categories = await getCategoryNames();
if (!categories.includes(name)) throw new StoreError("分类不存在", 404);
if (categories.length <= 1) throw new StoreError("至少需要保留一个文章分类", 409);
const affected = await categoryArticleFiles(name);
const count = new Set(affected.map((item) => item.article.slug)).size;
const replacement = String(replacementValue || "").trim();
if (count > 0 && (!replacement || !categories.includes(replacement) || replacement === name)) {
throw new StoreError("请先选择这些文章要迁移到的分类", 409, { requiresReplacement: true, count });
}
const next = categories.filter((category) => category !== name);
await updateCategoryArticles(name, replacement, next);
return next;
}
export async function getPublishedArticles(): Promise<Article[]> {
const items = await Promise.all((await markdownFiles(PUBLISHED_DIR)).map(async (file) => {
const article = await readArticleFrom(PUBLISHED_DIR, file.replace(/\.md$/, ""));
return {
id: article.slug,
data: {
title: article.title,
slug: article.slug,
date: new Date(article.date),
updated: new Date(article.updated),
category: article.category,
author: article.author,
excerpt: article.excerpt,
status: "published" as const,
},
body: article.body,
};
}));
return items.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
}
export async function getPublishedArticle(slug: string): Promise<(Article & { html: string }) | null> {
if (!safeSlug(slug)) return null;
try {
const article = await readArticleFrom(PUBLISHED_DIR, slug);
return {
id: article.slug,
data: {
title: article.title,
slug: article.slug,
date: new Date(article.date),
updated: new Date(article.updated),
category: article.category,
author: article.author,
excerpt: article.excerpt,
status: "published",
},
body: article.body,
html: await marked.parse(article.body),
};
} catch (error) {
if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;
throw error;
}
}
export async function saveUpload(dataUrl: unknown): Promise<string> {
await ensureStore();
const extensions: Record<string, string> = { "image/png": "png", "image/jpeg": "jpg", "image/webp": "webp", "image/gif": "gif" };
const match = String(dataUrl || "").match(/^data:([^;]+);base64,(.+)$/s);
if (!match || !extensions[match[1]]) throw new StoreError("仅支持 PNG、JPG、WEBP 或 GIF 图片");
const buffer = Buffer.from(match[2], "base64");
if (buffer.length > 20 * 1024 * 1024) throw new StoreError("图片不能超过 20MB", 413);
const name = `${Date.now()}-${crypto.randomBytes(4).toString("hex")}.${extensions[match[1]]}`;
await writeAtomic(path.join(UPLOADS_DIR, name), buffer);
return `/uploads/${name}`;
}
export async function removeUpload(url: unknown): Promise<void> {
const match = String(url || "").match(/^\/uploads\/([a-zA-Z0-9._-]+)$/);
if (!match) throw new StoreError("图片地址不合法");
await fs.unlink(path.join(UPLOADS_DIR, match[1])).catch((error: NodeJS.ErrnoException) => {
if (error.code !== "ENOENT") throw error;
});
}
import { getCategoryNames as readCategoryNames, getPublishedArticles as readPublishedArticles, type Article } from "./article-store";
export type { Article };
export const PAGE_SIZE = 9;
const CATEGORY_SLUGS: Record<string, string> = {
GEO洞察: "geo-insights",
SMO增长: "smo-growth",
AI搜索: "ai-search",
品牌内容: "brand-content",
};
function fallbackSlug(category: string): string {
const ascii = category.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
if (ascii) return ascii;
let hash = 0;
for (const char of category) hash = (hash * 31 + (char.codePointAt(0) ?? 0)) >>> 0;
return `c${hash.toString(36)}`;
}
export const categoryToSlug = (category: string) => CATEGORY_SLUGS[category] ?? fallbackSlug(category);
export function slugToCategory(slug: string, categories: string[]): string | undefined {
return categories.find((category) => categoryToSlug(category) === slug);
}
export async function getPublishedArticles(): Promise<Article[]> {
return readPublishedArticles();
}
export async function getCategoryNames(): Promise<string[]> {
return readCategoryNames();
}
export interface CategoryInfo {
name: string;
slug: string;
count: number;
}
export function getCategories(items: Article[], categoryNames: string[] = []): CategoryInfo[] {
const counts = new Map<string, number>(categoryNames.map((name) => [name, 0]));
for (const item of items) counts.set(item.data.category, (counts.get(item.data.category) ?? 0) + 1);
return [...counts.entries()]
.map(([name, count]) => ({ name, slug: categoryToSlug(name), count }))
.sort((a, b) => b.count - a.count || a.name.localeCompare(b.name, "zh-CN"));
}
export const lastPageOf = (total: number, pageSize = PAGE_SIZE) => Math.max(1, Math.ceil(total / pageSize));
export const pageSlice = <T>(items: T[], page: number, pageSize = PAGE_SIZE) => items.slice((page - 1) * pageSize, page * pageSize);
export const fmtDate = (date: Date) => date.toISOString().slice(0, 10);
export function paginationWindow(current: number, last: number, span = 2): number[] {
const pages = new Set<number>([1, last]);
for (let page = current - span; page <= current + span; page++) if (page >= 1 && page <= last) pages.add(page);
const sorted = [...pages].sort((a, b) => a - b);
const result: number[] = [];
let previous = 0;
for (const page of sorted) {
if (previous && page - previous > 1) result.push(0);
result.push(page);
previous = page;
}
return result;
}
import crypto from "node:crypto";
import { marked } from "marked";
import {
StoreError,
addCategory,
createContentSnapshot,
deleteArticle,
discardDraft,
generateSlug,
getCategoryNames,
getCategoryStats,
getPublishStatus,
listWorkingArticles,
publishArticle,
readWorkingArticle,
removeUpload,
removeCategory,
renameCategory,
safeSlug,
saveUpload,
unpublishArticle,
writeArticle,
} from "./article-store";
import { convertWordToMarkdown, decodeWordDataUrl } from "./word-import";
import { currentSessionVersion, savePassword, verifyPassword } from "./cms-auth";
import { buildSiteAtomic, tryAcquireSiteBuildLock, withSiteBuildLock } from "../../scripts/site-build.mjs";
const SECRET = process.env.CMS_SECRET || crypto.randomBytes(32).toString("hex");
const API_KEY = process.env.CMS_API_KEY || "";
const CAPTCHA_TTL = 5 * 60 * 1000;
const CAPTCHA_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
const MAX_LOGIN_FAILURES = 5;
const LOGIN_FAILURE_WINDOW = 10 * 60 * 1000;
const LOGIN_BLOCK_DURATION = 10 * 60 * 1000;
const loginAttempts = new Map<string, { count: number; first: number; blockedUntil: number }>();
type BuildState = {
status: "idle" | "building" | "success" | "error";
ok: boolean | null;
log: string;
startedAt: string | null;
finishedAt: string | null;
};
let buildState: BuildState = { status: "idle", ok: null, log: "", startedAt: null, finishedAt: null };
const json = (data: unknown, status = 200, headers?: HeadersInit) => Response.json(data, { status, headers });
const safeEqual = (leftValue: unknown, rightValue: unknown): boolean => {
const left = Buffer.from(String(leftValue));
const right = Buffer.from(String(rightValue));
return left.length === right.length && crypto.timingSafeEqual(left, right);
};
const sessionToken = async () => crypto.createHmac("sha256", SECRET)
.update(`zhiyinweilai-cms-v2:${await currentSessionVersion()}`)
.digest("hex");
function cookies(request: Request): Record<string, string> {
return Object.fromEntries((request.headers.get("cookie") || "").split(";").filter(Boolean).map((part) => {
const index = part.indexOf("=");
return [part.slice(0, index).trim(), decodeURIComponent(part.slice(index + 1).trim())];
}));
}
function apiKeyValid(request: Request): boolean {
if (!API_KEY) return false;
const auth = request.headers.get("authorization")?.match(/^Bearer\s+(.+)$/i)?.[1];
const key = auth || request.headers.get("x-api-key");
return key ? safeEqual(key, API_KEY) : false;
}
const sessionAuthed = async (request: Request): Promise<boolean> => {
const token = cookies(request).cms_session;
return Boolean(token && safeEqual(token, await sessionToken()));
};
const authed = async (request: Request): Promise<boolean> => await sessionAuthed(request) || apiKeyValid(request);
async function bodyOf(request: Request): Promise<Record<string, unknown>> {
try { return await request.json(); } catch { return {}; }
}
function cookieHeader(request: Request, name: string, value: string, maxAge: number): string {
const forwarded = request.headers.get("x-forwarded-proto");
const secure = new URL(request.url).protocol === "https:" || forwarded === "https";
return `${name}=${value}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${maxAge}${secure ? "; Secure" : ""}`;
}
function loginBlockedFor(ip: string): number {
const state = loginAttempts.get(ip);
return state?.blockedUntil && state.blockedUntil > Date.now()
? Math.ceil((state.blockedUntil - Date.now()) / 1000)
: 0;
}
function loginFailed(ip: string): void {
const now = Date.now();
let state = loginAttempts.get(ip);
if (!state || now - state.first > LOGIN_FAILURE_WINDOW) {
state = { count: 0, first: now, blockedUntil: 0 };
}
state.count += 1;
if (state.count >= MAX_LOGIN_FAILURES) state.blockedUntil = now + LOGIN_BLOCK_DURATION;
loginAttempts.set(ip, state);
}
function randomCaptcha(length = 4): string {
let code = "";
for (let index = 0; index < length; index += 1) {
code += CAPTCHA_CHARS[crypto.randomInt(CAPTCHA_CHARS.length)];
}
return code;
}
function captchaMac(code: unknown, expiresAt: number): string {
return crypto.createHmac("sha256", SECRET)
.update(`${String(code).toUpperCase()}|${expiresAt}`)
.digest("hex");
}
function captchaValid(request: Request, answer: unknown): boolean {
const value = cookies(request).cms_captcha;
if (!value || !answer) return false;
const separator = value.lastIndexOf(".");
const expiresAt = Number(value.slice(0, separator));
const mac = value.slice(separator + 1);
return Boolean(expiresAt && Date.now() <= expiresAt && safeEqual(mac, captchaMac(answer, expiresAt)));
}
function captchaSvg(code: string): string {
const width = 132;
const height = 46;
const colors = ["#8E1C17", "#6F1511", "#D1251A", "#5c3a2e"];
const randomBetween = (min: number, max: number) => crypto.randomInt(min, max + 1);
const pick = <T>(items: T[]): T => items[crypto.randomInt(items.length)];
let content = `<rect width="${width}" height="${height}" fill="#F4E6D6"/>`;
for (let index = 0; index < 4; index += 1) {
content += `<line x1="${randomBetween(0, width)}" y1="${randomBetween(0, height)}" x2="${randomBetween(0, width)}" y2="${randomBetween(0, height)}" stroke="${pick(colors)}" stroke-width="1" opacity="0.45"/>`;
}
[...code].forEach((character, index) => {
const x = 16 + index * 28 + randomBetween(-3, 3);
const y = 31 + randomBetween(-4, 4);
const rotation = randomBetween(-26, 26);
content += `<text x="${x}" y="${y}" font-family="Georgia,serif" font-weight="700" font-size="${randomBetween(24, 30)}" fill="${pick(colors)}" transform="rotate(${rotation} ${x} ${y})">${character}</text>`;
});
for (let index = 0; index < 26; index += 1) {
content += `<circle cx="${randomBetween(0, width)}" cy="${randomBetween(0, height)}" r="1" fill="${pick(colors)}" opacity="0.5"/>`;
}
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">${content}</svg>`;
}
function requireSlug(value: string | undefined): string {
const slug = safeSlug(value);
if (!slug) throw new StoreError("网址标识不合法");
return slug;
}
async function startContentBuild(change: () => Promise<void>): Promise<boolean> {
if (buildState.status === "building") return false;
const releaseLock = await tryAcquireSiteBuildLock();
if (!releaseLock) return false;
buildState = { status: "building", ok: null, log: "", startedAt: new Date().toISOString(), finishedAt: null };
void (async () => {
const snapshot = await createContentSnapshot();
try {
await change();
const log = await buildSiteAtomic();
buildState = { status: "success", ok: true, log, startedAt: buildState.startedAt, finishedAt: new Date().toISOString() };
} catch (error) {
let rollbackMessage = "";
try { await snapshot.restore(); } catch (rollbackError) {
rollbackMessage = `\n内容回滚失败:${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`;
}
const message = error instanceof Error ? error.message : String(error);
const log = typeof error === "object" && error && "log" in error ? String(error.log || "") : "";
buildState = {
status: "error",
ok: false,
log: `${log}${log ? "\n" : ""}${message}${rollbackMessage}`,
startedAt: buildState.startedAt,
finishedAt: new Date().toISOString(),
};
}
})().finally(releaseLock).catch((error) => {
buildState = {
status: "error",
ok: false,
log: error instanceof Error ? error.message : String(error),
startedAt: buildState.startedAt,
finishedAt: new Date().toISOString(),
};
});
return true;
}
async function startOrConflict(change: () => Promise<void>): Promise<Response> {
if (!await startContentBuild(change)) {
return json({ error: "网站正在部署或生成静态页面,本次操作未受理,请稍后重试" }, 409, { "Retry-After": "5" });
}
return json({ ok: true, status: "building" });
}
export async function handleCmsApi(request: Request, routeValue: string, clientAddress = "unknown"): Promise<Response> {
const route = routeValue.replace(/^\/+|\/+$/g, "");
const parts = route.split("/").filter(Boolean);
const method = request.method.toUpperCase();
try {
if (route === "captcha" && method === "GET") {
const code = randomCaptcha();
const expiresAt = Date.now() + CAPTCHA_TTL;
return new Response(captchaSvg(code), {
headers: {
"Cache-Control": "no-store",
"Content-Type": "image/svg+xml; charset=utf-8",
"Set-Cookie": cookieHeader(request, "cms_captcha", `${expiresAt}.${captchaMac(code, expiresAt)}`, CAPTCHA_TTL / 1000),
},
});
}
if (route === "session") {
if (method === "GET") return json({ authed: await authed(request) });
if (method === "POST") {
const blockedFor = loginBlockedFor(clientAddress);
if (blockedFor) return json({ error: `尝试过于频繁,请 ${Math.ceil(blockedFor / 60)} 分钟后再试` }, 429);
const body = await bodyOf(request);
const clearCaptcha = cookieHeader(request, "cms_captcha", "", 0);
if (!captchaValid(request, body.captcha)) {
return json({ error: "验证码错误或已过期" }, 400, { "Set-Cookie": clearCaptcha });
}
if (!await verifyPassword(body.password)) {
loginFailed(clientAddress);
return json({ error: "管理密码错误" }, 401, { "Set-Cookie": clearCaptcha });
}
loginAttempts.delete(clientAddress);
const headers = new Headers();
headers.append("Set-Cookie", clearCaptcha);
headers.append("Set-Cookie", cookieHeader(request, "cms_session", await sessionToken(), 86400));
return json({ ok: true }, 200, headers);
}
if (method === "DELETE") return json({ ok: true }, 200, { "Set-Cookie": cookieHeader(request, "cms_session", "", 0) });
}
if (route === "account/password" && method === "PUT") {
if (!await sessionAuthed(request)) throw new StoreError("请先登录文章后台", 401);
const body = await bodyOf(request);
const currentPassword = String(body.currentPassword || "");
const newPassword = String(body.newPassword || "");
if (!await verifyPassword(currentPassword)) throw new StoreError("当前密码错误", 401);
if (newPassword.length < 5) throw new StoreError("新密码至少需要 5 个字符");
if (newPassword.length > 128) throw new StoreError("新密码不能超过 128 个字符");
if (safeEqual(currentPassword, newPassword)) throw new StoreError("新密码不能与当前密码相同");
await savePassword(newPassword);
return json({ ok: true, requiresLogin: true }, 200, {
"Set-Cookie": cookieHeader(request, "cms_session", "", 0),
});
}
if (!await authed(request)) throw new StoreError("请先登录文章后台", 401);
if (route === "categories") {
if (method === "GET") return json({ categories: await getCategoryNames(), stats: await getCategoryStats() });
const body = await bodyOf(request);
if (method === "POST") {
return startOrConflict(async () => { await addCategory(body.name); });
}
if (method === "PATCH") {
return startOrConflict(async () => { await renameCategory(body.current, body.name); });
}
if (method === "DELETE") {
return startOrConflict(async () => { await removeCategory(body.name, body.replacement); });
}
}
if (route === "build" && method === "GET") return json(buildState);
if (route === "articles") {
if (method === "GET") return json(await listWorkingArticles());
if (method === "POST") {
const body = await bodyOf(request);
if (!String(body.title || "").trim()) throw new StoreError("请填写文章标题");
if (!String(body.body || "").trim()) throw new StoreError("请填写文章正文");
const slug = await generateSlug(body.category);
const article = await withSiteBuildLock(() => writeArticle(slug, body, true));
return json({ ok: true, slug, publishStatus: await getPublishStatus(article) }, 201);
}
}
if (route === "imports/word" && method === "POST") {
const body = await bodyOf(request);
const fileName = String(body.fileName || "").trim();
const buffer = decodeWordDataUrl(body.dataUrl, fileName);
const uploadedUrls: string[] = [];
let createdSlug: string | null = null;
try {
const converted = await convertWordToMarkdown(buffer, fileName, async (dataUrl) => {
const url = await saveUpload(dataUrl);
uploadedUrls.push(url);
return url;
});
const title = String(body.title || "").trim() || converted.suggestedTitle;
const imported = await withSiteBuildLock(async () => {
const slug = await generateSlug(body.category);
createdSlug = slug;
const article = await writeArticle(slug, { title, category: body.category, body: converted.body }, true);
return { slug, publishStatus: await getPublishStatus(article) };
});
return json({
ok: true,
slug: imported.slug,
title,
publishStatus: imported.publishStatus,
imageCount: converted.imageCount,
warnings: converted.warnings,
}, 201);
} catch (error) {
if (createdSlug) {
await withSiteBuildLock(() => discardDraft(createdSlug as string)).catch(() => {});
}
await Promise.allSettled(uploadedUrls.map((url) => removeUpload(url)));
throw error;
}
}
if (parts[0] === "articles" && parts[1]) {
const slug = requireSlug(parts[1]);
if (parts.length === 3 && parts[2] === "draft" && method === "DELETE") {
return json({ ok: true, ...await withSiteBuildLock(() => discardDraft(slug)) });
}
if (parts.length === 3 && parts[2] === "publish" && method === "POST") {
return startOrConflict(async () => { await publishArticle(slug); });
}
if (parts.length === 3 && parts[2] === "unpublish" && method === "POST") {
return startOrConflict(async () => { await unpublishArticle(slug); });
}
if (parts.length === 2 && method === "GET") {
const article = await readWorkingArticle(slug);
return json({ ...article, publishStatus: await getPublishStatus(article) });
}
if (parts.length === 2 && method === "PUT") {
const body = await bodyOf(request);
if (!String(body.title || "").trim()) throw new StoreError("请填写文章标题");
if (!String(body.body || "").trim()) throw new StoreError("请填写文章正文");
const article = await withSiteBuildLock(() => writeArticle(slug, body));
return json({ ok: true, slug, publishStatus: await getPublishStatus(article) });
}
if (parts.length === 2 && method === "DELETE") {
return startOrConflict(async () => { await deleteArticle(slug); });
}
}
if (route === "preview" && method === "POST") {
const body = await bodyOf(request);
return json({ html: await marked.parse(String(body.body || "")) });
}
if (route === "uploads" && method === "POST") {
const body = await bodyOf(request);
return json({ ok: true, url: await saveUpload(body.dataUrl) });
}
return json({ error: "接口不存在" }, 404);
} catch (error) {
if (error instanceof StoreError) return json({ error: error.message, ...error.details }, error.status);
if ((error as NodeJS.ErrnoException).code === "ENOENT") return json({ error: "文章不存在" }, 404);
console.error(error);
return json({ error: error instanceof Error ? error.message : "服务器处理失败" }, 500);
}
}
import crypto from "node:crypto";
import fs from "node:fs/promises";
import path from "node:path";
const ROOT = process.cwd();
const DATA_ROOT = process.env.CMS_DATA_DIR ? path.resolve(process.env.CMS_DATA_DIR) : path.join(ROOT, ".runtime");
const AUTH_DIR = path.join(DATA_ROOT, "auth");
const PASSWORD_FILE = path.join(AUTH_DIR, "password.json");
const ENV_PASSWORD = process.env.CMS_PASSWORD || "admin";
const HASH_LENGTH = 64;
const SCRYPT_OPTIONS = { N: 16384, r: 8, p: 1, maxmem: 32 * 1024 * 1024 };
type PasswordState = {
version: 1;
salt: string;
hash: string;
sessionVersion: number;
updatedAt: string;
};
const safeEqual = (leftValue: unknown, rightValue: unknown): boolean => {
const left = Buffer.from(String(leftValue));
const right = Buffer.from(String(rightValue));
return left.length === right.length && crypto.timingSafeEqual(left, right);
};
async function readPasswordState(): Promise<PasswordState | null> {
try {
const parsed = JSON.parse(await fs.readFile(PASSWORD_FILE, "utf8")) as Partial<PasswordState>;
if (parsed.version !== 1 || typeof parsed.salt !== "string" || typeof parsed.hash !== "string" || !Number.isInteger(parsed.sessionVersion)) {
throw new Error("后台密码文件格式无效");
}
return parsed as PasswordState;
} catch (error) {
if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;
throw error;
}
}
async function hashPassword(password: string, salt: Buffer): Promise<Buffer> {
return new Promise((resolve, reject) => {
crypto.scrypt(password, salt, HASH_LENGTH, SCRYPT_OPTIONS, (error, derivedKey) => {
if (error) reject(error);
else resolve(derivedKey);
});
});
}
export async function verifyPassword(password: unknown): Promise<boolean> {
// Check the .env credential first so it remains a recovery password even if
// the optional persisted password file is missing or damaged.
if (safeEqual(password || "", ENV_PASSWORD)) return true;
const state = await readPasswordState();
if (!state) return false;
const hash = await hashPassword(String(password || ""), Buffer.from(state.salt, "base64"));
return safeEqual(hash.toString("base64"), state.hash);
}
export async function currentSessionVersion(): Promise<number> {
try {
return (await readPasswordState())?.sessionVersion || 0;
} catch (error) {
// Keep .env login and recovery available if the optional file is corrupt.
console.error("读取后台密码文件失败:", error);
return 0;
}
}
export async function savePassword(password: string): Promise<void> {
const previous = await readPasswordState().catch(() => null);
const salt = crypto.randomBytes(16);
const hash = await hashPassword(password, salt);
const state: PasswordState = {
version: 1,
salt: salt.toString("base64"),
hash: hash.toString("base64"),
sessionVersion: (previous?.sessionVersion || 0) + 1,
updatedAt: new Date().toISOString(),
};
await fs.mkdir(AUTH_DIR, { recursive: true, mode: 0o700 });
const temporaryFile = `${PASSWORD_FILE}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`;
try {
await fs.writeFile(temporaryFile, `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600, flag: "wx" });
await fs.rename(temporaryFile, PASSWORD_FILE);
} catch (error) {
await fs.rm(temporaryFile, { force: true }).catch(() => {});
throw error;
}
}
import mammoth from "mammoth";
import TurndownService from "turndown";
import { gfm } from "turndown-plugin-gfm";
import { StoreError } from "./article-store";
export const MAX_WORD_FILE_SIZE = 20 * 1024 * 1024;
const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
const ACCEPTED_DOCX_MIMES = new Set([DOCX_MIME, "application/octet-stream", "application/zip"]);
const IMAGE_MIME_ALIASES: Record<string, string> = {
"image/jpg": "image/jpeg",
"image/x-png": "image/png",
};
const SUPPORTED_IMAGE_MIMES = new Set(["image/png", "image/jpeg", "image/webp", "image/gif"]);
export interface WordImportResult {
body: string;
suggestedTitle: string;
imageCount: number;
warnings: string[];
}
export function decodeWordDataUrl(dataUrl: unknown, fileName: unknown): Buffer {
const name = String(fileName || "").trim();
if (/\.doc$/i.test(name)) throw new StoreError("仅支持 .docx 文件,不支持旧版 .doc 格式");
if (!/\.docx$/i.test(name)) throw new StoreError("请选择 .docx 文件");
const match = String(dataUrl || "").match(/^data:([^;,]+);base64,([a-zA-Z0-9+/=\s]+)$/s);
if (!match || !ACCEPTED_DOCX_MIMES.has(match[1].toLowerCase())) {
throw new StoreError("Word 文件格式不正确,请上传 .docx 文件");
}
const buffer = Buffer.from(match[2].replace(/\s/g, ""), "base64");
if (!buffer.length || buffer.subarray(0, 2).toString("ascii") !== "PK") {
throw new StoreError("Word 文件无效或已经损坏");
}
if (buffer.length > MAX_WORD_FILE_SIZE) throw new StoreError("Word 文件不能超过 20MB", 413);
return buffer;
}
function titleFromFileName(fileName: string): string {
return fileName
.replace(/^.*[\\/]/, "")
.replace(/\.docx$/i, "")
.replace(/[_-]+/g, " ")
.trim() || "Word 导入文章";
}
function plainHeading(value: string): string {
return value
.replace(/!\[[^\]]*\]\([^)]*\)/g, "")
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
.replace(/[`*_~]/g, "")
.trim();
}
export async function convertWordToMarkdown(
buffer: Buffer,
fileName: string,
saveImage: (dataUrl: string) => Promise<string>,
): Promise<WordImportResult> {
let imageCount = 0;
let result: Awaited<ReturnType<typeof mammoth.convertToHtml>>;
try {
result = await mammoth.convertToHtml({ buffer }, {
styleMap: ["p[style-name='Title'] => h1:fresh"],
convertImage: mammoth.images.imgElement(async (image) => {
const mime = IMAGE_MIME_ALIASES[image.contentType] || image.contentType;
if (!SUPPORTED_IMAGE_MIMES.has(mime)) {
throw new StoreError(`Word 中包含不支持的图片格式:${image.contentType || "未知格式"}`);
}
const base64 = await image.readAsBase64String();
const src = await saveImage(`data:${mime};base64,${base64}`);
imageCount += 1;
return { src };
}),
});
} catch (error) {
if (error instanceof StoreError) throw error;
throw new StoreError(`Word 文件解析失败:${error instanceof Error ? error.message : "文件无效或已经损坏"}`);
}
const turndown = new TurndownService({
bulletListMarker: "-",
codeBlockStyle: "fenced",
headingStyle: "atx",
});
turndown.use(gfm);
let body = turndown.turndown(result.value).trim();
let suggestedTitle = titleFromFileName(fileName);
const firstHeading = body.match(/^#\s+(.+)$/m);
if (firstHeading && firstHeading.index !== undefined) {
suggestedTitle = plainHeading(firstHeading[1]) || suggestedTitle;
body = `${body.slice(0, firstHeading.index)}${body.slice(firstHeading.index + firstHeading[0].length)}`
.replace(/^\s+|\s+$/g, "")
.replace(/\n{3,}/g, "\n\n");
}
if (!body) throw new StoreError("Word 文件中没有可导入的正文内容");
return {
body,
suggestedTitle,
imageCount,
warnings: result.messages.map((message) => message.message),
};
}
---
import Base from "../layouts/Base.astro"; import Header from "../components/Header.astro"; import Footer from "../components/Footer.astro";
---
<Base title="页面未找到|智引未来" description="你访问的页面不存在。" noindex><Header /><main id="main-content"><section class="not-found"><div class="container" data-reveal><span>404</span><div class="eyebrow"><span></span>PAGE NOT FOUND</div><h1>这一页暂时找不到了</h1><p>可以返回首页,继续了解智引未来的GEO与SMO全域搜索服务。</p><a class="button" href="/">返回首页</a></div></section></main><Footer /></Base>
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import SectionHeading from "../../components/SectionHeading.astro";
import CTA from "../../components/CTA.astro";
import { site } from "../../data/site";
const title = `关于智引未来|${site.brand.name}`;
const description = "了解西安智引未来的公司定位、GEO与SMO双引擎业务、自研数据技术、透明服务理念与全域搜索增长愿景。";
---
<Base {title} {description}><Header /><main id="main-content">
<section class="page-hero about-hero"><div class="page-hero__mesh"></div><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 关于我们</div><div class="eyebrow"><span></span>ABOUT AILEAD FUTURE</div><h1>搜索入口正在重构<br /><em>品牌增长需要新的坐标系</em></h1><p>{site.about.position}</p></div></section>
<section id="position" class="section-pad section-white"><div class="container about-intro-layout"><div><SectionHeading eyebrow="OUR POSITION" title={site.about.heading} /></div><div class="story-column">{site.about.story.map((paragraph, index) => <p data-reveal><span>0{index + 1}</span>{paragraph}</p>)}</div></div></section>
<section class="stat-band"><div class="container stat-grid">{site.home.stats.map((stat) => <div data-reveal><strong>{stat.value}</strong><p>{stat.label}</p></div>)}</div></section>
<section id="advantages" class="section-pad section-muted"><div class="container"><SectionHeading eyebrow="WHY AILEAD" title="让每个结论,都能回到真实证据" description="能力不止体现在算法和平台覆盖,也体现在客户能否看懂过程、验证结果并持续迭代。" /><div class="advantage-grid">{site.about.advantages.map((item, index) => <article data-reveal><span>0{index + 1}</span><div class="advantage-icon">{["⌁", "▦", "◎", "↻", "∞", "◫"][index]}</div><h3>{item.title}</h3><p>{item.desc}</p></article>)}</div></div></section>
<section id="technology" class="section-pad about-tech"><div class="container about-tech-layout"><div><SectionHeading eyebrow="SELF-DEVELOPED TECHNOLOGY" title="五项技术,贯穿数据采集到效果监测" description="以合规采集、语义解析与时序分析为基础,为双引擎服务提供稳定的数据支撑。" light /></div><div class="technology-list">{site.about.technologies.map((item, index) => <article data-reveal><span>{String(index + 1).padStart(2, "0")}</span><h3>{item}</h3><i></i></article>)}</div></div></section>
<section class="section-pad vision-section"><div class="container vision-card" data-reveal><span>AILEAD FUTURE · OUR VISION</span><blockquote>“{site.about.vision}”</blockquote><div><i></i><p>科技蓝连接AI与数据,增长绿连接优化与结果。</p></div></div></section>
<CTA />
</main><Footer /></Base>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex,nofollow" />
<title>智引未来 · 洞察内容后台</title>
<link rel="stylesheet" href="/admin/style.css" />
</head>
<body>
<section id="login" class="login hidden">
<form id="login-form" class="login-card">
<div class="brand-mark">智引</div>
<h1>洞察内容后台</h1>
<p>输入管理密码和图片验证码,管理官网文章内容。</p>
<label>管理密码<input id="password" type="password" autocomplete="current-password" required /></label>
<label>图片验证码</label>
<div class="captcha-row">
<input id="captcha" autocomplete="off" maxlength="4" inputmode="text" aria-label="图片验证码" required />
<img id="captcha-image" alt="图片验证码,点击可更换" title="看不清?点击换一张" />
</div>
<button class="primary" type="submit">登录后台</button>
<div id="login-error" class="error"></div>
</form>
</section>
<div id="app" class="hidden">
<header class="topbar">
<div><strong>智引未来</strong><span>洞察内容后台</span></div>
<div class="top-actions">
<span id="pending-badge" class="pending-badge hidden"></span>
<a class="button ghost" href="/articles/" target="_blank" rel="noopener">查看前台</a>
<button id="change-password" class="ghost" type="button">修改密码</button>
<button id="logout" class="ghost">退出</button>
</div>
</header>
<main id="list-view" class="view">
<div class="view-head"><div><p>CONTENT</p><h1>洞察中心</h1></div><div class="view-actions"><button id="manage-categories" class="ghost">管理分类</button><button id="import-article" class="ghost">导入文件</button><button id="new-article" class="primary">+ 新建文章</button></div></div>
<input id="article-file" class="hidden" type="file" accept=".md,.docx,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
<p id="import-status" class="import-status" aria-live="polite"></p>
<div id="article-list" class="article-list"></div>
</main>
<main id="edit-view" class="view hidden">
<div class="view-head editor-titlebar">
<div><button id="back" class="back-button" type="button">← 返回文章列表</button><h1 id="edit-heading">编辑文章</h1></div>
<span id="editor-status" class="status"></span>
</div>
<div id="version-note" class="version-note"></div>
<form id="edit-form">
<section class="field-panel">
<label>文章标题<input id="title" required /></label>
<div class="field-label">
<span>文章分类</span>
<div id="category-select" class="custom-select">
<input id="category" type="hidden" />
<button id="category-trigger" class="select-trigger" type="button" aria-haspopup="listbox" aria-expanded="false">
<span id="category-value"></span><span class="select-chevron" aria-hidden="true"></span>
</button>
<div id="category-menu" class="select-menu hidden">
<div id="category-options" class="select-options" role="listbox" aria-label="文章分类"></div>
<div class="category-create">
<span>添加新分类</span>
<div><input id="new-category" maxlength="20" placeholder="输入分类名称" /><button id="add-category" class="primary small" type="button">添加</button></div>
<p id="category-error" class="error"></p>
</div>
</div>
</div>
</div>
<p class="auto-meta">文章网址、摘要、作者和 SEO 信息将由系统自动生成,无需填写。</p>
</section>
<section class="editor-panel">
<div class="editor-head"><div><strong>文章正文</strong><small>右侧会自动显示预览</small></div><div><span id="upload-status"></span><button id="upload-button" class="ghost small" type="button">插入图片</button></div></div>
<input id="file" class="hidden" type="file" accept="image/png,image/jpeg,image/webp,image/gif" />
<div class="editor-grid"><textarea id="body" required spellcheck="false" placeholder="在这里撰写文章正文……"></textarea><div id="preview" class="preview" aria-live="polite"></div></div>
</section>
<div class="edit-actions">
<button class="ghost save-button" type="submit">保存草稿</button>
<button id="publish" class="primary" type="button">发布到官网</button>
<details id="more-actions" class="more-actions hidden">
<summary>更多操作</summary>
<div class="action-menu">
<button id="discard" class="menu-action hidden" type="button">放弃未发布修改</button>
<button id="unpublish" class="menu-action danger hidden" type="button">下架文章</button>
<button id="delete-article" class="menu-action danger hidden" type="button">删除文章</button>
</div>
</details>
<span id="message"></span>
</div>
</form>
</main>
</div>
<div id="category-modal" class="modal hidden">
<div class="modal-card category-manager">
<div class="modal-head"><div><strong>文章分类管理</strong><small>重命名会同步更新该分类下的文章</small></div><button id="close-category-modal" class="ghost small" type="button">关闭</button></div>
<div class="category-manager-body">
<div class="manager-create"><input id="manager-new-category" maxlength="20" placeholder="输入新分类名称" /><button id="manager-add-category" class="primary" type="button">添加分类</button></div>
<p id="manager-category-error" class="error"></p>
<div id="category-manager-list" class="category-manager-list"></div>
</div>
</div>
</div>
<div id="password-modal" class="modal hidden">
<div class="modal-card password-card">
<div class="modal-head"><div><strong>修改后台密码</strong><small>修改成功后需要使用新密码重新登录</small></div><button id="close-password-modal" class="ghost small" type="button">关闭</button></div>
<form id="password-form" class="password-form">
<label>当前密码<input id="current-password" type="password" autocomplete="current-password" required /></label>
<label>新密码<input id="new-password" type="password" autocomplete="new-password" minlength="5" maxlength="128" required /></label>
<label>确认新密码<input id="confirm-password" type="password" autocomplete="new-password" minlength="5" maxlength="128" required /></label>
<p class="password-hint">新密码至少 5 个字符。</p>
<p id="password-error" class="error"></p>
<div class="password-actions"><button id="cancel-password" class="ghost" type="button">取消</button><button class="primary" type="submit">确认修改</button></div>
</form>
</div>
</div>
<div id="build-modal" class="modal hidden">
<div class="modal-card build-card">
<div><strong id="build-title">正在处理</strong><button id="close-modal" class="ghost small hidden" type="button">关闭</button></div>
<pre id="build-log">系统正在更新官网,请稍候。</pre>
</div>
</div>
<script is:inline src="/admin/app.js"></script>
</body>
</html>
import type { APIRoute } from "astro";
import { handleCmsApi } from "../../../lib/cms-api";
export const prerender = false;
const handler: APIRoute = ({ request, params, clientAddress }) =>
handleCmsApi(request, params.route || "", clientAddress);
export const GET = handler;
export const POST = handler;
export const PUT = handler;
export const PATCH = handler;
export const DELETE = handler;
---
import Base from "../../layouts/Base.astro"; import Header from "../../components/Header.astro"; import Footer from "../../components/Footer.astro"; import { site } from "../../data/site"; import { getPublishedArticle, getPublishedArticles } from "../../lib/article-store"; import { fmtDate } from "../../lib/articles";
type ArticleDetail = NonNullable<Awaited<ReturnType<typeof getPublishedArticle>>>;
export async function getStaticPaths() { const articles = await getPublishedArticles(); return Promise.all(articles.map(async (article) => ({ params: { slug: article.id }, props: { entry: await getPublishedArticle(article.id) } }))); }
const { entry } = Astro.props as { entry: ArticleDetail }; const article = entry.data; const date = fmtDate(article.date); const title = `${article.title}|洞察中心|${site.brand.name}`; const pageUrl = new URL(`/articles/${entry.id}/`, Astro.site).href;
const modified = fmtDate(article.updated || article.date);
const keywords = [article.category, article.title, "GEO", "SMO", site.brand.name];
const jsonLd = [{ "@context": "https://schema.org", "@type": "Article", headline: article.title, description: article.excerpt, datePublished: date, dateModified: modified, articleSection: article.category, inLanguage: "zh-CN", author: { "@type": "Organization", name: article.author }, publisher: { "@id": new URL("/#organization", Astro.site).href }, mainEntityOfPage: { "@type": "WebPage", "@id": `${pageUrl}#webpage` }, url: pageUrl }, { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [{ "@type": "ListItem", position: 1, name: "首页", item: Astro.site?.href }, { "@type": "ListItem", position: 2, name: "洞察中心", item: new URL("/articles/", Astro.site).href }, { "@type": "ListItem", position: 3, name: article.title, item: pageUrl }] }];
---
<Base {title} description={article.excerpt} {keywords} ogType="article" publishedTime={date} modifiedTime={modified} articleSection={article.category} articleAuthor={article.author} {jsonLd}><Header /><main id="main-content" class="article-detail-page"><article><header class="article-detail-head"><div class="article-detail-head__mesh"></div><div class="container article-detail-head__inner"><div class="breadcrumb"><a href="/">首页</a> / <a href="/articles/">洞察中心</a> / {article.category}</div><span class="article-detail-category">{article.category}</span><h1>{article.title}</h1><p>{article.excerpt}</p><div class="article-detail-meta"><time datetime={date}>{date}</time><span>{article.author}</span></div></div></header><div class="container article-detail-layout"><aside><a href="/articles/">← 返回洞察中心</a><p>持续关注GEO、SMO、AI搜索与品牌内容资产建设。</p></aside><div class="article-prose" set:html={entry.html}></div></div></article></main><Footer /></Base>
---
import ArticlesView from "../../components/ArticlesView.astro";
import { getPublishedArticles, getCategoryNames, getCategories, pageSlice, lastPageOf } from "../../lib/articles";
const all = await getPublishedArticles();
const categories = getCategories(all, await getCategoryNames());
const items = pageSlice(all, 1);
---
<ArticlesView items={items} categories={categories} totalCount={all.length} activeSlug={null} activeName={null} currentPage={1} lastPage={lastPageOf(all.length)} basePath="/articles" />
---
import ArticlesView from "../../../components/ArticlesView.astro";
import { getPublishedArticles, getCategoryNames, getCategories, pageSlice, lastPageOf } from "../../../lib/articles";
export async function getStaticPaths() {
const articles = await getPublishedArticles();
return Array.from({ length: Math.max(0, lastPageOf(articles.length) - 1) }, (_, index) => ({
params: { page: String(index + 2) },
}));
}
const all = await getPublishedArticles();
const page = Number(Astro.params.page);
---
<ArticlesView items={pageSlice(all, page)} categories={getCategories(all, await getCategoryNames())} totalCount={all.length} activeSlug={null} activeName={null} currentPage={page} lastPage={lastPageOf(all.length)} basePath="/articles" />
---
import ArticlesView from "../../../../components/ArticlesView.astro";
import { categoryToSlug, getPublishedArticles, getCategoryNames, getCategories, slugToCategory, pageSlice, lastPageOf } from "../../../../lib/articles";
export async function getStaticPaths() {
return (await getCategoryNames()).map((categoryName) => ({
params: { slug: categoryToSlug(categoryName) },
props: { categoryName },
}));
}
const all = await getPublishedArticles();
const categories = getCategories(all, await getCategoryNames());
const categoryName = String(Astro.props.categoryName || slugToCategory(Astro.params.slug!, categories.map((item) => item.name)) || "");
const filtered = all.filter((item) => item.data.category === categoryName);
---
<ArticlesView items={pageSlice(filtered, 1)} categories={categories} totalCount={all.length} activeSlug={Astro.params.slug!} activeName={categoryName} currentPage={1} lastPage={lastPageOf(filtered.length)} basePath={`/articles/topic/${Astro.params.slug}`} />
---
import ArticlesView from "../../../../../components/ArticlesView.astro";
import { getPublishedArticles, getCategoryNames, getCategories, slugToCategory, pageSlice, lastPageOf } from "../../../../../lib/articles";
export async function getStaticPaths() {
const articles = await getPublishedArticles();
const categories = getCategories(articles, await getCategoryNames());
const paths: Array<{ params: { slug: string; page: string }; props: { categoryName: string } }> = [];
for (const category of categories) {
for (let page = 2; page <= lastPageOf(category.count); page += 1) {
paths.push({ params: { slug: category.slug, page: String(page) }, props: { categoryName: category.name } });
}
}
return paths;
}
const all = await getPublishedArticles();
const categories = getCategories(all, await getCategoryNames());
const categoryName = String(Astro.props.categoryName || slugToCategory(Astro.params.slug!, categories.map((item) => item.name)) || "");
const filtered = all.filter((item) => item.data.category === categoryName);
const page = Number(Astro.params.page);
---
<ArticlesView items={pageSlice(filtered, page)} categories={categories} totalCount={all.length} activeSlug={Astro.params.slug!} activeName={categoryName} currentPage={page} lastPage={lastPageOf(filtered.length)} basePath={`/articles/topic/${Astro.params.slug}`} />
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import { site } from "../../data/site";
const title = `联系我们|${site.brand.name}`;
const description = `联系智引未来,咨询GEO、SMO、AI官网搭建与内容运营服务。电话${site.contact.phone},邮箱${site.contact.email}。`;
---
<Base {title} {description}><Header /><main id="main-content">
<section class="contact-hero"><div class="contact-hero__glow"></div><div class="container contact-hero__grid"><div data-reveal><div class="breadcrumb"><a href="/">首页</a> / 联系我们</div><div class="eyebrow eyebrow--light"><span></span>CONTACT AILEAD FUTURE</div><h1>{site.contact.heading}</h1><p>{site.contact.intro}</p><div class="hero__actions"><a class="button button--white" href={`tel:${site.contact.phone}`}>电话咨询 <span>↗</span></a><a class="button button--ghost" href={`mailto:${site.contact.email}`}>发送邮件</a></div></div><div class="contact-radar" data-reveal><div class="radar-ring radar-ring--one"></div><div class="radar-ring radar-ring--two"></div><div class="radar-core"><strong>AI</strong><span>品牌诊断</span></div><i class="radar-dot radar-dot--one"></i><i class="radar-dot radar-dot--two"></i><i class="radar-dot radar-dot--three"></i></div></div></section>
<section class="section-pad section-muted"><div class="container contact-grid"><article data-reveal><span>01</span><h2>咨询电话</h2><a class="contact-big-link" href={`tel:${site.contact.phone}`}>{site.contact.phoneDisplay}</a><p>项目咨询与需求沟通</p></article><article data-reveal><span>02</span><h2>联系邮箱</h2><a class="contact-big-link contact-big-link--small" href={`mailto:${site.contact.email}`}>{site.contact.email}</a><p>可发送品牌资料与需求说明</p></article><article data-reveal><span>03</span><h2>公司地址</h2><address>{site.contact.address}</address><p>西安 · 曲江新区</p></article><article data-reveal><span>04</span><h2>内容矩阵</h2><div class="social-list">{site.contact.socials.map((name) => <strong>{name}</strong>)}</div><p>品牌动态与行业洞察</p></article></div></section>
<section class="section-pad section-white"><div class="container visit-grid"><div><div class="eyebrow"><span></span>BEFORE WE TALK</div><h2>准备这些信息,<br />让诊断更聚焦</h2><p>无需制作复杂材料,现有品牌资料与最关心的问题就足够开始。</p></div><ol><li><span>01</span><div><strong>品牌名称与简介</strong><p>500字以内,帮助我们快速理解业务与定位</p></div></li><li><span>02</span><div><strong>5个品牌或品类关键词</strong><p>你最希望用户在哪些搜索问题中看见品牌</p></div></li><li><span>03</span><div><strong>当前主要痛点</strong><p>AI不可见、社媒排名、官网信源或内容运营</p></div></li><li><span>04</span><div><strong>联系人与官网</strong><p>便于后续沟通并快速查看现有品牌信息</p></div></li></ol></div></section>
<section class="contact-bottom"><div class="container"><p>AILEAD FUTURE · GEO × SMO</p><h2>先看清品牌可见度<br />再决定增长下一步</h2><a class="button button--white" href={`tel:${site.contact.phone}`}>立即联系 {site.contact.phoneDisplay}</a></div></section>
</main><Footer /></Base>
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import CTA from "../../components/CTA.astro";
import { site } from "../../data/site";
const title = `常见问题|${site.brand.name}`;
const description = "解答智引未来GEO与SMO的区别、覆盖平台、服务流程、技术能力、效果监测与联系方式等常见问题。";
const jsonLd = { "@context": "https://schema.org", "@type": "FAQPage", mainEntity: site.faq.map((item) => ({ "@type": "Question", name: item.q, acceptedAnswer: { "@type": "Answer", text: item.a } })) };
---
<Base {title} {description} {jsonLd}><Header /><main id="main-content">
<section class="page-hero faq-hero"><div class="page-hero__mesh"></div><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 常见问题</div><div class="eyebrow"><span></span>FREQUENTLY ASKED</div><h1>关于GEO与SMO<br /><em>你可能想知道</em></h1><p>从服务边界、平台覆盖到效果与交付,把重要问题清楚说明。</p></div></section>
<section class="section-pad section-muted"><div class="container faq-layout"><aside data-reveal><span>01 — {String(site.faq.length).padStart(2, "0")}</span><h2>全域搜索优化 FAQ</h2><p>如果你的问题不在其中,欢迎直接联系我们做一次针对品牌现状的沟通。</p><a class="button button--outline" href="/contact/">预约咨询</a></aside><div class="faq-list">{site.faq.map((item, index) => <details data-reveal open={index === 0}><summary><span>{String(index + 1).padStart(2, "0")}</span><strong>{item.q}</strong><i aria-hidden="true"></i></summary><div><p>{item.a}</p></div></details>)}</div></div></section>
<CTA />
</main><Footer /></Base>
---
import Base from "../layouts/Base.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import SectionHeading from "../components/SectionHeading.astro";
import ProductCarousel from "../components/ProductCarousel.astro";
import CTA from "../components/CTA.astro";
import { site } from "../data/site";
import { fmtDate, getPublishedArticles } from "../lib/articles";
const latest = (await getPublishedArticles()).slice(0, 3);
const title = site.seo.title;
const jsonLd = {
"@context": "https://schema.org",
"@type": "ItemList",
name: "智引未来全域搜索优化服务",
numberOfItems: site.services.length,
itemListElement: site.services.map((service, index) => ({
"@type": "ListItem",
position: index + 1,
item: {
"@type": "Service",
name: service.name,
description: service.intro,
url: new URL(`/services/${service.slug}/`, Astro.site).href,
provider: { "@id": new URL("/#organization", Astro.site).href },
},
})),
};
---
<Base {title} jsonLd={jsonLd}>
<Header />
<main id="main-content">
<section class="hero">
<div class="hero-grid-glow"></div>
<div class="container hero__grid">
<div class="hero__content" data-reveal>
<div class="hero-pill"><span></span>{site.home.eyebrow}<i>全域搜索优化</i></div>
<h1>智引未来,让品牌<br /><em>被每一个搜索看见</em></h1>
<p>{site.home.subhead}</p>
<div class="hero__actions">
<a class="button" href="/contact/">立即联系我们 <span>↗</span></a>
<a class="button button--outline" href="#solutions">了解核心能力 <span>↓</span></a>
</div>
<div class="hero__proof"><span>真实搜索数据</span><span>双引擎协同</span><span>白盒化效果</span></div>
</div>
<div class="hero-visual" data-reveal aria-label="全域搜索数据分析示意图">
<div class="visual-orbit visual-orbit--one"></div><div class="visual-orbit visual-orbit--two"></div>
<div class="search-card">
<div class="search-card__top"><div class="search-brand"><span class="search-brand__mark">AI</span><div><strong>品牌全域可见度</strong><small>实时监测概览</small></div></div><span class="live-dot">LIVE</span></div>
<div class="score-ring"><div><strong>86</strong><span>综合指数</span></div></div>
<div class="metric-list">
<div><span>AI 提及覆盖</span><i><b style="width:82%"></b></i><strong>82%</strong></div>
<div><span>引用可信度</span><i><b style="width:74%"></b></i><strong>74%</strong></div>
<div class="metric-list__green"><span>社媒搜索力</span><i><b style="width:91%"></b></i><strong>91%</strong></div>
</div>
<div class="trend-card"><div><span>搜索增长趋势</span><strong>+24.8%</strong></div><svg viewBox="0 0 320 88" role="img" aria-label="增长趋势折线"><defs><linearGradient id="area" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#19C7C4" stop-opacity=".3"/><stop offset="1" stop-color="#19C7C4" stop-opacity="0"/></linearGradient></defs><path class="trend-area" d="M2,74 C40,68 44,55 76,58 S116,74 151,49 S206,47 235,27 S278,34 318,8 L318,88 L2,88Z"/><path class="trend-line" d="M2,74 C40,68 44,55 76,58 S116,74 151,49 S206,47 235,27 S278,34 318,8"/></svg></div>
</div>
<div class="float-card float-card--geo"><span>GEO</span><div><strong>AI引用新增</strong><small>品牌知识被持续理解</small></div><b>+18</b></div>
<div class="float-card float-card--smo"><span>SMO</span><div><strong>搜索排名上升</strong><small>高价值问题持续覆盖</small></div><b>↑ 12</b></div>
</div>
</div>
<div class="container hero-platforms"><span>覆盖主流AI与社媒搜索场景</span><ProductCarousel /></div>
</section>
<section class="stat-band stat-band--light"><div class="container stat-grid">{site.home.stats.map((stat) => <div data-reveal><strong>{stat.value}</strong><p>{stat.label}</p></div>)}</div></section>
<section id="solutions" class="section-pad section-muted">
<div class="container">
<SectionHeading eyebrow="DUAL-ENGINE SOLUTION" title="一套面向企业的全域搜索获客方案" description="蓝色负责技术与GEO,绿色负责增长与SMO。两条产品线共享数据底座,可独立交付,也可组合形成全搜索覆盖。" align="center" />
<div class="engine-grid">
{site.services.slice(0, 2).map((service) => <article class:list={["engine-card", `engine-card--${service.type}`]} data-reveal>
<div class="engine-card__head"><span class="service-index">{service.index}</span><span class="service-badge">{service.type.toUpperCase()}</span></div>
<div class="engine-icon" aria-hidden="true">{service.type === "geo" ? "◎" : "↗"}</div>
<p class="engine-card__kicker">{service.kicker}</p><h2>{service.name}</h2><p>{service.intro}</p>
<ul>{service.features.slice(0, 2).map((feature) => <li><span>✓</span>{feature}</li>)}</ul>
<a href={`/services/${service.slug}/`}>了解{service.type.toUpperCase()}服务 <span>↗</span></a>
</article>)}
</div>
<div class="support-service-grid">{site.services.slice(2).map((service) => <a href={`/services/${service.slug}/`} data-reveal>
<span class="service-index">{service.index}</span><div><small>{service.kicker}</small><h3>{service.name}</h3><p>{service.intro}</p></div><i>↗</i>
</a>)}</div>
</div>
</section>
<section id="technology" class="section-pad tech-section">
<div class="tech-grid-lines"></div>
<div class="container tech-layout">
<div><SectionHeading eyebrow="TECHNOLOGY FOUNDATION" title="数据不是装饰,而是每次判断的起点" description="从跨平台采集、语义溯源到时序分析,五项自研能力支撑GEO与SMO的监测、诊断和复盘。" light /><a class="text-link text-link--light" href="/about/#technology">查看自研技术 <span>↗</span></a></div>
<div class="tech-stack">{site.about.technologies.map((item, index) => <div data-reveal><span>0{index + 1}</span><strong>{item}</strong><i></i></div>)}</div>
</div>
<div class="container tech-data-row">{[
["APP + WEB", "多端真实还原"], ["LLM TRACE", "引用来源解析"], ["GEO × SMO", "双频协同建模"], ["TIME SERIES", "持续趋势洞察"],
].map(([value, label]) => <div data-reveal><strong>{value}</strong><span>{label}</span></div>)}</div>
</section>
<section id="workflow" class="section-pad section-white">
<div class="container">
<div class="section-intro-row"><SectionHeading eyebrow="VISIBLE GROWTH LOOP" title="从看见问题,到看见增长" description="监测、诊断、优化、复盘四步贯通,让每个动作都能回到数据与证据。" /><a class="text-link" href="/methodology/">了解服务方法 <span>↗</span></a></div>
<div class="workflow-grid">{site.workflow.map((item, index) => <article data-reveal><div><span>{item.number}</span><i>{index < site.workflow.length - 1 ? "→" : "✓"}</i></div><h3>{item.title}</h3><p>{item.desc}</p></article>)}</div>
</div>
</section>
<section class="section-pad scenario-section">
<div class="container scenario-layout">
<div class="scenario-copy"><SectionHeading eyebrow="WHERE TO START" title="先从最影响增长的搜索缺口开始" description="不需要一次解决所有问题。用诊断确认优先级,再选择合适的产品与节奏。" /><a class="button button--outline" href="/contact/">预约全搜索诊断</a></div>
<div class="scenario-grid">{[
["01", "AI里搜不到品牌", "了解品牌为什么没有进入回答,以及缺少哪些可信信息。", "geo"],
["02", "AI回答被竞品占据", "分析决策问题与引用来源,找到品牌进入推荐的路径。", "geo"],
["03", "抖音/小红书排名靠后", "识别真实搜索需求,重构内容矩阵与问题覆盖。", "smo"],
["04", "官网内容难被理解", "完善语义结构、品牌知识与结构化信息,建立官方信源。", "platform"],
].map(([num, title, desc, type]) => <article class={`scenario-card scenario-card--${type}`} data-reveal><span>{num}</span><h3>{title}</h3><p>{desc}</p></article>)}</div>
</div>
</section>
{latest.length > 0 && <section class="section-pad section-white"><div class="container"><div class="section-intro-row"><SectionHeading eyebrow="AILEAD INSIGHTS" title="搜索增长洞察" description="关于GEO、SMO、AI品牌可见度与内容资产建设的持续观察。" /><a class="text-link" href="/articles/">查看全部文章 <span>↗</span></a></div><div class="article-grid">{latest.map((item, index) => <article class="article-card" data-reveal><a href={`/articles/${item.id}/`}><div class="article-card__meta"><span>{item.data.category}</span><time>{fmtDate(item.data.date)}</time></div><div class="article-card__index">0{index + 1}</div><h2>{item.data.title}</h2><p>{item.data.excerpt}</p><strong>阅读全文 ↗</strong></a></article>)}</div></div></section>}
<CTA />
</main>
<Footer />
</Base>
---
return Astro.redirect("/methodology/", 301);
---
import type { APIRoute } from "astro";
import { site } from "../data/site";
import { getPublishedArticles } from "../lib/articles";
export const prerender = true;
export const GET: APIRoute = async ({ site: configuredSite }) => {
const articles = await getPublishedArticles();
const origin = configuredSite ?? new URL("https://www.zhiyintec.com");
const url = (pathname: string) => new URL(pathname, origin).href;
const lines = [
`# ${site.brand.name}${site.brand.englishName})完整站点内容`, "", `> ${site.brand.tagline}`, "",
`官方网站:${url("/")}`, `企业主体:${site.brand.legalName}`, `咨询电话:${site.contact.phone}`, `联系邮箱:${site.contact.email}`, `公司地址:${site.contact.address}`, "",
"## 品牌与服务概览", "", site.home.subhead, "", ...site.about.story, "",
"## 核心能力数据", "", ...site.home.stats.map((stat) => `- ${stat.label}${stat.value}`), "",
"## 产品服务", "", `服务总览:${url("/services/")}`, "",
...site.services.flatMap((service) => [
`### ${service.name}`, "", `页面:${url(`/services/${service.slug}/`)}`, "", service.intro, "", "服务特点:", ...service.features.map((feature) => `- ${feature}`), "", "核心能力:", ...service.capabilities.map((capability) => `- ${capability.label}${capability.value}`), "",
]),
"## 自研技术", "", ...site.about.technologies.map((technology) => `- ${technology}`), "",
"## 服务闭环", "", ...site.workflow.map((step) => `- ${step.title}${step.desc}`), "",
"## 常见问题", "", `常见问题页面:${url("/faq/")}`, "", ...site.faq.flatMap((item) => [`### ${item.q}`, "", item.a, ""]),
"## 洞察中心全文", "", ...articles.flatMap((article) => [`### ${article.data.title}`, "", `页面:${url(`/articles/${article.id}/`)}`, `分类:${article.data.category}`, `作者:${article.data.author}`, `发布日期:${article.data.date.toISOString().slice(0, 10)}`, `更新时间:${article.data.updated.toISOString().slice(0, 10)}`, "", article.data.excerpt, "", article.body, ""]),
"## 联系方式", "", `联系页面:${url("/contact/")}`, `咨询电话:${site.contact.phone}`, `联系邮箱:${site.contact.email}`, `公司地址:${site.contact.address}`, `内容矩阵:${site.contact.socials.join("、")}`, "",
];
return new Response(lines.join("\n"), { headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "public, max-age=3600" } });
};
import type { APIRoute } from "astro";
import { site } from "../data/site";
import { getPublishedArticles } from "../lib/articles";
export const prerender = true;
export const GET: APIRoute = async ({ site: configuredSite }) => {
const articles = await getPublishedArticles();
const origin = configuredSite ?? new URL("https://www.zhiyintec.com");
const url = (pathname: string) => new URL(pathname, origin).href;
const lines = [
`# ${site.brand.name}`,
"",
`> ${site.brand.tagline}`,
"",
site.about.position,
"",
"## 核心页面",
`- [首页](${url("/")})`,
`- [产品服务](${url("/services/")})`,
...site.services.map((service) => `- [${service.name}](${url(`/services/${service.slug}/`)}): ${service.seoDescription}`),
`- [关于智引未来](${url("/about/")})`,
`- [服务方法](${url("/methodology/")})`,
`- [洞察中心](${url("/articles/")})`,
`- [常见问题](${url("/faq/")})`,
`- [联系我们](${url("/contact/")})`,
"",
"## 最新洞察",
...articles.map((article) => `- [${article.data.title}](${url(`/articles/${article.id}/`)}): ${article.data.excerpt}`),
"",
`- [完整站点内容](${url("/llms-full.txt")})`,
"", `咨询电话:${site.contact.phone}`, `联系邮箱:${site.contact.email}`, `公司地址:${site.contact.address}`,
];
return new Response(lines.join("\n"), { headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "public, max-age=3600" } });
};
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import SectionHeading from "../../components/SectionHeading.astro";
import CTA from "../../components/CTA.astro";
import { site } from "../../data/site";
const title = `服务方法|${site.brand.name}`;
const description = "了解智引未来从监测、诊断、优化到复盘的标准化服务闭环,以及GEO与SMO项目的透明交付方式。";
---
<Base {title} {description}><Header /><main id="main-content">
<section class="page-hero methodology-hero"><div class="page-hero__mesh"></div><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 服务方法</div><div class="eyebrow"><span></span>OUR METHODOLOGY</div><h1>不做无法解释的黑盒<br /><em>让每一步都有证据</em></h1><p>以真实搜索数据为起点,把复杂的品牌可见度问题拆解为清晰、可执行、可复盘的服务流程。</p></div></section>
<section id="workflow" class="section-pad section-white"><div class="container"><SectionHeading eyebrow="VISIBLE GROWTH LOOP" title="四步形成持续优化闭环" description="每一轮复盘都会成为下一轮监测和策略的输入,品牌搜索资产因此持续累积。" align="center" /><div class="method-flow">{site.workflow.map((item, index) => <article data-reveal><div><span>{item.number}</span><i>{index < site.workflow.length - 1 ? "→" : "↻"}</i></div><h2>{item.title}</h2><p>{item.desc}</p></article>)}</div></div></section>
<section id="delivery" class="section-pad delivery-section"><div class="container delivery-layout"><div><SectionHeading eyebrow="TRANSPARENT DELIVERY" title="过程看得见,结果可回溯" description="项目交付不仅是一份结论,更包含结论背后的数据、证据与下一步行动。" light /></div><div class="delivery-grid">{[
["01", "现状诊断", "品牌提及、排名、竞品与问题覆盖的基线结果"], ["02", "策略地图", "平台、问题、内容与优先级的可执行规划"], ["03", "内容资产", "可进入官网、AI与社媒场景的品牌知识内容"], ["04", "效果看板", "趋势变化、阶段结果与可回溯证据持续呈现"],
].map(([num, title, desc]) => <article data-reveal><span>{num}</span><h3>{title}</h3><p>{desc}</p></article>)}</div></div></section>
<section class="section-pad section-muted"><div class="container"><SectionHeading eyebrow="SERVICE PRINCIPLES" title="三条贯穿项目的服务原则" align="center" /><div class="principle-grid">{[
["真实", "优先使用可验证的搜索数据与用户可见结果,避免依赖模糊估算。"], ["透明", "说明为什么得出结论、为什么采取动作,以及结果如何判断。"], ["持续", "不以一次排名或单篇内容为终点,长期积累品牌知识与搜索权重。"],
].map(([title, desc], index) => <article data-reveal><span>0{index + 1}</span><h3>{title}</h3><p>{desc}</p></article>)}</div></div></section>
<CTA />
</main><Footer /></Base>
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import CTA from "../../components/CTA.astro";
import { site } from "../../data/site";
export function getStaticPaths() {
return site.services.map((service) => ({ params: { slug: service.slug }, props: { service } }));
}
type Service = (typeof site.services)[number];
const { service } = Astro.props as { service: Service };
const pageUrl = new URL(`/services/${service.slug}/`, Astro.site).href;
const jsonLd = [{
"@context": "https://schema.org", "@type": "Service", "@id": `${pageUrl}#service`, name: service.name,
serviceType: service.name, description: service.seoDescription, url: pageUrl,
provider: { "@id": new URL("/#organization", Astro.site).href }, areaServed: { "@type": "Country", name: "中国" },
}, { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [{ "@type": "ListItem", position: 1, name: "首页", item: new URL("/", Astro.site).href }, { "@type": "ListItem", position: 2, name: "产品服务", item: new URL("/services/", Astro.site).href }, { "@type": "ListItem", position: 3, name: service.name, item: pageUrl }] }];
const related = site.services.filter((item) => item.slug !== service.slug);
---
<Base title={service.seoTitle} description={service.seoDescription} keywords={service.seoKeywords} {jsonLd}>
<Header /><main id="main-content">
<section class:list={["service-hero", `service-hero--${service.type}`]}><div class="service-hero__grid"></div><div class="container service-hero__inner"><div data-reveal><div class="breadcrumb"><a href="/">首页</a> / <a href="/services/">产品服务</a> / {service.name}</div><div class="service-hero__tag"><span>{service.index}</span>{service.kicker}</div><h1>{service.name}<br /><em>{service.intro}</em></h1><div class="hero__actions"><a class:list={["button", { "button--green": service.type === "smo" }]} href="/contact/">预约服务咨询 <span>↗</span></a><a class="button button--outline" href="#capabilities">查看核心能力</a></div></div>
<div class="service-hero-console" data-reveal><div class="console-top"><i></i><i></i><i></i><span>AILEAD / {service.type.toUpperCase()} MONITOR</span></div><div class="console-main"><div class="console-score"><span>VISIBILITY</span><strong>{service.type === "smo" ? "91" : "86"}</strong><small>实时示意</small></div><div class="console-chart">{[48, 62, 54, 73, 69, 84, 92].map((height, index) => <i style={`height:${height}%`}><span>0{index + 1}</span></i>)}</div></div><div class="console-foot">{service.capabilities.map((item) => <span><i></i>{item.label}</span>)}</div></div>
</div></section>
<section id="capabilities" class="section-pad section-muted"><div class="container service-cap-layout"><div><div class="eyebrow"><span></span>WHAT WE DELIVER</div><h2>把复杂的搜索问题<br />拆成可执行的能力模块</h2><p>{service.seoDescription}</p></div><div class="service-cap-grid">{service.capabilities.map((capability, index) => <article data-reveal><span>0{index + 1}</span><h3>{capability.label}</h3><p>{capability.value}</p></article>)}</div></div></section>
<section class="section-pad section-white"><div class="container service-feature-layout"><div class={`service-symbol service-symbol--${service.type}`} data-reveal><span>{service.type.toUpperCase()}</span><i></i><strong>{service.index}</strong></div><div><div class="eyebrow"><span></span>WHY IT WORKS</div><h2>以数据和内容,持续建立品牌搜索资产</h2><ul class="large-check-list">{service.features.map((feature, index) => <li data-reveal><span>0{index + 1}</span><p>{feature}</p></li>)}</ul></div></div></section>
<section class="section-pad process-section"><div class="container"><div class="section-heading section-heading--center section-heading--light" data-reveal><div class="eyebrow"><span></span>STANDARD PROCESS</div><h2>四步标准化服务流程</h2><p>每个阶段都有清晰的输入、动作与可见输出,不做无法解释的黑盒操作。</p></div><div class="process-grid">{service.process.map((step, index) => <article data-reveal><span>0{index + 1}</span><h3>{step}</h3><i>{index < service.process.length - 1 ? "→" : "✓"}</i></article>)}</div></div></section>
<nav class="related-services" aria-label="其他服务"><div class="container">{related.map((item) => <a href={`/services/${item.slug}/`}><span>{item.index}</span><strong>{item.name}</strong><i>↗</i></a>)}</div></nav>
<CTA title={`从一次${service.name}诊断开始`} text="先看清品牌现状、关键问题和优先机会,再决定适合的优化节奏。" />
</main><Footer />
</Base>
---
import Base from "../../layouts/Base.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import SectionHeading from "../../components/SectionHeading.astro";
import CTA from "../../components/CTA.astro";
import { site } from "../../data/site";
const title = `产品服务|${site.brand.name}`;
const description = "智引未来提供GEO生成式引擎优化、SMO社媒搜索优化、AI官网搭建与公众号内容运营,帮助企业建立全域搜索获客能力。";
const keywords = site.services.flatMap((service) => service.seoKeywords);
const pageUrl = new URL("/services/", Astro.site).href;
const jsonLd = [{
"@context": "https://schema.org", "@type": "ItemList", name: "智引未来产品服务", url: pageUrl,
numberOfItems: site.services.length,
itemListElement: site.services.map((service, index) => ({ "@type": "ListItem", position: index + 1, url: new URL(`/services/${service.slug}/`, Astro.site).href, item: { "@type": "Service", name: service.name, description: service.intro, provider: { "@id": new URL("/#organization", Astro.site).href } } })),
}, { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [{ "@type": "ListItem", position: 1, name: "首页", item: new URL("/", Astro.site).href }, { "@type": "ListItem", position: 2, name: "产品服务", item: pageUrl }] }];
---
<Base {title} {description} {keywords} {jsonLd}><Header /><main id="main-content">
<section class="page-hero page-hero--services"><div class="page-hero__mesh"></div><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 产品服务</div><div class="eyebrow"><span></span>PRODUCTS & SERVICES</div><h1>双引擎协同<br /><em>覆盖每一个搜索入口</em></h1><p>从AI回答到社媒搜索,从官方信源到持续内容运营,建立可监测、可优化、可复盘的全域搜索增长体系。</p></div></section>
<nav class="anchor-nav"><div class="container">{site.services.map((item) => <a href={`#${item.slug}`}><span>{item.index}</span>{item.name}</a>)}</div></nav>
<section class="section-pad section-muted"><div class="container service-list">{site.services.map((item, index) => <article id={item.slug} class:list={["service-detail", `service-detail--${item.type}`, { "service-detail--reverse": index % 2 }]}>
<div class="service-detail__visual" data-reveal>
<div class="service-visual__top"><span>{item.type.toUpperCase()}</span><small>{item.kicker}</small></div>
<div class="service-visual__core"><div><i></i><strong>{item.index}</strong></div><span>{item.name}</span></div>
<div class="service-visual__nodes">{item.capabilities.map((capability) => <span>{capability.label}<i></i></span>)}</div>
</div>
<div class="service-detail__content" data-reveal><div class="eyebrow"><span></span>{item.kicker}</div><h2>{item.name}</h2><p class="lead">{item.intro}</p><ul>{item.features.map((feature) => <li><span>✓</span>{feature}</li>)}</ul><div class="capability-pills">{item.capabilities.map((capability) => <span>{capability.label}</span>)}</div><a class:list={["button", { "button--green": item.type === "smo" }]} href={`/services/${item.slug}/`}>查看服务详情 <span>↗</span></a></div>
</article>)}</div></section>
<section class="section-pad section-white"><div class="container"><SectionHeading eyebrow="ONE SHARED DATA FOUNDATION" title="四项服务,共用一套品牌知识与数据底座" description="诊断结论可以进入内容规划,优质内容可以同时服务官网、AI与社媒搜索,让每一次投入持续复用。" align="center" /><div class="connection-map" data-reveal><span>GEO</span><span>SMO</span><strong>品牌数据底座<i></i></strong><span>AI官网</span><span>内容运营</span></div></div></section>
<CTA title="不知道先做GEO还是SMO?" text="先用一次品牌全搜索诊断识别缺口,再决定服务组合与执行顺序。" />
</main><Footer /></Base>
import type { APIRoute } from "astro";
import path from "node:path";
import fs from "node:fs/promises";
import { UPLOADS_DIR } from "../../lib/article-store";
export const prerender = false;
const MIME_TYPES: Record<string, string> = {
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".webp": "image/webp",
".gif": "image/gif",
};
export const GET: APIRoute = async ({ params }) => {
const filename = params.file || "";
if (!/^[a-zA-Z0-9._-]+$/.test(filename)) return new Response("Not Found", { status: 404 });
try {
const content = await fs.readFile(path.join(UPLOADS_DIR, filename));
return new Response(content, {
headers: {
"Content-Type": MIME_TYPES[path.extname(filename).toLowerCase()] || "application/octet-stream",
"Cache-Control": "public, max-age=31536000, immutable",
},
});
} catch {
return new Response("Not Found", { status: 404 });
}
};
:root {
--brand-navy: #073b83;
--brand-blue: #1473e6;
--brand-blue-hover: #0e61c8;
--brand-green: #10b981;
--brand-green-hover: #0d966a;
--brand-teal: #19c7c4;
--brand-cyan: #43d4e8;
--text-primary: #142033;
--text-heading: #243247;
--text-secondary: #526070;
--text-muted: #8491a3;
--bg-primary: #fff;
--bg-secondary: #f7f9fc;
--bg-blue: #f1f7ff;
--bg-green: #effbf7;
--border-default: #e2e8f0;
--border-blue: #b9d7fa;
--border-green: #a8e8d2;
--dark-bg: #071d3b;
--dark-bg-secondary: #073b83;
--gradient-brand: linear-gradient(90deg, #1473e6 0%, #19c7c4 60%, #10b981 100%);
--gradient-ai: linear-gradient(135deg, #1473e6 0%, #43d4e8 100%);
--shadow-card: 0 4px 20px rgba(15, 35, 60, .06);
--shadow-hover: 0 16px 38px rgba(15, 35, 60, .1);
--container: 1240px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text-primary); background: var(--bg-primary); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
body, button, input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { color: inherit; }
address { font-style: normal; }
h1, h2, h3, p, ul, ol, blockquote { margin-top: 0; }
h1, h2, h3, strong { line-height: 1.25; }
::selection { color: #fff; background: var(--brand-blue); }
.container { width: min(calc(100% - 48px), var(--container)); margin-inline: auto; }
.section-pad { padding: 112px 0; }
.section-white { background: #fff; }
.section-muted { background: var(--bg-secondary); }
.section-blue { background: var(--bg-blue); }
.section-green { background: var(--bg-green); }
.skip-link { position: fixed; z-index: 1000; top: 12px; left: 12px; padding: 10px 16px; color: #fff; background: var(--dark-bg); transform: translateY(-150%); }
.skip-link:focus { transform: none; }
[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s ease; }
[data-reveal].is-visible { opacity: 1; transform: none; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--brand-blue); font-size: 12px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.eyebrow > span { width: 28px; height: 2px; background: var(--gradient-brand); }
.eyebrow--light, .section-heading--light .eyebrow { color: var(--brand-cyan); }
.section-heading { max-width: 710px; }
.section-heading--center { margin-inline: auto; text-align: center; }
.section-heading--center .eyebrow { justify-content: center; }
.section-heading h2 { margin-bottom: 22px; color: var(--text-primary); font-size: clamp(34px, 4vw, 54px); font-weight: 720; letter-spacing: -.035em; }
.section-heading p { margin-bottom: 0; color: var(--text-secondary); font-size: 17px; line-height: 1.9; }
.section-heading--light h2 { color: #fff; }
.section-heading--light p { color: rgba(255,255,255,.68); }
.section-intro-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 42px; margin-bottom: 55px; }
.text-link { display: inline-flex; align-items: center; gap: 12px; flex: none; color: var(--brand-navy); font-weight: 650; }
.text-link span { color: var(--brand-blue); transition: transform .25s; }
.text-link:hover span { transform: translate(4px,-4px); }
.text-link--light { color: #fff; }
.text-link--light span { color: var(--brand-cyan); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 27px; border: 1px solid var(--brand-blue); border-radius: 9px; color: #fff; background: var(--brand-blue); box-shadow: 0 8px 20px rgba(20,115,230,.16); font-size: 15px; font-weight: 680; line-height: 1; cursor: pointer; transition: background .25s, border-color .25s, transform .25s, box-shadow .25s; }
.button:hover { background: var(--brand-blue-hover); border-color: var(--brand-blue-hover); transform: translateY(-2px); box-shadow: 0 12px 26px rgba(20,115,230,.2); }
.button:focus-visible { outline: 4px solid rgba(20,115,230,.2); outline-offset: 2px; }
.button--small { min-height: 42px; padding-inline: 19px; font-size: 14px; }
.button--outline { color: var(--brand-navy); background: #fff; border-color: #cbd8e8; box-shadow: none; }
.button--outline:hover { color: var(--brand-blue); background: var(--bg-blue); border-color: var(--brand-blue); box-shadow: none; }
.button--green { background: var(--brand-green); border-color: var(--brand-green); box-shadow: 0 8px 20px rgba(16,185,129,.14); }
.button--green:hover { background: var(--brand-green-hover); border-color: var(--brand-green-hover); }
.button--white { color: var(--brand-navy); background: #fff; border-color: #fff; box-shadow: 0 12px 28px rgba(0,0,0,.12); }
.button--white:hover { color: var(--brand-blue); background: var(--bg-blue); border-color: var(--bg-blue); }
.button--ghost { color: #fff; background: transparent; border-color: rgba(255,255,255,.32); box-shadow: none; }
.button--ghost:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.6); box-shadow: none; }
.site-header { position: sticky; z-index: 50; top: 0; height: 78px; border-bottom: 1px solid rgba(226,232,240,.8); background: rgba(255,255,255,.92); backdrop-filter: blur(16px); transition: height .25s, box-shadow .25s; }
.site-header.is-scrolled { height: 70px; box-shadow: 0 8px 30px rgba(15,35,60,.07); }
.site-header__inner { display: flex; align-items: center; height: 100%; }
.brand { flex: none; width: 200px; }
.brand img { width: 100%; height: auto; }
.desktop-nav { margin-left: auto; }
.desktop-nav > ul { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav-item { position: relative; }
.nav-link { display: flex; align-items: center; min-height: 70px; padding: 0 13px; color: var(--text-secondary); font-size: 14px; font-weight: 620; transition: color .2s; }
.nav-link::after { position: absolute; right: 13px; bottom: 9px; left: 13px; height: 2px; content: ""; background: var(--gradient-brand); transform: scaleX(0); transition: transform .25s; }
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--brand-navy); }
.nav-link[aria-current="page"]::after { transform: scaleX(1); }
.nav-dropdown { position: absolute; top: calc(100% - 5px); left: 50%; min-width: 210px; padding-top: 10px; opacity: 0; pointer-events: none; transform: translate(-50%,8px); transition: opacity .2s, transform .2s; }
.nav-item:hover .nav-dropdown, .nav-item:focus-within .nav-dropdown { opacity: 1; pointer-events: auto; transform: translate(-50%,0); }
.nav-dropdown ul { margin: 0; padding: 9px; border: 1px solid var(--border-default); border-radius: 12px; background: #fff; box-shadow: 0 18px 46px rgba(15,35,60,.12); list-style: none; }
.nav-dropdown a { display: flex; justify-content: space-between; gap: 18px; padding: 10px 12px; border-radius: 7px; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.nav-dropdown a:hover { color: var(--brand-blue); background: var(--bg-blue); }
.nav-dropdown span { color: var(--text-muted); }
.header-cta { margin-left: 18px; }
.mobile-nav { display: none; margin-left: auto; }
.hero { position: relative; overflow: hidden; padding: 86px 0 0; background: radial-gradient(circle at 10% 20%, rgba(20,115,230,.1), transparent 35%), radial-gradient(circle at 88% 55%, rgba(25,199,196,.12), transparent 38%), #fff; }
.hero::before { position: absolute; inset: 0; content: ""; background-image: linear-gradient(rgba(20,115,230,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(20,115,230,.035) 1px, transparent 1px); background-size: 72px 72px; mask-image: linear-gradient(to bottom, #000, transparent 90%); }
.hero-grid-glow { position: absolute; top: 12%; right: 6%; width: 480px; height: 480px; border-radius: 50%; background: rgba(67,212,232,.1); filter: blur(70px); }
.hero__grid { position: relative; display: grid; grid-template-columns: 1.02fr .98fr; align-items: center; gap: 70px; min-height: 590px; }
.hero__content { position: relative; z-index: 2; padding-bottom: 60px; }
.hero-pill { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 25px; padding: 7px 9px 7px 12px; border: 1px solid #d8e6f5; border-radius: 999px; color: var(--brand-navy); background: rgba(255,255,255,.74); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.hero-pill > span { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green); box-shadow: 0 0 0 4px rgba(16,185,129,.12); }
.hero-pill i { padding: 4px 9px; border-radius: 999px; color: var(--brand-blue); background: var(--bg-blue); font-style: normal; }
.hero h1 { margin-bottom: 28px; color: var(--text-primary); font-size: clamp(48px, 5.3vw, 76px); font-weight: 760; letter-spacing: -.055em; line-height: 1.12; }
.hero h1 em { color: transparent; background: var(--gradient-brand); background-clip: text; -webkit-background-clip: text; font-style: normal; }
.hero__content > p { max-width: 650px; margin-bottom: 34px; color: var(--text-secondary); font-size: 18px; line-height: 1.9; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 14px; }
.hero__proof { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 30px; color: var(--text-muted); font-size: 13px; }
.hero__proof span::before { margin-right: 6px; color: var(--brand-green); content: "✓"; font-weight: 800; }
.hero-visual { position: relative; min-height: 530px; }
.visual-orbit { position: absolute; border: 1px dashed rgba(20,115,230,.16); border-radius: 50%; }
.visual-orbit--one { inset: 34px 0 20px 25px; animation: orbit 25s linear infinite; }
.visual-orbit--two { inset: 92px 58px 78px 82px; border-color: rgba(16,185,129,.18); animation: orbit 18s linear infinite reverse; }
@keyframes orbit { to { transform: rotate(360deg); } }
.search-card { position: absolute; z-index: 2; inset: 52px 26px 35px 48px; padding: 26px; border: 1px solid rgba(185,215,250,.8); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: 0 30px 80px rgba(14,61,110,.14); backdrop-filter: blur(18px); }
.search-card__top { display: flex; align-items: center; justify-content: space-between; }
.search-brand { display: flex; align-items: center; gap: 12px; }
.search-brand__mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: var(--gradient-ai); font-size: 13px; font-weight: 800; }
.search-brand div { display: flex; flex-direction: column; }
.search-brand strong { font-size: 14px; }
.search-brand small { color: var(--text-muted); font-size: 11px; }
.live-dot { padding: 5px 8px; border-radius: 999px; color: var(--brand-green); background: var(--bg-green); font-size: 10px; font-weight: 800; }
.live-dot::before { display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; content: ""; background: currentColor; }
.score-ring { display: grid; place-items: center; width: 132px; height: 132px; margin: 22px auto 12px; border-radius: 50%; background: conic-gradient(var(--brand-blue) 0 65%, var(--brand-teal) 65% 86%, #e9eef5 86%); }
.score-ring::before { position: absolute; width: 102px; height: 102px; border-radius: 50%; content: ""; background: #fff; }
.score-ring > div { position: relative; z-index: 1; display: flex; flex-direction: column; text-align: center; }
.score-ring strong { color: var(--brand-navy); font-size: 34px; }
.score-ring span { color: var(--text-muted); font-size: 10px; }
.metric-list { display: grid; gap: 10px; }
.metric-list > div { display: grid; grid-template-columns: 90px 1fr 38px; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 11px; }
.metric-list i { overflow: hidden; height: 5px; border-radius: 999px; background: #e9eef5; }
.metric-list b { display: block; height: 100%; border-radius: inherit; background: var(--brand-blue); }
.metric-list__green b { background: var(--brand-green); }
.metric-list strong { color: var(--text-heading); text-align: right; }
.trend-card { margin-top: 20px; padding: 13px 15px 8px; border: 1px solid var(--border-default); border-radius: 12px; background: #fbfdff; }
.trend-card > div { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; }
.trend-card strong { color: var(--brand-green); font-size: 12px; }
.trend-card svg { width: 100%; height: 54px; }
.trend-line { fill: none; stroke: var(--brand-teal); stroke-width: 2.5; }
.trend-area { fill: url(#area); }
.float-card { position: absolute; z-index: 3; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-width: 250px; padding: 13px; border: 1px solid var(--border-default); border-radius: 13px; background: rgba(255,255,255,.96); box-shadow: 0 14px 36px rgba(15,35,60,.12); }
.float-card > span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; color: #fff; background: var(--brand-blue); font-size: 10px; font-weight: 800; }
.float-card div { display: flex; flex-direction: column; }
.float-card strong { font-size: 12px; }
.float-card small { color: var(--text-muted); font-size: 9px; }
.float-card b { color: var(--brand-blue); font-size: 14px; }
.float-card--geo { top: 35px; right: -8px; }
.float-card--smo { right: 75px; bottom: 10px; }
.float-card--smo > span { background: var(--brand-green); }
.float-card--smo b { color: var(--brand-green); }
.hero-platforms { position: relative; z-index: 3; display: grid; grid-template-columns: 180px 1fr; align-items: center; min-height: 94px; border-top: 1px solid rgba(226,232,240,.8); color: var(--text-muted); font-size: 12px; }
.platform-strip { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.platform-strip__track { display: flex; width: max-content; animation: marquee 30s linear infinite; }
.platform-strip span { display: flex; align-items: center; gap: 8px; padding: 0 22px; color: var(--text-secondary); font-size: 13px; font-weight: 620; white-space: nowrap; }
.platform-strip i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-teal); }
@keyframes marquee { to { transform: translateX(-50%); } }
.stat-band { color: #fff; background: var(--brand-navy); }
.stat-band--light { color: var(--text-primary); background: #fff; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); }
.stat-grid > div { position: relative; padding: 34px 36px; border-right: 1px solid rgba(255,255,255,.16); }
.stat-band--light .stat-grid > div { border-color: var(--border-default); }
.stat-grid > div:first-child { border-left: 1px solid rgba(255,255,255,.16); }
.stat-band--light .stat-grid > div:first-child { border-color: var(--border-default); }
.stat-grid strong { display: block; color: var(--brand-cyan); font-size: clamp(34px,4vw,50px); letter-spacing: -.04em; }
.stat-band--light .stat-grid strong { color: var(--brand-blue); }
.stat-grid p { margin: 4px 0 0; color: rgba(255,255,255,.68); font-size: 13px; }
.stat-band--light .stat-grid p { color: var(--text-muted); }
.engine-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 24px; margin-top: 56px; }
.engine-card { position: relative; overflow: hidden; padding: 38px; border: 1px solid var(--border-blue); border-radius: 18px; background: linear-gradient(145deg,#fff 20%,var(--bg-blue)); transition: transform .3s, box-shadow .3s; }
.engine-card::after { position: absolute; right: -80px; bottom: -80px; width: 230px; height: 230px; border: 1px solid rgba(20,115,230,.12); border-radius: 50%; content: ""; box-shadow: 0 0 0 35px rgba(20,115,230,.04), 0 0 0 70px rgba(20,115,230,.025); }
.engine-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }
.engine-card--smo { border-color: var(--border-green); background: linear-gradient(145deg,#fff 20%,var(--bg-green)); }
.engine-card--smo::after { border-color: rgba(16,185,129,.14); box-shadow: 0 0 0 35px rgba(16,185,129,.04), 0 0 0 70px rgba(16,185,129,.025); }
.engine-card__head { display: flex; align-items: center; justify-content: space-between; }
.service-index { color: var(--text-muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.service-badge { padding: 5px 9px; border-radius: 999px; color: var(--brand-blue); background: #e7f1ff; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.engine-card--smo .service-badge { color: var(--brand-green); background: #dff8ee; }
.engine-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 28px 0 22px; border-radius: 15px; color: var(--brand-blue); background: #e7f1ff; font-size: 28px; }
.engine-card--smo .engine-icon { color: var(--brand-green); background: #dff8ee; }
.engine-card__kicker { margin-bottom: 6px; color: var(--text-muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.engine-card h2 { margin-bottom: 15px; font-size: 32px; }
.engine-card > p:not(.engine-card__kicker) { color: var(--text-secondary); }
.engine-card ul { display: grid; gap: 12px; margin: 25px 0; padding: 24px 0; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); list-style: none; }
.engine-card li { display: grid; grid-template-columns: 20px 1fr; gap: 7px; color: var(--text-secondary); font-size: 13px; }
.engine-card li span { color: var(--brand-blue); font-weight: 800; }
.engine-card--smo li span { color: var(--brand-green); }
.engine-card > a { position: relative; z-index: 1; display: inline-flex; gap: 9px; color: var(--brand-blue); font-size: 14px; font-weight: 700; }
.engine-card--smo > a { color: var(--brand-green); }
.support-service-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; margin-top: 20px; }
.support-service-grid > a { display: grid; grid-template-columns: 32px 1fr auto; gap: 18px; padding: 28px 30px; border: 1px solid var(--border-default); border-radius: 15px; background: #fff; box-shadow: var(--shadow-card); transition: transform .25s, border-color .25s; }
.support-service-grid > a:hover { transform: translateY(-4px); border-color: var(--brand-teal); }
.support-service-grid small { color: var(--brand-teal); font-size: 10px; font-weight: 750; letter-spacing: .1em; }
.support-service-grid h3 { margin: 5px 0 8px; font-size: 20px; }
.support-service-grid p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.support-service-grid i { color: var(--brand-blue); font-style: normal; font-size: 20px; }
.tech-section { position: relative; overflow: hidden; color: #fff; background: radial-gradient(circle at 80% 20%, rgba(20,115,230,.3), transparent 35%), var(--dark-bg); }
.tech-grid-lines { position: absolute; inset: 0; opacity: .1; background-image: linear-gradient(rgba(67,212,232,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(67,212,232,.6) 1px, transparent 1px); background-size: 80px 80px; mask-image: linear-gradient(90deg, transparent, #000 40%, #000); }
.tech-layout { position: relative; display: grid; grid-template-columns: .9fr 1.1fr; gap: 100px; align-items: center; }
.tech-layout .text-link { margin-top: 30px; }
.tech-stack { border-top: 1px solid rgba(255,255,255,.16); }
.tech-stack > div { display: grid; grid-template-columns: 42px 1fr 60px; align-items: center; min-height: 76px; border-bottom: 1px solid rgba(255,255,255,.14); }
.tech-stack span { color: var(--brand-cyan); font-size: 11px; }
.tech-stack strong { color: rgba(255,255,255,.9); font-size: 15px; }
.tech-stack i { height: 3px; background: linear-gradient(90deg,var(--brand-blue),var(--brand-teal)); transform-origin: left; transition: transform .3s; }
.tech-stack > div:hover i { transform: scaleX(1.35); }
.tech-data-row { position: relative; display: grid; grid-template-columns: repeat(4,1fr); margin-top: 76px; border: 1px solid rgba(255,255,255,.12); }
.tech-data-row > div { display: flex; flex-direction: column; gap: 4px; padding: 24px; border-right: 1px solid rgba(255,255,255,.12); }
.tech-data-row > div:last-child { border-right: 0; }
.tech-data-row strong { color: var(--brand-cyan); font-size: 14px; letter-spacing: .08em; }
.tech-data-row span { color: rgba(255,255,255,.58); font-size: 12px; }
.workflow-grid { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.workflow-grid article { padding: 32px 28px; border-right: 1px solid var(--border-default); }
.workflow-grid article:last-child { border-right: 0; }
.workflow-grid article > div { display: flex; justify-content: space-between; margin-bottom: 40px; }
.workflow-grid article span { color: var(--brand-blue); font-size: 12px; font-weight: 700; }
.workflow-grid article i { color: var(--brand-teal); font-style: normal; }
.workflow-grid h3 { margin-bottom: 12px; font-size: 24px; }
.workflow-grid p { margin: 0; color: var(--text-secondary); font-size: 14px; }
.scenario-section { background: linear-gradient(90deg,#f8fbff 0,#f8fbff 45%,#f1fbf8 100%); }
.scenario-layout { display: grid; grid-template-columns: .82fr 1.18fr; gap: 70px; align-items: center; }
.scenario-copy .button { margin-top: 30px; }
.scenario-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.scenario-card { min-height: 220px; padding: 27px; border: 1px solid var(--border-blue); border-radius: 14px; background: rgba(255,255,255,.86); box-shadow: var(--shadow-card); }
.scenario-card--smo { border-color: var(--border-green); }
.scenario-card--platform { border-color: #bce5e4; }
.scenario-card > span { display: inline-block; margin-bottom: 42px; color: var(--brand-blue); font-size: 11px; font-weight: 800; }
.scenario-card--smo > span { color: var(--brand-green); }
.scenario-card--platform > span { color: var(--brand-teal); }
.scenario-card h3 { margin-bottom: 11px; font-size: 18px; }
.scenario-card p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.page-hero { position: relative; overflow: hidden; min-height: 500px; padding: 112px 0 92px; background: radial-gradient(circle at 12% 20%, rgba(20,115,230,.1), transparent 34%), radial-gradient(circle at 88% 62%, rgba(25,199,196,.12), transparent 38%), #fff; }
.page-hero::after { position: absolute; right: -5%; bottom: -55%; width: 600px; height: 600px; border: 1px solid rgba(20,115,230,.1); border-radius: 50%; content: ""; box-shadow: 0 0 0 70px rgba(20,115,230,.025), 0 0 0 140px rgba(25,199,196,.025); }
.page-hero__mesh { position: absolute; inset: 0; opacity: .45; background-image: linear-gradient(rgba(20,115,230,.04) 1px, transparent 1px), linear-gradient(90deg,rgba(20,115,230,.04) 1px,transparent 1px); background-size: 80px 80px; mask-image: linear-gradient(90deg,#000,transparent 75%); }
.page-hero__inner { position: relative; z-index: 2; max-width: 950px; margin-left: max(24px, calc((100% - min(calc(100% - 48px), var(--container))) / 2)); margin-right: auto; }
.breadcrumb { margin-bottom: 42px; color: var(--text-muted); font-size: 12px; }
.breadcrumb a:hover { color: var(--brand-blue); }
.page-hero h1 { margin-bottom: 24px; font-size: clamp(46px,6vw,72px); letter-spacing: -.05em; }
.page-hero h1 em { color: transparent; background: var(--gradient-brand); background-clip: text; -webkit-background-clip: text; font-style: normal; }
.page-hero__inner > p { max-width: 720px; margin: 0; color: var(--text-secondary); font-size: 18px; line-height: 1.9; }
.anchor-nav { position: sticky; z-index: 20; top: 70px; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); background: rgba(255,255,255,.95); backdrop-filter: blur(14px); }
.anchor-nav .container { display: grid; grid-template-columns: repeat(4,1fr); }
.anchor-nav a { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 64px; border-right: 1px solid var(--border-default); color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.anchor-nav a:first-child { border-left: 1px solid var(--border-default); }
.anchor-nav a:hover { color: var(--brand-blue); background: var(--bg-blue); }
.anchor-nav span { color: var(--brand-teal); font-size: 10px; }
.service-list { display: grid; gap: 30px; }
.service-detail { display: grid; grid-template-columns: .9fr 1.1fr; gap: 72px; align-items: center; padding: 52px; border: 1px solid var(--border-default); border-radius: 20px; background: #fff; box-shadow: var(--shadow-card); scroll-margin-top: 150px; }
.service-detail--reverse .service-detail__visual { order: 2; }
.service-detail__visual { position: relative; overflow: hidden; min-height: 420px; border-radius: 16px; color: #fff; background: linear-gradient(145deg,#0b438d,var(--brand-blue)); }
.service-detail--smo .service-detail__visual { background: linear-gradient(145deg,#087b5d,var(--brand-green)); }
.service-detail--platform .service-detail__visual { background: linear-gradient(145deg,#0d6087,var(--brand-teal)); }
.service-detail__visual::before { position: absolute; inset: 0; content: ""; background-image: linear-gradient(rgba(255,255,255,.06) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.06) 1px,transparent 1px); background-size: 48px 48px; }
.service-visual__top { position: relative; display: flex; justify-content: space-between; padding: 25px; border-bottom: 1px solid rgba(255,255,255,.16); }
.service-visual__top span { font-size: 12px; font-weight: 800; }
.service-visual__top small { opacity: .62; font-size: 9px; letter-spacing: .12em; }
.service-visual__core { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 260px; }
.service-visual__core > div { position: relative; display: grid; place-items: center; width: 130px; height: 130px; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; box-shadow: 0 0 0 25px rgba(255,255,255,.05), 0 0 0 50px rgba(255,255,255,.03); }
.service-visual__core i { position: absolute; inset: 18px; border: 1px dashed rgba(255,255,255,.45); border-radius: 50%; animation: orbit 12s linear infinite; }
.service-visual__core strong { font-size: 30px; }
.service-visual__core > span { margin-top: 28px; font-size: 13px; font-weight: 700; }
.service-visual__nodes { position: relative; display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid rgba(255,255,255,.16); }
.service-visual__nodes span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 55px; border-right: 1px solid rgba(255,255,255,.12); font-size: 10px; }
.service-visual__nodes i { width: 4px; height: 4px; border-radius: 50%; background: var(--brand-cyan); }
.service-detail__content h2 { margin-bottom: 18px; font-size: 38px; }
.service-detail__content .lead { color: var(--text-secondary); font-size: 17px; }
.service-detail__content ul { display: grid; gap: 14px; margin: 28px 0; padding: 25px 0; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); list-style: none; }
.service-detail__content li { display: grid; grid-template-columns: 24px 1fr; color: var(--text-secondary); font-size: 14px; }
.service-detail__content li span { color: var(--brand-blue); font-weight: 800; }
.service-detail--smo .service-detail__content li span { color: var(--brand-green); }
.capability-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.capability-pills span { padding: 6px 10px; border-radius: 5px; color: var(--brand-navy); background: var(--bg-blue); font-size: 11px; }
.service-detail--smo .capability-pills span { color: var(--brand-green-hover); background: var(--bg-green); }
.connection-map { position: relative; display: grid; grid-template-columns: 1fr 1fr 1.4fr 1fr 1fr; align-items: center; max-width: 980px; margin: 60px auto 0; }
.connection-map::before { position: absolute; top: 50%; right: 8%; left: 8%; height: 1px; content: ""; background: var(--gradient-brand); }
.connection-map > span, .connection-map > strong { position: relative; z-index: 1; display: grid; place-items: center; width: 110px; height: 110px; margin: auto; border: 1px solid var(--border-default); border-radius: 50%; background: #fff; font-size: 12px; }
.connection-map > strong { width: 160px; height: 160px; color: #fff; background: var(--brand-navy); border-color: var(--brand-navy); text-align: center; }
.connection-map i { position: absolute; inset: 16px; border: 1px dashed rgba(255,255,255,.4); border-radius: 50%; animation: orbit 16s linear infinite; }
.service-hero { position: relative; overflow: hidden; padding: 100px 0; background: linear-gradient(120deg,#fff 0,#f3f8ff 65%,#edfbfa); }
.service-hero--smo { background: linear-gradient(120deg,#fff 0,#f4fbf8 65%,#e9faf5); }
.service-hero__grid { position: absolute; inset: 0; opacity: .55; background-image: linear-gradient(rgba(20,115,230,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(20,115,230,.04) 1px,transparent 1px); background-size: 68px 68px; }
.service-hero__inner { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 70px; }
.service-hero__tag { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; color: var(--brand-blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.service-hero__tag span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--brand-blue); }
.service-hero--smo .service-hero__tag { color: var(--brand-green); }
.service-hero--smo .service-hero__tag span { background: var(--brand-green); }
.service-hero h1 { margin-bottom: 34px; font-size: clamp(44px,5.2vw,68px); letter-spacing: -.05em; }
.service-hero h1 em { display: block; max-width: 650px; margin-top: 18px; color: var(--text-secondary); font-size: 19px; font-style: normal; font-weight: 430; letter-spacing: 0; line-height: 1.8; }
.service-hero-console { overflow: hidden; border: 1px solid var(--border-blue); border-radius: 17px; background: rgba(255,255,255,.94); box-shadow: 0 28px 70px rgba(20,70,120,.14); }
.service-hero--smo .service-hero-console { border-color: var(--border-green); }
.console-top { display: flex; align-items: center; gap: 6px; height: 45px; padding: 0 16px; border-bottom: 1px solid var(--border-default); }
.console-top i { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.console-top i:nth-child(1) { background: #e5484d; }.console-top i:nth-child(2) { background: #f59e0b; }.console-top i:nth-child(3) { background: var(--brand-green); }
.console-top span { margin-left: auto; color: var(--text-muted); font-size: 9px; letter-spacing: .1em; }
.console-main { display: grid; grid-template-columns: 150px 1fr; gap: 20px; min-height: 280px; padding: 28px; }
.console-score { display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid var(--border-default); }
.console-score span { color: var(--text-muted); font-size: 9px; letter-spacing: .1em; }
.console-score strong { color: var(--brand-blue); font-size: 62px; letter-spacing: -.07em; }
.service-hero--smo .console-score strong { color: var(--brand-green); }
.console-score small { color: var(--text-muted); font-size: 10px; }
.console-chart { display: flex; align-items: flex-end; gap: 9px; padding-top: 30px; border-bottom: 1px solid var(--border-default); }
.console-chart > i { position: relative; flex: 1; min-height: 15px; border-radius: 4px 4px 0 0; background: linear-gradient(to top,var(--brand-blue),var(--brand-cyan)); }
.service-hero--smo .console-chart > i { background: linear-gradient(to top,var(--brand-green),var(--brand-teal)); }
.console-chart span { position: absolute; bottom: -25px; left: 50%; color: var(--text-muted); font-size: 8px; font-style: normal; transform: translateX(-50%); }
.console-foot { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--border-default); }
.console-foot span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; border-right: 1px solid var(--border-default); color: var(--text-secondary); font-size: 10px; }
.console-foot i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-teal); }
.service-cap-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 80px; }
.service-cap-layout > div:first-child h2 { margin-bottom: 18px; font-size: 42px; letter-spacing: -.04em; }
.service-cap-layout > div:first-child p { color: var(--text-secondary); }
.service-cap-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.service-cap-grid article { min-height: 190px; padding: 27px; border: 1px solid var(--border-default); border-radius: 13px; background: #fff; }
.service-cap-grid span { color: var(--brand-blue); font-size: 11px; font-weight: 700; }
.service-cap-grid h3 { margin: 35px 0 8px; font-size: 19px; }
.service-cap-grid p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.service-feature-layout { display: grid; grid-template-columns: .85fr 1.15fr; align-items: center; gap: 90px; }
.service-symbol { position: relative; display: grid; place-items: center; aspect-ratio: 1; max-width: 480px; margin: auto; border-radius: 50%; background: var(--bg-blue); box-shadow: inset 0 0 0 1px var(--border-blue), inset 0 0 0 40px #fff, inset 0 0 0 41px var(--border-blue); }
.service-symbol--smo { background: var(--bg-green); box-shadow: inset 0 0 0 1px var(--border-green),inset 0 0 0 40px #fff,inset 0 0 0 41px var(--border-green); }
.service-symbol::after { position: absolute; inset: 100px; border: 1px dashed var(--brand-blue); border-radius: 50%; content: ""; animation: orbit 20s linear infinite; }
.service-symbol--smo::after { border-color: var(--brand-green); }
.service-symbol span { position: absolute; top: 65px; color: var(--brand-blue); font-size: 12px; font-weight: 800; letter-spacing: .15em; }
.service-symbol--smo span { color: var(--brand-green); }
.service-symbol strong { color: var(--brand-navy); font-size: 72px; }
.service-symbol i { position: absolute; width: 10px; height: 10px; margin: -210px 0 0 160px; border-radius: 50%; background: var(--brand-teal); box-shadow: 0 0 0 8px rgba(25,199,196,.14); }
.service-feature-layout > div:last-child h2 { margin-bottom: 24px; font-size: 42px; letter-spacing: -.04em; }
.large-check-list { margin: 0; padding: 0; border-top: 1px solid var(--border-default); list-style: none; }
.large-check-list li { display: grid; grid-template-columns: 42px 1fr; gap: 18px; padding: 22px 0; border-bottom: 1px solid var(--border-default); }
.large-check-list span { color: var(--brand-blue); font-size: 11px; font-weight: 700; }
.large-check-list p { margin: 0; color: var(--text-secondary); }
.process-section { color: #fff; background: var(--brand-navy); }
.process-section .section-heading { margin-bottom: 55px; }
.process-grid { display: grid; grid-template-columns: repeat(4,1fr); border: 1px solid rgba(255,255,255,.15); }
.process-grid article { position: relative; min-height: 190px; padding: 28px; border-right: 1px solid rgba(255,255,255,.14); }
.process-grid article:last-child { border-right: 0; }
.process-grid span { color: var(--brand-cyan); font-size: 11px; }
.process-grid h3 { margin-top: 65px; color: #fff; font-size: 18px; }
.process-grid i { position: absolute; top: 50%; right: -10px; z-index: 2; color: var(--brand-teal); font-style: normal; }
.process-grid article:last-child i { right: 24px; }
.related-services { background: #fff; border-bottom: 1px solid var(--border-default); }
.related-services .container { display: grid; grid-template-columns: repeat(3,1fr); }
.related-services a { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; min-height: 86px; padding: 0 22px; border-right: 1px solid var(--border-default); }
.related-services a:first-child { border-left: 1px solid var(--border-default); }
.related-services span { color: var(--brand-teal); font-size: 10px; }
.related-services strong { font-size: 13px; }
.related-services i { color: var(--brand-blue); font-style: normal; }
.about-intro-layout { display: grid; grid-template-columns: .78fr 1.22fr; gap: 90px; }
.story-column { border-top: 1px solid var(--border-default); }
.story-column p { display: grid; grid-template-columns: 44px 1fr; gap: 20px; margin: 0; padding: 26px 0; border-bottom: 1px solid var(--border-default); color: var(--text-secondary); line-height: 1.9; }
.story-column span { color: var(--brand-blue); font-size: 11px; font-weight: 700; }
.advantage-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-top: 52px; }
.advantage-grid article { min-height: 250px; padding: 28px; border: 1px solid var(--border-default); border-radius: 14px; background: #fff; transition: transform .25s,box-shadow .25s,border-color .25s; }
.advantage-grid article:hover { transform: translateY(-5px); border-color: var(--border-blue); box-shadow: var(--shadow-hover); }
.advantage-grid article > span { color: var(--text-muted); font-size: 10px; }
.advantage-icon { display: grid; place-items: center; width: 45px; height: 45px; margin: 28px 0 20px; border-radius: 11px; color: var(--brand-blue); background: var(--bg-blue); font-size: 22px; }
.advantage-grid article:nth-child(2n) .advantage-icon { color: var(--brand-green); background: var(--bg-green); }
.advantage-grid h3 { margin-bottom: 10px; font-size: 20px; }
.advantage-grid p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.about-tech { color: #fff; background: var(--dark-bg); }
.about-tech-layout { display: grid; grid-template-columns: .9fr 1.1fr; gap: 90px; align-items: center; }
.technology-list { border-top: 1px solid rgba(255,255,255,.16); }
.technology-list article { display: grid; grid-template-columns: 45px 1fr 60px; align-items: center; min-height: 82px; border-bottom: 1px solid rgba(255,255,255,.14); }
.technology-list span { color: var(--brand-cyan); font-size: 10px; }
.technology-list h3 { margin: 0; color: rgba(255,255,255,.88); font-size: 15px; font-weight: 560; }
.technology-list i { height: 2px; background: var(--gradient-brand); }
.vision-section { background: linear-gradient(120deg,var(--bg-blue),#fff 55%,var(--bg-green)); }
.vision-card { padding: 70px; border: 1px solid rgba(185,215,250,.8); border-radius: 20px; background: rgba(255,255,255,.82); box-shadow: var(--shadow-card); text-align: center; }
.vision-card > span { color: var(--brand-blue); font-size: 11px; font-weight: 750; letter-spacing: .13em; }
.vision-card blockquote { max-width: 900px; margin: 32px auto; color: var(--text-primary); font-size: clamp(28px,4vw,46px); font-weight: 700; letter-spacing: -.035em; line-height: 1.45; }
.vision-card > div { display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }
.vision-card i { width: 34px; height: 3px; background: var(--gradient-brand); }
.vision-card p { margin: 0; }
.method-flow { display: grid; grid-template-columns: repeat(4,1fr); margin-top: 55px; }
.method-flow article { padding: 30px; border: 1px solid var(--border-default); border-right: 0; }
.method-flow article:last-child { border-right: 1px solid var(--border-default); }
.method-flow article > div { display: flex; justify-content: space-between; margin-bottom: 80px; }
.method-flow span { color: var(--brand-blue); font-size: 12px; font-weight: 700; }
.method-flow i { color: var(--brand-teal); font-style: normal; }
.method-flow h2 { margin-bottom: 12px; font-size: 24px; }
.method-flow p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.delivery-section { color: #fff; background: linear-gradient(135deg,var(--dark-bg),var(--brand-navy)); }
.delivery-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 85px; }
.delivery-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.delivery-grid article { min-height: 190px; padding: 26px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.04); }
.delivery-grid span { color: var(--brand-cyan); font-size: 10px; }
.delivery-grid h3 { margin: 45px 0 10px; color: #fff; }
.delivery-grid p { margin: 0; color: rgba(255,255,255,.62); font-size: 13px; }
.principle-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; margin-top: 50px; }
.principle-grid article { padding: 36px; border: 1px solid var(--border-default); border-radius: 14px; background: #fff; }
.principle-grid span { color: var(--brand-blue); font-size: 10px; }
.principle-grid h3 { margin: 55px 0 12px; font-size: 24px; }
.principle-grid p { margin: 0; color: var(--text-secondary); }
.faq-layout { display: grid; grid-template-columns: 310px 1fr; gap: 70px; align-items: start; }
.faq-layout aside { position: sticky; top: 120px; padding: 28px; border: 1px solid var(--border-default); border-radius: 14px; background: #fff; }
.faq-layout aside > span { color: var(--brand-blue); font-size: 11px; font-weight: 750; }
.faq-layout aside h2 { margin: 38px 0 14px; font-size: 24px; }
.faq-layout aside p { color: var(--text-secondary); font-size: 13px; }
.faq-layout aside .button { margin-top: 15px; }
.faq-list { border-top: 1px solid var(--border-default); }
.faq-list details { border-bottom: 1px solid var(--border-default); }
.faq-list summary { display: grid; grid-template-columns: 48px 1fr 24px; gap: 12px; align-items: center; min-height: 94px; padding: 20px 0; cursor: pointer; list-style: none; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary > span { color: var(--brand-blue); font-size: 11px; font-weight: 700; }
.faq-list summary strong { font-size: 17px; }
.faq-list summary i { position: relative; width: 16px; height: 16px; }
.faq-list summary i::before,.faq-list summary i::after { position: absolute; top: 7px; left: 0; width: 16px; height: 2px; content: ""; background: var(--brand-blue); transition: transform .25s; }
.faq-list summary i::after { transform: rotate(90deg); }
.faq-list details[open] summary i::after { transform: rotate(0); }
.faq-list details > div { padding: 0 40px 26px 60px; }
.faq-list details p { margin: 0; color: var(--text-secondary); line-height: 1.9; }
.contact-hero { position: relative; overflow: hidden; padding: 110px 0; color: #fff; background: linear-gradient(130deg,var(--dark-bg) 0,var(--brand-navy) 70%,#075b88); }
.contact-hero__glow { position: absolute; right: 5%; bottom: -50%; width: 600px; height: 600px; border-radius: 50%; background: rgba(25,199,196,.18); filter: blur(40px); }
.contact-hero__grid { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 80px; }
.contact-hero .breadcrumb { color: rgba(255,255,255,.52); }
.contact-hero h1 { max-width: 720px; margin-bottom: 22px; font-size: clamp(46px,6vw,72px); letter-spacing: -.05em; }
.contact-hero__grid > div:first-child > p { max-width: 650px; margin-bottom: 32px; color: rgba(255,255,255,.7); font-size: 17px; }
.contact-radar { position: relative; min-height: 410px; }
.radar-ring { position: absolute; top: 50%; left: 50%; border: 1px solid rgba(67,212,232,.28); border-radius: 50%; transform: translate(-50%,-50%); }
.radar-ring--one { width: 360px; height: 360px; box-shadow: inset 0 0 60px rgba(25,199,196,.06); }
.radar-ring--two { width: 240px; height: 240px; border-style: dashed; animation: orbit 22s linear infinite; }
.radar-core { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; background: var(--gradient-brand); box-shadow: 0 0 50px rgba(67,212,232,.35); transform: translate(-50%,-50%); }
.radar-core strong { font-size: 34px; }
.radar-core span { font-size: 10px; }
.radar-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--brand-cyan); box-shadow: 0 0 0 8px rgba(67,212,232,.1); }
.radar-dot--one { top: 70px; right: 95px; }.radar-dot--two { right: 55px; bottom: 95px; background: var(--brand-green); }.radar-dot--three { bottom: 70px; left: 100px; }
.contact-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }
.contact-grid article { min-height: 250px; padding: 32px; border: 1px solid var(--border-default); border-radius: 14px; background: #fff; }
.contact-grid article > span { color: var(--brand-blue); font-size: 11px; font-weight: 700; }
.contact-grid h2 { margin: 48px 0 15px; font-size: 18px; }
.contact-grid p { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; }
.contact-big-link { color: var(--brand-blue); font-size: clamp(24px,3vw,38px); font-weight: 700; }
.contact-big-link--small { font-size: clamp(17px,2.2vw,27px); }
.contact-grid address { max-width: 420px; color: var(--text-heading); font-size: 21px; font-weight: 600; line-height: 1.6; }
.social-list { display: flex; flex-wrap: wrap; gap: 8px; }
.social-list strong { padding: 7px 11px; border-radius: 7px; color: var(--brand-navy); background: var(--bg-blue); font-size: 12px; }
.visit-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 90px; }
.visit-grid > div h2 { margin-bottom: 16px; font-size: 42px; letter-spacing: -.04em; }
.visit-grid > div p { color: var(--text-secondary); }
.visit-grid ol { margin: 0; padding: 0; border-top: 1px solid var(--border-default); list-style: none; }
.visit-grid li { display: grid; grid-template-columns: 45px 1fr; gap: 15px; padding: 20px 0; border-bottom: 1px solid var(--border-default); }
.visit-grid li > span { color: var(--brand-blue); font-size: 10px; }
.visit-grid li strong { font-size: 15px; }
.visit-grid li p { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.contact-bottom { padding: 100px 0; color: #fff; background: var(--gradient-brand); text-align: center; }
.contact-bottom p { font-size: 11px; font-weight: 750; letter-spacing: .16em; }
.contact-bottom h2 { margin: 22px 0 34px; font-size: clamp(38px,5vw,60px); letter-spacing: -.045em; }
.article-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 36px; }
.article-tab { padding: 8px 13px; border: 1px solid var(--border-default); border-radius: 999px; color: var(--text-secondary); background: #fff; font-size: 12px; }
.article-tab span { margin-left: 5px; color: var(--text-muted); }
.article-tab:hover,.article-tab.active { color: #fff; background: var(--brand-blue); border-color: var(--brand-blue); }
.article-tab.active span { color: rgba(255,255,255,.7); }
.article-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.article-card { min-height: 340px; border: 1px solid var(--border-default); border-radius: 14px; background: #fff; box-shadow: var(--shadow-card); transition: transform .25s,border-color .25s,box-shadow .25s; }
.article-card:hover { transform: translateY(-5px); border-color: var(--border-blue); box-shadow: var(--shadow-hover); }
.article-card > a { display: flex; flex-direction: column; height: 100%; padding: 28px; }
.article-card__meta { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 10px; }
.article-card__meta span { color: var(--brand-blue); font-weight: 700; }
.article-card__index { margin: 42px 0 18px; color: var(--brand-teal); font-size: 11px; font-weight: 700; }
.article-card h2 { margin-bottom: 14px; font-size: 20px; }
.article-card p { flex: 1; color: var(--text-secondary); font-size: 13px; }
.article-card strong { color: var(--brand-blue); font-size: 12px; }
.article-empty { padding: 50px; color: var(--text-muted); border: 1px dashed var(--border-default); text-align: center; }
.article-pagination { display: flex; justify-content: center; gap: 6px; margin-top: 38px; }
.article-pagination a,.article-pagination > span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border-default); border-radius: 7px; background: #fff; font-size: 12px; }
.article-pagination .active { color: #fff; background: var(--brand-blue); border-color: var(--brand-blue); }
.article-detail-head { position: relative; overflow: hidden; padding: 100px 0 80px; background: linear-gradient(130deg,var(--dark-bg),var(--brand-navy)); color: #fff; }
.article-detail-head__mesh { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.04) 1px,transparent 1px); background-size: 70px 70px; }
.article-detail-head__inner { position: relative; max-width: 920px; }
.article-detail-head .breadcrumb { color: rgba(255,255,255,.5); }
.article-detail-category { color: var(--brand-cyan); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.article-detail-head h1 { margin: 18px 0 22px; font-size: clamp(38px,5vw,60px); letter-spacing: -.045em; }
.article-detail-head__inner > p { color: rgba(255,255,255,.7); font-size: 17px; }
.article-detail-meta { display: flex; gap: 18px; color: rgba(255,255,255,.48); font-size: 11px; }
.article-detail-layout { display: grid; grid-template-columns: 230px 1fr; gap: 80px; padding-top: 70px; padding-bottom: 100px; }
.article-detail-layout aside { align-self: start; position: sticky; top: 110px; padding: 20px 0; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.article-detail-layout aside a { color: var(--brand-blue); font-size: 12px; font-weight: 700; }
.article-detail-layout aside p { margin: 18px 0 0; color: var(--text-muted); font-size: 11px; }
.article-prose { max-width: 780px; color: var(--text-secondary); font-size: 17px; line-height: 2; }
.article-prose h1 { display: none; }
.article-prose h2 { margin: 52px 0 18px; color: var(--text-primary); font-size: 28px; }
.article-prose h3 { margin: 36px 0 14px; color: var(--text-heading); font-size: 21px; }
.article-prose a { color: var(--brand-blue); text-decoration: underline; }
.article-prose img { margin: 30px auto; border-radius: 12px; }
.article-prose blockquote { margin: 28px 0; padding: 18px 24px; border-left: 3px solid var(--brand-teal); background: var(--bg-blue); }
.cta-band { position: relative; overflow: hidden; padding: 82px 0; color: #fff; background: linear-gradient(120deg,var(--brand-navy),var(--brand-blue) 55%,#0d9fa2); }
.cta-band::after { position: absolute; right: -140px; top: -220px; width: 520px; height: 520px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; content: ""; box-shadow: 0 0 0 60px rgba(255,255,255,.035),0 0 0 120px rgba(255,255,255,.02); }
.cta-band__inner { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 60px; }
.cta-band h2 { max-width: 760px; margin-bottom: 14px; font-size: clamp(34px,4.5vw,52px); letter-spacing: -.04em; }
.cta-band p { max-width: 680px; margin: 0; color: rgba(255,255,255,.7); }
.cta-band__actions { display: flex; flex-direction: column; align-items: flex-start; gap: 15px; flex: none; }
.site-footer { position: relative; overflow: hidden; padding-top: 82px; color: rgba(255,255,255,.66); background: var(--dark-bg); }
.footer-glow { position: absolute; right: 8%; top: -260px; width: 500px; height: 500px; border-radius: 50%; background: rgba(20,115,230,.22); filter: blur(70px); }
.footer-grid { position: relative; display: grid; grid-template-columns: 1.55fr .65fr .85fr 1fr; gap: 60px; padding-bottom: 62px; }
.footer-logo { display: block; width: 210px; filter: brightness(0) invert(1); opacity: .95; }
.footer-brand > p { max-width: 400px; margin: 24px 0; font-size: 13px; line-height: 1.9; }
.footer-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.footer-tags span { padding: 5px 9px; border: 1px solid rgba(255,255,255,.14); border-radius: 5px; color: var(--brand-cyan); font-size: 10px; }
.footer-grid h2 { margin-bottom: 23px; color: #fff; font-size: 13px; }
.footer-grid > div:not(.footer-brand) > a { display: block; margin: 11px 0; font-size: 12px; }
.footer-grid > div:not(.footer-brand) > a:hover { color: var(--brand-cyan); }
.footer-phone { color: #fff !important; font-size: 20px !important; font-weight: 700; }
.footer-contact address { margin: 15px 0; font-size: 12px; line-height: 1.8; }
.footer-arrow { color: var(--brand-cyan) !important; }
.footer-bottom { position: relative; display: flex; justify-content: space-between; padding: 22px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 11px; }
.footer-bottom p { margin: 0; }
.contact-dialog { width: min(920px,calc(100% - 32px)); padding: 0; border: 0; border-radius: 18px; color: var(--text-primary); background: #fff; box-shadow: 0 35px 100px rgba(0,20,50,.3); }
.contact-dialog::backdrop { background: rgba(7,29,59,.65); backdrop-filter: blur(5px); }
.contact-dialog__panel { position: relative; padding: 42px; }
.contact-dialog__close { position: absolute; top: 18px; right: 20px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border-default); border-radius: 50%; background: #fff; cursor: pointer; font-size: 22px; }
.contact-dialog__heading { margin-bottom: 28px; }
.contact-dialog__heading h2 { margin-bottom: 8px; font-size: 34px; }
.contact-dialog__heading > p { max-width: 640px; color: var(--text-secondary); }
.contact-dialog__grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.contact-dialog__grid article { min-height: 180px; padding: 22px; border: 1px solid var(--border-default); border-radius: 11px; background: var(--bg-secondary); }
.contact-dialog__grid article > span { color: var(--brand-blue); font-size: 10px; }
.contact-dialog__grid h3 { margin: 28px 0 8px; font-size: 13px; }
.contact-dialog__primary { display: block; color: var(--brand-blue); font-size: 21px; font-weight: 700; }
.contact-dialog__email { font-size: 16px; }
.contact-dialog__grid p,.contact-dialog__grid address { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; }
.not-found { display: grid; place-items: center; min-height: 70vh; padding: 80px 0; background: radial-gradient(circle,var(--bg-blue),#fff 65%); text-align: center; }
.not-found .container > span { color: var(--brand-blue); font-size: clamp(100px,20vw,240px); font-weight: 800; letter-spacing: -.08em; opacity: .11; }
.not-found .eyebrow { justify-content: center; }
.not-found h1 { font-size: 42px; }
.not-found p { color: var(--text-secondary); }
.not-found .button { margin-top: 15px; }
@media (max-width: 1100px) {
.desktop-nav { display: none; }
.header-cta { margin-left: auto; }
.mobile-nav { display: block; margin-left: 12px; }
.mobile-nav summary { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 42px; height: 42px; padding: 9px; border: 1px solid var(--border-default); border-radius: 8px; cursor: pointer; list-style: none; }
.mobile-nav summary::-webkit-details-marker { display: none; }
.mobile-nav summary span { width: 100%; height: 2px; background: var(--brand-navy); }
.mobile-nav nav { position: fixed; top: 78px; right: 0; left: 0; max-height: calc(100vh - 78px); padding: 20px 24px 30px; overflow-y: auto; border-top: 1px solid var(--border-default); background: #fff; box-shadow: 0 25px 45px rgba(15,35,60,.12); }
.mobile-nav__group { padding: 13px 0; border-bottom: 1px solid var(--border-default); }
.mobile-nav__primary { display: block; margin-bottom: 8px; font-weight: 700; }
.mobile-subnav { display: flex; flex-wrap: wrap; gap: 7px 18px; }
.mobile-subnav a { color: var(--text-muted); font-size: 12px; }
.mobile-nav nav > .button { width: 100%; margin-top: 18px; }
.hero__grid { gap: 20px; }
.hero-visual { transform: scale(.9); transform-origin: right center; }
.tech-layout,.about-tech-layout { gap: 55px; }
.service-detail { gap: 44px; padding: 38px; }
.footer-grid { grid-template-columns: 1.25fr repeat(3,1fr); gap: 32px; }
}
@media (max-width: 860px) {
.section-pad { padding: 82px 0; }
.hero { padding-top: 60px; }
.hero__grid,.service-hero__inner,.contact-hero__grid { grid-template-columns: 1fr; }
.hero__content { padding-bottom: 0; }
.hero-visual { width: min(100%,620px); min-height: 510px; margin: 0 auto; transform: none; }
.hero-platforms { grid-template-columns: 1fr; gap: 14px; padding: 18px 0; }
.stat-grid { grid-template-columns: repeat(2,1fr); }
.stat-grid > div:nth-child(2) { border-right: 0; }
.engine-grid { grid-template-columns: 1fr; }
.tech-layout,.scenario-layout,.about-intro-layout,.delivery-layout,.visit-grid,.service-cap-layout,.service-feature-layout { grid-template-columns: 1fr; }
.tech-data-row,.workflow-grid,.method-flow,.process-grid { grid-template-columns: repeat(2,1fr); }
.tech-data-row > div:nth-child(2),.workflow-grid article:nth-child(2),.process-grid article:nth-child(2) { border-right: 0; }
.tech-data-row > div:nth-child(-n+2),.workflow-grid article:nth-child(-n+2),.process-grid article:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.12); }
.workflow-grid article:nth-child(-n+2) { border-bottom-color: var(--border-default); }
.service-detail { grid-template-columns: 1fr; }
.service-detail--reverse .service-detail__visual { order: 0; }
.connection-map { grid-template-columns: repeat(2,1fr); gap: 14px; }
.connection-map::before { display: none; }
.connection-map > strong { grid-column: 1 / -1; grid-row: 1; }
.anchor-nav { top: 70px; overflow-x: auto; }
.anchor-nav .container { width: max-content; min-width: 100%; }
.anchor-nav a { min-width: 180px; }
.advantage-grid,.article-grid { grid-template-columns: repeat(2,1fr); }
.faq-layout { grid-template-columns: 1fr; }
.faq-layout aside { position: static; }
.method-flow article:nth-child(2) { border-right: 1px solid var(--border-default); }
.method-flow article:nth-child(-n+2) { border-bottom: 0; }
.contact-radar { min-height: 360px; }
.article-detail-layout { grid-template-columns: 1fr; gap: 20px; }
.article-detail-layout aside { position: static; }
.cta-band__inner { align-items: flex-start; flex-direction: column; }
.footer-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
.container { width: min(calc(100% - 32px),var(--container)); }
.site-header { height: 68px; }
.brand { width: 160px; }
.header-cta { display: none; }
.mobile-nav nav { top: 68px; max-height: calc(100vh - 68px); }
.section-pad { padding: 66px 0; }
.section-heading h2 { font-size: 34px; }
.section-heading p { font-size: 15px; }
.section-intro-row { align-items: flex-start; flex-direction: column; margin-bottom: 38px; }
.hero { padding-top: 42px; }
.hero h1 { font-size: 43px; }
.hero__content > p { font-size: 16px; }
.hero__actions .button { width: 100%; }
.hero__proof { gap: 8px 14px; }
.hero-visual { min-height: 400px; }
.search-card { inset: 28px 0 25px; padding: 18px; }
.float-card { display: none; }
.score-ring { width: 105px; height: 105px; }
.score-ring::before { width: 80px; height: 80px; }
.score-ring strong { font-size: 27px; }
.trend-card { margin-top: 13px; }
.stat-grid > div { padding: 25px 17px; }
.engine-card { padding: 26px; }
.support-service-grid,.scenario-grid,.service-cap-grid,.delivery-grid,.principle-grid,.contact-grid,.article-grid,.advantage-grid { grid-template-columns: 1fr; }
.tech-layout,.scenario-layout,.about-intro-layout,.delivery-layout,.visit-grid,.service-cap-layout,.service-feature-layout { gap: 46px; }
.tech-data-row,.workflow-grid,.method-flow,.process-grid { grid-template-columns: 1fr; }
.tech-data-row > div,.workflow-grid article,.process-grid article { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.workflow-grid article { border-bottom-color: var(--border-default); }
.tech-data-row > div:last-child,.workflow-grid article:last-child,.process-grid article:last-child { border-bottom: 0; }
.service-detail { padding: 16px; border-radius: 14px; }
.service-detail__visual { min-height: 370px; }
.service-detail__content { padding: 14px 10px 22px; }
.service-visual__nodes { grid-template-columns: repeat(2,1fr); }
.page-hero { min-height: 440px; padding: 80px 0 70px; }
.page-hero__inner { width: calc(100% - 32px); margin-inline: auto; }
.page-hero h1 { font-size: 42px; }
.page-hero__inner > p { font-size: 15px; }
.breadcrumb { margin-bottom: 30px; }
.service-hero { padding: 70px 0; }
.service-hero h1 { font-size: 41px; }
.console-main { grid-template-columns: 100px 1fr; padding: 18px; }
.console-score strong { font-size: 45px; }
.console-foot { grid-template-columns: repeat(2,1fr); }
.service-cap-layout > div:first-child h2,.service-feature-layout > div:last-child h2,.visit-grid > div h2 { font-size: 34px; }
.service-symbol { max-width: 340px; }
.service-symbol::after { inset: 75px; }
.related-services .container { grid-template-columns: 1fr; }
.related-services a { border-left: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.vision-card { padding: 45px 20px; }
.vision-card blockquote { font-size: 29px; }
.method-flow article { border-right: 1px solid var(--border-default); border-bottom: 0; }
.method-flow article:last-child { border-bottom: 1px solid var(--border-default); }
.contact-hero { padding: 76px 0; }
.contact-hero h1 { font-size: 43px; }
.contact-radar { min-height: 300px; }
.radar-ring--one { width: 290px; height: 290px; }.radar-ring--two { width: 190px; height: 190px; }
.contact-grid article { min-height: 220px; }
.faq-list summary { grid-template-columns: 36px 1fr 20px; }
.faq-list details > div { padding-left: 48px; padding-right: 0; }
.article-card { min-height: 310px; }
.article-detail-head { padding: 75px 0 60px; }
.article-detail-head h1 { font-size: 37px; }
.article-detail-layout { padding-top: 45px; padding-bottom: 70px; }
.article-prose { font-size: 16px; }
.cta-band { padding: 65px 0; }
.cta-band__actions { width: 100%; }
.cta-band__actions .button { width: 100%; }
.footer-grid { grid-template-columns: 1fr; }
.footer-bottom { gap: 10px; flex-direction: column; }
.contact-dialog__panel { padding: 32px 18px 20px; }
.contact-dialog__grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
*,*::before,*::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
[data-reveal] { opacity: 1; transform: none; }
}
declare module "turndown-plugin-gfm" {
import type TurndownService from "turndown";
export function gfm(service: TurndownService): void;
}
import assert from "node:assert/strict";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import test, { after } from "node:test";
const dataDirectory = await fs.mkdtemp(path.join(os.tmpdir(), "zhiyin-auth-"));
process.env.CMS_DATA_DIR = dataDirectory;
process.env.CMS_PASSWORD = "environment-master-password";
process.env.CMS_SECRET = "auth-test-session-secret";
process.env.CMS_API_KEY = "auth-test-api-key";
const { handleCmsApi } = await import("../src/lib/cms-api");
let requestNumber = 0;
after(async () => {
await fs.rm(dataDirectory, { recursive: true, force: true });
});
function cookieFrom(response: Response, name: string): string {
const header = response.headers.get("set-cookie") || "";
const match = header.match(new RegExp(`(?:^|,\\s*)${name}=([^;]*)`));
assert.ok(match, `missing ${name} cookie in ${header}`);
return `${name}=${match[1]}`;
}
async function login(password: string): Promise<{ response: Response; cookie?: string }> {
requestNumber += 1;
const captchaResponse = await handleCmsApi(
new Request("http://localhost/api/cms/captcha"),
"captcha",
`captcha-${requestNumber}`,
);
const code = [...(await captchaResponse.text()).matchAll(/<text\b[^>]*>([^<])<\/text>/g)]
.map((match) => match[1])
.join("");
assert.equal(code.length, 4);
const response = await handleCmsApi(new Request("http://localhost/api/cms/session", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: cookieFrom(captchaResponse, "cms_captcha"),
},
body: JSON.stringify({ password, captcha: code }),
}), "session", `login-${requestNumber}`);
return {
response,
cookie: response.ok ? cookieFrom(response, "cms_session") : undefined,
};
}
async function sessionStatus(cookie: string): Promise<boolean> {
const response = await handleCmsApi(new Request("http://localhost/api/cms/session", {
headers: { Cookie: cookie },
}), "session");
return Boolean((await response.json()).authed);
}
async function changePassword(cookie: string, currentPassword: string, newPassword: string): Promise<Response> {
return handleCmsApi(new Request("http://localhost/api/cms/account/password", {
method: "PUT",
headers: { "Content-Type": "application/json", Cookie: cookie },
body: JSON.stringify({ currentPassword, newPassword }),
}), "account/password");
}
test("users can change the persisted password while the .env password remains valid", async () => {
const initialLogin = await login("environment-master-password");
assert.equal(initialLogin.response.status, 200);
assert.ok(initialLogin.cookie);
const tooShort = await changePassword(initialLogin.cookie, "environment-master-password", "abcd");
assert.equal(tooShort.status, 400);
assert.match((await tooShort.json()).error, /至少需要 5 个字符/);
assert.equal(await sessionStatus(initialLogin.cookie), true);
const firstPassword = "first-user-password";
const changed = await changePassword(initialLogin.cookie, "environment-master-password", firstPassword);
assert.equal(changed.status, 200);
assert.match(changed.headers.get("set-cookie") || "", /cms_session=;/);
assert.equal((await changed.json()).requiresLogin, true);
assert.equal(await sessionStatus(initialLogin.cookie), false);
const stored = await fs.readFile(path.join(dataDirectory, "auth", "password.json"), "utf8");
assert.doesNotMatch(stored, new RegExp(firstPassword));
const userLogin = await login(firstPassword);
assert.equal(userLogin.response.status, 200);
assert.ok(userLogin.cookie);
assert.equal((await login("environment-master-password")).response.status, 200);
const secondPassword = "abcde";
const changedAgain = await changePassword(userLogin.cookie, firstPassword, secondPassword);
assert.equal(changedAgain.status, 200);
assert.equal(await sessionStatus(userLogin.cookie), false);
assert.equal((await login(firstPassword)).response.status, 401);
assert.equal((await login(secondPassword)).response.status, 200);
assert.equal((await login("environment-master-password")).response.status, 200);
});
test("an API key alone cannot change the browser login password", async () => {
const response = await handleCmsApi(new Request("http://localhost/api/cms/account/password", {
method: "PUT",
headers: {
Authorization: "Bearer auth-test-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({
currentPassword: "environment-master-password",
newPassword: "api-key-must-not-change-this",
}),
}), "account/password");
assert.equal(response.status, 401);
});
# 企业开始GEO诊断前,建议先准备这五类信息
一次有效的GEO诊断,需要把品牌事实、用户问题和当前AI可见结果放在同一个框架中观察。准备资料不必复杂,但应尽量准确。
![智引未来品牌示意图]({{TEST_IMAGE_URL}})
## 一、品牌与业务简介
用简洁语言说明企业是谁、服务谁、解决什么问题,以及当前最重要的产品与市场。
## 二、核心品牌与品类关键词
整理用户可能主动搜索的品牌词、品类词、场景词和问题词,作为诊断范围的初始输入。
## 三、重点竞品与替代方案
列出用户在比较阶段可能同时考虑的品牌或方案,便于观察AI回答中的推荐结构。
## 四、现有官方内容
准备官网、公众号、产品资料和权威报道等内容入口,确认品牌事实是否统一。
## 五、当前最关心的问题
说明品牌是完全没有被提及、描述不准确,还是在关键问题中被竞品压制。
智引未来会基于真实可见结果建立诊断基线,让后续优化有明确方向和可追溯依据。
测试标记:ZHIYIN-PRODUCTION-IMPORT-20260811-MARKDOWN
import assert from "node:assert/strict";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import test, { after } from "node:test";
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, TextRun } from "docx";
const TEST_IMAGE = path.join(process.cwd(), "pic", "智引未来GEO_原始版本_渐变背景.png");
const UNIQUE_MARKER = "ZHIYIN-IMPORT-TEST-20260811";
const dataDirectory = await fs.mkdtemp(path.join(os.tmpdir(), "zhiyin-import-"));
process.env.CMS_DATA_DIR = dataDirectory;
process.env.CMS_BUILD_LOCK = path.join(dataDirectory, "site-build.lock");
process.env.CMS_API_KEY = "word-import-test-key";
const [{ handleCmsApi }, { GET: getUpload }] = await Promise.all([
import("../src/lib/cms-api"),
import("../src/pages/uploads/[file]"),
]);
after(async () => {
await fs.rm(dataDirectory, { recursive: true, force: true });
});
function cmsRequest(route: string, method = "GET", body?: Record<string, unknown>, key = "word-import-test-key"): Request {
return new Request(`http://localhost/api/cms/${route}`, {
method,
headers: {
Authorization: `Bearer ${key}`,
...(body ? { "Content-Type": "application/json" } : {}),
},
body: body ? JSON.stringify(body) : undefined,
});
}
async function wordDocument(): Promise<Buffer> {
const png = await fs.readFile(TEST_IMAGE);
const document = new Document({
sections: [{
children: [
new Paragraph({ text: "Ailead Word Import Test", heading: HeadingLevel.HEADING_1 }),
new Paragraph({ children: [new TextRun(`Imported Word body marker: ${UNIQUE_MARKER}`)] }),
new Paragraph({ children: [new ImageRun({ data: png, transformation: { width: 160, height: 105 }, type: "png" })] }),
],
}],
});
return Packer.toBuffer(document);
}
test("imports a Markdown file payload as a draft", async () => {
const markdown = `# 智引未来 Markdown 导入测试\n\n这是 Markdown 上传测试:${UNIQUE_MARKER}`;
const heading = markdown.match(/^#\s+(.+)$/m);
assert.ok(heading?.index !== undefined);
const body = `${markdown.slice(0, heading.index)}${markdown.slice(heading.index + heading[0].length)}`.trim();
const response = await handleCmsApi(cmsRequest("articles", "POST", {
title: heading[1],
category: "GEO洞察",
body,
}), "articles");
assert.equal(response.status, 201);
const imported = await response.json();
assert.equal(imported.publishStatus, "new-draft");
const articleResponse = await handleCmsApi(cmsRequest(`articles/${imported.slug}`), `articles/${imported.slug}`);
const article = await articleResponse.json();
assert.equal(article.title, "智引未来 Markdown 导入测试");
assert.match(article.body, new RegExp(UNIQUE_MARKER));
assert.doesNotMatch(article.body, /^#\s+/);
});
test("imports a docx with the requested embedded PNG as a Markdown draft", async () => {
const buffer = await wordDocument();
const response = await handleCmsApi(cmsRequest("imports/word", "POST", {
fileName: "智引未来导入测试.docx",
category: "AI搜索",
dataUrl: `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,${buffer.toString("base64")}`,
}), "imports/word");
assert.equal(response.status, 201);
const imported = await response.json();
assert.equal(imported.title, "Ailead Word Import Test");
assert.equal(imported.publishStatus, "new-draft");
assert.equal(imported.imageCount, 1);
const articleResponse = await handleCmsApi(cmsRequest(`articles/${imported.slug}`), `articles/${imported.slug}`);
assert.equal(articleResponse.status, 200);
const article = await articleResponse.json();
assert.equal(article.category, "AI搜索");
assert.match(article.body, new RegExp(UNIQUE_MARKER));
assert.doesNotMatch(article.body, /^#\s+Ailead Word Import Test/m);
const imageUrl = article.body.match(/!\[[^\]]*\]\((\/uploads\/[^)]+)\)/)?.[1];
assert.ok(imageUrl);
const filename = imageUrl.replace(/^\/uploads\//, "");
const imageResponse = await getUpload({ params: { file: filename } } as never);
assert.equal(imageResponse.status, 200);
assert.equal(imageResponse.headers.get("content-type"), "image/png");
assert.deepEqual(Buffer.from(await imageResponse.arrayBuffer()), await fs.readFile(TEST_IMAGE));
});
test("requires valid authentication for Word import", async () => {
const response = await handleCmsApi(cmsRequest("imports/word", "POST", {}, "wrong-key"), "imports/word");
assert.equal(response.status, 401);
});
test("rejects legacy .doc files", async () => {
const response = await handleCmsApi(cmsRequest("imports/word", "POST", {
fileName: "旧文章.doc",
dataUrl: "data:application/octet-stream;base64,AA==",
}), "imports/word");
assert.equal(response.status, 400);
assert.match((await response.json()).error, /不支持旧版 \.doc/);
});
{
"extends": "astro/tsconfigs/strict"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment