From a6f19b7aa67fac8c668b927bbe43489a6209e190 Mon Sep 17 00:00:00 2001 From: Msg-Lbo <24130801@qq.com> Date: Sat, 9 Mar 2024 19:55:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components.d.ts | 4 + client/package-lock.json | 63 +- client/src/apis/album.ts | 12 +- client/src/views/home/Articledetail.vue | 7 +- .../home/article/components/AddArticle.vue | 26 +- .../home/article/components/AlbumList.vue | 84 +- .../home/article/components/CollectList.vue | 1 - cultural.sql | 60 +- package-lock.json | 6 + server/controller/album.js | 56 +- server/controller/article.js | 11 +- server/router/album.js | 3 +- ...\235\242(\350\241\245\345\205\205).drawio" | 923 ++++++++++++++++++ 13 files changed, 1196 insertions(+), 60 deletions(-) create mode 100644 package-lock.json create mode 100644 "\346\211\200\346\234\211\345\233\276\351\203\275\345\234\250\351\207\214\351\235\242(\350\241\245\345\205\205).drawio" diff --git a/client/components.d.ts b/client/components.d.ts index ac67f26..23eedd7 100644 --- a/client/components.d.ts +++ b/client/components.d.ts @@ -8,6 +8,7 @@ export {} declare module 'vue' { export interface GlobalComponents { Bread_crumb: typeof import('./src/components/bread_crumb.vue')['default'] + NAlert: typeof import('naive-ui')['NAlert'] NAvatar: typeof import('naive-ui')['NAvatar'] NBadge: typeof import('naive-ui')['NBadge'] NBreadcrumb: typeof import('naive-ui')['NBreadcrumb'] @@ -17,6 +18,8 @@ declare module 'vue' { NCarousel: typeof import('naive-ui')['NCarousel'] NCheckbox: typeof import('naive-ui')['NCheckbox'] NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup'] + NCollapse: typeof import('naive-ui')['NCollapse'] + NCollapseItem: typeof import('naive-ui')['NCollapseItem'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NDatePicker: typeof import('naive-ui')['NDatePicker'] NDialog: typeof import('naive-ui')['NDialog'] @@ -50,6 +53,7 @@ declare module 'vue' { NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] + NSpin: typeof import('naive-ui')['NSpin'] NTable: typeof import('naive-ui')['NTable'] NTabPane: typeof import('naive-ui')['NTabPane'] NTabs: typeof import('naive-ui')['NTabs'] diff --git a/client/package-lock.json b/client/package-lock.json index bb44dd5..5f01c53 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1243,11 +1243,11 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.5.0", - "resolved": "https://registry.npmmirror.com/axios/-/axios-1.5.0.tgz", - "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", + "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.4", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -1525,9 +1525,15 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], "engines": { "node": ">=4.0" }, @@ -1899,9 +1905,15 @@ } }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -1991,11 +2003,25 @@ } }, "node_modules/postcss": { - "version": "8.4.29", - "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.29.tgz", - "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", + "version": "8.4.35", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", + "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.3.7", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -2266,9 +2292,9 @@ } }, "node_modules/vite": { - "version": "4.4.9", - "resolved": "https://registry.npmmirror.com/vite/-/vite-4.4.9.tgz", - "integrity": "sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==", + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.2.tgz", + "integrity": "sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==", "dev": true, "dependencies": { "esbuild": "^0.18.10", @@ -2281,6 +2307,9 @@ "engines": { "node": "^14.18.0 || >=16.0.0" }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, "optionalDependencies": { "fsevents": "~2.3.2" }, diff --git a/client/src/apis/album.ts b/client/src/apis/album.ts index 7dbf1a2..01fd145 100644 --- a/client/src/apis/album.ts +++ b/client/src/apis/album.ts @@ -5,7 +5,9 @@ export const createAlbumApi = async (name: string) => { return await $http({ url: '/album/add-album', method: 'POST', - data: name + data: { + name + } }) } @@ -15,4 +17,12 @@ export const getAlbumListApi = async () => { url: '/album/album-list', method: 'GET', }) +} + +// 获取专辑ID列表 +export const getIdListApi = async () => { + return await $http({ + url: '/album/albumId-list', + method: 'GET', + }) } \ No newline at end of file diff --git a/client/src/views/home/Articledetail.vue b/client/src/views/home/Articledetail.vue index 6ee44b8..b0e1599 100644 --- a/client/src/views/home/Articledetail.vue +++ b/client/src/views/home/Articledetail.vue @@ -6,6 +6,7 @@

{{ title }}

作者:{{ author }} + 专辑:{{ name }} 发布时间:{{ time }}
@@ -65,7 +66,9 @@ {{ is_like === true ? "取消点赞" : "点赞" }} - {{ is_collect === true ? '取消收藏' : '收藏' }} + {{ + is_collect === true ? "取消收藏" : "收藏" + }} 分享 发送 @@ -91,6 +94,7 @@ const route = useRoute(); // 获取路由对象 const id = ref(route.query.id); // 获取路由参数 const title = ref(""); const author = ref(""); +const name = ref(""); const time = ref(""); const comment = ref(""); const user = ref(); @@ -146,6 +150,7 @@ const getArticleDetail = async () => { time.value = res.data.create_time; console.log(res.data.is_campaigns); user.value = res.data.user; + name.value = res.data.name; is_campaigns.value = res.data.is_campaigns == 1 ? true : false; }; getArticleDetail(); diff --git a/client/src/views/home/article/components/AddArticle.vue b/client/src/views/home/article/components/AddArticle.vue index 3a1b284..33ff4b1 100644 --- a/client/src/views/home/article/components/AddArticle.vue +++ b/client/src/views/home/article/components/AddArticle.vue @@ -14,6 +14,9 @@ + + +
@@ -48,6 +51,7 @@ import { MdEditor } from 'md-editor-v3'; import 'md-editor-v3/lib/style.css'; import { UploadFileInfo, useMessage } from 'naive-ui'; import { addArticleApi, getArticleDetailApi, updateArticleApi, uploadArticleImageApi } from '@/apis/article'; +import { getIdListApi } from "@/apis/album"; import { useUserStore } from '@/store/userinfo'; import { getCategoryListApi } from '@/apis/category'; @@ -63,8 +67,10 @@ const articleForm = ref({ cover: '', content: '', category_id: '', + album:'', author: userStore.account }) + // 父组件传递过来的id const props = defineProps({ editId: { @@ -72,11 +78,11 @@ const props = defineProps({ default: 0 } }) -// 或者文章详情 +// 获取文章详情 const getArticleDetail = async () => { const res = await getArticleDetailApi(props.editId) if (res.code === 200) { - articleForm.value = res.data[0] + articleForm.value = res.data } } // 如果有id,就获取文章详情 @@ -84,7 +90,21 @@ if (props.editId) { getArticleDetail() } - +// 获取专辑列表 +const albumOptions = ref([]) +const getAlbumList = async () => { + const res = await getIdListApi() + if (res.code === 200) { + const formatData = res.data.map((item: any) => { + return { + label: item.name, + value: item.id + } + }) + albumOptions.value = formatData + } +} +getAlbumList() // 获取分类列表 const categoryOptions = ref([]) const getCategoryList = async () => { diff --git a/client/src/views/home/article/components/AlbumList.vue b/client/src/views/home/article/components/AlbumList.vue index fca1a50..6c4769d 100644 --- a/client/src/views/home/article/components/AlbumList.vue +++ b/client/src/views/home/article/components/AlbumList.vue @@ -1,13 +1,37 @@ - + diff --git a/client/src/views/home/article/components/CollectList.vue b/client/src/views/home/article/components/CollectList.vue index ae41158..488f87b 100644 --- a/client/src/views/home/article/components/CollectList.vue +++ b/client/src/views/home/article/components/CollectList.vue @@ -1,7 +1,6 @@