diff --git a/src/api/halo-plugin/link.ts b/src/api/halo-plugin/link.ts index 83a788c..635eb60 100644 --- a/src/api/halo-plugin/link.ts +++ b/src/api/halo-plugin/link.ts @@ -1,13 +1,52 @@ import { http } from '@/http/alova' +import type { IHaloListPaginationRequestBase, IHaloListResponseBase } from '@/api/types/halo' + +const EndpointBase = '/apis/api.link.halo.run/v1alpha1' + +export type LinkTypes = 'website' | 'mpweixin' | 'android' | 'ios' + +export interface ILink { + metadata: { + name: string + version: string + creationTimestamp: string + } + spec: { + displayName: string + url: string + logo: string + groupName: string + priority: number + description: string + } + // uni halo 独有配置 + uh: { + // 站点类型 + type: LinkTypes + } +} + +export interface ILinkGroup { + metadata: { + name: string + creationTimestamp: string + version: string + } + spec: { + name?: string + displayName: string + priority: number + links: ILink[] + } + links: ILink[] +} /** * 获取链接组分组列表 - * @param params 获取链接分分组列表请求参数 * @returns 获取链接分分组组列表响应参数 */ -export function queryLinkGroups(params: any) { - return http.Get(`/apis/api.link.halo.run/v1alpha1/linkgroups`, { - params, +export function queryLinkGroups() { + return http.Get(`${EndpointBase}/linkgroups`, { meta: { isHalo: true }, }) } @@ -17,9 +56,32 @@ export function queryLinkGroups(params: any) { * @param params 获取链接列表请求参数 * @returns 获取链接列表响应参数 */ -export function queryLinks(params: any) { - return http.Get(`/apis/api.link.halo.run/v1alpha1/links`, { +export function queryLinks(params: IHaloListPaginationRequestBase) { + return http.Get>(`${EndpointBase}/links`, { params, meta: { isHalo: true }, }) } + +/** + * 随机返回一组链接 + * @param params 随机返回一组链接请求参数 + * @param params.maxSize 随机返回的链接数量 取值范围为 1 到 100 + * @returns 获取随机一组链接响应参数 + */ +export function queryRandomLinks(params: { maxSize: number }) { + return http.Get(`${EndpointBase}/-/random`, { + params, + meta: { isHalo: true }, + }) +} + +/** + * 获取链接总数 + * @returns 获取链接总数响应参数 + */ +export function queryTotalLinks() { + return http.Get(`${EndpointBase}/-/total`, { + meta: { isHalo: true }, + }) +} diff --git a/src/api/halo-plugin/moment.ts b/src/api/halo-plugin/moment.ts index 3202fb9..e12eba4 100644 --- a/src/api/halo-plugin/moment.ts +++ b/src/api/halo-plugin/moment.ts @@ -1,14 +1,64 @@ import { http } from '@/http/alova' +import type { TimeParseResult } from '@/utils/base/time' +import type { IHaloListResponseBase } from '@/api/types/halo' const EndpointBase = '/apis/api.moment.halo.run/v1alpha1/moments' +export interface IMomentListRequest { + page: number // 分页页码,从 1 开始 + size: number // 分页条数 + tag?: string // 标签 + ownerName?: string // 创建者用户名 name + startDate?: string // 开始时间 通过时间区间筛选发布时间 + endDate?: string // 结束时间 + sort?: string[] // 排序字段,格式为 字段名,排序方式,排序方式可选值为 asc 或 desc,如 spec.releaseTime,desc, +} + +export type MomentMediaType = 'PHOTO' | 'VIDEO' | 'POST' | 'AUDIO' +export interface IMoment { + metadata: { + name: string // 唯一标识 + creationTimestamp: string // 创建时间 + } + spec: { + content: { + raw: string // 原始内容,一般用于编辑器使用 + html: string // HTML 内容,用于主题端进行最终渲染的内容 + medium: [ + // 媒体内容 + { + type: MomentMediaType // 类型 + url: string // 链接 + originType: string // 原始类型,例如:image/jpeg + }, + ] + } + _parseReleaseTime: TimeParseResult // 用于后续存储发布时间的结构化时间对象 + releaseTime: string // 发布时间 + visible: 'PUBLIC' | 'PRIVATE' // 可见性 + owner: string // 所属用户 + tags: string[] // 所拥有的标签 + } + owner: { + name: string // 用户名 + avatar: string // 头像 + bio: string // 描述 + displayName: string // 显示名称 + } + stats: { + upvote: number // 点赞数 + totalComment: number // 评论数 + approvedComment: number // 审核通过的评论数 + } +} + /** * 获取瞬间列表 * @param params 获取瞬间列表请求参数 * @returns 获取瞬间列表响应参数 */ -export function queryMoments(params: any) { - return http.Get(`${EndpointBase}`, { +export function queryMoments(params: IMomentListRequest) { + return http.Get>(`${EndpointBase}`, { params, meta: { isHalo: true, @@ -22,7 +72,7 @@ export function queryMoments(params: any) { * @returns 获取瞬间详情响应参数 */ export function queryMomentByName(name: string) { - return http.Get(`${EndpointBase}/${name}`, { + return http.Get(`${EndpointBase}/${name}`, { meta: { isHalo: true, }, diff --git a/src/api/halo-plugin/uni-halo.ts b/src/api/halo-plugin/uni-halo.ts index 19a3692..df87979 100644 --- a/src/api/halo-plugin/uni-halo.ts +++ b/src/api/halo-plugin/uni-halo.ts @@ -1,7 +1,25 @@ import { http } from '@/http/alova' export interface IUniHaloConfig { - baseURL: string + base: { + // 博客域名 + domain: string + // 是否为个人资质的小程序 + isIndividual: boolean + } + home: { + // 是否显示金刚区 + isShowShortcutDock: boolean + } + moment: { + + } + link: { + + } + gallery: { + + } } /** diff --git a/src/api/types/halo.ts b/src/api/types/halo.ts index 5148748..174782b 100644 --- a/src/api/types/halo.ts +++ b/src/api/types/halo.ts @@ -21,3 +21,13 @@ export interface IHaloListRequestBase { page?: number size?: number } + +/** + * Halo 列表分页请求基础结构 + */ +export interface IHaloListPaginationRequestBase extends IHaloListRequestBase { + keyword?: string + sort?: string + labelSelector?: string + fieldSelector?: string +} diff --git a/src/components/uh-post-card/uh-post-card.vue b/src/components/uh-post-card/uh-post-card.vue index d347791..bd01209 100644 --- a/src/components/uh-post-card/uh-post-card.vue +++ b/src/components/uh-post-card/uh-post-card.vue @@ -5,11 +5,11 @@ import type { ListedPostVo } from '@halo-dev/api-client' interface IProps { post?: ListedPostVo - type?: 'default' | 'topCover' | 'rightCover' + type?: 'noCover' | 'leftCover' | 'bottomCover' | 'rightCover' | 'topCover' } const props = withDefaults(defineProps(), { - type: 'default', + type: 'leftCover', post: undefined, }) @@ -20,6 +20,15 @@ const wrapClass = computed(() => { if (props.type === 'rightCover') { return 'relative h-28 p-0! border-2 border-solid border-white' } + if (props.type === 'noCover') { + return 'pl-0' + } + if (props.type === 'leftCover') { + return ' ' + } + if (props.type === 'bottomCover') { + return 'flex-col gap-y-2' + } return '' }) @@ -30,7 +39,16 @@ const coverClass = computed(() => { if (props.type === 'rightCover') { return 'absolute right-0 top-0 bottom-0 w-32 rounded-lt-0 rounded-lb-0' } - return 'h-22 w-22' + if (props.type === 'noCover') { + return 'hidden!' + } + if (props.type === 'leftCover') { + return 'h-22 w-22' + } + if (props.type === 'bottomCover') { + return 'w-full h-32 order-2' + } + return '' }) const textWrapClass = computed(() => { @@ -40,6 +58,10 @@ const textWrapClass = computed(() => { if (props.type === 'rightCover') { return 'p-4 pr-32 relative z-10' } + + if (props.type === 'bottomCover') { + return 'order-1' + } return 'pl-4' }) @@ -47,9 +69,15 @@ const textContainerClass = computed(() => { if (props.type === 'topCover') { return 'gap-y-2' } + if (props.type === 'noCover') { + return 'gap-y-2' + } if (props.type === 'rightCover') { return '' } + if (props.type === 'bottomCover') { + return 'gap-y-2' + } return '' }) @@ -60,12 +88,15 @@ const textFooterClass = computed(() => { if (props.type === 'rightCover') { return 'gap-x-2' } + if (props.type === 'bottomCover') { + return '' + } return 'gap-x-2' })