From 779e4eae2fedfbe7ab52555fb126c4ad03ecd05a Mon Sep 17 00:00:00 2001 From: zhenyi <434836402@qq.com> Date: Sun, 31 May 2026 03:09:49 +0800 Subject: [PATCH] feat(channel): add article feed and composer with room type support - Add ArticleFeed component for article-based channels - Implement ArticleComposer with draft persistence - Add Newspaper icon for article room type - Update ChannelPage to conditionally render article feed vs message view - Add article-related API endpoints and models - Reset thread view when switching rooms - Add room type check in channel sidebar - Update CSS to hide scrollbars globally - Add gRPC message size limit configuration - Fix git diff tree handling --- index.html | 20 + lib/api/src/channel/mod.rs | 30 + lib/api/src/channel/rest_article.rs | 306 ++++++++ lib/api/src/channel/rest_room.rs | 2 + lib/api/src/openapi.rs | 11 + lib/channel/bus.rs | 2 +- lib/channel/event/article.rs | 115 +++ lib/channel/event/common.rs | 2 +- lib/channel/event/mod.rs | 3 +- lib/channel/http/dispatch.rs | 2 +- lib/channel/http/handler/article.rs | 717 ++++++++++++++++++ lib/channel/http/handler/category.rs | 8 +- lib/channel/http/handler/forward.rs | 2 +- lib/channel/http/handler/helpers.rs | 2 +- lib/channel/http/handler/message.rs | 16 +- lib/channel/http/handler/mod.rs | 86 ++- lib/channel/http/handler/room.rs | 19 +- lib/channel/http/handler/thread.rs | 6 +- lib/channel/http/out_event.rs | 42 +- lib/channel/http/types.rs | 55 ++ lib/channel/pagination.rs | 12 +- lib/channel/reconnect.rs | 2 +- lib/channel/rooms.rs | 3 +- lib/channel/search.rs | 2 +- lib/git/cmd/diff/diff_patch.rs | 2 - lib/git/cmd/diff/diff_stats.rs | 1 - lib/git/cmd/diff/diff_tree_to_tree.rs | 2 - lib/git/rpc/server.rs | 1 + .../sql/room/channel_article_down_01.sql | 3 + .../channel_article_like_comment_down_01.sql | 2 + .../channel_article_like_comment_up_01.sql | 28 + .../sql/room/channel_article_up_01.sql | 28 + lib/model/channel/channel.rs | 85 +++ lib/model/channel/channel_article.rs | 69 ++ lib/model/channel/channel_article_interact.rs | 51 ++ lib/model/{room => channel}/message_read.rs | 0 lib/model/{room => channel}/message_star.rs | 0 lib/model/{room => channel}/mod.rs | 16 +- .../{room => channel}/room_attachments.rs | 0 .../{room => channel}/room_categories.rs | 0 lib/model/{room => channel}/room_mention.rs | 0 lib/model/{room => channel}/room_message.rs | 0 .../room_message_edit_history.rs | 0 .../room_permission_overwrite.rs | 0 lib/model/{room => channel}/room_pins.rs | 0 lib/model/{room => channel}/room_reactions.rs | 0 .../{room => channel}/room_server_label.rs | 0 lib/model/{room => channel}/room_threads.rs | 0 .../{room => channel}/user_room_state.rs | 0 lib/model/lib.rs | 2 +- lib/model/room/room.rs | 22 - lib/service/git/diff.rs | 17 +- openapi.json | 530 +++++++++++++ src/App.css | 2 + src/App.tsx | 4 +- src/client/endpoints.ts | 129 +++- .../models/articleCommentCreateRequest.ts | 13 + src/client/models/articleCreateRequest.ts | 22 + src/client/models/articleLikeRequest.ts | 11 + src/client/models/articleUpdateRequest.ts | 26 + .../models/channelArticleCommentListParams.ts | 18 + .../models/channelArticleLikedUsersParams.ts | 18 + src/client/models/channelArticleListParams.ts | 18 + src/client/models/index.ts | 7 + src/client/models/roomCreateRequest.ts | 2 + src/components/right-drawer.tsx | 87 +++ src/hooks/use-drawer.ts | 8 + src/page/workspace/channel/article-card.tsx | 140 ++++ .../workspace/channel/article-composer.tsx | 261 +++++++ src/page/workspace/channel/article-detail.tsx | 400 ++++++++++ src/page/workspace/channel/article-feed.tsx | 325 ++++++++ src/page/workspace/channel/article-types.ts | 106 +++ src/page/workspace/channel/channel-header.tsx | 17 +- .../workspace/channel/channel-sidebar.tsx | 3 + .../channel/channel-thread-panel.tsx | 60 +- src/page/workspace/channel/index.tsx | 119 ++- .../workspace/channel/message-content.tsx | 68 ++ src/page/workspace/channel/message-item.tsx | 57 +- src/page/workspace/channel/repo-drawer.tsx | 45 ++ .../workspace/channel/repo-embed-card.tsx | 167 ++++ .../workspace/channel/repo-link-parser.ts | 38 + .../workspace/channel/room-create-dialog.tsx | 45 +- .../workspace/channel/use-article-draft.ts | 111 +++ src/page/workspace/repo/code.tsx | 8 + src/page/workspace/repo/commit-detail.tsx | 2 +- src/page/workspace/repo/layout.tsx | 18 +- 86 files changed, 4503 insertions(+), 176 deletions(-) create mode 100644 lib/api/src/channel/rest_article.rs create mode 100644 lib/channel/event/article.rs create mode 100644 lib/channel/http/handler/article.rs create mode 100644 lib/migrate/sql/room/channel_article_down_01.sql create mode 100644 lib/migrate/sql/room/channel_article_like_comment_down_01.sql create mode 100644 lib/migrate/sql/room/channel_article_like_comment_up_01.sql create mode 100644 lib/migrate/sql/room/channel_article_up_01.sql create mode 100644 lib/model/channel/channel.rs create mode 100644 lib/model/channel/channel_article.rs create mode 100644 lib/model/channel/channel_article_interact.rs rename lib/model/{room => channel}/message_read.rs (100%) rename lib/model/{room => channel}/message_star.rs (100%) rename lib/model/{room => channel}/mod.rs (60%) rename lib/model/{room => channel}/room_attachments.rs (100%) rename lib/model/{room => channel}/room_categories.rs (100%) rename lib/model/{room => channel}/room_mention.rs (100%) rename lib/model/{room => channel}/room_message.rs (100%) rename lib/model/{room => channel}/room_message_edit_history.rs (100%) rename lib/model/{room => channel}/room_permission_overwrite.rs (100%) rename lib/model/{room => channel}/room_pins.rs (100%) rename lib/model/{room => channel}/room_reactions.rs (100%) rename lib/model/{room => channel}/room_server_label.rs (100%) rename lib/model/{room => channel}/room_threads.rs (100%) rename lib/model/{room => channel}/user_room_state.rs (100%) delete mode 100644 lib/model/room/room.rs create mode 100644 src/client/models/articleCommentCreateRequest.ts create mode 100644 src/client/models/articleCreateRequest.ts create mode 100644 src/client/models/articleLikeRequest.ts create mode 100644 src/client/models/articleUpdateRequest.ts create mode 100644 src/client/models/channelArticleCommentListParams.ts create mode 100644 src/client/models/channelArticleLikedUsersParams.ts create mode 100644 src/client/models/channelArticleListParams.ts create mode 100644 src/components/right-drawer.tsx create mode 100644 src/hooks/use-drawer.ts create mode 100644 src/page/workspace/channel/article-card.tsx create mode 100644 src/page/workspace/channel/article-composer.tsx create mode 100644 src/page/workspace/channel/article-detail.tsx create mode 100644 src/page/workspace/channel/article-feed.tsx create mode 100644 src/page/workspace/channel/article-types.ts create mode 100644 src/page/workspace/channel/message-content.tsx create mode 100644 src/page/workspace/channel/repo-drawer.tsx create mode 100644 src/page/workspace/channel/repo-embed-card.tsx create mode 100644 src/page/workspace/channel/repo-link-parser.ts create mode 100644 src/page/workspace/channel/use-article-draft.ts diff --git a/index.html b/index.html index 8346b2f..d1594d2 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,26 @@