diff --git a/public/img/audio-player/play.svg b/public/img/audio-player/play.svg
new file mode 100644
index 0000000..28e89bb
--- /dev/null
+++ b/public/img/audio-player/play.svg
@@ -0,0 +1,5 @@
+
diff --git a/src/app/vol/[journalId]/page.tsx b/src/app/vol/[journalId]/page.tsx
index 04c5474..812ff63 100644
--- a/src/app/vol/[journalId]/page.tsx
+++ b/src/app/vol/[journalId]/page.tsx
@@ -4,22 +4,22 @@ import Image from 'next/image';
import Link from 'next/link';
import { notFound } from 'next/navigation';
-import { JournalCard, SongCardList, HotJournalList, Comment } from '@/components';
-import { apiGetJournalInfoById, apiGetSongsByJournalNo } from '@/services';
+import { JournalCard, SongCardList, HotJournalList, Comment, Coolect } from '@/components';
+import { apiGetJournalInfoById, apiGetSongsByJournalNo, apiCollect } from '@/services';
const getData = async (journalId: string) => {
const [journalInfoRes, songListRes] = await Promise.all([
apiGetJournalInfoById({ id: journalId }),
apiGetSongsByJournalNo({ id: journalId }),
]);
+ if (!(journalInfoRes.code === 200 && songListRes.code === 200)) return notFound();
+ return { journalInfo: journalInfoRes.data, songList: songListRes.data };
+};
- if (journalInfoRes.code === 200 && songListRes.code === 200) {
- return {
- journalInfo: journalInfoRes.data,
- songList: songListRes.data,
- };
- } else {
- return notFound();
+// 收藏/取消收藏
+const handleCollect = async ({ isAdd, id }: { isAdd: boolean; id: string }) => {
+ const res = await apiCollect({ isAdd: !isAdd, objectId: id, collectType: '1' });
+ if (res.code === 200) {
}
};
@@ -59,15 +59,24 @@ export default async function JournalDetail({ params: { journalId } }: { params:
{/* 收藏 */}
-
+
+ {/*
{`${journalInfo.totalCommentReply}人收藏`}
-
-
+
handleCollect({ id: journalInfo.id, isAdd: !journalInfo.haveCollect })}>
+
+
+
*/}
{/* 内容 */}
(false); // 收藏状态
+
+ useEffect(() => {
+ setState(haveCollect);
+ }, [haveCollect]);
+
+ // 收藏/取消收藏
+ const handleCollect = async () => {
+ setState(!state);
+ const res = await apiCollect({ isAdd: !state, objectId: id, collectType: type });
+ if (res.code !== 200) {
+ setState(!state);
+ }
+ };
+
+ return (
+
+ {/* 文案 */}
+ {!!text && (
+
+ {`${count}${text}`}
+
+ )}
+ {/* 图标 */}
+
+
+
+ );
+}
diff --git a/src/components/Journal/HotJournalCard.tsx b/src/components/Journal/HotJournalCard.tsx
index 0c8299f..a94924f 100644
--- a/src/components/Journal/HotJournalCard.tsx
+++ b/src/components/Journal/HotJournalCard.tsx
@@ -9,10 +9,10 @@ export default function JournalItem({ title, image, totalCommentReply, journalNo
-
+
{title}
-
{`${totalCommentReply}人收藏`}
+
{`${totalCommentReply}人收藏`}
);
diff --git a/src/components/Journal/JournalItem.tsx b/src/components/Journal/JournalItem.tsx
index e220556..59c0bea 100644
--- a/src/components/Journal/JournalItem.tsx
+++ b/src/components/Journal/JournalItem.tsx
@@ -18,7 +18,7 @@ export default function JournalItem({
{/* 摘要 */}
-
+
{summary}
{/* 精选评论 */}
@@ -32,7 +32,7 @@ export default function JournalItem({
)}
-
+
{commentList[0].content}
@@ -41,7 +41,7 @@ export default function JournalItem({
{/* 评论 & 收藏 */}
-
+
{totalCommentReply}
-
+
{totalCommentReply}
diff --git a/src/components/index.ts b/src/components/index.ts
index 0125dec..d0213ac 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -37,3 +37,5 @@ export { default as CommentHeader } from './Comment/CommentHeader';
export { default as CommentForm } from './Comment/CommentForm';
export { default as CommentItem } from './Comment/CommentItem';
export { default as CommentList } from './Comment/CommentList';
+
+export { default as Coolect } from './Collect';
diff --git a/src/services/client/operate.ts b/src/services/client/operate.ts
new file mode 100644
index 0000000..5b7ba3d
--- /dev/null
+++ b/src/services/client/operate.ts
@@ -0,0 +1,46 @@
+import clientHttp from '@/utils/request/client';
+
+/**
+ * @description 喜欢歌曲/收藏期刊/关注/黑名单
+ * @objectId 喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单的id
+ * @collectType 0:歌曲,1:期刊,2:关注,3:黑名单
+ */
+export const apiCollectAdd = async (params: { objectId: string; collectType: string }) => {
+ const result: FetchResponse = await clientHttp.post('/queyueapi/user/collect', params);
+ return result;
+};
+
+/**
+ * @description 取消 喜欢歌曲/收藏期刊/关注/黑名单
+ * @objectId 喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单的id
+ * @collectType 0:歌曲,1:期刊,2:关注,3:黑名单
+ */
+export const apiCollectRemove = async ({ objectId, collectType }: { objectId: string; collectType: string }) => {
+ const result: FetchResponse = await clientHttp.delete(
+ `/queyueapi/user/collect?objectId=${objectId}&collectType=${collectType}`,
+ {},
+ );
+ return result;
+};
+
+/**
+ * @description 喜欢/取消 歌曲/收藏期刊/关注/黑名单
+ * @isAdd 是否添加收藏
+ * @objectId 喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单的id
+ * @collectType 0:歌曲,1:期刊,2:关注,3:黑名单
+ */
+export const apiCollect = async ({
+ isAdd,
+ objectId,
+ collectType,
+}: {
+ isAdd: boolean;
+ objectId: string;
+ collectType: string;
+}) => {
+ if (isAdd) {
+ return await apiCollectAdd({ objectId, collectType });
+ } else {
+ return await apiCollectRemove({ objectId, collectType });
+ }
+};
diff --git a/src/services/index.ts b/src/services/index.ts
index b489492..4fe3b19 100644
--- a/src/services/index.ts
+++ b/src/services/index.ts
@@ -9,3 +9,4 @@ export * from './server/journal';
* @description client request
*/
export * from './client/user';
+export * from './client/operate';
diff --git a/src/services/type.d.ts b/src/services/type.d.ts
new file mode 100644
index 0000000..b082a28
--- /dev/null
+++ b/src/services/type.d.ts
@@ -0,0 +1,18 @@
+export type IAuthType = 'noToken' | 'default' | 'ai';
+
+export interface IOptions {
+ headers?: { [key: string]: string };
+ body?: any;
+ authType?: IAuthType;
+ requestUrl: string;
+}
+
+export interface IResponse {
+ code: number;
+ data: T;
+ message: string;
+}
+
+export type IQueryParams = {
+ [key: string]: any;
+};
diff --git a/src/utils/request/client/index.ts b/src/utils/request/client/index.ts
index 4ed7838..648a2b8 100644
--- a/src/utils/request/client/index.ts
+++ b/src/utils/request/client/index.ts
@@ -33,17 +33,21 @@ export const get = async (url: string, data: any = null, revalidate = 20): Pr
return await handleResponse(response);
};
-export const remove = async (url: string, data: any = null, revalidate = 20): Promise> => {
+export const remove = async (url: string, data: any, revalidate = 20): Promise> => {
const token = await getAuthorization();
const response = await fetch(url, {
headers: {
Authorization: token || '',
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
+ Connection: 'keep-alive',
},
method: 'DELETE',
+ body: data && createFormBody(data),
next: {
revalidate: revalidate,
},
});
+
return await handleResponse(response);
};
@@ -63,7 +67,7 @@ export const uploadFile = async (url: string, file: File): Promise {
// setSession("local", tokenKey, res?.data);
// authorization = `Bearer ${res?.data}`;
}
- console.log({ authorization });
return authorization;
};
diff --git a/uno.config.ts b/uno.config.ts
index 639e8c5..e2a6bdc 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -13,7 +13,6 @@ export default defineConfig({
],
rules: [
- ['color-theme', { color: '#B44343' }],
['bg-theme', { 'background-color': '#B44343' }],
['text-flow', { 'text-overflow': 'ellipsis', 'white-space': 'nowrap', overflow: 'hidden' }],
],