Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
e97ed93
add jquery + swiper
HaibinLai Jul 27, 2025
9260049
add style for quote block
HaibinLai Dec 12, 2025
f49e8c0
try to fix 图片加载导致导航栏错位问题
HaibinLai Jan 14, 2026
403d86d
try to fix 导航栏错位重新刷新
HaibinLai Jan 14, 2026
a8605ec
try to fix 每次滑动重新刷新
HaibinLai Jan 14, 2026
479f15a
英文化部分标题
HaibinLai Jan 14, 2026
44d956c
英文化组建
HaibinLai Jan 14, 2026
0bb08a9
更新README
HaibinLai Jan 14, 2026
42e0339
更新README,减少冗余
HaibinLai Jan 14, 2026
bd572d0
英文化评论区
HaibinLai Jan 14, 2026
e11c894
打赏?
HaibinLai Jan 14, 2026
b471d0b
把我加进去
HaibinLai Jan 14, 2026
5cfe2b7
分类
HaibinLai Jan 14, 2026
850fe58
调大字体到1rem
HaibinLai Jan 14, 2026
4780c8e
fix jquery problem
HaibinLai Jan 31, 2026
6ca1fee
update readme for 0201 updates
HaibinLai Jan 31, 2026
aa98c2e
已为 <details> 和 <summary> 添加样式
HaibinLai Feb 7, 2026
02721a5
一旦 Markdown 被正确解析为 HTML,标题会正确显示
HaibinLai Feb 7, 2026
327c5aa
try to decode '|' in figure
HaibinLai Feb 7, 2026
470d831
reroll
HaibinLai Feb 7, 2026
d2545f9
try to do word counting
HaibinLai Feb 7, 2026
a400940
update readme
HaibinLai Feb 7, 2026
59cb508
update intro
HaibinLai Feb 7, 2026
64fd052
update counting algo that avoiding url
HaibinLai Feb 7, 2026
bfaf3a1
rollback
HaibinLai Feb 8, 2026
f921db2
实现图片懒加载
HaibinLai Feb 26, 2026
e989f8b
侧边目录的 JS 滚动逻辑在 Firefox 上兼容性不好,修复
HaibinLai Feb 26, 2026
dc46e62
侧边目录的 JS 滚动逻辑在 Firefox 上兼容性不好,修复
HaibinLai Feb 26, 2026
1759a4f
侧边目录的 JS 滚动逻辑在 Firefox 上兼容性不好,修复
HaibinLai Feb 26, 2026
b4f4bf4
update readme
HaibinLai Feb 26, 2026
7a09e81
新增待办事项功能,支持增删改查、优先级、截止日期、拖拽排序,LocalStorage缓存实现瞬间渲染
HaibinLai Apr 17, 2026
07745c6
美化待办事项:优先级彩条移至左侧、日期增加倒计时、修复深色模式字体不可见
HaibinLai Apr 17, 2026
13741d1
新增2D艾森豪威尔矩阵视图:X轴紧急度(截止日期)、Y轴重要度(1-5星),支持列表/矩阵双视图切换
HaibinLai Apr 17, 2026
313a13e
升级主题版本至 1.4.1
HaibinLai Apr 17, 2026
ea86cd6
修复矩阵视图不显示:display用block替代空字符串,移除CSS中的display:none
HaibinLai Apr 17, 2026
46c1cfa
紧急度改为4级(随时可以/这周处理/这两天/紧急),支持按deadline自动升级;X轴刻度优化为过期~14天后,图表颜色加深
HaibinLai Apr 17, 2026
402e5d6
图表背景透明度加深约2倍,象限文字改为对应颜色替代灰色
HaibinLai Apr 17, 2026
1778419
图表新增TODAY红虚线标注今天位置
HaibinLai Apr 17, 2026
4f3df36
v1.4.2: 页面布局紧凑化、图表文字放大、颜色鲜艳化、重叠点螺旋散开
HaibinLai Apr 17, 2026
8ba0eb4
v1.4.2: 紧急区改为3天内,计划区3~14天,重要分界线3.2★,>14天自动升星
HaibinLai Apr 17, 2026
da2fbb6
矩阵视图新增侧边栏,按象限分类展示待办事项
HaibinLai Apr 17, 2026
b868d21
矩阵视图突破容器宽度,利用页面两侧空白区域
HaibinLai Apr 17, 2026
ed0bad5
图表从6象限简化为4象限:立即做/快速做/计划做/一般事务
HaibinLai Apr 17, 2026
e9bc26b
矩阵视图扩展为宽屏模式,侧边栏改为底部4列卡片布局
HaibinLai Apr 17, 2026
fb77217
紧急X轴分界线从3天改为3.2天
HaibinLai Apr 17, 2026
2fc37ba
计划做/一般事务分界线改为升星斜线:x≤14水平y=3.2,x>14沿斜线上升
HaibinLai Apr 17, 2026
6a49b43
象限标签文字居中放置在各区域视觉中心
HaibinLai Apr 17, 2026
ae355f6
新增小玩具导航页面模板,卡片网格布局,支持管理员单独设定每个玩具的可见性
HaibinLai Apr 17, 2026
a89c01f
在PAGES配置中注册小玩具页面模板,修复模板不显示的问题
HaibinLai Apr 17, 2026
d42e4fd
小玩具链接支持完整URL,外部链接自动新标签页打开
HaibinLai Apr 17, 2026
f5c496b
移除点击弹窗外部关闭行为,仅通过按钮关闭弹窗
HaibinLai Apr 17, 2026
cfca43a
修复右键编辑时链接路径丢失的问题,改用data-url存储原始路径
HaibinLai Apr 17, 2026
51a00df
待办事项默认链接改为 /index.php/todo-list/
HaibinLai Apr 17, 2026
b93e2f1
v1.4.3: 默认打开矩阵视图
HaibinLai Apr 17, 2026
63fd7f8
Rename to My Corner, fully convert all UI text and comments to English
HaibinLai Apr 17, 2026
a59f7c5
Icon field now supports emoji, image URL, or media library upload wit…
HaibinLai Apr 17, 2026
dbc9dd1
Add drag-and-drop reorder for admin, cards can be dragged to rearrange
HaibinLai Apr 17, 2026
3eae920
Security hardening: escape icon output to prevent XSS, block javascri…
HaibinLai Apr 17, 2026
13b17d4
新增番茄钟功能:25分钟专注+休息提醒,集成到待办事项页面
HaibinLai Apr 17, 2026
d2a5ec7
侧边栏每个任务旁添加 ▶ 番茄钟启动按钮
HaibinLai Apr 17, 2026
2d499e7
Add Clipboard Helper: global copy listener + management page with fil…
HaibinLai Apr 17, 2026
abb95b3
修复▶按钮不显示:completed为字符串\"0\"时的truthy判断问题
HaibinLai Apr 17, 2026
f6cda55
番茄钟:矩阵中专注任务脉冲闪烁 + 最多同时专注3件事
HaibinLai Apr 17, 2026
8540046
番茄钟状态持久化:刷新页面后自动恢复计时
HaibinLai Apr 17, 2026
fddd2a8
Add Snake Game with leaderboard: modern smooth style, open to all vis…
HaibinLai Apr 17, 2026
9c6a424
Fix snake AJAX 404: fallback to HOME URL; walls now wrap around inste…
HaibinLai Apr 17, 2026
414844b
Update README: document My Corner, Clipboard, and Snake Game features
HaibinLai Apr 17, 2026
3482469
feat: 多番茄钟并行 + 一行横排展示 + 所有活跃点闪烁
HaibinLai Apr 17, 2026
93f8ce8
style: 多个番茄钟时隐藏"专注中"文字,避免遮挡标题
HaibinLai Apr 17, 2026
13451f4
Add detailed error logging to snake AJAX calls for debugging leaderbo…
HaibinLai Apr 17, 2026
1c8dd17
style: 短休息浅绿色、长休息深绿色区分显示
HaibinLai Apr 17, 2026
984a412
Fix snake invalid token: inject SNAKE_DAY_SALT via wp_add_inline_scri…
HaibinLai Apr 17, 2026
22013aa
docs: 添加待办事项微网页详细文档
HaibinLai Apr 17, 2026
14a4deb
Fix snake anti-cheat token and add score cleanup
HaibinLai Apr 17, 2026
2f71dfe
Fix My Corner styles not showing for non-admin users; add technical docs
HaibinLai Apr 17, 2026
f77ffe7
feat: 番茄钟多端同步 — 状态存服务端 wp_options
HaibinLai Apr 18, 2026
36d42fd
feat: 统计每个任务累计专注时长,多端同步
HaibinLai Apr 18, 2026
710afc8
Add Doom FPS: raycasting first-person shooter with leaderboard
HaibinLai Apr 18, 2026
689af4d
Enemy projectiles, Q weapon switch, fix camera angle jump
HaibinLai Apr 18, 2026
2f50178
Fix enemies spawning in walls and camera jump on fast mouse
HaibinLai Apr 18, 2026
874bba5
Fix camera jump: clamp each mousemove event and tighten frame cap
HaibinLai Apr 18, 2026
bf0d2ac
Smooth mouse rotation with EMA + rotation cap
HaibinLai Apr 18, 2026
0f13798
Fix camera jump: discard outlier mousemove events instead of smoothing
HaibinLai Apr 18, 2026
746aaa9
Enlarge game screen to 960x540 (16:9)
HaibinLai Apr 18, 2026
f13cbb9
Fix Doom layout: vertical stack, transparent background, responsive c…
HaibinLai Apr 18, 2026
f971898
Add procedural sound effects via Web Audio API
HaibinLai Apr 18, 2026
14e8125
v1.5.1: 引入 esbuild 前端资源压缩,减少页面加载体积约 206KB
HaibinLai Apr 18, 2026
044dd44
Fix close-range combat: reduce min hit distance, add melee attack
HaibinLai Apr 18, 2026
b25cf33
Prevent player-enemy overlap with mutual collision blocking
HaibinLai Apr 18, 2026
ab8a85a
Add knife as starting melee weapon
HaibinLai Apr 18, 2026
42dc057
perf: 所有前端 JS 移至 footer 并添加 defer 属性
HaibinLai Apr 18, 2026
3d06f0d
Add Level 2, new weapons, grenades, and gameplay polish to Doom FPS
HaibinLai Apr 18, 2026
859066b
Build minified doom.js
HaibinLai Apr 18, 2026
e915746
Start with pistol, add realistic grenade physics with arc and wall bo…
HaibinLai Apr 18, 2026
124f903
Add weapon models for sniper rifle and M4A1
HaibinLai Apr 18, 2026
21d3f8f
v1.5.2: Add Doom technical blog article
HaibinLai Apr 18, 2026
346cd04
Doom: pistol dmg 25→15, sniper long-press zoom, bilingual blog toggle…
HaibinLai Apr 18, 2026
8fa438f
Doom: M4A1 damage 20→25, add coin counter to HUD
HaibinLai Apr 18, 2026
439de3c
Doom: revert sniper to right-click toggle scope (2x zoom)
HaibinLai Apr 18, 2026
a818b9b
Doom: grenade inherits player movement velocity
HaibinLai Apr 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
.idea/
node_modules/
103 changes: 103 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# CLAUDE.md - Document WordPress Theme

## 项目概述

这是一个 WordPress 博客主题(Document),基于文档类型设计,方便记录和查询学习笔记。

- **类型**: WordPress 主题
- **版本**: 1.5.1
- **版本号位置**: `style.css` (第8行) 和 `include/config.php` (`DOCUMENT_VERSION` 常量),两处必须同步修改

## 项目结构

```
├── style.css / style.scss # 主样式(WordPress 主题入口)
├── functions.php # 主题初始化,加载所有 include
├── header.php / footer.php # 全局头尾模板
├── index.php / single.php / page.php / 404.php # 页面模板
├── include/
│ ├── config.php # 主题版本号、后台设置表单定义、所有配置项默认值
│ ├── themes/
│ │ ├── load.php # ★ 前端资源加载(JS/CSS enqueue)核心文件
│ │ ├── theme.php # 主题钩子入口,include 所有子模块
│ │ ├── shortcode.php # 短标签
│ │ └── ...
│ ├── admin/ # 后台相关(设置页面、编辑器插件)
│ ├── functions/ # 通用函数、SMTP、初始化
│ ├── widget/ # 侧边栏小部件
│ ├── todo/ clipboard/ snake/ doom/ # 各功能模块的数据库和API
│ └── ...
├── common/
│ ├── main.js # 前端主逻辑
│ ├── inline/ # 各页面内联脚本(emoji, index, monitor, view 等)
│ ├── prism/ # 代码高亮(Prism.js)
│ ├── viewer/ # 图片灯箱(Viewer.js)
│ ├── plugins/ # TinyMCE 编辑器插件
│ ├── todo/ clipboard/ snake/ doom/ friend/ swiper/ widget/ # 各功能模块前端
│ └── admin/ # 后台前端(Vue + Ant Design)
├── assets/theme/ # 第三方库(jQuery, Swiper, Vue, Ant Design, Moment, Axios)
├── template/ # 模板片段(文章列表、分页、页面模板等)
├── build.js # ★ 前端构建脚本(esbuild 压缩)
└── package.json # Node.js 依赖(仅 esbuild)
```

## 构建流程

### 重要:修改 JS 或 CSS 后必须重新构建

本主题使用 esbuild 将所有前端 JS/CSS 压缩为 `.min.js` / `.min.css` 文件。WordPress 生产环境加载的是压缩版。

```bash
# 首次使用需安装依赖
npm install

# 构建(压缩所有 JS/CSS,约1秒完成)
node build.js
```

### 构建机制说明

- `build.js` 读取所有前端 JS/CSS 源文件,用 esbuild 压缩后输出为同目录下的 `.min.js` / `.min.css`
- `include/themes/load.php` 中的 `nicen_theme_min_path()` 函数自动检测 `.min` 文件是否存在:
- 存在 → 加载压缩版(生产环境)
- 不存在 → 回退到原版(开发调试)
- **只修改源文件**(如 `common/main.js`),**不要手动编辑** `.min.js` 文件

### 什么时候需要构建

- 修改了 `common/` 下的任何 `.js` 文件 → 需要 `node build.js`
- 修改了 `style.css` → 需要 `node build.js`
- 修改了 `.php` 文件 → **不需要**构建
- 新增了 JS/CSS 文件 → 需要在 `build.js` 的文件列表中添加该文件,然后构建

## 开发规范

### 文件修改后的完整流程

1. 修改源文件(`.js` / `.css` / `.php`)
2. 如果改了 JS 或 CSS:运行 `node build.js`
3. 确认 `.min` 文件已更新
4. 提交所有文件(包括源文件和 `.min` 文件)

### 版本号更新

需要同时修改两处:
- `style.css` 头部注释中的 `Version:` 字段
- `include/config.php` 中的 `DOCUMENT_VERSION` 常量

### 新增页面模板

在 `include/config.php` 的 `PAGES` 常量中添加配置,包括模板文件路径和依赖的样式/脚本。

### 资源加载

- 前端资源加载集中在 `include/themes/load.php`
- 后台资源加载在 `include/admin/load.php`
- 页面模板的资源通过 `PAGES` 配置自动加载

### 注意事项

- jQuery 是全局依赖,`window.$ = jQuery` 已在 inline script 中设置
- 后台使用 Vue 2 + Ant Design,前端不使用
- 主题配置通过 `nicen_theme_config('key', false)` 读取
- 主题色等样式变量通过 CSS 变量注入(`include/themes/load.php` 底部的 inline style)
201 changes: 201 additions & 0 deletions DOOM_DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Doom-Style FPS Game (Raycasting)

## Context
Add a Doom/Wolfenstein-style first-person shooter to the blog as a "My Corner" game. Built entirely with Canvas 2D raycasting — no WebGL, no external libraries. One map, 3 weapons, level-based (find exit to win). Flat color walls with distance shading. Leaderboard reuses the same pattern as Snake Game.

## Game Design

### Gameplay
- **Objective**: Navigate a maze, kill all enemies, find the exit door
- **Perspective**: First-person, Wolfenstein 3D / Doom style
- **Map**: 1 hand-crafted map (grid-based, ~24x24), walls are solid colors with distance-based shading
- **Win condition**: Reach exit door (all enemies killed or exit found)
- **Score**: Kills × 100 + health remaining × 10 + time bonus (faster = more points)

### Weapons
| # | Weapon | Damage | Fire Rate | Ammo | Notes |
|---|--------|--------|-----------|------|-------|
| 1 | Pistol | 25 | Medium | Unlimited | Starting weapon |
| 2 | Shotgun | 80 (spread) | Slow | 20 | Pickup in map, wide spread |
| 3 | Machine Gun | 15 | Fast | 100 | Pickup in map, rapid fire |

Weapon switching: keys 1/2/3 or scroll wheel. Weapon sprite drawn at bottom-center of screen (simple geometric shapes, not image assets).

### Enemies
- **Type 1: Guard** — walks a patrol route, detects player by line-of-sight, shoots when in range (hitscan), low HP (50)
- **Type 2: Soldier** — faster, more HP (100), chases aggressively once alerted
- Enemies rendered as colored billboard sprites (circles/rectangles, not images), scaled by distance
- Basic state machine: IDLE → ALERT (heard gunshot / saw player) → CHASE → ATTACK → DEAD
- Collision: enemies block player movement

### Player
- HP: 100, displayed as health bar in HUD
- Movement: WASD (forward/back/strafe), mouse or arrow keys to rotate
- Interaction: approach exit door to trigger win

### HUD
- Health bar (bottom-left)
- Ammo count (bottom-right)
- Current weapon indicator
- Minimap (top-right corner, toggleable with M key) — shows walls, player position/direction, enemy dots
- Crosshair at screen center
- Kill count

## Technical Architecture

### Raycasting Engine
- Cast one ray per screen column (e.g., 640 rays for 640px wide canvas)
- DDA algorithm (Digital Differential Analyzer) for fast grid-based wall intersection
- Wall height = `screenHeight / perpDistance` (fish-eye corrected)
- Wall color based on wall type value in map grid, darkened by distance (`color * (1 - distance/maxDist)`)
- North/South walls slightly darker than East/West for depth perception
- Floor/ceiling: solid colors (no texture mapping needed)

### Sprite Rendering
- After walls are drawn, render sprites (enemies, pickups, exit door)
- Sort sprites by distance (far to near), draw back-to-front
- Each column checks against the wall depth buffer — only draw sprite pixels closer than the wall
- Sprites scale with distance: `spriteHeight = screenHeight / distance`

### Map Format
```javascript
// 0 = empty, 1-4 = wall types (different colors), 9 = exit door
const MAP = [
[1,1,1,1,1,1,...],
[1,0,0,0,0,1,...],
[1,0,2,0,0,1,...],
...
];
// Separate arrays for entity placement
const ENTITIES = [
{ type: 'guard', x: 3.5, y: 5.5 },
{ type: 'soldier', x: 10.5, y: 8.5 },
{ type: 'shotgun', x: 7.5, y: 3.5 },
{ type: 'machinegun', x: 15.5, y: 12.5 },
{ type: 'health', x: 12.5, y: 6.5 },
];
```

### Game Loop
```
requestAnimationFrame loop:
1. Process input (movement, rotation, shooting)
2. Update entities (enemy AI, projectiles, animations)
3. Cast rays → build wall depth buffer
4. Draw ceiling + floor
5. Draw walls (column by column)
6. Draw sprites (sorted by distance)
7. Draw weapon sprite (bottom of screen)
8. Draw HUD (health, ammo, minimap, crosshair)
9. Check win/lose conditions
```

### Controls
| Input | Action |
|-------|--------|
| W / ArrowUp | Move forward |
| S / ArrowDown | Move backward |
| A | Strafe left |
| D | Strafe right |
| ArrowLeft | Rotate left |
| ArrowRight | Rotate right |
| Mouse move (pointer lock) | Rotate view |
| Left click / Space | Shoot |
| 1, 2, 3 | Switch weapon |
| Scroll wheel | Cycle weapon |
| M | Toggle minimap |

Mobile: virtual joystick (left side) + virtual buttons (right side: shoot, weapon switch).

## Files to Create

### Frontend
1. **`common/doom/doom.js`** (~800-1200 lines) — Complete game engine:
- Raycasting renderer
- Player movement + collision
- Enemy AI + sprite rendering
- Weapon system
- HUD rendering
- Map data
- Game state management (MENU → PLAYING → WIN → GAMEOVER)
- Score submission + leaderboard display
- Built-in md5 for anti-cheat token

2. **`common/doom/doom.css`** — Page layout, canvas styling, leaderboard panel, responsive

### Page Template
3. **`template/page/doom.php`** — WordPress page template "Doom FPS"
- Canvas element (640×480 or responsive)
- Start overlay (enter name + start)
- Win/GameOver overlay (score, rank, play again)
- Leaderboard panel (reuse snake's layout pattern)

### Backend
4. **`include/doom/install.php`** — DB table `wp_document_doom_scores`
```sql
id BIGINT AUTO_INCREMENT PRIMARY KEY
player_name VARCHAR(50) NOT NULL
score INT NOT NULL DEFAULT 0
kills INT NOT NULL DEFAULT 0
duration INT NOT NULL DEFAULT 0
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
INDEX idx_score (score DESC)
INDEX idx_created (created_at)
```

5. **`include/doom/api.php`** — AJAX endpoints
- `doom_submit` — submit score with anti-cheat token, rate limit
- `doom_leaderboard` — alltime (top 20) / weekly (top 10)
- Cleanup: top 20 retained, 3-week expiry (same as snake)

## Files to Modify

1. **`include/config.php`** — Add "Doom FPS" to PAGES array:
```php
'Doom FPS' => [
'template' => 'template/page/doom.php',
'dependent' => [
'styles' => ['/common/doom/doom.css'],
'scripts' => ['/common/doom/doom.js'],
]
]
```

2. **`include/themes/theme.php`** — Add includes:
```php
include_once $root . '/include/doom/install.php';
include_once $root . '/include/doom/api.php';
```

3. **`include/themes/load.php`** — Add inline var injection for Doom:
```php
if ( $key === 'Doom FPS' ) {
$doom_salt = md5('doom_' . date('Y-m-d') . '_' . wp_salt('auth'));
wp_add_inline_script($key, 'window.DOOM_DAY_SALT="'.$doom_salt.'";window.DOOM_AJAX="'.admin_url('admin-ajax.php').'";', 'before');
}
```

4. **`README.md`** — Add Doom FPS entry to changelog

## Implementation Order

1. **Raycasting engine** — walls rendering, player movement, collision detection
2. **Map design** — create the 24x24 map layout
3. **Weapon system** — 3 weapons, shooting, ammo
4. **Enemy system** — sprites, AI state machine, combat
5. **HUD** — health, ammo, minimap, crosshair
6. **Game states** — menu, playing, win, gameover overlays
7. **Backend** — DB, API, leaderboard (copy-paste from snake, adjust fields)
8. **Integration** — config.php, theme.php, load.php, template
9. **Mobile controls** — virtual joystick + buttons
10. **Polish** — sound effects (optional), README update

## Verification
1. Create WP page with "Doom FPS" template → visit as guest → game loads
2. Enter name → start → WASD movement works, walls render correctly
3. Find and pick up weapons → ammo shows in HUD
4. Enemies patrol, detect player, combat works
5. Kill enemies → find exit → win screen → score submitted → appears in leaderboard
6. Test alltime/weekly leaderboard tabs
7. Test mouse pointer lock for smooth rotation
8. Verify on mobile with virtual controls
Loading