fix(ESLint): Process error for build.

mack-mac
mackt 7 months ago
parent 2ed57b5f9f
commit 26e60cd197

@ -36,7 +36,7 @@ export default function Journal() {
// journal: apiGetSongCollect,
// };
const result = await apiGetSongCollect({ userId: userInfo?.id, pageNum, pageSize });
console.log(result);
// console.log(result);
if (result.code === 200) setList(result.data.rows);
};

@ -24,7 +24,7 @@ export default function AudioPlayer({ className }: { className?: string }) {
}),
);
const audio: SongInfo = playQueue.find((item) => item.id === audioId) || playQueue[0];
const audio: SongInfo = playQueue.find((item) => item?.id === audioId) || playQueue[0];
const audioRef = useRef(new Audio(audio?.src || ''));
const isReady = useRef<boolean>(false); // 是否加载过组件

@ -1,5 +1,6 @@
'use client';
import { useEffect, useState } from 'react';
// import { useEffect, useState } from 'react';
import { useEffect } from 'react';
import dynamic from 'next/dynamic';
@ -8,19 +9,19 @@ import Player from './Player';
// import { debounce } from 'lodash';
const PlayerBar = ({ className }: { className?: string }) => {
let oldScrollY: number = 0;
function handleScroll() {
if (window.scrollY > oldScrollY) {
// 向下滚动
// if (oldScrollY < 0) return;
setPositionBottom(-130);
} else {
// 向上滚动
// if (oldScrollY > 0) return;
setPositionBottom(0);
}
oldScrollY = window.scrollY;
}
// let oldScrollY: number = 0;
// function handleScroll() {
// if (window.scrollY > oldScrollY) {
// // 向下滚动
// // if (oldScrollY < 0) return;
// setPositionBottom(-130);
// } else {
// // 向上滚动
// // if (oldScrollY > 0) return;
// setPositionBottom(0);
// }
// oldScrollY = window.scrollY;
// }
useEffect(() => {
// window.addEventListener('scroll', handleScroll);
@ -29,14 +30,17 @@ const PlayerBar = ({ className }: { className?: string }) => {
// };
});
const [positionBottom, setPositionBottom] = useState<number>(0);
// const [positionBottom, setPositionBottom] = useState<number>(0);
return (
// <div
// className={`fixed w-[100vw] h-[130px] bg-[#fff] ${className} transition-bottom duration-700 shadow-lg shadow-black-[0_0_10px] z-10`}
// style={{ bottom: positionBottom }}
// >
<div className={`fixed w-[100vw] h-[130px] bg-[#fff] shadow-lg shadow-black-[0_0_10px] z-10`} style={{ bottom: 0 }}>
<div
className={`fixed w-[100vw] h-[130px] bg-[#fff] shadow-lg shadow-black-[0_0_10px] z-10 ${className}`}
style={{ bottom: 0 }}
>
<div className="w-[1200px] h-full m-auto">
<Player className="m-auto" />
</div>

@ -2,13 +2,12 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import throttle from 'lodash/throttle';
// import throttle from 'lodash/throttle';
import scrollToBottom from '@/utils/scroolToBottom';
// import { scrollToBottom } from '@/utils/helpers';
import { CommentForm, CommentHeader, CommentList } from '@/components';
import { apiGetComment, apiCommentSave } from '@/services';
import { size } from 'lodash';
interface Props {
journalId: string;

@ -3,7 +3,7 @@
/** 评论输入框 */
import { useState, useRef, useMemo, useEffect } from 'react';
import { Avatar, Button, Input } from '@/components';
import { Avatar, Button } from '@/components';
interface Props {
nickName: string;

@ -24,13 +24,13 @@ export default function CommentItem({
className,
}: Comment & { className?: string }) {
const inputRef = useRef<HTMLInputElement>(null);
const [showAll, setShowAll] = useState<boolean>(false);
// const [showAll, setShowAll] = useState<boolean>(false);
const [showInput, setShowInput] = useState<boolean>(false);
const [subCommentList, setSubCommentList] = useState<Comment[]>(topChildrenComment ? [topChildrenComment] : []);
// 展示全部评论
const handleShowAll = async () => {
setShowAll(true);
// setShowAll(true);
const res = await apiGetSubComment({ parentId: _id, size: commentCount, page: 1 });
if (res.code === 200) setSubCommentList(res.data.rows);
return res.code === 200;

@ -4,10 +4,9 @@ import Image from 'next/image';
import { useRouter } from 'next/navigation';
import { useShallow } from 'zustand/react/shallow';
import { Avatar } from '@/components';
import logout from '@/utils/logout';
import { Avatar } from '@/components';
import useUserStore from '@/store/user';
interface Props {

@ -1,6 +1,6 @@
import Image from 'next/image';
export default function JournalItem({ title, image, totalCommentReply, journalNo }: JournalInfo) {
export default function JournalItem({ title, image, totalCommentReply }: JournalInfo) {
return (
<div className="flex flex-row items-center h-[56px] group">
<Image src={image} alt={title} width={80} height={56} unoptimized className="w-[80px] h-[56px] rounded-[3px]" />{' '}

@ -15,11 +15,10 @@ interface Props {
}
export default function JournalItem({ listId, songList, className }: Props) {
const { setPlayList, setAudioId, playListId, audioId } = useAudioStore(
const { setPlayList, setAudioId, playListId } = useAudioStore(
useShallow((state) => ({
setplayList: state.setPlayList,
setAudioId: state.setAudioId,
audioId: state.audioId,
playList: state.playList,
setPlayList: state.setPlayList,
playListId: state.playListId,

@ -1,17 +0,0 @@
import { useGetUserInfoQuery } from '@/store/services';
import useVerify from './useVerify';
import { useAppDispatch } from './useRedux';
import { userLogin } from '@/store';
export default function useUserInfo() {
const dispatch = useAppDispatch();
const isVerify = useVerify();
const { data, isLoading, error, isError } = useGetUserInfoQuery(undefined, {
skip: !isVerify,
});
if (isError) dispatch(userLogin(''));
return { userInfo: data?.data, isVerify, isLoading, error, isError };
}

@ -1,17 +0,0 @@
import { useSelector } from 'react-redux';
import jwt from 'jsonwebtoken';
export default function useVerify() {
const { token } = useSelector((state) => state.user);
let status;
if (!token) return false;
jwt.verify(token, process.env.NEXT_PUBLIC_ACCESS_TOKEN_SECRET, (err, decoded) => {
if (err) status = false;
if (decoded) status = true;
});
if (status) return true;
else return false;
}

@ -1,7 +1,7 @@
import { setCookie } from 'nookies';
// import { setCookie } from 'nookies';
import clientHttp from '@/utils/request/client';
import { request, verifyResponse } from '@/utils';
// import { request, verifyResponse } from '@/utils';
/**
* @description

@ -2,7 +2,6 @@
* @description server request
*/
export * from './server/user';
export * from './server/music';
export * from './server/journal';
/**

@ -1,15 +0,0 @@
import serverHttp from '@/utils/request/client';
// /**
// * @description 根据期刊号查询期刊信息
// * @id 期刊号
// */
// export const apiGetSongsByJournalNo = async (params: {
// mobile: string;
// deviceId: string;
// countryCode?: string;
// imageCheckCode?: string;
// }) => {
// const result: FetchResponse<SongInfo[]> = await serverHttp.post('/music/song/getByJournalNo', params);
// return result;
// };

@ -53,7 +53,12 @@ const useUserStore = create<UserState>()(
thumbUpCount: 0,
};
const setUserInfo = (value: UserInfo) => set(produce((state) => (state.userInfo = value)));
const setUserInfo = (value: UserInfo) =>
set(
produce((state) => {
state.userInfo = value;
}),
);
const getUserInfo = async () => {
const result = await apiGetMyUserInfo();
@ -64,7 +69,12 @@ const useUserStore = create<UserState>()(
return {
userInfo: initialUserInfo,
showLogin: false,
setShowLogin: (value) => set(produce((state) => (state.showLogin = value))),
setShowLogin: (value) =>
set(
produce((state) => {
state.showLogin = value;
}),
),
setUserInfo,
userLogin: async (params) => {
const result = await apiUserLogin(params);

@ -1,4 +1,2 @@
export { default as request } from './request';
export { default as verifyResponse } from './verifyResponse';
export * from './helpers';
export * from './wrapper';

@ -1,7 +1,7 @@
import { getAuthorization, handleResponse, createFormBody } from '@/utils/request/client/utils';
import { IResponse } from '@/utils/request/type';
export const get = async <T>(url: string, data: any = null, revalidate = 20): Promise<IResponse<T>> => {
export const get = async <T>(url: string, revalidate = 20): Promise<IResponse<T>> => {
const token = await getAuthorization();
const response = await fetch(url, {
headers: {

@ -4,7 +4,6 @@ import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
import { formatBody } from '@/utils/request/server/utils';
import { IAuthType } from '@/utils/request/type';
const host = process.env.NEXT_PUBLIC_HOST;
export const get = async (request: Request) => {

@ -44,14 +44,27 @@ export const formatBody = async (body: any, contentType: string) => {
};
const streamToFormUrlEncoded = async (stream: ReadableStream<Uint8Array> | null) => {
if (stream === null) {
throw new Error('Stream cannot be null');
}
const chunks = [];
const decoder = new TextDecoder('utf-8');
const reader = stream.getReader();
// 逐块读取流数据
for await (const chunk of stream) {
chunks.push(decoder.decode(chunk, { stream: true }));
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
if (value) {
chunks.push(decoder.decode(value, { stream: true }));
}
}
// 合并块并转换为 URL 编码的形式
const formData = chunks.join('');
const urlEncodedFormData = new URLSearchParams(formData);

Loading…
Cancel
Save