fix build

This commit is contained in:
songtianlun 2025-07-30 17:06:44 +08:00
parent 012d8756d8
commit 4180300ab1
6 changed files with 48 additions and 51 deletions

View File

@ -97,9 +97,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
// 模拟 AI API 调用
async function runAITest({
content,
model,
temperature: _temperature,
maxTokens: _maxTokens
model
}: {
content: string
model: string

View File

@ -3,7 +3,7 @@ import { prisma } from '@/lib/prisma'
import { createServerSupabaseClient } from '@/lib/supabase-server'
// POST /api/users/sync - 同步Supabase用户到Prisma数据库
export async function POST(request: NextRequest) {
export async function POST(_request: NextRequest) {
try {
const supabase = await createServerSupabaseClient()
const { data: { user: supabaseUser }, error: authError } = await supabase.auth.getUser()
@ -64,7 +64,7 @@ export async function POST(request: NextRequest) {
}
// GET /api/users/sync - 获取当前用户信息
export async function GET(request: NextRequest) {
export async function GET(_request: NextRequest) {
try {
const supabase = await createServerSupabaseClient()
const { data: { user: supabaseUser }, error: authError } = await supabase.auth.getUser()

View File

@ -1,6 +1,6 @@
'use client'
import { useState, useEffect } from 'react'
import { useState, useEffect, useCallback } from 'react'
import { useTranslations } from 'next-intl'
import { useAuth } from '@/hooks/useAuth'
import { createClient } from '@/lib/supabase'
@ -57,10 +57,7 @@ export default function ProfilePage() {
const supabase = createClient()
useEffect(() => {
if (!user) return
const loadProfile = async () => {
const loadProfile = useCallback(async () => {
setProfileLoading(true)
try {
// Get user metadata and profile data
@ -93,10 +90,12 @@ export default function ProfilePage() {
} finally {
setProfileLoading(false)
}
}
}, [supabase, t])
useEffect(() => {
if (!user) return
loadProfile()
}, [user, supabase, t])
}, [user, loadProfile])
const updateProfile = async (field: string, value: string) => {
if (!user) return

View File

@ -81,7 +81,7 @@ export default function PromptPage({ params }: PromptPageProps) {
const processedData = {
...data,
tags: Array.isArray(data.tags)
? data.tags.map((tag: any) => typeof tag === 'string' ? tag : tag.name || '')
? data.tags.map((tag: string | { name: string }) => typeof tag === 'string' ? tag : tag.name || '')
: []
}
setPrompt(processedData)
@ -273,8 +273,8 @@ export default function PromptPage({ params }: PromptPageProps) {
<p className="text-xs text-muted-foreground mt-1 line-clamp-2">{prompt?.description || ''}</p>
<div className="flex items-center mt-2 space-x-2">
{prompt?.tags?.slice(0, 1).map((tag) => (
<span key={typeof tag === 'string' ? tag : (tag as any)?.name || ''} className="inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-primary/10 text-primary rounded">
{typeof tag === 'string' ? tag : (tag as any)?.name || ''}
<span key={typeof tag === 'string' ? tag : (tag as { name: string })?.name || ''} className="inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-primary/10 text-primary rounded">
{typeof tag === 'string' ? tag : (tag as { name: string })?.name || ''}
</span>
))}
{prompt?.tags && prompt.tags.length > 1 && (
@ -349,7 +349,7 @@ export default function PromptPage({ params }: PromptPageProps) {
</div>
<div className="pt-2 border-t border-border">
<div className="flex flex-wrap gap-1">
{prompt?.tags?.map((tag: any) => {
{prompt?.tags?.map((tag: string | { name: string }) => {
const tagName = typeof tag === 'string' ? tag : tag?.name || '';
return (
<span

View File

@ -55,7 +55,7 @@ export function EditPromptModal({
setDescription(prompt.description || '')
// 确保tags是字符串数组
const processedTags = Array.isArray(prompt.tags)
? prompt.tags.map((tag: any) => typeof tag === 'string' ? tag : tag.name || '')
? prompt.tags.map((tag: string | { name: string }) => typeof tag === 'string' ? tag : tag.name || '')
: []
setTags(processedTags)
fetchAvailableTags()

View File

@ -11,7 +11,7 @@ export function useAuth() {
useEffect(() => {
// 同步用户到Prisma数据库
const syncUser = async (_userData: User) => {
const syncUser = async () => {
try {
await fetch('/api/users/sync', {
method: 'POST',
@ -25,7 +25,7 @@ export function useAuth() {
const getUser = async () => {
const { data: { user: userData } } = await supabase.auth.getUser()
if (userData) {
await syncUser(userData)
await syncUser()
}
setUser(userData)
setLoading(false)
@ -36,7 +36,7 @@ export function useAuth() {
const { data: { subscription } } = supabase.auth.onAuthStateChange(async (event, session) => {
const userData = session?.user ?? null
if (userData && (event === 'SIGNED_IN' || event === 'TOKEN_REFRESHED')) {
await syncUser(userData)
await syncUser()
}
setUser(userData)
setLoading(false)