快乐的梦鱼 пре 2 недеља
родитељ
комит
61cf676f4c
2 измењених фајлова са 23 додато и 16 уклоњено
  1. 14 6
      server/api/ecms/article/byChannelName.ts
  2. 9 10
      src/pages/index.vue

+ 14 - 6
server/api/ecms/article/byChannelName.ts

@@ -11,6 +11,9 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
     const query = getQuery(event);
     const page = Number(query.page as string) || 1;
     const pageSize = Number(query.pageSize as string) || 10;
+    const onlySelf = query.onlySelf === 'true';
+    const bannedChannels = (query.bannedChannels as string || '').split(',');
+
     const channelName = query.channelName as string;
     if (!channelName)
       return createErrorResponse('分类名称不能为空');
@@ -27,12 +30,17 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
         .first();
       if (channel) {
         channelIds.push(channel.id);
-        const subChannelIds = (await DB.table('pr_cms_channel')
-          .where('parent_id', channel.id)
-          .where('status', 'normal')
-          .select('id')
-          .get()).map(item => item.id);
-        channelIds.push(...subChannelIds);
+        if (!onlySelf) {
+          const subChannels = (await DB.table('pr_cms_channel')
+            .where('parent_id', channel.id)
+            .where('status', 'normal')
+            .select('id', '')
+            .get()).map(item => item.id);
+          if (bannedChannels.length > 0) {
+            channelIds.push(...subChannels.filter(item => !bannedChannels.includes(item.name)).map(item => item.id));
+          } else
+            channelIds.push(...subChannels.map(item => item.id));
+        }
       }
     }
     

+ 9 - 10
src/pages/index.vue

@@ -182,7 +182,7 @@
             </div> -->
 
             <!-- 通知公告 -->
-            <!-- <div class="main-box flex-fill">
+            <div class="main-box flex-fill">
               <div class="section-title">
                 <h2>
                   <Icon name="famicons:logo-designernews" />
@@ -201,8 +201,13 @@
                   </div>
                 </SimplePageContentLoader>
               </div>
-            </div> -->
-        
+            </div>
+          </div>
+        </div>
+
+        <!-- 精彩推荐 -->
+        <div class="row mt-lg-3 mt-md-2 mt-sm-2">
+          <div class="col col-12">
             <!-- 精彩推荐 -->
             <div class="main-box mt-lg-3 mt-md-2 mt-sm-2">
               <div class="section-title">
@@ -223,12 +228,6 @@
           </div>
         </div>
 
-        <!-- 精彩推荐 -->
-        <!-- <div class="row mt-lg-3 mt-md-2 mt-sm-2">
-          <div class="col col-12">
-          </div>
-        </div> -->
-
         <hr class="main-hr" />
 
         <!-- 公共服务 -->
@@ -333,7 +332,7 @@ const notices = await useSSrSimpleDataLoader('notices', async () => {
 });
 // 工作动态数据
 const workUppublishtimes = await useSSrSimpleDataLoader('workUppublishtimes', async () => {
-  const res = await $fetch(`/api/ecms/article/byChannelName?channelName=工作动态`);
+  const res = await $fetch(`/api/ecms/article/byChannelName?channelName=工作动态&bannedChannels=新闻公告`);
   if (!res.status)
     throw new Error(res.message);
   return res.data;