fix rm callback page
This commit is contained in:
@ -133,7 +133,6 @@ export default function App() {
|
|||||||
<CommentForm
|
<CommentForm
|
||||||
user={user}
|
user={user}
|
||||||
agent={agent}
|
agent={agent}
|
||||||
pageContext={pageContext}
|
|
||||||
onCommentPosted={() => {
|
onCommentPosted={() => {
|
||||||
refreshAdminData?.()
|
refreshAdminData?.()
|
||||||
refreshUserData?.()
|
refreshUserData?.()
|
||||||
|
@ -2,34 +2,21 @@ import React, { useState } from 'react'
|
|||||||
import { atproto, collections } from '../api/atproto.js'
|
import { atproto, collections } from '../api/atproto.js'
|
||||||
import { env } from '../config/env.js'
|
import { env } from '../config/env.js'
|
||||||
|
|
||||||
export default function CommentForm({ user, agent, onCommentPosted, pageContext }) {
|
export default function CommentForm({ user, agent, onCommentPosted }) {
|
||||||
const [text, setText] = useState('')
|
const [text, setText] = useState('')
|
||||||
|
const [url, setUrl] = useState('')
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
|
|
||||||
// Get current URL automatically, but exclude OAuth callback URLs
|
|
||||||
const getCurrentUrl = () => {
|
|
||||||
const currentPath = window.location.href
|
|
||||||
|
|
||||||
// If on OAuth callback page, get the stored return URL or use root
|
|
||||||
if (currentPath.includes('/oauth/callback')) {
|
|
||||||
return sessionStorage.getItem('oauth_return_url') || window.location.origin
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove hash fragments for clean URLs
|
|
||||||
return currentPath.split('#')[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentUrl = getCurrentUrl()
|
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (!text.trim()) return
|
if (!text.trim() || !url.trim()) return
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
setError(null)
|
setError(null)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const currentUrl = url.trim()
|
||||||
const timestamp = new Date().toISOString()
|
const timestamp = new Date().toISOString()
|
||||||
|
|
||||||
// Create ai.syui.log record structure (new unified format)
|
// Create ai.syui.log record structure (new unified format)
|
||||||
@ -68,6 +55,7 @@ export default function CommentForm({ user, agent, onCommentPosted, pageContext
|
|||||||
|
|
||||||
// Clear form
|
// Clear form
|
||||||
setText('')
|
setText('')
|
||||||
|
setUrl('')
|
||||||
|
|
||||||
// Notify parent component
|
// Notify parent component
|
||||||
if (onCommentPosted) {
|
if (onCommentPosted) {
|
||||||
@ -98,8 +86,18 @@ export default function CommentForm({ user, agent, onCommentPosted, pageContext
|
|||||||
<h3>コメントを投稿</h3>
|
<h3>コメントを投稿</h3>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="form-group" style={{ marginBottom: '8px', fontSize: '0.9em', color: 'var(--text-secondary)' }}>
|
<div className="form-group">
|
||||||
<span>ページ: {currentUrl}</span>
|
<label htmlFor="comment-url">ページURL:</label>
|
||||||
|
<input
|
||||||
|
id="comment-url"
|
||||||
|
type="url"
|
||||||
|
value={url}
|
||||||
|
onChange={(e) => setUrl(e.target.value)}
|
||||||
|
placeholder="https://syui.ai/posts/example"
|
||||||
|
required
|
||||||
|
disabled={loading}
|
||||||
|
className="form-input"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
|
@ -20,18 +20,11 @@ export default function OAuthCallback({ onAuthSuccess }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
setStatus('認証成功!元のページに戻ります...')
|
setStatus('認証成功!メインページに戻ります...')
|
||||||
|
|
||||||
// 認証前のページを復元するか、ルートページに戻る
|
// 少し待ってからメインページにリダイレクト
|
||||||
const returnUrl = sessionStorage.getItem('oauth_return_url') || '/'
|
|
||||||
sessionStorage.removeItem('oauth_return_url')
|
|
||||||
|
|
||||||
// Clean up URL fragments and normalize
|
|
||||||
const cleanReturnUrl = returnUrl.split('#')[0]
|
|
||||||
|
|
||||||
// 少し待ってから元のページにリダイレクト
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.replace(cleanReturnUrl)
|
window.location.href = '/'
|
||||||
}, 1500)
|
}, 1500)
|
||||||
} else {
|
} else {
|
||||||
setStatus('認証情報が見つかりません')
|
setStatus('認証情報が見つかりません')
|
||||||
|
@ -97,13 +97,6 @@ export class OAuthService {
|
|||||||
async login(handle) {
|
async login(handle) {
|
||||||
await this.initialize()
|
await this.initialize()
|
||||||
|
|
||||||
// Save current URL for return after OAuth
|
|
||||||
const currentUrl = window.location.href
|
|
||||||
// Only save if not already on oauth callback page
|
|
||||||
if (!currentUrl.includes('/oauth/callback')) {
|
|
||||||
sessionStorage.setItem('oauth_return_url', currentUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = isSyuIsHandle(handle) ? this.clients.syu : this.clients.bsky
|
const client = isSyuIsHandle(handle) ? this.clients.syu : this.clients.bsky
|
||||||
const authUrl = await client.authorize(handle, {
|
const authUrl = await client.authorize(handle, {
|
||||||
scope: 'atproto transition:generic'
|
scope: 'atproto transition:generic'
|
||||||
|
Reference in New Issue
Block a user