优化工具箱详情页面及API接口类型

This commit is contained in:
wangqiao
2025-09-24 22:42:52 +08:00
parent 70a75333e8
commit 38fc29ccaa
4 changed files with 69 additions and 70 deletions

View File

@ -1,6 +1,6 @@
import * as useDollarFetchRequest from '~/composables/useDollarFetchRequest'
import * as useFetchRequest from '~/composables/useFetchRequest'
import type { TcreateReq, TpageReq, TpageRes } from './types'
import type { TcreateReq, TpageReq, TpageRes, ProjectResourceRespVO } from './types'
/**
* 新建工具箱
@ -24,7 +24,7 @@ export const page = (params: any) => {
* 获得工具箱
*/
export const get = (params: { id: string }) => {
return useFetchRequest.get<IResponse<TcreateReq>>('/prod-api/app-api/business/resource/get', {
return useFetchRequest.get<IResponse<ProjectResourceRespVO>>('/prod-api/app-api/business/resource/get', {
query: params,
})
}

View File

@ -8,6 +8,7 @@ export interface TcreateReq {
projectType: number[]
categoryId?: number
sourceType?: number
categoryName?: string
files: {
id: number
title: string
@ -61,3 +62,55 @@ export interface TpageItem {
commentsPoint: number
ownedUserId: string
}
export interface ProjectResourceRespVO {
id: number
title: string
labels: string[]
createAddress: string
createIp: string
projectType: number[]
categoryId: number
categoryName: string
favoriteId?: number
downloadId?: number
sourceType: number
ownedUserIdInfo: {
id: number
nickName: string
avatar: string
}
files: {
id: number
title: string
fileId: number
drawId: number
type: number
url: string
sort: number
size: number
}[]
coverImages: {
id: number
title: string
fileId: number
drawId: number
type: number
url: string
sort: number
size: number
}[]
points: number
createTime: string
updateTime: string
status: number
recommend: boolean
iconUrl: string
hotPoint: number
description: string
previewPoint: number
previewUrl: string
previewImageUrl: string
commentsPoint: number
ownedUserId: string
}

View File

@ -43,7 +43,7 @@
<div class="ma-auto mt-[21px] flex">
<div class="w-[1019px]">
<div>
<ThumBnail :data="detail?.coverImages" :type="detail?.type"></ThumBnail>
<ThumBnail :data="detail?.coverImages"></ThumBnail>
</div>
<div class="mb-[20px] mt-[34px] flex items-center text-[16px] text-[#333333] font-normal">
<div class="h-[24px] w-[4px] rounded-[1px] bg-[#1A65FF]"></div><span class="ml-[10px]">{{ detail?.title }}描述</span></div
@ -79,41 +79,21 @@
</div>
</div>
</div>
<!-- 关联项目 -->
<div class="mb-[20px] mt-[34px] flex items-center text-[16px] text-[#333333] font-normal">
<div class="h-[24px] w-[4px] rounded-[1px] bg-[#1A65FF]"></div>
<span class="ml-[10px]">关联{{ detail?.type === 1 ? '图纸' : detail?.type === 2 ? '文本' : '模型' }}</span>
</div>
<el-row :gutter="20">
<el-col v-for="(item, index) in detail?.relationDraws" :key="index" :span="12">
<CardPicture :item-info="item" />
</el-col>
</el-row>
<el-empty v-if="!detail?.relationDraws?.length" description="暂无数据"></el-empty>
<!-- 关联模型 -->
<div class="mb-[20px] mt-[34px] flex items-center text-[16px] text-[#333333] font-normal">
<div class="h-[24px] w-[4px] rounded-[1px] bg-[#1A65FF]"></div
><span class="ml-[10px]">相关{{ detail?.type === 1 ? '图纸' : detail?.type === 2 ? '文本' : '模型' }}推荐</span></div
>
<el-row :gutter="20">
<el-col v-for="(item, index) in relationRecommend" :key="index" :span="12">
<CardPicture :item-info="item" />
</el-col>
</el-row>
<!-- 评论 -->
<CommentSection :relation-id="detail!.id" :project-id="detail!.projectId" />
<!-- <CommentSection :relation-id="detail!.id" :project-id="detail!.projectId" /> -->
</div>
<div class="ml-[22px]">
<div class="box-border min-h-[269px] w-[397px] border border-[#EEEEEE] rounded-[12px] border-solid bg-[#FFFFFF] pa-[22px]">
<div class="mb-[10px]">图纸ID: {{ detail?.no }}</div>
<div class="mb-[10px]">文件大小{{ detail?.filesInfo?.fileSize || 0 }} </div>
<div class="mb-[10px]">工具ID: {{ detail?.no }}</div>
<!-- <div class="mb-[10px]">文件大小{{ detail?.filesInfo?.fileSize || 0 }} </div> -->
<!-- <div class="mb-10px">图纸版本{{ detail.editionsName }} </div> -->
<div class="mb-[10px]">图纸格式{{ detail?.formatType?.toString() }}</div>
<!-- <div class="mb-[10px]">工具格式{{ detail?.formatType?.toString() }}</div> -->
<div class="mb-[10px]">所需金币{{ detail?.points }}金币</div>
<div class="mb-[10px]">发布时间{{ dayjs(detail?.createTime).format('YYYY-MM-DD HH:mm:ss') }}</div>
<div class="mb-[10px]">图纸参数{{ detail?.editTypeName }}</div>
<div class="mb-[10px]">图纸分类{{ detail?.projectTypeName }}</div>
<div class="mb-[10px]">软件分类{{ detail?.editionsName }}</div>
<!-- <div class="mb-[10px]">工具参数{{ detail?.editTypeName }}</div> -->
<div class="mb-[10px]">工具标签{{ detail?.labels?.toString() }}</div>
<div class="mb-[10px]">软件分类{{ detail?.categoryName }}</div>
</div>
<div class="mt-[20px] w-[398px] border border-[#EEEEEE] border-rd-[10px_10px_0px_0px] border-solid bg-[#FFFFFF]">
<img src="~/assets/images/banner.png" alt="" srcset="" class="w-[100%]" />
@ -190,10 +170,8 @@
import { getDetail, getRelationRecommend, report, getUserInfo, getMainWork, createContent, createUserProject, deleteProject } from '~/api/drawe-detail/index'
import KlNavTab from '~/components/kl-nav-tab/index.vue'
import ThumBnail from './components/swiper.vue'
import CommentSection from '~/components/comment-section/index.vue'
// import CommentSection from '~/components/comment-section/index.vue'
import { useRoute } from 'vue-router'
import { onMounted } from 'vue'
import type { ProjectRespVO, ProjectDrawPageRespVO, UserExtendSimpleRespDTO, ProjectDrawMemberRespVO } from '~/api/drawe-detail/types'
import useUserStore from '~/stores/user'
const message = useMessage()
const userStore = useUserStore()
@ -201,9 +179,6 @@
const route = useRoute()
const id = route.params.id as string
// 获取详情
// const detail = ref<ProjectRespVO>({} as ProjectRespVO)
const { data: detail, refresh: refreshDetail } = await useAsyncData(`toolbox-getDetail${id}`, async () => {
const res = await get({ id: id as string })
return res.data
@ -219,40 +194,11 @@
})
}
// 获取面包屑
// const { data: breadList } = await useAsyncData(`breadList-detail-${route.params.id}}`, async () => {
// const res = await getDictTree({ type: 1, id: detail.value?.projectType?.[0] })
// const all = [
// {
// id: -1,
// name: detail.value?.type === 1 ? '图纸库' : detail.value?.type === 3 ? '模型库' : '文本库',
// isChildren: false,
// },
// ]
// const arr = [...res.data, ...all]
// return arr.reverse()
// })
// const init = () => {
// getDetail({ id }).then((res) => {
// if (res.code === 0) {
// detail.value = res.data
// // 获取推荐信息
// getRelationRecommendList()
// // 获取用户信息
// handleGetUserInfo()
// // 最新发布
// handleGetMainWork()
// }
// })
// }
// init()
const [{ data: mainWork }, { data: userInfo }, { data: relationRecommend }] = await Promise.all([
const [{ data: mainWork }, { data: userInfo }] = await Promise.all([
getMainWork({ id: detail.value?.id, limit: 10, memberId: detail.value?.ownedUserId }),
getUserInfo({ id: detail.value?.id }),
getRelationRecommend({ type: detail.value?.type, projectType: detail.value?.projectType[0] }),
])
// 获取最新发布
@ -318,7 +264,7 @@
const res = await message.confirm(`是否花费${detail.value?.points}金币下载此资源,是否继续?`, '提示')
if (res) {
createUserProject({ relationId: detail.value?.id, type: getType(detail.value?.type as number) }).then((res) => {
createUserProject({ relationId: detail.value?.id, type: 2 }).then((res) => {
if (res.code === 0) {
ElMessage.success('获取下载权限成功')
detail.value!.downloadId = res.data
@ -383,7 +329,7 @@
}
const handleClick = (id: string | number) => {
navigateTo(`/down-drawe-detail/${id}`) // 修改为在新窗口打开
navigateTo(`/toolbox-detail/${id}`) // 修改为在新窗口打开
}
const handleDownloadFile = (url: string, name: string) => {

View File

@ -12,7 +12,7 @@
</div>
<div class="mb-[20px] mt-[34px] flex items-center text-[16px] text-[#333333] font-normal">
<div class="h-[24px] w-[4px] rounded-[1px] bg-[#1A65FF]"></div>
<span class="ml-[10px]">{{ props.type === 1 ? '图纸' : props.type === 2 ? '文本' : '模型' }}</span>
<span class="ml-[10px]">工具</span>
</div>
<div class="box-border h-[126px] w-[1019px] border border-[#EEEEEE] rounded-[6px] border-solid bg-[#FFFFFF] pa-[23px]">
<div thumbsSlider="" class="swiper mySwiper">