feat: 对接新的接口
This commit is contained in:
parent
24df3f413f
commit
3ca5a56127
|
|
@ -29,6 +29,7 @@ export default function CharacterBasicInfo({
|
||||||
{/* 角色头像 - 使用 figure 语义化标签 */}
|
{/* 角色头像 - 使用 figure 语义化标签 */}
|
||||||
<figure>
|
<figure>
|
||||||
<Image
|
<Image
|
||||||
|
className="rounded-[30px]"
|
||||||
src={avatar}
|
src={avatar}
|
||||||
alt={`${characterName} - 角色头像`}
|
alt={`${characterName} - 角色头像`}
|
||||||
width={338}
|
width={338}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
||||||
import CharacterBasicInfo from './components/BasicInfo';
|
import CharacterBasicInfo from './components/BasicInfo';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import TabsNavigation from './components/TabsNavigation';
|
import TabsNavigation from './components/TabsNavigation';
|
||||||
import { fetchCharacterDetail } from './service';
|
import { fetchCharacterDetail } from '../../service-server';
|
||||||
|
|
||||||
type CharacterDetailLayoutProps = {
|
type CharacterDetailLayoutProps = {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import { cache } from 'react';
|
|
||||||
import { publicServerRequest } from '@/lib/server-request';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色详情(公开数据,不需要 token)
|
|
||||||
* 用于 SEO,搜索引擎爬虫可以正常访问
|
|
||||||
* 使用 cache 确保在同一个请求周期内只请求一次
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const fetchCharacterDetail = cache(async (id: string) => {
|
|
||||||
return {};
|
|
||||||
const { data } = await publicServerRequest(
|
|
||||||
`/character/select/roleInfo/${id}`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
|
|
@ -4,7 +4,7 @@ import React from 'react';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useInfiniteScroll } from '@/hooks/useInfiniteScroll';
|
import { useInfiniteScroll } from '@/hooks/useInfiniteScroll';
|
||||||
import { fetchCharacters } from './service';
|
import { fetchCharacters } from './service-client';
|
||||||
import { fetchTags } from '@/services/tag';
|
import { fetchTags } from '@/services/tag';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import Tags from '@/components/ui/Tags';
|
import Tags from '@/components/ui/Tags';
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import request from '@/lib/request';
|
import request from '@/lib/client/request';
|
||||||
|
|
||||||
export async function fetchCharacters({ index, limit, query }: any) {
|
export async function fetchCharacters({ index, limit, query }: any) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
const { data } = await request('/api/character/select/list', {
|
const { data } = await request('/api/character/list', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { index, limit, ...query },
|
data: { index, limit, ...query },
|
||||||
});
|
});
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { cache } from 'react';
|
||||||
|
import { publicServerRequest } from '@/lib/server/request';
|
||||||
|
|
||||||
|
export const fetchCharacterDetail = cache(async (id: string) => {
|
||||||
|
const res = await publicServerRequest(`/character/detail`, {
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
roleId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return res.data ?? {};
|
||||||
|
});
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import axios, { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
import axios, { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
||||||
import { getServerToken } from './server-auth';
|
import { getServerToken } from './auth';
|
||||||
|
|
||||||
type ResponseType<T = any> = {
|
type ResponseType<T = any> = {
|
||||||
code: number;
|
code: number;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import request from '@/lib/request';
|
import request from '@/lib/client/request';
|
||||||
|
|
||||||
export async function fetchTags(params: any = {}) {
|
export async function fetchTags(params: any = {}) {
|
||||||
const { data } = await request('/api/tag/selectByCondition', {
|
const { data } = await request('/api/tag/list', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { limit: 20, ...params },
|
data: { limit: 20, ...params },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue