From fc41ab927ba8a7e3e8f3fbbc57033b8e0d667be8 Mon Sep 17 00:00:00 2001 From: tab Date: Fri, 10 Feb 2023 09:04:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9admin=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ssr/assets/css/main.scss | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/ssr/assets/css/main.scss b/apps/ssr/assets/css/main.scss index 8f7e465..e1b5a37 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,7 @@ } .author{ .name{ - @include ellipsis(180px); + @include ellipsis(100%); } } } -- Gitee From ad3af45e6334c90a38cad637ce9fefb34e812668 Mon Sep 17 00:00:00 2001 From: tab Date: Fri, 10 Feb 2023 09:13:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E4=BD=9C=E8=80=85=E6=A0=B7=E5=BC=8F=E4=B8=8D?= =?UTF-8?q?=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ssr/assets/css/main.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/ssr/assets/css/main.scss b/apps/ssr/assets/css/main.scss index e1b5a37..bb49019 100644 --- a/apps/ssr/assets/css/main.scss +++ b/apps/ssr/assets/css/main.scss @@ -316,6 +316,7 @@ .author{ .name{ @include ellipsis(100%); + color: #333; } } } -- Gitee From 057756528725df460b0132a838656e307db6d138 Mon Sep 17 00:00:00 2001 From: tab Date: Fri, 10 Feb 2023 10:29:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ssr/api/admin.ts | 4 +- apps/ssr/components/CardItem/index.vue | 8 +-- apps/ssr/components/Home/BodyPart/index.vue | 6 +-- apps/ssr/components/SearchBar/index.vue | 4 +- apps/ssr/composables/useHttp.ts | 24 +++++++-- apps/ssr/pages/admin/index.vue | 12 ++--- apps/ssr/pages/index.vue | 11 ++-- apps/ssr/types/global.d.ts | 60 +++++++++++++++++++++ 8 files changed, 103 insertions(+), 26 deletions(-) diff --git a/apps/ssr/api/admin.ts b/apps/ssr/api/admin.ts index ea6cfe0..68465b0 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/components/CardItem/index.vue b/apps/ssr/components/CardItem/index.vue index 76dadfe..7b4566e 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 0e29832..c1005a1 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 8ff9554..d6bbdd2 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 d21cce1..8a8e8de 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 46bc0c3..858430d 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 eb099ca..401971e 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 6dc0937..2efa121 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 -- Gitee