跪拜 Guibai
← All articles
Backend · Java · Python

Character Game for a Daughter with ADHD Meets cj-tauri's Silent Failures and a Drift Bug

By 特立独行的猫A ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

cj-tauri's documentation and tooling still carry gaps that cost a weekend: silent asset-loading failures, PATH-order dependencies, a missing DLL, and a drift bug that makes sync and check disagree. For anyone evaluating Cangjie or similar cross-platform frameworks, these exact failure modes and the author's fixes are directly reusable.

Summary

The game offers five mini-games with 102 character groups from grades one to five. Difficulty adapts by adding distractors on correct answers and showing a memory mnemonic after three misses. The parent dashboard tracks session time, accuracy trends, and automatically aggregates repeatedly missed pairs into a review area. Progress is saved via four Cangjie commands to a local JSON file, with a localStorage fallback.

Three silent environment and framework issues cost time: relative CSS and JS fail to load because the framework reads the HTML as a string and uses NavigateToString, solved by a build-time inliner; cjpm exits with 127 unless Cangjie's bin, tools, and runtime are first on PATH; and a missing WebView2Loader.dll makes the window close instantly. The author also traced a sync/check drift bug to TOML escaping and path normalization, fixed it, added regression tests, and documented the correct HarmonyOS signing order (sync, sign, build, never sync after sign).

Takeaways
— 102 character groups cover grades 1-5, each with pinyin, compound words, and a memory mnemonic.
— Five mini-games: find the odd one out, character-word matching, radical detective, listen-and-choose, and fill-in-the-blank.
— Difficulty adapts: correct answers add a distractor up to six options; three wrong attempts reveal a memory mnemonic.
— All in-game copy praises effort, never correctness, per the requirement for a child with ADHD.
— Parent dashboard is password-protected and shows session time, accuracy trend, and a key review area of repeatedly missed pairs.
— Progress persists via four Cangjie commands to a JSON file in the app's local data dir, with a localStorage fallback.
— Relative CSS/JS fail when the page is loaded via NavigateToString; a 30-line build-time inliner solves it.
— cjpm exits 127 unless Cangjie's bin, tools, and runtime are first on PATH.
— Missing WebView2Loader.dll next to the exe makes the window flash and close instantly.
— The sync/check drift bug stems from TOML escaping, different root-resolution paths, and no separator merging; fixed by normalizing and using one root source.
— HarmonyOS signing order matters: sync, then sign, then build; re-syncing after signing wipes signingConfigs and produces an unsigned HAP.
— One codebase (200 lines of Cangjie + 10 frontend files) runs both Windows desktop and HarmonyOS tablet.
Conclusions

The silent relative-path failure is a classic WebView2 behavior: NavigateToString provides no base URL, so any local CSS or JS reference is unresolvable; the build-time inline workaround is a simple, portable pattern for any WebView wrapper.

The A/B comparison against the base commit before touching existing failing tests is a good contributor habit: it separates pre-existing breakage from newly introduced regressions.

The signing-order trap (sync regenerates build-profile.json5 and wipes signingConfigs) is a footgun that any framework automating HarmonyOS packaging should document prominently or make idempotent.

Concepts & terms
cj-tauri
A cross-platform framework for the Cangjie programming language that pairs a Cangjie backend with a system WebView frontend, generating Windows desktop and HarmonyOS applications from one codebase.
NavigateToString
A WebView2 method that loads an HTML string as the document source without a base URL, so relative paths to CSS/JS files fail to resolve.
HAP
HarmonyOS application package, the installable artifact for HarmonyOS devices.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗