diff --git a/package.json b/package.json index 432594c..6b034b4 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "ant-design-vue": "^4.1.1", "aos": "^2.3.4", "axios": "^1.6.2", + "lucide-vue-next": "^0.507.0", "pinia": "^2.1.7", "swiper": "^11.0.5", "tailwindcss": "^4.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73d2601..5100226 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: axios: specifier: ^1.6.2 version: 1.8.4 + lucide-vue-next: + specifier: ^0.507.0 + version: 0.507.0(vue@3.5.13) pinia: specifier: ^2.1.7 version: 2.3.1(vue@3.5.13) @@ -878,6 +881,11 @@ packages: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true + lucide-vue-next@0.507.0: + resolution: {integrity: sha512-n0AZRmez4xq5vu5ZOfnrhC5wKBpu5tpwDHA6Ue2+sKyJv3USAPxqIerXLbdYbkHRW1tVZ3U9GE1MACsu6X/Z7Q==} + peerDependencies: + vue: '>=3.0.1' + magic-string@0.30.17: resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} @@ -1769,6 +1777,10 @@ snapshots: dependencies: js-tokens: 4.0.0 + lucide-vue-next@0.507.0(vue@3.5.13): + dependencies: + vue: 3.5.13 + magic-string@0.30.17: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 diff --git a/src/api/request/project.js b/src/api/request/project.js index 37f3296..01e31e1 100644 --- a/src/api/request/project.js +++ b/src/api/request/project.js @@ -2,12 +2,15 @@ import {get, post} from '../request.js' const prefix = 'project' -export function labelListApi(credentials) { +export function projectListApi(credentials) { return get(`${prefix}/list`, credentials) } -export function labelOptionApi(credentials) { +export function projectOptionApi(credentials) { return get(`${prefix}/option`, credentials) } +export function projectDetailApi(credentials) { + return get(`${prefix}/detail`, credentials) +} export function createProjectApi(credentials) { return post(`${prefix}/create`, credentials) } diff --git a/src/views/admin/Projects.vue b/src/views/admin/Projects.vue index acc6513..16ad51e 100644 --- a/src/views/admin/Projects.vue +++ b/src/views/admin/Projects.vue @@ -5,8 +5,15 @@ import "aos/dist/aos.css" import { message, Upload, Select } from "ant-design-vue" import {labelOptionApi} from "@/api/request/label.js"; import {categoryOptionApi} from "@/api/request/category.js"; -import {createProjectApi, labelListApi, updateProjectApi} from "@/api/request/project.js"; +import { + createProjectApi, + deleteProjectApi, + projectDetailApi, + projectListApi, + updateProjectApi +} from "@/api/request/project.js"; import {uploadImageApi, uploadVideoApi} from "@/api/request/upload.js"; +import ProjectDetails from './common/ProjectDetails.vue' onMounted(() => { AOS.init({ @@ -110,7 +117,7 @@ const dataSource = ref([ ]) const getList = () => { - labelListApi({ + projectListApi({ page: currentPage.value, pageSize: pageSize.value, }).then((res) => { @@ -165,6 +172,10 @@ const videoUploading = ref(false) const videoPreviewVisible = ref(false) const videoPreviewUrl = ref("") +// 详情模态框 +const showDetailModal = ref(false) +const currentDetailItem = ref(null) + const handlePreview = (file) => { previewImage.value = file.url || file.preview previewVisible.value = true @@ -371,9 +382,13 @@ const closeDeleteConfirm = () => { const handleDelete = () => { if (itemToDelete.value) { - dataSource.value = dataSource.value.filter((item) => item.id !== itemToDelete.value) - totalItems.value = dataSource.value.length - closeDeleteConfirm() + deleteProjectApi({ + ids: [itemToDelete.value] + }).then(() => { + message.success("项目删除成功") + closeDeleteConfirm() + getList(); + }) } } @@ -406,7 +421,7 @@ const handleSubmit = () => { // 更新现有项目 const index = dataSource.value.findIndex((item) => item.id === currentItem.value.id) if (index !== -1) { - dataSource.value[index] = { ...currentItem.value } + dataSource.value[index] = {...currentItem.value} } } else { createProjectApi(currentItem.value).then((res) => { @@ -435,7 +450,7 @@ const handleAddTag = () => { // 如果不存在,创建新标签并添加 else if (!existingTag) { const newTagId = Math.max(...tagsOption.map((tag) => tag.id), 0) + 1 - const newTag = { id: newTagId, name: tagInputValue.value } + const newTag = {id: newTagId, name: tagInputValue.value} tagsOption.push(newTag) currentItem.value.tags.push(newTag) } @@ -468,6 +483,15 @@ const removeFeature = (index) => { currentItem.value.features.splice(index, 1) } +const openDetailModal = (item) => { + projectDetailApi({ + id: item.id + }).then((res) => { + currentDetailItem.value = res + showDetailModal.value = true + }) +} + getList(); @@ -480,8 +504,9 @@ getList(); class="px-5 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl shadow-md hover:shadow-lg transition-all duration-300 flex items-center cursor-pointer" @click="openModal()" > - - + + 新建项目 @@ -494,25 +519,32 @@ getList();
- + 项目名称 - + 分类 - + 标签 - + 价格 - + 状态 - + 创建时间 - + 操作
@@ -520,11 +552,12 @@ getList(); -
+
- +
{{ item.title }} @@ -569,10 +602,14 @@ getList();
@@ -601,7 +642,8 @@ getList();
-
+
共 {{ totalItems }} 条记录
@@ -639,7 +681,8 @@ getList();
-