学习路径Learning path · 第 5 阶段Stage 5
存档与离线行为
Save and offline behaviour
一句话:这两个是「开发机上永远正常、上线后立刻出问题」的东西。
In one line: these are the two things that are "always fine on the dev machine and broken the moment you ship".
存档的四个坑
| 坑 | 症状 | 原因 |
|---|---|---|
| ⚠ 平台存储 API 不可用 | 刷新后进度没了 | 原生 API 在 Web 上常常不可用 |
| ⚠ 存储配额超限 | 到某个关卡就崩 | localStorage 通常只有 5MB |
| ⚠ 隐私模式 | 玩家说「我存不了」 | 隐私模式下存储受限 |
| ⚠ 版本不兼容 | 更新后读不了旧档 | 存档格式变了没做迁移 |
Four ways saves break
| Trap | Symptom | Cause |
|---|
| ⚠ The platform's storage API is unavailable | Progress gone after a refresh | Native APIs are often unavailable on the web |
|---|
| ⚠ Storage quota exceeded | Crashes at a certain level | localStorage is typically only 5 MB |
| ⚠ Private browsing | Players report "I can't save" | Storage is restricted in private mode |
| ⚠ Version incompatibility | Old saves unreadable after an update | The format changed with no migration |
⚠ 离线的三种处理
| 做法 | 适用 |
|---|---|
| 优雅降级 | ⚠ 断网时提示「需要网络」并暂停 |
| 本地优先 | 离线可玩,联网后同步 |
| 拒绝启动 | 强联网游戏(但 ⚠ 要给清晰提示) |
⚠ 最差的做法是崩溃 —— 玩家不会给你第二次机会。
⚠ Three ways to handle being offline
| Approach | When it fits |
|---|---|
| Graceful degradation | ⚠ Show "needs network" and pause |
| Local-first | Playable offline, syncs when connected |
| Refuse to start | Strictly online games (but ⚠ give a clear message) |
⚠ The worst option is crashing — a player will not give you a second chance.
发布前必测清单
- ⚠ 刷新页面后进度还在
- ⚠ 存档满了会怎样(填满一个存档,看会不会崩)
- ⚠ 断网后会怎样(飞行模式打开游戏)
- ⚠ 更新版本后旧档能读吗
- ⚠ 隐私模式下能玩吗
⚠ 这五条在开发机上全部正常 —— 因为开发机有正常的存储、有网络、
不涉及隐私模式。⚠ 必须用手机测,且开飞行模式。
The pre-ship checklist
- ⚠ Progress survives a page refresh
[ ] ⚠ What happens when a save fills up (fill one and see if it crashes)
- ⚠ What happens offline (open the game in aeroplane mode)
- ⚠ Can old saves be read after an update
- ⚠ Does it work in private browsing
⚠ All five pass on the dev machine — it has normal storage, a network, and no private mode. ⚠ Test on a phone, in aeroplane mode.
常见失败
- ⚠ 只在开发机测 —— 开发机什么都是正常的
- 忘了隐私模式 —— 相当一部分玩家会开
- ⚠ 更新时不做存档迁移 —— 玩家会丢掉全部进度,然后不会再玩
Common failures
- ⚠ Testing only on the dev machine — everything is normal there
- Forgetting private browsing — a fair number of players use it
- ⚠ No save migration on update — players lose all progress and do not come back