diff --git a/app/components/DevelopNews.vue b/app/components/DevelopNews.vue new file mode 100644 index 0000000..34bb39f --- /dev/null +++ b/app/components/DevelopNews.vue @@ -0,0 +1,177 @@ + + + + + + + + + 开发资讯 + + + NEWS + + + + + + + 正在加载新闻... + + + + + + 加载失败: {{ error }} + + 重新加载 + + + + + + + + + + + {{ category.name }} + + + + + + + + + + + {{ article.title }} + {{ formatTime(article.createTime) }} + + + + + + + + 暂无文章 + + + + + + + + + 暂无新闻数据 + + + + + + diff --git a/app/config/api.ts b/app/config/api.ts index 92f2a0a..479fa14 100644 --- a/app/config/api.ts +++ b/app/config/api.ts @@ -35,6 +35,43 @@ export interface ApiResponse { data: T } +/** + * 文章数据类型定义 + */ +export interface Article { + id: string + title: string + brief: string | null + content: string | null + createTime: string + createBy?: string | null + updateTime?: string | null + updateBy?: string | null + remark?: string | null + code?: string | null + status?: string | null + scope?: string | null + deleted?: string | null + areaPermissions?: string | null +} + +/** + * 分页响应数据结构 + */ +export interface PageResponse { + total: number + rows: T[] +} + +/** + * 获取文章列表的查询参数 + */ +export interface GetArticleListParams { + pageNum?: number + pageSize?: number + code?: string +} + /** * 获取轮播图列表 * @returns Promise 返回轮播图数据数组 @@ -72,3 +109,52 @@ export async function getBannerList(): Promise { } } +/** + * 获取文章列表 + * @param params 查询参数(pageNum, pageSize, code等) + * @returns Promise> 返回分页的文章数据 + */ +export async function getArticleList( + params: GetArticleListParams = {} +): Promise> { + try { + const { pageNum = 1, pageSize = 10, code } = params + + // 构建查询参数 + const queryParams: Record = { + pageNum: pageNum.toString(), + pageSize: pageSize.toString(), + } + + if (code) { + queryParams.code = code + } + + const response = await $fetch>( + `${API_BASE_URL}/app/owArticle/list`, + { + method: 'GET', + params: queryParams, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + + // 检查响应数据 + if (response && Array.isArray(response.rows)) { + return { + total: response.total || 0, + rows: response.rows || [], + } + } + + console.warn('获取文章列表失败,返回空数据', response) + return { total: 0, rows: [] } + } catch (error) { + console.error('获取文章列表时发生错误:', error) + // 发生错误时返回空数据,避免页面崩溃 + return { total: 0, rows: [] } + } +} + diff --git a/app/layouts/default.vue b/app/layouts/default.vue index cce3b6b..e72f587 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -2,6 +2,7 @@ +