This commit is contained in:
2025-07-13 02:46:13 +09:00
parent fdf242c060
commit 0c46cf28db
29 changed files with 509 additions and 456 deletions
+8 -14
View File
@@ -1,9 +1,8 @@
import axios from 'axios'
import React, { useEffect, useState, useRef } from 'react'
import { useEffect, useState, useRef } from 'react'
import { Helmet } from 'react-helmet-async'
import { Link, useLocation, useParams, useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import NicoViewer from '@/components/NicoViewer'
import Form from '@/components/common/Form'
import Label from '@/components/common/Label'
import PageTitle from '@/components/common/PageTitle'
@@ -12,16 +11,8 @@ import MainArea from '@/components/layout/MainArea'
import { Button } from '@/components/ui/button'
import { toast } from '@/components/ui/use-toast'
import { API_BASE_URL, SITE_TITLE } from '@/config'
import { cn } from '@/lib/utils'
import type { Post, Tag } from '@/types'
type Props = { posts: Post[]
setPosts: (posts: Post[]) => void }
export default () => {
const location = useLocation ()
const navigate = useNavigate ()
const [title, setTitle] = useState ('')
@@ -41,7 +32,8 @@ export default () => {
formData.append ('title', title)
formData.append ('url', url)
formData.append ('tags', tags)
formData.append ('thumbnail', thumbnailFile)
if (thumbnailFile)
formData.append ('thumbnail', thumbnailFile)
void (axios.post (`${ API_BASE_URL }/posts`, formData, { headers: {
'Content-Type': 'multipart/form-data',
@@ -78,9 +70,10 @@ export default () => {
const fetchTitle = async () => {
setTitle ('')
setTitleLoading (true)
const { data } = await axios.get (`${ API_BASE_URL }/preview/title`, {
const res = await axios.get (`${ API_BASE_URL }/preview/title`, {
params: { url },
headers: { 'X-Transfer-Code': localStorage.getItem ('user_code') || '' } })
const data = res.data as { title: string }
setTitle (data.title || '')
setTitleLoading (false)
}
@@ -91,10 +84,11 @@ export default () => {
setThumbnailLoading (true)
if (thumbnailPreview)
URL.revokeObjectURL (thumbnailPreview)
const { data } = await axios.get (`${ API_BASE_URL }/preview/thumbnail`, {
const res = await axios.get (`${ API_BASE_URL }/preview/thumbnail`, {
params: { url },
headers: { 'X-Transfer-Code': localStorage.getItem ('user_code') || '' },
responseType: 'blob' })
const data = res.data as Blob
const imageURL = URL.createObjectURL (data)
setThumbnailPreview (imageURL)
setThumbnailFile (new File ([data],