增加前端格式检查配置
This commit is contained in:
@@ -29,8 +29,13 @@ export interface PaginatedResult<T> {
|
||||
page_size: number
|
||||
}
|
||||
|
||||
export async function fetchAnnouncements(params: AnnouncementListParams = {}): Promise<PaginatedResult<Announcement>> {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<Announcement>>>('/announcements', { params })
|
||||
export async function fetchAnnouncements(
|
||||
params: AnnouncementListParams = {}
|
||||
): Promise<PaginatedResult<Announcement>> {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<Announcement>>>(
|
||||
'/announcements',
|
||||
{ params }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ArrowLeft, Bell, Calendar, Document, QuestionFilled, View, Warning } from '@element-plus/icons-vue'
|
||||
import {
|
||||
ArrowLeft,
|
||||
Bell,
|
||||
Calendar,
|
||||
Document,
|
||||
QuestionFilled,
|
||||
View,
|
||||
Warning,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { fetchAnnouncementDetail, type Announcement } from '@/features/announcement'
|
||||
import { formatDateTime } from '@/utils/time'
|
||||
import { marked } from 'marked'
|
||||
@@ -82,14 +90,20 @@ function getCategoryLabel(category: string) {
|
||||
class="category-tag"
|
||||
:style="{
|
||||
borderColor: getCategoryInfo(announcement.category)?.color || '#94a3b8',
|
||||
color: getCategoryInfo(announcement.category)?.color || '#94a3b8'
|
||||
color: getCategoryInfo(announcement.category)?.color || '#94a3b8',
|
||||
}"
|
||||
>
|
||||
<el-icon><component :is="getCategoryInfo(announcement.category)?.icon || Bell" /></el-icon>
|
||||
<el-icon
|
||||
><component :is="getCategoryInfo(announcement.category)?.icon || Bell"
|
||||
/></el-icon>
|
||||
{{ getCategoryLabel(announcement.category) }}
|
||||
</el-tag>
|
||||
<el-tag v-if="announcement.is_pinned" type="warning" effect="plain" size="small">置顶</el-tag>
|
||||
<el-tag v-if="announcement.is_important" type="danger" effect="plain" size="small">重要</el-tag>
|
||||
<el-tag v-if="announcement.is_pinned" type="warning" effect="plain" size="small"
|
||||
>置顶</el-tag
|
||||
>
|
||||
<el-tag v-if="announcement.is_important" type="danger" effect="plain" size="small"
|
||||
>重要</el-tag
|
||||
>
|
||||
</div>
|
||||
|
||||
<h1 class="detail-title">{{ announcement.title }}</h1>
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Bell, Document, InfoFilled, QuestionFilled, Tickets, Warning } from '@element-plus/icons-vue'
|
||||
import {
|
||||
Bell,
|
||||
Document,
|
||||
InfoFilled,
|
||||
QuestionFilled,
|
||||
Tickets,
|
||||
Warning,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { fetchAnnouncements, type Announcement } from '@/features/announcement'
|
||||
import { formatDateTime } from '@/utils/time'
|
||||
|
||||
@@ -114,7 +121,10 @@ function getCategoryLabel(category: string) {
|
||||
effect="plain"
|
||||
size="small"
|
||||
class="category-tag"
|
||||
:style="{ borderColor: getCategoryInfo(item.category)?.color || '#94a3b8', color: getCategoryInfo(item.category)?.color || '#94a3b8' }"
|
||||
:style="{
|
||||
borderColor: getCategoryInfo(item.category)?.color || '#94a3b8',
|
||||
color: getCategoryInfo(item.category)?.color || '#94a3b8',
|
||||
}"
|
||||
>
|
||||
<el-icon><component :is="getCategoryInfo(item.category)?.icon || Bell" /></el-icon>
|
||||
{{ getCategoryLabel(item.category) }}
|
||||
@@ -122,10 +132,14 @@ function getCategoryLabel(category: string) {
|
||||
<el-tag v-if="item.is_pinned" type="warning" effect="plain" size="small">置顶</el-tag>
|
||||
<el-tag v-if="item.is_important" type="danger" effect="plain" size="small">重要</el-tag>
|
||||
</div>
|
||||
<span class="announcement-date">{{ formatDateTime(item.published_at || item.created_at) }}</span>
|
||||
<span class="announcement-date">{{
|
||||
formatDateTime(item.published_at || item.created_at)
|
||||
}}</span>
|
||||
</div>
|
||||
<h3 class="announcement-title">{{ item.title }}</h3>
|
||||
<p class="announcement-preview">{{ item.content.substring(0, 120) }}{{ item.content.length > 120 ? '...' : '' }}</p>
|
||||
<p class="announcement-preview">
|
||||
{{ item.content.substring(0, 120) }}{{ item.content.length > 120 ? '...' : '' }}
|
||||
</p>
|
||||
<div class="announcement-footer">
|
||||
<span class="view-count">
|
||||
<el-icon><Tickets /></el-icon>
|
||||
@@ -159,9 +173,7 @@ function getCategoryLabel(category: string) {
|
||||
padding: 32px;
|
||||
border: 1px solid #e6eaf2;
|
||||
border-radius: 12px;
|
||||
background:
|
||||
linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.06)),
|
||||
#ffffff;
|
||||
background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.06)), #ffffff;
|
||||
box-shadow: 0 14px 36px rgba(17, 24, 39, 0.06);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user