diff --git a/app/ApiHandler.php b/app/ApiHandler.php index 5dc56dc..1ed663d 100644 --- a/app/ApiHandler.php +++ b/app/ApiHandler.php @@ -1765,6 +1765,36 @@ final class ApiHandler } } + /* 🔴 工单 #26(用户 2026-10-28「鸿蒙端对齐网页端」):任务共享。 + 端上没有「共享给谁」入口;`Task::shares/setShare/dropShare` 模型早就齐 + (Web 端 tasks/share、tasks/unshare 在用),只缺 API 子端点。 */ + if ($sub === 'shares') { + if ($method === 'GET') { + Api::ok(['items' => Task::shares($id)]); + } + Api::requireWrite(); + if (!Task::canWrite($t, $pid)) { + Api::fail('这项任务不能共享。', 'forbidden', 403); + } + if ($method === 'POST') { + $who = Api::int('person_id'); + if ($who <= 0) { + Api::fail('要共享给谁?缺 `person_id`。', 'unprocessable', 422); + } + Task::setShare($id, $who, Api::str('perm', 'write')); + Api::ok(['items' => Task::shares($id)]); + } + if ($method === 'DELETE') { + $who = Api::int('person_id'); + if ($who <= 0) { + Api::fail('要取消谁的共享?缺 `person_id`。', 'unprocessable', 422); + } + Task::dropShare($id, $who); + Api::ok(['items' => Task::shares($id)]); + } + Api::fail('不支持的方法。', 'method_not_allowed', 405); + } + /* ═══════════════════════════════════════════════════════════ v79(用户 2026-10-22):「鸿蒙端的功能,也需要同样适配…… 任务模块的功能需要完善。」