#57 修正
This commit is contained in:
@@ -20,25 +20,27 @@ export default () => {
|
|||||||
const location = useLocation ()
|
const location = useLocation ()
|
||||||
const query = new URLSearchParams (location.search)
|
const query = new URLSearchParams (location.search)
|
||||||
const tagsQuery = query.get ('tags') ?? ''
|
const tagsQuery = query.get ('tags') ?? ''
|
||||||
// const anyFlg = query.get ('match') === 'any'
|
const anyFlg = query.get ('match') === 'any'
|
||||||
const anyFlg = false
|
|
||||||
const tags = tagsQuery.split (' ').filter (e => e !== '')
|
const tags = tagsQuery.split (' ').filter (e => e !== '')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void (axios.get (`${ API_BASE_URL }/posts`, {
|
void (axios.get (`${ API_BASE_URL }/posts`, {
|
||||||
params: { tags: tags.join (','),
|
params: { tags: tags.join (','),
|
||||||
match: (anyFlg ? 'any' : 'all') } })
|
match: (anyFlg ? 'any' : 'all') } })
|
||||||
.then (res => setPosts (res.data))
|
.then (res => setPosts (toCamel (res.data, { deep: true })))
|
||||||
.catch (err => {
|
.catch (err => {
|
||||||
console.error ('Failed to fetch posts:', err)
|
console.error ('Failed to fetch posts:', err)
|
||||||
setPosts ([])
|
setPosts ([])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
setWikiPage (null)
|
||||||
if (!(tags.length))
|
if (!(tags.length))
|
||||||
return
|
return
|
||||||
void (axios.get (`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (tags.join (' ')) }`)
|
void (axios.get (`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (tags.join (' ')) }`)
|
||||||
.then (res => setWikiPage (toCamel (res.data, { deep: true })))
|
.then (res => setWikiPage (toCamel (res.data, { deep: true })))
|
||||||
.catch (() => setWikiPage (null)))
|
.catch (() => {
|
||||||
|
;
|
||||||
|
}))
|
||||||
}, [location.search])
|
}, [location.search])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -58,13 +60,12 @@ export default () => {
|
|||||||
? (
|
? (
|
||||||
<div className="flex flex-wrap gap-4 p-4">
|
<div className="flex flex-wrap gap-4 p-4">
|
||||||
{posts.map (post => (
|
{posts.map (post => (
|
||||||
<Link to={`/posts/${ post.id }`}
|
<Link to={`/posts/${ post.id }`}
|
||||||
key={post.id}
|
key={post.id}
|
||||||
className="w-40 h-40 overflow-hidden rounded-lg shadow-md hover:shadow-lg">
|
className="w-40 h-40 overflow-hidden rounded-lg shadow-md hover:shadow-lg">
|
||||||
<img src={post.thumbnail ?? post.thumbnail_base}
|
<img src={post.thumbnail ?? post.thumbnailBase}
|
||||||
className="object-none w-full h-full" />
|
className="object-none w-full h-full" />
|
||||||
</Link>
|
</Link>))}
|
||||||
))}
|
|
||||||
</div>)
|
</div>)
|
||||||
: '広場には何もありませんよ.'}
|
: '広場には何もありませんよ.'}
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { CATEGORIES, USER_ROLES } from '@/consts'
|
|||||||
export type Category = typeof CATEGORIES[number]
|
export type Category = typeof CATEGORIES[number]
|
||||||
|
|
||||||
export type Post = {
|
export type Post = {
|
||||||
id: number
|
id: number
|
||||||
url: string
|
url: string
|
||||||
title: string
|
title: string
|
||||||
thumbnail: string
|
thumbnail: string
|
||||||
tags: Tag[]
|
thumbnailBase: string
|
||||||
viewed: boolean }
|
tags: Tag[]
|
||||||
|
viewed: boolean }
|
||||||
|
|
||||||
export type Tag = {
|
export type Tag = {
|
||||||
id: number
|
id: number
|
||||||
|
|||||||
Reference in New Issue
Block a user