Merge remote-tracking branch 'origin/main' into feature/169

This commit is contained in:
2025-12-30 10:58:30 +09:00
8 changed files with 175 additions and 72 deletions
@@ -1,5 +1,6 @@
import { AnimatePresence, motion } from 'framer-motion'
import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import TagLink from '@/components/TagLink'
import TagSearch from '@/components/TagSearch'
@@ -128,6 +129,9 @@ export default (({ post }: Props) => {
&& `${ (new Date (post.originalCreatedBefore)).toLocaleString () } より前`}
</>)}
</li>
<li>
<Link to={`/posts/changes?id=${ post.id }`}></Link>
</li>
</ul>
</div>)}
</motion.div>
+37 -4
View File
@@ -1,5 +1,8 @@
import axios from 'axios'
import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { API_BASE_URL } from '@/config'
import { LIGHT_COLOUR_SHADE, DARK_COLOUR_SHADE, TAG_COLOUR } from '@/consts'
import { cn } from '@/lib/utils'
@@ -27,6 +30,27 @@ export default (({ tag,
withWiki = true,
withCount = true,
...props }: Props) => {
const [havingWiki, setHavingWiki] = useState (true)
const wikiExists = async (tagName: string) => {
try
{
await axios.get (`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (tagName) }/exists`)
setHavingWiki (true)
}
catch
{
setHavingWiki (false)
}
}
useEffect (() => {
if (!(linkFlg) || !(withWiki))
return
wikiExists (tag.name)
}, [tag.name, linkFlg, withWiki])
const spanClass = cn (
`text-${ TAG_COLOUR[tag.category] }-${ LIGHT_COLOUR_SHADE }`,
`dark:text-${ TAG_COLOUR[tag.category] }-${ DARK_COLOUR_SHADE }`)
@@ -39,10 +63,19 @@ export default (({ tag,
<>
{(linkFlg && withWiki) && (
<span className="mr-1">
<Link to={`/wiki/${ encodeURIComponent (tag.name) }`}
className={linkClass}>
?
</Link>
{havingWiki
? (
<Link to={`/wiki/${ encodeURIComponent (tag.name) }`}
className={linkClass}>
?
</Link>)
: (
<Link to={`/wiki/${ encodeURIComponent (tag.name) }`}
className="animate-[wiki-blink_.25s_steps(2,end)_infinite]
dark:animate-[wiki-blink-dark_.25s_steps(2,end)_infinite]"
title={`${ tag.name } Wiki が存在しません.`}>
!
</Link>)}
</span>)}
{nestLevel > 0 && (
<span
+12
View File
@@ -96,3 +96,15 @@ button:focus-visible
background-color: #f9f9f9;
}
}
@keyframes wiki-blink
{
0%, 100% { color: #dc2626; }
50% { color: #2563eb; }
}
@keyframes wiki-blink-dark
{
0%, 100% { color: #f87171; }
50% { color: #60a5fa; }
}
+43 -29
View File
@@ -25,19 +25,20 @@ export default (() => {
const page = Number (query.get ('page') ?? 1)
const limit = Number (query.get ('limit') ?? 20)
// 投稿列の結合で使用
let rowsCnt: number
useEffect (() => {
void (async () => {
const res = await axios.get (`${ API_BASE_URL }/posts/changes`,
{ params: { ...(id && { id }),
...(page && { page }),
...(limit && { limit }) } })
{ params: { ...(id && { id }), page, limit } })
const data = toCamel (res.data as any, { deep: true }) as {
changes: PostTagChange[]
count: number }
setChanges (data.changes)
setTotalPages (Math.trunc ((data.count - 1) / limit))
setTotalPages (Math.ceil (data.count / limit))
}) ()
}, [location.search])
}, [id, page, limit])
return (
<MainArea>
@@ -47,7 +48,7 @@ export default (() => {
<PageTitle>
{Boolean (id) && <>: 稿 {<Link to={`/posts/${ id }`}>#{id}</Link>}</>}
{id && <>: 稿 {<Link to={`/posts/${ id }`}>#{id}</Link>}</>}
</PageTitle>
<table className="table-auto w-full border-collapse">
@@ -59,29 +60,42 @@ export default (() => {
</tr>
</thead>
<tbody>
{changes.map (change => (
<tr key={`${ change.timestamp }-${ change.post.id }-${ change.tag.id }`}>
<td>
<Link to={`/posts/${ change.post.id }`}>
<img src={change.post.thumbnail || change.post.thumbnailBase || undefined}
alt={change.post.title || change.post.url}
title={change.post.title || change.post.url || undefined}
className="w-40"/>
</Link>
</td>
<td>
<TagLink tag={change.tag} withWiki={false} withCount={false}/>
{`${ change.changeType === 'add' ? '追加' : '削除' }`}
</td>
<td>
{change.user ? (
<Link to={`/users/${ change.user.id }`}>
{change.user.name}
</Link>) : 'bot 操作'}
<br/>
{change.timestamp}
</td>
</tr>))}
{changes.map ((change, i) => {
let withPost = i === 0 || change.post.id !== changes[i - 1].post.id
if (withPost)
{
rowsCnt = 1
for (let j = i + 1;
(j < changes.length
&& change.post.id === changes[j].post.id);
++j)
++rowsCnt
}
return (
<tr key={`${ change.timestamp }-${ change.post.id }-${ change.tag.id }`}>
{withPost && (
<td className="align-top" rowSpan={rowsCnt}>
<Link to={`/posts/${ change.post.id }`}>
<img src={change.post.thumbnail || change.post.thumbnailBase || undefined}
alt={change.post.title || change.post.url}
title={change.post.title || change.post.url || undefined}
className="w-40"/>
</Link>
</td>)}
<td>
<TagLink tag={change.tag} withWiki={false} withCount={false}/>
{`${ change.changeType === 'add' ? '追加' : '削除' }`}
</td>
<td>
{change.user ? (
<Link to={`/users/${ change.user.id }`}>
{change.user.name}
</Link>) : 'bot 操作'}
<br/>
{change.timestamp}
</td>
</tr>)
})}
</tbody>
</table>
+12 -3
View File
@@ -36,9 +36,16 @@ export default () => {
if (/^\d+$/.test (title))
{
void (async () => {
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
const data = res.data as WikiPage
navigate (`/wiki/${ data.title }`, { replace: true })
try
{
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
const data = res.data as WikiPage
navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
}
catch
{
;
}
}) ()
return
@@ -51,6 +58,8 @@ export default () => {
`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (title) }`,
{ params: version ? { version } : { } })
const data = toCamel (res.data as any, { deep: true }) as WikiPage
if (data.title !== title)
navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
setWikiPage (data)
WikiIdBus.set (data.id)
}