chore: Update meta title and add navigation event to UserCard.

mack-mac
mackt 7 months ago
parent 936593553c
commit 60dda04cc1

@ -5,6 +5,11 @@ import styles from './about.module.css';
import { ContributorCard } from '@/components'; import { ContributorCard } from '@/components';
import { apiThanks } from '@/services'; import { apiThanks } from '@/services';
import type { Metadata } from 'next';
export const metadata: Metadata = {
title: '关于我们',
};
export interface ContributorCardType { export interface ContributorCardType {
id: string; id: string;
nickName: string; nickName: string;

@ -1,3 +1,5 @@
'use client';
import { useState } from 'react'; import { useState } from 'react';
import Image from 'next/image'; import Image from 'next/image';

@ -1,9 +1,13 @@
'use client';
import Image from 'next/image'; import Image from 'next/image';
import DownloadCard from '@/app/download/components/DownloadCard'; import DownloadCard from '@/app/download/components/DownloadCard';
import type { Metadata } from 'next';
export const metadata: Metadata = {
title: '下载',
};
const qrCodeList: Array<DownloadQrcodeCard> = [ const qrCodeList: Array<DownloadQrcodeCard> = [
{ {
platform: 'APP Store', platform: 'APP Store',

@ -1,10 +1,14 @@
import { Metadata, Viewport } from 'next';
import { Header, Footer, PlayerBar } from '@/components'; import { Header, Footer, PlayerBar } from '@/components';
import type { Metadata, Viewport } from 'next';
import './globals.css'; import './globals.css';
export const metadata: Metadata = { export const metadata: Metadata = {
title: '雀乐', title: {
template: '%s - 雀乐',
default: '雀乐',
},
description: '独立 不独于世', description: '独立 不独于世',
icons: { icons: {
icon: '/favicon.ico', icon: '/favicon.ico',

@ -4,6 +4,7 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import Head from 'next/head';
import { useShallow } from 'zustand/react/shallow'; import { useShallow } from 'zustand/react/shallow';
import styles from './index.module.css'; import styles from './index.module.css';
@ -12,11 +13,10 @@ import { SongCardList } from '@/components';
import { apiGetSongCollect } from '@/services'; import { apiGetSongCollect } from '@/services';
import useUserStore from '@/store/user'; import useUserStore from '@/store/user';
export default function Journal({ params }: { params: { category?: string; page?: number } }) { export default function Journal() {
const { userInfo, userLogout } = useUserStore( const { userInfo } = useUserStore(
useShallow((state) => ({ useShallow((state) => ({
userInfo: state.userInfo, userInfo: state.userInfo,
userLogout: state.userLogout,
})), })),
); );
@ -52,6 +52,7 @@ export default function Journal({ params }: { params: { category?: string; page?
]; ];
useEffect(() => { useEffect(() => {
document.title = '我的收藏 - 雀乐';
getList(); getList();
}, [type, pageNum]); }, [type, pageNum]);

@ -6,6 +6,12 @@ import { notFound } from 'next/navigation';
import { JournalCard, SongCardList, HotJournalList, Comment, Collect } from '@/components'; import { JournalCard, SongCardList, HotJournalList, Comment, Collect } from '@/components';
import { apiGetJournalInfoById, apiGetSongsByJournalNo } from '@/services'; import { apiGetJournalInfoById, apiGetSongsByJournalNo } from '@/services';
export async function generateMetadata({ params: { journalId } }: { params: { journalId: string } }) {
const res = await apiGetJournalInfoById({ id: journalId });
const title = res.code === 200 ? res.data.title : '期刊详情';
return { title };
}
const getData = async (journalId: string) => { const getData = async (journalId: string) => {
const [journalInfoRes, songListRes] = await Promise.all([ const [journalInfoRes, songListRes] = await Promise.all([
apiGetJournalInfoById({ id: journalId }), apiGetJournalInfoById({ id: journalId }),

@ -3,6 +3,12 @@
import { Category, JournalList, HotJournalList } from '@/components'; import { Category, JournalList, HotJournalList } from '@/components';
import { apiSearchCategory } from '@/services'; import { apiSearchCategory } from '@/services';
import type { Metadata } from 'next';
export const metadata: Metadata = {
title: '期刊',
};
const getCategoryList = async () => { const getCategoryList = async () => {
const result = await apiSearchCategory(); const result = await apiSearchCategory();
return result.code === 200 ? result.data : []; return result.code === 200 ? result.data : [];

@ -1,12 +1,14 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import Image from 'next/image'; import Image from 'next/image';
import { useRouter } from 'next/navigation';
import { useShallow } from 'zustand/react/shallow'; import { useShallow } from 'zustand/react/shallow';
import { Avatar } from '@/components'; import { Avatar } from '@/components';
import useUserStore from '@/store/user'; import useUserStore from '@/store/user';
interface Props { interface Props {
onClose: () => void;
className?: string; className?: string;
} }
@ -15,7 +17,8 @@ interface TDataList {
value: number; value: number;
} }
export default function UserCard({ className }: Props) { export default function UserCard({ onClose, className }: Props) {
const router = useRouter();
const { userInfo, userLogout } = useUserStore( const { userInfo, userLogout } = useUserStore(
useShallow((state) => ({ useShallow((state) => ({
userInfo: state.userInfo, userInfo: state.userInfo,
@ -30,6 +33,17 @@ export default function UserCard({ className }: Props) {
{ label: '获赞', value: userInfo.thumbUpCount }, { label: '获赞', value: userInfo.thumbUpCount },
]); ]);
const handleGoMyList = () => {
router.push('/myList');
onClose();
};
const handleLogout = async () => {
await userLogout;
router.push('/');
onClose();
};
useEffect(() => { useEffect(() => {
setUserDataList([ setUserDataList([
{ label: '关注', value: userInfo.followCount }, { label: '关注', value: userInfo.followCount },
@ -64,13 +78,16 @@ export default function UserCard({ className }: Props) {
{/* 按钮 */} {/* 按钮 */}
<ul className="px-[15px] mt-[6px]"> <ul className="px-[15px] mt-[6px]">
<li className="flex flex-row justify-between items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer"> <li
className="flex flex-row justify-between items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer"
onClick={handleGoMyList}
>
<span></span> <span></span>
<Image width={24} height={24} src="/img/icon/love.svg" alt="我的收藏" /> <Image width={24} height={24} src="/img/icon/love.svg" alt="我的收藏" />
</li> </li>
<li <li
className="flex flex-row items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer" className="flex flex-row items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer"
onClick={userLogout} onClick={handleLogout}
> >
<span>退</span> <span>退</span>
</li> </li>

@ -1,6 +1,6 @@
'use client'; 'use client';
import React, { useState, useRef } from 'react'; import React, { useState } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
@ -80,7 +80,7 @@ export default function Header() {
onMouseEnter={handleShowUserCard} onMouseEnter={handleShowUserCard}
onMouseLeave={handleHideUserCard} onMouseLeave={handleHideUserCard}
> >
<UserCard /> <UserCard onClose={() => setShowUserCard(false)} />
</div> </div>
)} )}
</div> </div>

Loading…
Cancel
Save