diff --git a/apps/ssr/api/admin.ts b/apps/ssr/api/admin.ts index ea6cfe06423a043751e599efa0dd029370484cd6..68465b0d75dc990462666620e6224a1792e027a6 100644 --- a/apps/ssr/api/admin.ts +++ b/apps/ssr/api/admin.ts @@ -1,5 +1,5 @@ // 获取文章列表 -export const useArticleData = (params?: any) => useHttpGet('ArticleData', 'article', { lazy: true, params }) +export const useArticleData = (params: Article.ArticleListParam): Promise> => useHttpGet('ArticleData', 'article', { lazy: true, params }) // 获取文章详情 export const useArticleDetail = (params?: any) => useHttpGet('ArticleDetail', `article/${params.id}`, { lazy: true, params }) // 新增文件 @@ -7,4 +7,4 @@ export const fetchArticleAdd = (body?: any) => useHttpPost('FetchArticle', 'arti // 获取后台语言列表 export const useBackendData = (params?: any) => useHttpGet('BackendData', 'backend', { lazy: true, params }) // 获取标签列表 -export const useTagsData = (params?: any) => useHttpGet('TagsData', 'tags', { lazy: true, params }) +export const useTagsData = (params?: any): Promise> => useHttpGet('TagsData', 'tags', { lazy: true, params }) diff --git a/apps/ssr/assets/css/main.scss b/apps/ssr/assets/css/main.scss index 8f7e46577a766c542de6ff52f1b8941a4855705a..bb49019c1052ba09119f53fd8bfe747fab517fbe 100644 --- a/apps/ssr/assets/css/main.scss +++ b/apps/ssr/assets/css/main.scss @@ -207,11 +207,12 @@ .app-admins-col{ margin-bottom:20px; .el-card{ - height:350px; + height:auto; .image{ width:100%; height:220px; border:1px solid #efefef; + object-fit: cover; } } .title{ @@ -225,11 +226,12 @@ } .time{ color:#ccc; + white-space: nowrap; } } .app-page-admin{ .app-admin-body{ - min-height:calc(100vh - 190px); + // min-height:calc(100vh - 190px); } .meta{ .author{ @@ -313,7 +315,8 @@ } .author{ .name{ - @include ellipsis(180px); + @include ellipsis(100%); + color: #333; } } } diff --git a/apps/ssr/components/CardItem/index.vue b/apps/ssr/components/CardItem/index.vue index 76dadfecab8b7fc18cdbfaf7a414ac17eb21d8db..7b4566e1cf8cbb59f595d97e28af8bcc657b4351 100644 --- a/apps/ssr/components/CardItem/index.vue +++ b/apps/ssr/components/CardItem/index.vue @@ -31,16 +31,16 @@ diff --git a/apps/ssr/components/Home/BodyPart/index.vue b/apps/ssr/components/Home/BodyPart/index.vue index 0e29832b1146298d386d2e16c939b43017213bfa..c1005a1388e25fccd72ab768ec257a5a02d3851a 100644 --- a/apps/ssr/components/Home/BodyPart/index.vue +++ b/apps/ssr/components/Home/BodyPart/index.vue @@ -9,11 +9,11 @@ diff --git a/apps/ssr/components/SearchBar/index.vue b/apps/ssr/components/SearchBar/index.vue index 8ff9554f4769bd5e29c5d820b25e30695d21d676..d6bbdd2d4251bfe6bb5a866e1350fd0795dbd9c2 100644 --- a/apps/ssr/components/SearchBar/index.vue +++ b/apps/ssr/components/SearchBar/index.vue @@ -43,10 +43,10 @@ interface EditProps { isShowBack?: boolean isShowVersion?: boolean backendList?: any - tagList?: any + tagList?: Article.TagItem[] } -const props = withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { isShowTag: true, isShowVersion: true, isShowBack: true, diff --git a/apps/ssr/composables/useHttp.ts b/apps/ssr/composables/useHttp.ts index d21cce1dd9ec750da4ac3127fc47f37bd83a7a15..8a8e8de412fac068dace4d7ea31d11e31f54d62e 100644 --- a/apps/ssr/composables/useHttp.ts +++ b/apps/ssr/composables/useHttp.ts @@ -46,15 +46,33 @@ export async function useHttp(key: string, url: string, options: any = {}) { return { error } }) } - +type SearchParams = typeof URLSearchParams +type UseFetchOptions = { + key?: string + method?: string + query?: SearchParams + params?: Omit + body?: RequestInit['body'] | Record + headers?: { key: string, value: string }[] + baseURL?: string + server?: boolean + lazy?: boolean + immediate?: boolean + pick?: string[] +} +interface BaseResponse { + code: 0 | 1 | 400 | 401 | 403 | 500 | 502; + msg: string; + data: T +} // GET请求 -export function useHttpGet(key: string, url: string, options: any = {}) { +export function useHttpGet(key: string, url: string, options: UseFetchOptions = {}): Promise { options.method = 'GET' return useHttp(key, url, options) } // POST请求 -export function useHttpPost(key: string, url: string, options: any = {}) { +export function useHttpPost(key: string, url: string, options: UseFetchOptions = {}): Promise { options.method = 'POST' return useHttp(key, url, options) } diff --git a/apps/ssr/pages/admin/index.vue b/apps/ssr/pages/admin/index.vue index 46bc0c3ed3f50c34af46691a2d1af548a205c93d..858430dcfc67d71efae559d6c79bc66357d35e4f 100644 --- a/apps/ssr/pages/admin/index.vue +++ b/apps/ssr/pages/admin/index.vue @@ -38,13 +38,13 @@ import { cloneDeep } from 'lodash-es' import { BasePagination } from '~~/config' const { page, limit } = BasePagination -const state = reactive({ +const state = reactive({ // 列表数据 - list: [], + list: [] as any, // 后台语言列表 - backendList: [], + backendList: [] as any, // 标签列表 - tagList: [], + tagList: [] as Article.TagItem[], // 总页数 total: 0, // 查询对象 @@ -88,8 +88,8 @@ getBackend() // 获取列表 const getTags = async () => { - const { data }: any = await useAsyncData('use_TagsData', () => useTagsData({ type: 1 })) - state.tagList = data.value.rows + const { data } = await useAsyncData('use_TagsData', () => useTagsData({ type: 1 })) + state.tagList = data.value?.rows || [] } getTags() diff --git a/apps/ssr/pages/index.vue b/apps/ssr/pages/index.vue index eb099cabe035c8178a296916b587cf6bb4c14127..401971ee2240fd0b1bfa0bab20e83c6a004f4160 100644 --- a/apps/ssr/pages/index.vue +++ b/apps/ssr/pages/index.vue @@ -45,7 +45,7 @@ import { set } from '@vueuse/core' import { TopList } from '@/config' -const state = reactive({ +const state = reactive({ meta: { ui: { title: 'UI组件库', @@ -61,7 +61,7 @@ const state = reactive({ adminList: [], uiList: [], hooksList: [], - }, + } as Record, // 查询对象 queryParams: { version: 3, @@ -69,7 +69,7 @@ const state = reactive({ title: '', page: 1, limit: 4, - }, + } as Article.ArticleListParam, }) const loading = ref(true) // 获取列表 @@ -77,9 +77,8 @@ const getList = async (params: any) => { const { query, type } = params const arg = Object.assign(state.queryParams, query) - const { data }: any = await useAsyncData(`use_ArticleData_${query.navId}`, () => useArticleData(arg)) - state.list[type] = data.value.rows - + const { data } = await useAsyncData(`use_ArticleData_${query.navId}`, () => useArticleData(arg)) + state.list[type] = data.value?.rows || [] set(loading, false) } diff --git a/apps/ssr/types/global.d.ts b/apps/ssr/types/global.d.ts index 6dc0937fb77151e8a7f98de843fb468b76d5f693..2efa121e742703901ca041a8cac14cc8a293bc5a 100644 --- a/apps/ssr/types/global.d.ts +++ b/apps/ssr/types/global.d.ts @@ -1,3 +1,4 @@ + declare interface INavList { value: number label?: string @@ -11,3 +12,62 @@ declare interface ITopList extends INavList { declare interface ICodeMessage { [propName: number]: string } +interface PageRequestParam { + page: number; + limit: number; +} +interface PageResult { + rows: T[]; + page?: { + limit: number; + page: number; + total: number; + } +} +declare namespace Article { + interface ArticleListParam extends PageRequestParam { + version: number; + navId: number; + title?: string; + } + interface Detail { + appId: number; + author: string; + backend:any[]; + categoryId: number; + cityId: number; + commentCount: number; + content: string; + coverUrl:string; + createTime:string; + gitee:string; + github:string; + homepage:string; + id: number; + isTop: number; + keywords:string; + likeCount: number; + md: string; + navId: number; + order: number; + status: number; + summary:string; + tags:string[]; + title:string; + updateTime:string; + userId: number; + version: string; + viewsCount: number; + } + interface TagItem { + appId: number; + cityId: number; + createTime: string; + id: number; + tagName: string; + tagUrl: string; + thumbnail: string; + type: number; + updateTime: string + } +} \ No newline at end of file