File tree Expand file tree Collapse file tree 3 files changed +64
-13
lines changed
Expand file tree Collapse file tree 3 files changed +64
-13
lines changed Original file line number Diff line number Diff line change 1313 <h1 class =" header-title" >首页</h1 >
1414
1515 </div >
16- <div class =" header-tabs" >
16+ <div v-if = " isLogin " class =" header-tabs" >
1717 <button
1818 class =" header-tab"
1919 :class =" { 'header-tab--active': feedType === 'for-you' }"
2828 >
2929 关注
3030 </button >
31+ <button
32+ class =" header-tab"
33+ :class =" { 'header-tab--active': feedType === 'global' }"
34+ @click =" feedType = 'global'"
35+ >
36+ 全局
37+ </button >
3138 </div >
3239 </header >
3340
@@ -125,11 +132,21 @@ const loadFeed = async (isInitial = false) => {
125132 }
126133
127134 try {
128- const res = await PostsService .getFeed ({
129- cursor: isInitial ? undefined : cursor .value ,
130- limit: 20 ,
131- includeReplies: false
132- });
135+ let res;
136+ if (feedType .value === ' global' ) {
137+ res = await PostsService .getGlobalFeed ({
138+ cursor: isInitial ? undefined : cursor .value ,
139+ limit: 20 ,
140+ includeReplies: false ,
141+ });
142+ } else {
143+ res = await PostsService .getFeed ({
144+ cursor: isInitial ? undefined : cursor .value ,
145+ limit: 20 ,
146+ includeReplies: false ,
147+ followingOnly: feedType .value === ' following' ,
148+ });
149+ }
133150
134151 if (isInitial) {
135152 posts .value = res .posts ;
Original file line number Diff line number Diff line change 1919 <div class =" header-content" >
2020 <h1 class =" header-title" >首页</h1 >
2121 </div >
22- <div class =" header-tabs" >
22+ <div v-if = " isLogin " class =" header-tabs" >
2323 <button
2424 class =" header-tab"
2525 :class =" { 'header-tab--active': feedType === 'for-you' }"
3434 >
3535 关注
3636 </button >
37+ <button
38+ class =" header-tab"
39+ :class =" { 'header-tab--active': feedType === 'global' }"
40+ @click =" feedType = 'global'"
41+ >
42+ 全局
43+ </button >
3744 </div >
3845 </header >
3946
@@ -149,12 +156,21 @@ const loadFeed = async (isInitial = false) => {
149156 }
150157
151158 try {
152- const res = await PostsService .getFeed ({
153- cursor: isInitial ? undefined : cursor .value ,
154- limit: 20 ,
155- includeReplies: false ,
156- followingOnly: feedType .value === ' following'
157- });
159+ let res;
160+ if (feedType .value === ' global' ) {
161+ res = await PostsService .getGlobalFeed ({
162+ cursor: isInitial ? undefined : cursor .value ,
163+ limit: 20 ,
164+ includeReplies: false ,
165+ });
166+ } else {
167+ res = await PostsService .getFeed ({
168+ cursor: isInitial ? undefined : cursor .value ,
169+ limit: 20 ,
170+ includeReplies: false ,
171+ followingOnly: feedType .value === ' following' ,
172+ });
173+ }
158174
159175 if (isInitial) {
160176 posts .value = res .posts ;
Original file line number Diff line number Diff line change @@ -346,6 +346,24 @@ export const PostsService = {
346346 }
347347 } ,
348348
349+ /**
350+ * 获取全局信息流(包含 Mastodon 同步帖子,仅登录可用)
351+ * @param {Object } options
352+ * @param {string } options.cursor - 分页游标
353+ * @param {number } options.limit - 每页数量
354+ * @param {boolean } options.includeReplies - 是否包含回复
355+ */
356+ async getGlobalFeed ( { cursor, limit = 20 , includeReplies = false } = { } ) {
357+ try {
358+ const params = { limit, include_replies : String ( includeReplies ) } ;
359+ if ( cursor ) params . cursor = cursor ;
360+ const response = await axios . get ( '/posts/global' , { params } ) ;
361+ return normalizeListResponse ( response . data ) ;
362+ } catch ( error ) {
363+ throw new Error ( getErrorMessage ( error , '获取全局时间线失败' ) ) ;
364+ }
365+ } ,
366+
349367 /**
350368 * 获取提及列表
351369 * @param {Object } options
You can’t perform that action at this time.
0 commit comments