fix(desktop): skip obfuscation for electron main to preserve page.evaluate
Desktop Client Build / Resolve Build Metadata (push) Successful in 19s
Desktop Client Build / Build Desktop Client (push) Successful in 21m39s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 30s

Playwright serializes page.evaluate callbacks via Function.prototype.toString and runs them in the target page context. Obfuscating the main bundle injected string-array helper references that the browser page could not resolve, surfacing as `ReferenceError: wO is not defined` for bilibili and dongchedi publishes. Mirrors the existing Vite `minify: false` guard for main/preload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Xu Liang
2026-05-09 17:46:37 +08:00
parent 1082e9010e
commit 708a45ba16
3 changed files with 24 additions and 6 deletions
+12
View File
@@ -812,5 +812,17 @@
- Started Phase 48/49 for the user's content-management "发文管理" request.
- Confirmed desktop-client already has a publish management table with the requested columns/actions, but admin-web needs tenant HTTP APIs because Electron IPC is unavailable in the browser.
## 2026-05-09T17:40:00+08:00 - Desktop publisher page.evaluate packaging fix
- Investigated `page.evaluate: ReferenceError: wO is not defined` reported for desktop-client Bilibili publishing and then confirmed dongchedi has the same risk pattern.
- Root cause: packaged desktop builds run `build:obf`; `scripts/obfuscate.cjs` obfuscated `out/main/*.cjs`, and Playwright `page.evaluate` callbacks then carried obfuscator helper names into the browser page context where those helpers do not exist.
- Updated `apps/desktop-client/scripts/obfuscate.cjs` so the Electron main bundle is left unobfuscated and only renderer assets are obfuscated. This aligns the post-build obfuscation step with the existing Vite main-process `minify: false` guard.
- Verification passed:
- `pnpm --filter @geo/desktop-client typecheck`
- `pnpm --filter @geo/desktop-client build:obf`
- `pnpm --filter @geo/desktop-client exec vitest run src/main/adapters/dongchedi.test.ts`
- `pnpm --filter @geo/desktop-client exec vitest run src/main/adapters/baijiahao.test.ts`
- Searched `apps/desktop-client/out/main/bootstrap.cjs` for `wO`, `_0x...`, `stringArray`, `javascript-obfuscator`, and `['evaluate']`; no obfuscator helper traces were present after `build:obf`.
- Scoped implementation to tenant publish task list/retry endpoints plus a new admin-web `/publish-management` page under 内容管理.
- Noted existing dirty files in i18n/Knowledge/TemplateWizard/config/swagger/knowledge service and will avoid reverting or overwriting unrelated changes.