Files
wordpress-theme-aksrt/assets/creator-studio/README.md
T
kate522 8bb4b98fc9 chore(creator-studio): stop tracking the build output
assets/creator-studio/build is generated by `npm run build`, so committing it
put a rebuilt bundle in every diff. It now follows the same deploy-only rule
as assets/admin/build.

- Root .gitignore ignores build/* and node_modules/, keeping a .gitkeep so
  the directory still exists in a clean checkout.
- Drops the three tracked artifacts from the index.
- The contract test no longer requires the artifacts to exist; it checks the
  set is all-or-nothing, so a clean checkout and a locally built tree both
  pass. This mirrors admin-build-graph-contract.
- README documents that build/ is produced on the target machine.

887 widget-system tests pass.
2026-11-09 16:44:41 +08:00

2.7 KiB
Raw Blame History

Jio Creator Studio(前台沉浸式创作工作台)

面向作者的前台写作体验:WordPress TinyMCE 负责 HTML 正文编辑,React + TypeScript 负责两行固定顶栏(站点身份 + 居中工具条)、写作工作台与发布抽屉,Jio 服务端继续作为权限、审核、付费与附件交付的唯一权威。

启动

cd assets/creator-studio
npm install            # 首次安装(packages 已锁定 WordPress 6.4 时代的版本)
npm run build          # 产物写入 assets/creator-studio/build/

build/ 是构建产物,不进版本库(与 assets/admin/build 同一约定);部署时在目标机上执行上面的 npm run build。

PHP 读取 build/index.asset.php(依赖清单 + 版本)并只在投稿模板加载,构建产物缺失时自动回退到原有 TinyMCE 投稿表单。

使用前提

  • 已登录且具备 new_post_add(编辑已有文章需作者本人或审核权限)。
  • 私有附件(付费资料)需要在 wp-config.php 里配置私有目录:
define('JIO_PRIVATE_STORAGE_DIR', '/var/private/jio-assets'); // ABSPATH 之外

若目录位于站点根目录内,还必须在 Web 服务器层禁止访问,并显式声明:

define('JIO_PRIVATE_STORAGE_VERIFIED', true);

未配置时付费资料上传/下载接口返回 501(fail closed),普通图片与视频上传不受影响。

关键行为

场景 行为
新文章草稿/投稿 复用 FrontSubmit::persist();草稿为 draft,投稿按 new_post_audit_no 决定 publish 或 pending
编辑已发布文章 写入私有改稿版本(jio_submission),线上文章与永久链接保持不变
审核通过 后台「文章 → 改稿审核」一次性应用内容、摘要、分类、标签、封面与付费设置
自动保存 云端 4 秒防抖 + rev 版本号;冲突返回 409,不覆盖较新内容
本地恢复 仅保存标题与 TinyMCE HTML 正文,恢复前询问用户
付费附件 上传到私有存储,只保存随机 asset_key;下载先取短期令牌,服务端每次复核订单/VIP/配额

相关代码

  • 服务端:src/Core/CreatorRest.php、CreatorStudio.php、SubmissionVersion.php、PreviewToken.php
  • 安全交付:src/Content/PrivateAssets.php、src/Content/ProtectedDownload.php
  • 原生审核:src/Admin/Native/SubmissionReview.php
  • 前端:assets/creator-studio/src/(index.tsx / components/editor-toolbar.tsx / panels/ / hooks/ / services/ / styles/)
  • 契约测试:tests/widget-system/creator-studio-contract.test.cjs

测试

node --test tests/widget-system/*.test.cjs
php tools/audit-psr4-paths.php