diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..a2cfb07 --- /dev/null +++ b/.env.development @@ -0,0 +1,3 @@ +# Dev: load images/audio from OSS (same prefix as production). +# Layout: {VITE_OSS_BASE}/assets/... → oss://dukang-prod/dukang_office/assets/... +VITE_OSS_BASE=https://dukang-prod.oss-cn-hangzhou.aliyuncs.com/dukang_office diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d937270 --- /dev/null +++ b/.env.example @@ -0,0 +1,19 @@ +# Public CDN/OSS base for static images & audio (no trailing slash). +# Object layout: {VITE_OSS_BASE}/assets/... → oss://dukang-prod/dukang_office/assets/... +# +# Used by: +# .env.development → npm run dev +# .env.production → npm run build +# +# Examples: +# VITE_OSS_BASE=https://dukang-prod.oss-cn-hangzhou.aliyuncs.com/dukang_office +# VITE_OSS_BASE=https://cdn.dukanghaoke.com/dukang_office +# Leave empty only if you intentionally want local /assets during that mode. +VITE_OSS_BASE= + +# --- For npm run oss:sync only (do not commit secrets) --- +# OSS_REGION=oss-cn-hangzhou +# OSS_BUCKET=dukang-prod +# OSS_PREFIX=dukang_office +# OSS_ACCESS_KEY_ID= +# OSS_ACCESS_KEY_SECRET= diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..f8d6ffb --- /dev/null +++ b/.env.production @@ -0,0 +1,3 @@ +# Production OSS public prefix (no trailing slash). +# Layout: {VITE_OSS_BASE}/assets/... → oss://dukang-prod/dukang_office/assets/... +VITE_OSS_BASE=https://dukang-prod.oss-cn-hangzhou.aliyuncs.com/dukang_office diff --git a/.gitignore b/.gitignore index b2af1db..ccfe9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,8 @@ node_modules dist .DS_Store *.local +.env +.env.local +.env.*.local _tmp_*.txt .vite diff --git a/deploy/BAIDU_SEO.md b/deploy/BAIDU_SEO.md new file mode 100644 index 0000000..04a7a18 --- /dev/null +++ b/deploy/BAIDU_SEO.md @@ -0,0 +1,40 @@ +# 百度搜索资源平台操作清单(部署后执行) + +目标站点:https://www.dukanghaoke.com + +## 1. 验证站点 + +1. 打开 https://ziyuan.baidu.com/ 登录 +2. 添加站点:`https://www.dukanghaoke.com`(若裸域跳转到 www,可一并添加) +3. 验证归属(二选一): + - **HTML 文件**:把平台下发的 `baidu_verify_xxxx.html` 放到 `public/` 后重新部署 + - **Meta 标签**:把验证码填入 `index.html` 中 `baidu-site-verification` 的 content(替换 REPLACE_WITH_BAIDU_CODE)后重新部署 + +## 2. 提交资源 + +1. Sitemap:提交 `https://www.dukanghaoke.com/sitemap.xml` +2. 普通收录:优先推送 + - https://www.dukanghaoke.com/ + - https://www.dukanghaoke.com/brand + - https://www.dukanghaoke.com/qingxiang + - https://www.dukanghaoke.com/haoke + - https://www.dukanghaoke.com/contact +3. 有 API Token 时可用普通收录 API 每日推送核心 URL + +## 3. 自检 + +- 浏览器打开 `https://www.dukanghaoke.com/robots.txt`、`/sitemap.xml` +- 百度搜索:`site:www.dukanghaoke.com` +- 品牌词「杜康好客」通常需数天到数周才稳定展示新站 + +## 4. OSS 图片(与收录并行) + +1. 将 `public/assets`(及如有 `public/audio`)上传到 `oss://dukang-prod/dukang_office/assets/`(音频到 `.../audio/`) +2. 确认 `.env.production` 中 `VITE_OSS_BASE` 与公网前缀一致后 `npm run build` 再部署 +3. 抽查:`{VITE_OSS_BASE}/assets/logo.png` 可公网打开 + +## 5. 缓存 + +- 站点 HTML:短校验(见 `deploy/nginx-cache.conf` / `public/_headers`) +- Vite 带 hash 的 JS/CSS:长缓存 +- OSS 图片:建议 30 天 Cache-Control;发版后一般只需 purge 首页 HTML diff --git a/deploy/nginx-cache.conf b/deploy/nginx-cache.conf new file mode 100644 index 0000000..2ccd637 --- /dev/null +++ b/deploy/nginx-cache.conf @@ -0,0 +1,37 @@ +# Nginx / 宝塔:分层缓存片段(并入 server {} 后 reload) +# Vite 构建产物在 /assets/ 下且文件名含 content hash → 长缓存 +# 注意:若 public 静态图也挂在 /assets/,与构建产物同前缀时用扩展名区分 + +location = /index.html { + add_header Cache-Control "public, max-age=0, must-revalidate"; +} + +location ~* \.html$ { + add_header Cache-Control "public, max-age=0, must-revalidate"; +} + +# Vite 打出的带 hash 的 JS/CSS(部署后路径通常为 /assets/index-xxxxx.js) +location ~* ^/assets/.*\.(?:js|css)$ { + add_header Cache-Control "public, max-age=31536000, immutable"; + try_files $uri =404; +} + +# 同域兜底图片(生产主图应走 OSS;若仍有本地图则 7 天) +location ~* ^/assets/.*\.(?:png|jpe?g|gif|webp|svg|ico)$ { + add_header Cache-Control "public, max-age=604800"; + try_files $uri =404; +} + +location = /robots.txt { + add_header Cache-Control "public, max-age=0, must-revalidate"; +} + +location = /sitemap.xml { + add_header Cache-Control "public, max-age=0, must-revalidate"; + default_type application/xml; +} + +# SPA 路由回退(按实际根目录调整) +# location / { +# try_files $uri $uri/ /index.html; +# } diff --git a/index.html b/index.html index 89fd800..c9f948c 100644 --- a/index.html +++ b/index.html @@ -4,18 +4,77 @@ - + + + + + + - - -