Explorar o código

📦 按要求修改

快乐的梦鱼 hai 2 semanas
pai
achega
7357e0355e

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

@@ -14,25 +14,35 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
     const channelName = query.channelName as string;
     if (!channelName)
       return createErrorResponse('分类名称不能为空');
+
+    const channelNames = channelName.split(',');
     // 1. 从pr_cms_channel表中通过name查询channel_id
-    const channel = await DB.table('pr_cms_channel')
-      .where('name', channelName)
-      .where('status', 'normal')
-      .select('id')
-      .first();
+
+    const channelIds : number[] = [];
+    for (const channelName of channelNames) {
+      const channel = await DB.table('pr_cms_channel')
+        .where('name', channelName)
+        .where('status', 'normal')
+        .select('id')
+        .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 (!channel) 
+    if (channelIds.length === 0) 
       return createSuccessResponse(new CommonPageResult<IArticle>(undefined, [], page, pageSize, 0));
-        
-    const subChannelIds = (await DB.table('pr_cms_channel')
-      .where('parent_id', channel.id)
-      .where('status', 'normal')
-      .select('id')
-      .get()).map(item => item.id);
 
     // 2. 从pr_cms_archives表中通过channel_id查询文章
     const articles = await DB.table('pr_cms_archives')
-            .whereIn('channel_id', [channel.id, ...subChannelIds])
+            .whereIn('channel_id', channelIds)
             .where('status', 'normal')
             .whereNull('deletetime')
             .orderBy('weigh', 'desc')
@@ -44,7 +54,7 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
       return createErrorResponse('文章不存在');
 
     return createSuccessResponse({
-      channel_id: channel.id,
+      channel_id: channelIds[0],
       ...articles
     });
   } catch (error) {

+ 1 - 1
src/App.vue

@@ -12,8 +12,8 @@
     <main>
       <NuxtPage />
     </main>
+    <LinkInfos showType="list" />
     <Footer>
-      <LinkInfos showType="list" />
     </Footer>
   </a-config-provider>
 </template>

BIN=BIN
src/assets/images/qr1/activity.png


BIN=BIN
src/assets/images/qr1/volunteer.png


+ 10 - 5
src/components/LinkInfos.vue

@@ -87,17 +87,22 @@ const linkInfos = ref([
     flex-wrap: wrap;
     align-items: center;
     justify-content: center;
-    gap: 20px;
-    padding: 10px 0;
+    gap: 36px;
+    padding: 20px 0;
     width: auto;
     left: unset;
     right: unset;
     bottom: unset;
 
     > div {
+
+      &:hover {
+        background-color: transparent;
+      }
+
       > img {
-        width: 100px;
-        height: 100px;
+        width: 120px;
+        height: 120px;
         object-fit: contain;
       }
     }
@@ -112,7 +117,7 @@ const linkInfos = ref([
     font-size: 12px;
     padding: 5px 0;
     gap: 5px;
-    color: #d3d3d3;
+    color: #999;
 
     > img {
       width: 20px;

+ 47 - 21
src/pages/index.vue

@@ -235,20 +235,20 @@
           <img class="title" src="@/assets/images/box-service.png" alt="公共服务">
           <div class="services-grid">
 
-            <a class="service-card" href="https://mp.weixin.qq.com/s/r6Tgsp068VNo4tVIA2sEHA" target="_blank">
+            <div class="service-card" @click="handleServiceClick('volunteer')">
               <img class="icon" src="@/assets/images/icon-explore.png">
               <h3>志愿者招募</h3>
               <div class="service-link">
                 <Icon name="material-symbols-light:chevron-right" />
               </div>
-            </a>
+            </div>
 
             <div class="service-card" @click="handleServiceClick('activity')">
               <img class="icon" src="@/assets/images/icon-join.png">
               <h3>活动报名</h3>
-              <a href="#" class="service-link">
+              <div class="service-link">
                 <Icon name="material-symbols-light:chevron-right" />
-              </a>
+              </div>
             </div>
 
             <div class="service-card" @click="router.push('/about/')">
@@ -262,15 +262,30 @@
         </div>
       </div>
     </div>
+
+    <!-- 扫码进入小程序对话框 -->
+    <AModal
+      v-model:open="qrModalVisible"
+      :title="qrModalTitle"
+      :footer="null"
+      centered
+    >
+      <div class="qr-modal-content">
+        <p class="qr-modal-tip">请扫码进入小程序</p>
+        <img v-if="qrImageSrc" :src="qrImageSrc" alt="小程序二维码" class="qr-modal-img">
+      </div>
+    </AModal>
   </div>
 </template>
 
 <script setup lang="ts">
 import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
-import { ref } from 'vue';
+import { ref, computed } from 'vue';
 import { useSSrSimpleDataLoader } from '@/composeable/SimpleDataLoader';
 import { DataDateUtils } from '@imengyu/js-request-transform';
 import { MemoryTimeOut } from '@imengyu/imengyu-utils';
+import volunteerQr from '@/assets/images/qr1/volunteer.png';
+import activityQr from '@/assets/images/qr1/activity.png';
 import CarouselItem1 from '@/assets/images/board1/1.jpg';
 import CarouselItem2 from '@/assets/images/board1/2.jpg';
 import CarouselItem3 from '@/assets/images/board1/3.jpg';
@@ -335,31 +350,25 @@ const hot = await useSSrSimpleDataLoader('hot', async () => {
 });
 // 精彩推荐数据
 const featured = await useSSrSimpleDataLoader('featured', async () => {
-  const res = await $fetch(`/api/ecms/article/byChannelName?channelName=鹭岛文脉&pageSize=12`);
+  const res = await $fetch(`/api/ecms/article/byChannelName?channelName=非遗流韵,文保家园&pageSize=12`);
   if (!res.status)
     throw new Error(res.message);
   return res.data;
 });
 
+const qrModalVisible = ref(false);
+const qrModalType = ref<'volunteer' | 'activity'>('volunteer');
+const qrModalTitle = computed(() => qrModalType.value === 'volunteer' ? '志愿者招募' : '活动报名');
+const qrImageSrc = computed(() => qrModalType.value === 'volunteer' ? volunteerQr : activityQr);
+
 function handleImageClick(image: ICarousel) {
   window.open(image.url || image.image, '_blank');
 }
-function handleServiceClick(service: string) {
-  if (service === 'activity') {
-    Modal.info({
-      title: '提示',
-      content: '暂无最新活动',
-    });
-  } else {
-    Modal.info({
-      title: '提示',
-      content: '网站正在进行内部测试,暂未对外开放功能,敬请期待。',
-    });
-  }
+function handleServiceClick(service: 'volunteer' | 'activity') {
+  qrModalType.value = service;
+  qrModalVisible.value = true;
 }
 
-
-
 const tipCounter = new MemoryTimeOut('devtip', 1000 * 3600);
 
 onMounted(() => {
@@ -373,8 +382,25 @@ onMounted(() => {
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 @use "sass:list";
 @use "sass:math";
+
+.qr-modal-content {
+  text-align: center;
+  padding: 8px 0;
+  .qr-modal-tip {
+    margin-bottom: 16px;
+    color: rgba(0, 0, 0, 0.85);
+    font-size: 14px;
+  }
+  .qr-modal-img {
+    max-width: 100%;
+    width: 240px;
+    height: auto;
+    display: block;
+    margin: 0 auto;
+  }
+}
 </style>