docs(readme): 添加一键部署指南和安全配置

- 新增 Vercel、Netlify、Cloudflare Pages 一键部署按钮与命令行方法
- 添加 Netlify 重定向与安全头配置文件
- 添加 Vercel 部署配置文件支持静态站点托管
- 更新文档中的引号为英文格式以保持一致性
- 补充部署相关常见问题说明
This commit is contained in:
hehh
2025-11-25 14:40:02 +08:00
parent 24d2321218
commit b6d0f51a98
6 changed files with 87 additions and 3 deletions

View File

@@ -7,6 +7,49 @@
- 任意静态站点环境Nginx/Apache/Node 静态服务、Vercel、Netlify、GitHub Pages 等)
- 现代浏览器(移动/桌面)
## 一键部署
### Vercel
点击下方按钮一键部署到 Vercel
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/listener-He/Home)
或者通过命令行部署:
```bash
# 安装 Vercel CLI
npm install -g vercel
# 在项目根目录运行
vercel
```
### Netlify
点击下方按钮一键部署到 Netlify
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/listener-He/Home)
或者通过命令行部署:
```bash
# 安装 Netlify CLI
npm install -g netlify-cli
# 在项目根目录运行
netlify deploy
```
### Cloudflare Pages
1. 登录 Cloudflare 控制台
2. 进入 Pages 服务
3. 选择 "Create a project"
4. 连接 GitHub 账户并选择此仓库
5. 配置设置:
- 构建命令:`echo "No build command needed"`
- 发布目录:`.`
6. 点击 "Deploy"
## 本地预览
- 直接在本地打开 `index.html``about.html` 即可(双击或使用任意静态服务器)
@@ -58,7 +101,7 @@ server {
- `SiteConfig.cacheKeys.blog`:缓存键与过期时间(毫秒)
- Artalk 评论
- `SiteConfig.artalk.server``SiteConfig.artalk.site`
- `dev.isLocal`:本地或非 HTTPS 环境下自动显示评论区已关闭提示
- `dev.isLocal`:本地或非 HTTPS 环境下自动显示"评论区已关闭"提示
- 主题与语言
- 主题缓存:`SiteConfig.cacheKeys.theme.key/ttlMs`
- 语言存取:使用 `localStorage('lang')`,页面内可切换 CN/EN
@@ -76,7 +119,7 @@ server {
- 标题渐变:仅在白天保留轻微渐变,正文统一实色以提升可读性
- 评论组件Artalk
- 桌/移端响应式:容器 `#artalk-container` 自动加 `.atk-mobile/.atk-desktop`
- 移动端折叠:评论内容默认折叠,按钮展开/收起交互
- 移动端折叠:评论内容默认折叠,按钮"展开/收起"交互
## 数据缓存与性能
@@ -86,7 +129,7 @@ server {
## 常见问题
- 评论区在本地或非 HTTPS 环境显示评论区已关闭
- 评论区在本地或非 HTTPS 环境显示"评论区已关闭"
- 这是预期行为;上线到 HTTPS 环境并设置 `SiteConfig.artalk` 可开启
- 夜间兴趣文本未显示渐变
- 清理浏览器缓存后重试;检查 CSS 覆盖是否被自定义样式覆盖

View File

@@ -31,6 +31,16 @@
- 🌗 **主题与语言**:一键切换 Day/Night 与 CN/EN自动缓存记忆
-**性能与体验**:缓存字段精简、骨架占位与淡入过渡、异步抓取避免阻塞
## 🚀 一键部署
<div align="center">
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flistener-He%2FHome)
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/listener-He/Home)
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/listener-He/Home)
</div>
## 🖼️ 页面预览
<div align="center">

6
_headers Normal file
View File

@@ -0,0 +1,6 @@
# Security headers for Netlify
/*
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin

2
_redirects Normal file
View File

@@ -0,0 +1,2 @@
# Netlify redirects
/* /index.html 200

8
netlify.toml Normal file
View File

@@ -0,0 +1,8 @@
[build]
publish = "."
command = "echo 'No build command needed for static site'"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200

15
vercel.json Normal file
View File

@@ -0,0 +1,15 @@
{
"version": 2,
"builds": [
{
"src": "**/*.html",
"use": "@vercel/static"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/$1"
}
]
}