parent
2ed57b5f9f
commit
26e60cd197
@ -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,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;
|
||||
// };
|
@ -1,4 +1,2 @@
|
||||
export { default as request } from './request';
|
||||
export { default as verifyResponse } from './verifyResponse';
|
||||
export * from './helpers';
|
||||
export * from './wrapper';
|
||||
|
Loading…
Reference in new issue