Commit ad00ed3a authored by tao355667's avatar tao355667

feat: build Qiyouxue corporate website

parents
# 复制为 .env 后使用。生产环境请生成独立密钥。
CMS_PORT=8793
# 后台主密码始终有效,用于登录和找回;在后台修改的用户密码会另存于 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/qiyouxue/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
.firecrawl/
# 启优学官网 · GitLab CI/CD 单目录覆盖部署
# 流程:停止应用 → 覆盖 current → 安装与构建 → 启动并检查 → 更新 Nginx
# 触发:push 到 main 分支
#
# GitLab 版本:11.7
# 仅使用 stages、only、script 等基础语法;服务器部署锁用于拒绝并发部署。
variables:
DEPLOY_ROOT: "/root/qiyouxue"
CURRENT_DIR: "/root/qiyouxue/current"
SHARED_DIR: "/root/qiyouxue/shared"
SHARED_ENV: "/root/qiyouxue/shared/.env"
DEPLOY_LOCK: "/root/qiyouxue/shared/deploy.lock"
APP_NAME: "qiyouxue"
SITE_URL: "http://127.0.0.1:8793/"
PM2_BIN: "/usr/bin/pm2"
PM2_HOME_DIR: "/root/.pm2"
PM2_USE_SUDO: "1"
PUBLIC_HOST: "qiyouxueedu.com"
stages:
- deploy
deploy:
stage: deploy
tags:
- qiyouxue-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/qiyouxue.conf" || (echo "缺少 Nginx 配置" >&2 && exit 2)
sudo -n /usr/bin/install -o root -g root -m 0644 "$CURRENT_DIR/deploy/nginx/qiyouxue.conf" /etc/nginx/conf.d/qiyouxue.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 与 AI 搜索发现。
## 本地使用
```bash
source ~/.nvm/nvm.sh
nvm use 20
cp .env.example .env
npm install
npm run build
npm start
```
- 官网:`http://localhost:8793/`
- 后台:`http://localhost:8793/admin/`
- 学习资讯:`http://localhost:8793/articles/`
## 环境变量
- `CMS_PORT`:官网与后台共用端口,默认 `8793`
- `CMS_PASSWORD`:后台初始/主密码
- `CMS_SECRET`:会话签名密钥
- `CMS_API_KEY`:Bearer API 密钥
- `CMS_DATA_DIR`:文章、分类与上传文件的持久化目录
- `CMS_BUILD_LOCK`:发布重建共享锁
生产示例:
```dotenv
CMS_PORT=8793
CMS_DATA_DIR=/root/qiyouxue/shared/cms-data
CMS_BUILD_LOCK=/root/qiyouxue/shared/site-build.lock
```
## 内容工作流
- 工作稿:`src/content/articles/`
- 已发布:`src/content/published/`
- 默认分类:学情指南、学习方法、家长课堂、服务说明
- 支持新建、编辑、发布、下架、删除与未发布修改回退
- 支持分类新增、重命名、删除与文章迁移
- 支持 Markdown、Word `.docx` 导入和内嵌图片提取
- 支持图片上传、Markdown 预览和后台密码修改
生产环境配置 `CMS_DATA_DIR` 后,内容持久化到仓库外,不随单目录部署被覆盖。发布、下架、删除与分类变更会触发共享锁保护的原子站点重建。
## API
后台浏览器会话与 Bearer API 均由 `/api/cms/*` 提供。API 调用使用:
```http
Authorization: Bearer <CMS_API_KEY>
```
Word 导入示例字段:
```json
{
"fileName": "学习方法文章.docx",
"category": "学习方法",
"dataUrl": "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,..."
}
```
## 部署
`.gitlab-ci.yml` 使用单目录覆盖部署:停止 `qiyouxue` PM2 进程,更新 `/root/qiyouxue/current`,关联 `/root/qiyouxue/shared/.env`,安装依赖并构建,重新启动、健康检查,然后安装并验证 Nginx 配置。
- 部署根目录:`/root/qiyouxue`
- PM2 应用名:`qiyouxue`
- 服务端口:`8793`
- Nginx 配置:`/etc/nginx/conf.d/qiyouxue.conf`
- 公网域名:`qiyouxueedu.com`
Runner 需具备安装固定 Nginx 配置、执行 `nginx -t` 与 reload 的最小 sudo 权限。生产密钥、上传文件、CMS 数据与构建锁必须位于 `shared/`
# 启优学企业官网
启优学一对一品牌官网。项目基于 Astro 5 + Node standalone adapter,包含品牌首页、学科辅导详情、教学服务、常见问题、联系页面、学习资讯 CMS、SEO/AI 可发现性、响应式适配、原子构建与 GitLab/Nginx 部署配置。
## 本地运行(Node 20)
```bash
source ~/.nvm/nvm.sh
nvm use 20
npm install
npm run dev
```
- 官网开发地址:`http://localhost:4321/`
- 内容后台:`http://localhost:4321/admin/`
生产构建与本地服务:
```bash
npm run build
npm start
```
生产模式默认监听 `http://127.0.0.1:8793/`
## 常用命令
```bash
npm run check
npm test
npm run build
npm start
```
## 内容管理
学习资讯使用 Markdown 存储,并由同端口 `/admin/` 后台管理。工作稿位于 `src/content/articles/`,线上稿位于 `src/content/published/`;生产环境通过 `CMS_DATA_DIR` 将内容持久化到仓库外。后台支持草稿、发布、下架、删除、分类管理、Markdown/Word 导入、图片上传、预览、修改密码与 Bearer API。
完整说明见 [CMS_README.md](./CMS_README.md)
## SEO 与性能
- 页面级标题、描述、关键词、canonical、Open Graph 与 Twitter Card
- EducationalOrganization、WebSite、WebPage、Service、FAQ、Article 和 Breadcrumb 结构化数据
- sitemap、robots.txt、语义化页面、分类分页、`llms.txt``llms-full.txt`
- Astro 图片优化、响应式图片、移动端适配、减少动态效果偏好
- Astro standalone、原子构建、共享锁与 Nginx 反向代理
## 部署
- Nginx 配置:`deploy/nginx/qiyouxue.conf`
- 生产端口:`8793`
- 站点域名:`qiyouxueedu.com`
- 服务器目录:`/root/qiyouxue/current``/root/qiyouxue/shared`
生产部署前需在 `/root/qiyouxue/shared/.env` 配置独立的 `CMS_PASSWORD``CMS_SECRET``CMS_API_KEY``CMS_DATA_DIR``CMS_BUILD_LOCK`
import { defineConfig } from "astro/config";
import sitemap from "@astrojs/sitemap";
import node from "@astrojs/node";
import path from "node:path";
const customOutDir = process.env.QIYOUXUE_BUILD_OUT_DIR;
export default defineConfig({
site: "https://qiyouxueedu.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 主域名。
server {
listen 80;
server_name qiyouxueedu.com www.qiyouxueedu.com;
return 301 https://qiyouxueedu.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.qiyouxueedu.com;
ssl_certificate /etc/nginx/certs/qiyouxueedu.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/qiyouxueedu.com.certkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
return 301 https://qiyouxueedu.com$request_uri;
}
server {
listen 443 ssl http2;
server_name qiyouxueedu.com;
ssl_certificate /etc/nginx/certs/qiyouxueedu.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/qiyouxueedu.com.certkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:QIYOUXUE:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
client_max_body_size 28m;
location / {
proxy_pass http://127.0.0.1:8793;
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 diff is collapsed.
{
"name": "qiyouxue-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"
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
<rect width="1200" height="630" fill="#FCFDFC"/>
<rect x="0" y="0" width="18" height="630" fill="#F6B900"/>
<rect x="740" y="70" width="360" height="490" rx="32" fill="#EEF7FC" stroke="#DCE8EF" stroke-width="2"/>
<circle cx="920" cy="245" r="96" fill="#0868AC"/>
<path d="M854 230h132M854 258h132M880 200l40-32 40 32" fill="none" stroke="#fff" stroke-width="15" stroke-linecap="round"/>
<circle cx="1010" cy="145" r="25" fill="#F6B900"/>
<text x="82" y="118" fill="#0868AC" font-family="sans-serif" font-size="20" font-weight="700" letter-spacing="4">QIYOUXUE · 1 ON 1</text>
<text x="82" y="255" fill="#172B3A" font-family="sans-serif" font-size="76" font-weight="800">先看清问题</text>
<text x="82" y="355" fill="#0868AC" font-family="sans-serif" font-size="76" font-weight="800">再规划每一步</text>
<text x="82" y="442" fill="#4B5E6B" font-family="sans-serif" font-size="28">小学 · 初中 · 高中在线一对一个性化辅导</text>
<rect x="82" y="508" width="210" height="54" rx="9" fill="#F6B900"/>
<text x="187" y="543" text-anchor="middle" fill="#172B3A" font-family="sans-serif" font-size="20" font-weight="700">启优学一对一</text>
</svg>
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /api/
Sitemap: https://qiyouxueedu.com/sitemap-index.xml
{
"name": "启优学一对一",
"short_name": "启优学",
"description": "小学初中高中在线一对一个性化辅导",
"start_url": "/",
"display": "standalone",
"background_color": "#FCFDFC",
"theme_color": "#0868AC",
"lang": "zh-CN"
}
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.QIYOUXUE_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", "主页大图素材-1.png");
const marker = "QIYOUXUE-PRODUCTION-IMPORT-20260812";
await fs.mkdir(outputDirectory, { recursive: true });
await fs.writeFile(path.join(outputDirectory, "import-test.md"), [
"# 开始学情沟通前,建议家长准备这四类信息",
"",
"一次有效的学情沟通,需要把年级、教材进度、近期试卷和阶段目标放在一起观察。资料不必复杂,但应尽量准确。",
"",
"![启优学在线一对一课堂示意图]({{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: "家长如何准备一次学情沟通", heading: HeadingLevel.HEADING_1 }),
body("AI搜索可见度诊断的目标,是确认品牌在哪些问题中出现、如何被描述,以及信息来自哪些引用来源。"),
new Paragraph({ children: [new ImageRun({ data: image, transformation: { width: 320, height: 240 }, 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, QIYOUXUE_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", { QIYOUXUE_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:8793";
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 ["学情指南", "学习方法"]) assert.ok(categories.categories.includes(required));
const image = await fs.readFile(path.resolve("pic/主页大图素材-1.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: "学情指南", 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: "学习方法",
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, "学情指南");
assert.match(markdownArticle.body, /QIYOUXUE-PRODUCTION-IMPORT-20260812-MARKDOWN/);
assert.match(markdownArticle.body, new RegExp(uploadedImage.url.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
assert.equal(wordImport.publishStatus, "new-draft");
assert.equal(wordImport.title, "家长如何准备一次学情沟通");
assert.equal(wordImport.imageCount, 1);
assert.equal(wordArticle.category, "学习方法");
assert.match(wordArticle.body, /QIYOUXUE-PRODUCTION-IMPORT-20260812-WORD/);
assert.doesNotMatch(wordArticle.body, /^#\s+家长如何准备一次学情沟通/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 || "8793";
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}分类文章,分享学情判断、学科方法与家庭学习规划。`:"启优学学习资讯:关于小初高学情判断、学习方法、阶段复习和在线一对一服务的公开说明。"; const keywords=[heading,"学习方法","学情诊断","在线一对一",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}))}};
---
<Base {title} {description} {keywords} {jsonLd}><Header /><main id="main-content"><section class="page-hero"><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>LEARNING NOTES</div><h1>{heading}</h1><p>{description}</p></div></section><section class="section-pad section-blue"><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 = "准备学生年级、意向学科、近期试卷或错题与阶段目标,领取一对一专属学情分析。" } = Astro.props;
---
<section class="cta-band"><div class="container cta-band__inner" data-reveal><div><div class="eyebrow eyebrow--light"><span></span>START WITH LEARNING PROFILE</div><h2>{title}</h2><p>{text}</p></div><div class="cta-band__actions"><a class="button button--yellow" 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>COURSE CONSULTATION</div><h2 id="contact-dialog-title">从一次学情沟通开始</h2><p>准备学生年级、地区、意向学科、当前情况与阶段目标,我们会协助梳理下一步。</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>周一至周日 · 7×24 小时</p></article><article><span>02</span><h3>微信小程序</h3><strong>启优学一对一</strong><p>搜索小程序名称提交咨询</p></article><article><span>03</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>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/启优学LOGO-白底.jpg";
import { site } from "../data/site";
---
<footer class="site-footer"><div class="container footer-grid">
<div class="footer-brand"><a href="/" class="footer-logo" aria-label="启优学首页"><img src={logo.src} width="1725" height="970" loading="lazy" alt="启优学一对一" /></a><p>优质师资直达,个性化辅导看得见。</p><div class="footer-tags"><span>小学</span><span>初中</span><span>高中</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><p>周一至周日 · 7×24 小时</p><a href={`mailto:${site.contact.email}`}>{site.contact.email}</a><a class="footer-arrow" href="/contact/">预约学情分析 <span>↗</span></a></div>
</div><div class="container footer-bottom"><p>© {new Date().getFullYear()} 启优学一对一</p><p><a href="https://beian.miit.gov.cn/" rel="nofollow">冀ICP备2025133748号-7</a> · 具体课程、教师、时间与费用以咨询确认方案为准</p></div></footer>
---
import logo from "../../pic/启优学LOGO-白底.jpg";
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="1725" height="970" alt="启优学一对一" /></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 platforms = {
douyin: { name: "抖音搜索", color: "#161823", glow: "rgba(22,24,35,.12)" },
xiaohongshu: { name: "小红书搜索", color: "#FF2442", glow: "rgba(255,36,66,.14)" },
doubao: { name: "豆包", color: "#2F6BFF", glow: "rgba(47,107,255,.14)" },
qwen: { name: "通义千问", color: "#6F5BFF", glow: "rgba(111,91,255,.14)" },
deepseek: { name: "DeepSeek", color: "#4D6BFE", glow: "rgba(77,107,254,.14)" },
kimi: { name: "Kimi", color: "#111827", glow: "rgba(17,24,39,.11)" },
yuanbao: { name: "腾讯元宝", color: "#10B981", glow: "rgba(16,185,129,.14)" },
baidu: { name: "百度AI", color: "#2932E1", glow: "rgba(41,50,225,.14)" },
wenxin: { name: "文心一言", color: "#2468F2", glow: "rgba(36,104,242,.14)" },
};
const rows = [
[platforms.douyin, platforms.xiaohongshu, platforms.doubao, platforms.qwen, platforms.deepseek],
[platforms.kimi, platforms.yuanbao, platforms.baidu, platforms.wenxin, platforms.xiaohongshu],
[platforms.deepseek, platforms.doubao, platforms.douyin, platforms.qwen, platforms.kimi],
[platforms.wenxin, platforms.yuanbao, platforms.xiaohongshu, platforms.baidu, platforms.deepseek],
];
---
<div class="platform-flow" role="img" aria-label="覆盖抖音搜索、小红书搜索、豆包、通义千问、DeepSeek等主流AI与社媒搜索平台">
{rows.map((row, rowIndex) => (
<div class:list={["platform-flow__row", { "platform-flow__row--reverse": rowIndex % 2 === 1 }]}>
<div class="platform-flow__track">
{[false, true].map(() => (
<div class="platform-flow__group" aria-hidden="true">
{row.map((item) => <span class="platform-flow__item" style={`--platform-color:${item.color};--platform-glow:${item.glow}`}>{item.name}</span>)}
</div>
))}
</div>
</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: "学情分析在分析什么:从一次错题看见真正的问题"
slug: "how-to-read-learning-profile"
date: 2026-08-08
updated: 2026-08-12
category: "学情指南"
author: "启优学教研中心"
excerpt: "同一道错题背后,可能是知识缺口、方法不熟,也可能是审题和学习习惯问题。有效的学情分析需要先把原因分清楚。"
status: "published"
---
# 学情分析在分析什么:从一次错题看见真正的问题
孩子说“这道题不会”,并不等于再讲一遍答案就能解决。一次错误可能来自概念没有理解、题型方法不熟、条件遗漏,或计算和表达习惯不稳定。
## 先看错误发生在哪一步
有效的学情沟通会结合近期试卷、错题、教材进度和学生自己的解题过程,判断问题更接近知识、方法还是习惯。只有原因清楚,近期任务才不会变成泛泛刷题。
## 把宽泛目标拆小
“提高数学”很难直接执行,“本周检查一次函数取值范围的分类讨论”则更具体。阶段方案需要说明先做什么、如何检查,以及什么时候根据表现调整。
---
title: "错题复盘不只是重做:把失分原因分成四类"
slug: "how-to-review-mistakes"
date: 2026-08-10
updated: 2026-08-12
category: "学习方法"
author: "启优学教研中心"
excerpt: "知识概念、解题方法、审题表达和计算习惯需要不同的改进方式。错题复盘的第一步,是不再把所有错误归为粗心。"
status: "published"
---
# 错题复盘不只是重做:把失分原因分成四类
把错题答案抄一遍,并不一定能减少下一次错误。更有效的方式,是先判断错误发生的类型:知识概念、解题方法、审题表达和计算习惯,需要不同的改进方式。
复盘的目标不是收藏更多错题,而是发现重复出现的原因,并安排下一次可以检查的任务。
---
title: "在线一对一适合哪些学生?先看三个判断维度"
slug: "online-one-to-one-fit"
date: 2026-08-09
updated: 2026-08-12
category: "家长课堂"
author: "启优学教研中心"
excerpt: "一对一更适合问题较明确、需要个别讲解节奏或持续反馈的学生,是否适合还要结合目标、配合情况与学习周期判断。"
status: "published"
---
# 在线一对一适合哪些学生?先看三个判断维度
在线一对一并不是所有学习问题的统一答案。判断是否适合,可以先看问题是否明确、学生是否需要个别节奏,以及家庭是否能为持续练习与反馈留出空间。
## 学习问题是否可以被具体描述
单科短板、某一章节基础断层、校内进度衔接困难,通常比“想全面提高”更容易形成明确方案。
## 是否需要更多互动检查
如果学生在大班课堂中不容易表达思路,或需要教师根据作答即时调整讲解,一对一互动会提供更集中的反馈机会。
[
"学情指南",
"学习方法",
"家长课堂",
"服务说明"
]
---
title: "学情分析在分析什么:从一次错题看见真正的问题"
slug: "how-to-read-learning-profile"
date: 2026-08-08
updated: 2026-08-12
category: "学情指南"
author: "启优学教研中心"
excerpt: "同一道错题背后,可能是知识缺口、方法不熟,也可能是审题和学习习惯问题。有效的学情分析需要先把原因分清楚。"
status: "published"
---
# 学情分析在分析什么:从一次错题看见真正的问题
孩子说“这道题不会”,并不等于再讲一遍答案就能解决。一次错误可能来自概念没有理解、题型方法不熟、条件遗漏,或计算和表达习惯不稳定。
## 先看错误发生在哪一步
有效的学情沟通会结合近期试卷、错题、教材进度和学生自己的解题过程,判断问题更接近知识、方法还是习惯。只有原因清楚,近期任务才不会变成泛泛刷题。
## 把宽泛目标拆小
“提高数学”很难直接执行,“本周检查一次函数取值范围的分类讨论”则更具体。阶段方案需要说明先做什么、如何检查,以及什么时候根据表现调整。
学习结果受基础、频率、练习与学习周期等多种因素影响。学情分析的价值,是让下一步安排更有依据,而不是给出统一答案。
---
title: "错题复盘不只是重做:把失分原因分成四类"
slug: "how-to-review-mistakes"
date: 2026-08-10
updated: 2026-08-12
category: "学习方法"
author: "启优学教研中心"
excerpt: "知识概念、解题方法、审题表达和计算习惯需要不同的改进方式。错题复盘的第一步,是不再把所有错误归为粗心。"
status: "published"
---
# 错题复盘不只是重做:把失分原因分成四类
把错题答案抄一遍,并不一定能减少下一次错误。更有效的方式,是先判断错误发生的类型。
## 知识概念
定义、公式或概念边界没有理解,需要回到基础知识并用相近问题检查。
## 解题方法
知道知识点,却不知道从什么条件切入,需要梳理题型结构和步骤。
## 审题与表达
遗漏条件、答非所问或步骤不完整,需要把读题标记与答题规范纳入练习。
## 计算与学习习惯
符号、单位、抄写和检查中的重复错误,需要用固定的自查流程逐步减少。
复盘的目标不是收藏更多错题,而是发现重复出现的原因,并安排下一次可以检查的任务。
---
title: "在线一对一适合哪些学生?先看三个判断维度"
slug: "online-one-to-one-fit"
date: 2026-08-09
updated: 2026-08-12
category: "家长课堂"
author: "启优学教研中心"
excerpt: "一对一更适合问题较明确、需要个别讲解节奏或持续反馈的学生,是否适合还要结合目标、配合情况与学习周期判断。"
status: "published"
---
# 在线一对一适合哪些学生?先看三个判断维度
在线一对一并不是所有学习问题的统一答案。判断是否适合,可以先看问题是否明确、学生是否需要个别节奏,以及家庭是否能为持续练习与反馈留出空间。
## 学习问题是否可以被具体描述
单科短板、某一章节基础断层、校内进度衔接困难,通常比“想全面提高”更容易形成明确方案。
## 是否需要更多互动检查
如果学生在大班课堂中不容易表达思路,或需要教师根据作答即时调整讲解,一对一互动会提供更集中的反馈机会。
## 是否能配合阶段任务
课堂只是学习的一部分。课后巩固、错题复盘与阶段沟通同样重要。具体课程与教师安排,应在学情沟通后由双方确认。
This diff is collapsed.
---
import "../styles/global.css";
import logo from "../../pic/启优学LOGO-白底.jpg";
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: 480, format: "webp" });
const optimizedFavicon = await getImage({ src: logo, width: 128, height: 128, fit: "cover", 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": ["EducationalOrganization", "Organization"], "@id": new URL("/#organization", Astro.site).href, name: site.brand.name, alternateName: [site.brand.shortName, 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, areaServed: { "@type": "Country", name: "中国" } };
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, 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 serializedLd = JSON.stringify([organizationLd, websiteLd, webPageLd, ...pageLd.filter((item) => Object.keys(item).length > 0)]).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="#FCFDFC" /><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',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:.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 dialog=document.querySelector('[data-contact-dialog]');const mobile=()=>matchMedia('(max-width:760px),(hover:none) and (pointer:coarse)').matches;document.addEventListener('click',event=>{const trigger=event.target.closest('[data-open-contact]');const phone=event.target.closest('a[href^="tel:"]');if(!dialog||(!trigger&&(!phone||mobile())))return;event.preventDefault();dialog.showModal()});dialog?.querySelector('[data-contact-dialog-close]')?.addEventListener('click',()=>dialog.close());dialog?.addEventListener('click',event=>{if(event.target===dialog)dialog.close()});
</script></body></html>
This diff is collapsed.
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> = {
学情指南: "learning-profile",
学习方法: "learning-methods",
家长课堂: "parent-guides",
服务说明: "service-guides",
};
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;
}
This diff is collapsed.
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>可以返回首页,继续了解启优学在线一对一课程与教学服务。</p><a class="button button--yellow" 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 CTA from "../../components/CTA.astro"; import SectionHeading from "../../components/SectionHeading.astro"; import { site } from "../../data/site";
const title=`关于启优学|${site.brand.name}`; const description="了解启优学一对一的品牌定位、教育理念、师资匹配方式与在线个性化教学服务。";
---
<Base {title} {description}><Header /><main id="main-content"><section class="page-hero"><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 关于我们</div><div class="eyebrow"><span></span>ABOUT QIYOUXUE</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-blue"><div class="container"><SectionHeading eyebrow="TEACHING ADVANTAGES" title="从看见问题,到看见每一步进展" description="诊断、匹配、互动、回放、反馈与复盘,共同组成可以持续调整的学习服务。" /><div class="advantage-grid">{site.about.advantages.map((item,index)=><article data-reveal><span>0{index+1}</span><h3>{item.title}</h3><p>{item.desc}</p></article>)}</div></div></section><section class="section-pad principle-section"><div class="container principle-layout"><div><div class="eyebrow eyebrow--light"><span></span>EDUCATION PRINCIPLES</div><h2>我们的教育理念</h2><p>成绩是阶段结果,理解力、方法和主动思考能力则陪伴更久。</p></div><div>{[["启发引导","拒绝单向灌输,通过提问与反馈培养主动思考。"],["因材施教","从真实学情出发,为不同学生确定不同任务。"],["能力优先","关注知识掌握,也重视方法、表达与学习习惯。"],["长期陪伴","固定教师持续跟踪,在阶段复盘中稳步调整。"]].map(([name,text],index)=><article data-reveal><span>0{index+1}</span><div><h3>{name}</h3><p>{text}</p></div></article>)}</div></div></section><section class="section-pad vision-section"><div class="container vision-card" data-reveal><span>QIYOUXUE · OUR VISION</span><blockquote>“{site.about.vision}”</blockquote><div><i></i><p>因材施教不是一句口号,而是每一次诊断、匹配与调整。</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, "学习方法", "在线一对一", 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="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>分享学情判断、学习方法、阶段复习与在线一对一服务说明。</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=`联系启优学一对一,咨询课程安排、教师匹配和学习方案。客服电话 ${site.contact.phoneDisplay}。`;
---
<Base {title} {description}><Header /><main id="main-content"><section class="contact-hero"><div class="container contact-hero__grid"><div data-reveal><div class="breadcrumb"><a href="/">首页</a> / 联系我们</div><div class="eyebrow eyebrow--light"><span></span>CONTACT QIYOUXUE</div><h1>{site.contact.heading}</h1><p>{site.contact.intro}</p><div class="hero__actions"><a class="button button--yellow" href={`tel:${site.contact.phone}`}>电话咨询 <span>↗</span></a><a class="button button--ghost" href={`mailto:${site.contact.email}`}>发送邮件</a></div></div><div class="contact-hours" data-reveal><span>7×24</span><strong>服务时间</strong><p>周一至周日</p></div></div></section><section class="section-pad section-blue"><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><strong class="contact-big-link">启优学一对一</strong><p>搜索小程序名称提交预约</p></article><article data-reveal><span>03</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>04</span><h2>官方网站</h2><a class="contact-big-link contact-big-link--small" href={`https://${site.contact.website}`}>{site.contact.website}</a><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>{[["学生年级与地区","帮助确认学段、教材与当前可匹配资源"],["意向学科与教材进度","了解目前正在学习的内容与具体章节"],["近期试卷或错题","定位知识缺口、方法与学习习惯问题"],["当前情况与阶段目标","确定近期任务与适合的检查方式"]].map(([name,text],index)=><li><span>0{index+1}</span><div><strong>{name}</strong><p>{text}</p></div></li>)}</ol></div></section><section class="contact-bottom"><div class="container"><p>QIYOUXUE · PERSONAL LEARNING</p><h2>先看清问题<br />再规划每一步</h2><a class="button button--yellow" 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="启优学一对一关于课程适配、覆盖学段与科目、教师匹配、课堂回放、课后反馈和咨询预约的常见问题。"; 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"><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 常见问题</div><div class="eyebrow"><span></span>PARENTS OFTEN ASK</div><h1>关于在线一对一<br /><em>家长关心的问题</em></h1><p>从课程适配、教师匹配到课堂反馈,把重要信息公开说明。</p></div></section><section class="section-pad section-blue"><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></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 CTA from "../components/CTA.astro";
import SectionHeading from "../components/SectionHeading.astro";
import heroImage from "../../pic/主页大图素材-1.png";
import { Image } from "astro:assets";
import { site } from "../data/site";
import { fmtDate, getPublishedArticles } from "../lib/articles";
const latest = (await getPublishedArticles()).slice(0, 3);
const jsonLd = [{ "@context": "https://schema.org", "@type": "Service", name: "启优学在线一对一个性化辅导", provider: { "@id": new URL("/#organization", Astro.site).href }, areaServed: { "@type": "Country", name: "中国" }, audience: { "@type": "EducationalAudience", educationalRole: "student" }, description: site.home.subhead }, { "@context": "https://schema.org", "@type": "FAQPage", mainEntity: site.faq.slice(0, 4).map((item) => ({ "@type": "Question", name: item.q, acceptedAnswer: { "@type": "Answer", text: item.a } })) }];
---
<Base title={site.seo.title} jsonLd={jsonLd}><Header /><main id="main-content">
<section class="home-hero"><div class="container home-hero__grid"><div class="home-hero__copy" data-reveal><div class="hero-label"><span>QIYOUXUE · 1 ON 1</span><i></i><strong>小初高在线辅导</strong></div><h1>不是多上一节课<br /><em>是让每一步更适合孩子</em></h1><p>{site.home.subhead}</p><div class="hero__actions"><a class="button button--yellow" href="/contact/">免费领取学情分析 <span>↗</span></a><a class="button button--outline" href="#workflow">了解学习流程</a></div><div class="hero__proof"><span>固定教师</span><span>互动课堂</span><span>课程回放</span><span>阶段复盘</span></div></div><div class="home-hero__visual" data-reveal><div class="image-frame"><Image src={heroImage} widths={[580, 760, 980]} sizes="(max-width: 760px) 100vw, 52vw" alt="启优学老师与学生在线一对一互动学习" format="webp" loading="eager" fetchpriority="high" /></div><div class="hero-note hero-note--top"><span>01</span><strong>先诊断</strong><small>再制定方案</small></div><div class="hero-note hero-note--bottom"><span>✓</span><strong>课后反馈</strong><small>进展清楚可见</small></div></div></div><div class="container stage-ruler" aria-label="覆盖学段"><span>小学 1—6 年级</span><i></i><span>初中 1—3 年级</span><i></i><span>高中 1—3 年级</span></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><p class="data-note">师资数据来源于启优学一对一教务系统内部统计,截至 2026 年 7 月;相关数据会随师资及业务情况动态更新。</p></section>
<section id="services" class="section-pad section-blue"><div class="container"><div class="section-intro-row"><SectionHeading eyebrow="LEARNING NEEDS" title="从当前最需要解决的问题开始" description="课程不按统一模板推进。先看学生现在在哪里,再决定近期先做什么。" /><a class="text-link" href="/services/">查看全部学习需求 <span>↗</span></a></div><div class="need-grid">{site.services.map((item) => <a class="need-card" href={`/services/${item.slug}/`} data-reveal><div><span>{item.index}</span><small>{item.kicker}</small></div><h3>{item.name}</h3><p>{item.intro}</p><strong>了解适配方式 ↗</strong></a>)}</div></div></section>
<section id="workflow" class="section-pad section-white"><div class="container learning-map"><div class="learning-map__copy"><SectionHeading eyebrow="A VISIBLE LEARNING LOOP" title="学习不是一条直线,而是一轮轮看见问题、解决问题" description="启优学把一次辅导拆成四个可理解的环节,家长知道为什么这样安排,学生知道下一步做什么。" /><a class="button button--outline" href="/methodology/">查看完整教学服务</a></div><div class="learning-map__steps">{site.workflow.map((item, index) => <article data-reveal><span>{item.number}</span><div><small>{index === 0 ? "START" : index === 3 ? "REVIEW" : "NEXT"}</small><h3>{item.title}</h3><p>{item.desc}</p></div><i>{index < 3 ? "↓" : "↻"}</i></article>)}</div></div></section>
<section id="teachers" class="section-pad teacher-section"><div class="container teacher-layout"><div><div class="eyebrow eyebrow--light"><span></span>TEACHER MATCHING</div><h2><em>20000+</em> 签约严选教师<br />匹配的不只是学科</h2><p>综合学生所在地区、学段、学科、教材进度、当前基础、阶段目标与沟通特点进行匹配。教师录取率约 3%,85% 以上来自 985 / 211 或重点师范院校,均要求持有教师资格证。</p><div class="teacher-tags"><span>平均 5—8 年一线经验</span><span>固定教师持续跟进</span><span>分学段分学科匹配</span></div></div><div class="teacher-ledger" data-reveal><div class="ledger-head"><span>MATCHING PROFILE</span><strong>匹配维度</strong></div>{["所在地区与教材版本", "学生学段与意向学科", "当前基础与具体薄弱点", "阶段目标与可用学习时间", "授课节奏与沟通特点"].map((item, index) => <div><span>0{index + 1}</span><strong>{item}</strong><i>✓</i></div>)}</div></div></section>
<section class="section-pad section-yellow"><div class="container feedback-layout"><div class="feedback-board" data-reveal><div class="feedback-board__head"><span>本节学习反馈</span><strong>数学 · 函数基础</strong></div><div class="feedback-score"><span>掌握情况</span><strong>继续巩固</strong></div><ul><li><i></i><div><strong>本节内容</strong><p>梳理函数概念与自变量取值范围</p></div></li><li><i></i><div><strong>课堂观察</strong><p>概念理解清楚,分类讨论仍容易遗漏</p></div></li><li><i></i><div><strong>下节安排</strong><p>从同类错题检查分类讨论步骤</p></div></li></ul></div><div><SectionHeading eyebrow="FEEDBACK AFTER CLASS" title="不是上完就结束,学习进展需要被记录" description="课程支持回放;课后反馈会说明学习内容、课堂表现、仍需巩固的问题及后续安排。具体反馈形式以实际课程方案为准。" /><div class="feedback-points"><span>课堂互动</span><span>课程回放</span><span>错题复盘</span><span>阶段沟通</span></div></div></div></section>
<section class="section-pad section-white"><div class="container faq-preview"><div><SectionHeading eyebrow="PARENTS OFTEN ASK" title="开始一对一辅导前,家长通常会问" description="把课程适配、教师匹配和学习反馈的重要信息公开说明。" /><a class="text-link" href="/faq/">查看全部常见问题 <span>↗</span></a></div><div class="faq-list">{site.faq.slice(0, 4).map((item, index) => <details data-reveal open={index === 0}><summary><span>{String(index + 1).padStart(2, "0")}</span><strong>{item.q}</strong><i></i></summary><div><p>{item.a}</p></div></details>)}</div></div></section>
{latest.length > 0 && <section class="section-pad section-blue"><div class="container"><div class="section-intro-row"><SectionHeading eyebrow="LEARNING NOTES" title="学习资讯与家长指南" description="围绕学情判断、学科方法、阶段复习和在线学习服务的公开说明。" /><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://qiyouxueedu.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://qiyouxueedu.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 CTA from "../../components/CTA.astro"; import SectionHeading from "../../components/SectionHeading.astro"; import { site } from "../../data/site";
const title=`教学服务|${site.brand.name}`; const description="了解启优学一对一从学情沟通、问题诊断、教师匹配到课堂反馈与阶段复盘的教学服务流程。";
---
<Base {title} {description}><Header /><main id="main-content"><section class="page-hero"><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 教学服务</div><div class="eyebrow"><span></span>TEACHING SERVICE</div><h1>不从一套课程开始<br /><em>从孩子当前的问题开始</em></h1><p>通过学情沟通和诊断,把宽泛目标拆成近期任务,再匹配教师、开展互动课堂并持续复盘。</p></div></section><section id="workflow" class="section-pad section-white"><div class="container"><SectionHeading eyebrow="LEARNING LOOP" title="四步形成可持续调整的学习闭环" description="每一轮课堂与反馈,都会成为下一轮安排的依据。" align="center" /><div class="method-flow">{site.workflow.map((item,index)=><article data-reveal><div><span>{item.number}</span><i>{index<3?"→":"↻"}</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="VISIBLE FEEDBACK" title="课堂过程有记录,下一步有依据" description="学习服务不仅是一节在线课,也包含课堂互动、课程回放、课后记录和阶段沟通。" light /></div><div class="delivery-grid">{[["01","学情沟通","年级、教材、试卷、错题与目标等基础信息"],["02","课堂互动","提问、作答、即时纠错与难度调整"],["03","课后反馈","本节内容、掌握情况、仍需巩固的问题"],["04","阶段复盘","结合课堂与练习表现调整后续安排"]].map(([num,name,text])=><article data-reveal><span>{num}</span><h3>{name}</h3><p>{text}</p></article>)}</div></div></section><section class="section-pad section-blue"><div class="container"><SectionHeading eyebrow="SERVICE BOUNDARIES" title="把重要信息提前说清楚" align="center" /><div class="principle-grid">{[["适配","一对一更适合问题较明确、需要个别讲解节奏或持续反馈的学生。"],["透明","实际课程、教师、时间、费用与反馈形式以双方确认的方案为准。"],["共同参与","学习效果还会受到基础、频率、练习、周期与家庭配合等因素影响。"]].map(([name,text],index)=><article data-reveal><span>0{index+1}</span><h3>{name}</h3><p>{text}</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 related=site.services.filter(item=>item.slug!==service.slug);
const jsonLd={"@context":"https://schema.org","@type":"Service",name:service.name,serviceType:"在线一对一个性化辅导",description:service.seoDescription,provider:{"@id":new URL("/#organization",Astro.site).href},areaServed:{"@type":"Country",name:"中国"}};
---
<Base title={service.seoTitle} description={service.seoDescription} keywords={service.seoKeywords} {jsonLd}><Header /><main id="main-content"><section class="service-hero"><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="button button--yellow" href="/contact/">预约学情分析 <span>↗</span></a><a class="button button--outline" href="#capabilities">了解课程重点</a></div></div><div class="plan-sheet" data-reveal><div><small>PERSONAL LEARNING PLAN</small><strong>个性化阶段方案</strong></div>{service.capabilities.map((item,index)=><article><span>0{index+1}</span><div><small>{item.label}</small><p>{item.value}</p></div><i>✓</i></article>)}<p>示意内容 · 实际方案以学情沟通后确认为准</p></div></div></section><section id="capabilities" class="section-pad section-blue"><div class="container service-cap-layout"><div><div class="eyebrow"><span></span>HOW IT WORKS</div><h2>把宽泛目标<br />拆成可检查的任务</h2><p>{service.seoDescription}</p></div><div class="service-cap-grid">{service.capabilities.map((item,index)=><article data-reveal><span>0{index+1}</span><h3>{item.label}</h3><p>{item.value}</p></article>)}</div></div></section><section class="section-pad section-white"><div class="container service-feature-layout"><div class="service-symbol" data-reveal><small>QIYOUXUE</small><strong>{service.index}</strong><span>1 ON 1</span></div><div><div class="eyebrow"><span></span>COURSE FOCUS</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"><div class="eyebrow"><span></span>LEARNING 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<3?"→":"↻"}</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 CTA from "../../components/CTA.astro"; import SectionHeading from "../../components/SectionHeading.astro"; import { site } from "../../data/site";
const title = `学科辅导|${site.brand.name}`; const description = "启优学一对一覆盖基础巩固、偏科补弱、校内同步、阶段复习与升学冲刺等小初高学习需求。";
const jsonLd = { "@context": "https://schema.org", "@type": "ItemList", name: "启优学学科辅导", itemListElement: site.services.map((item, index) => ({ "@type": "ListItem", position: index + 1, name: item.name, url: new URL(`/services/${item.slug}/`, Astro.site).href })) };
---
<Base {title} {description} {jsonLd}><Header /><main id="main-content"><section class="page-hero"><div class="container page-hero__inner" data-reveal><div class="breadcrumb"><a href="/">首页</a> / 学科辅导</div><div class="eyebrow"><span></span>SUBJECT SUPPORT</div><h1>同一个年级<br /><em>也应该有不同的学习路径</em></h1><p>覆盖小学、初中和高中常见校内学科。从当前基础、教材进度和具体问题出发,确定近期最需要解决的任务。</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-blue"><div class="container service-list">{site.services.map((item) => <article id={item.slug} class="service-detail"><div class="service-detail__content" data-reveal><div class="service-detail__summary"><div class="eyebrow"><span></span>{item.kicker}</div><h2>{item.name}</h2><p class="lead">{item.intro}</p><a class="button button--outline" href={`/services/${item.slug}/`}>查看适配方式 <span>↗</span></a></div><div class="service-detail__delivery"><ul>{item.features.map((feature) => <li><span>✓</span>{feature}</li>)}</ul><div class="capability-pills">{item.capabilities.map((capability) => <span>{capability.label}</span>)}</div></div></div></article>)}</div></section><section class="section-pad section-white"><div class="container"><SectionHeading eyebrow="STAGES & SUBJECTS" title="学段不同,学习重点也不同" description="小学关注基础与习惯,初中梳理知识结构与偏科问题,高中更重视知识体系、题型方法与复习节奏。" align="center" /><div class="stage-grid">{[["小学","1—6 年级","语文 · 数学 · 英语"],["初中","1—3 年级","语数英 · 物理 · 化学 · 道法 · 地理"],["高中","1—3 年级","语数英 · 物化生 · 政史地"]].map(([name,grade,subjects])=><article data-reveal><span>{grade}</span><h3>{name}</h3><p>{subjects}</p></article>)}</div></div></section><CTA title="不确定孩子适合哪种学习安排?" 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 });
}
};
This diff is collapsed.
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(), "qiyouxue-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);
});
# 开始学情沟通前,建议家长准备这四类信息
一次有效的学情沟通,需要把年级、教材进度、近期试卷和阶段目标放在一起观察。资料不必复杂,但应尽量准确。
![启优学在线一对一课堂示意图]({{TEST_IMAGE_URL}})
## 一、品牌与业务简介
用简洁语言说明企业是谁、服务谁、解决什么问题,以及当前最重要的产品与市场。
## 二、核心品牌与品类关键词
整理用户可能主动搜索的品牌词、品类词、场景词和问题词,作为诊断范围的初始输入。
## 三、重点竞品与替代方案
列出用户在比较阶段可能同时考虑的品牌或方案,便于观察AI回答中的推荐结构。
## 四、现有官方内容
准备官网、公众号、产品资料和权威报道等内容入口,确认品牌事实是否统一。
## 五、当前最关心的问题
说明品牌是完全没有被提及、描述不准确,还是在关键问题中被竞品压制。
启优学会结合沟通与诊断结果梳理近期任务,实际课程安排以双方确认的方案为准。
测试标记:QIYOUXUE-PRODUCTION-IMPORT-20260812-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", "主页大图素材-1.png");
const UNIQUE_MARKER = "QIYOUXUE-IMPORT-TEST-20260812";
const dataDirectory = await fs.mkdtemp(path.join(os.tmpdir(), "qiyouxue-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: "Qiyouxue 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: "学情指南",
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: "学习方法",
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, "Qiyouxue 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, "学习方法");
assert.match(article.body, new RegExp(UNIQUE_MARKER));
assert.doesNotMatch(article.body, /^#\s+Qiyouxue 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