fix: profile photo upload field name mismatch ('file'→'photo'), sitemap auto-run only on CLI

This commit is contained in:
2026-05-09 13:55:22 +08:00
parent 7094e05227
commit 11d944bef2
2 changed files with 11 additions and 8 deletions
+3 -3
View File
@@ -72,7 +72,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId }: ProfilePh
setPreviewUrl(objectUrl)
const formData = new FormData()
formData.append("file", file)
formData.append("photo", file)
try {
const res = await fetch("/api/user/profile-photo", {
@@ -86,8 +86,8 @@ export function ProfilePhotoUpload({ currentImage, userName, userId }: ProfilePh
}
const data = await res.json()
if (data.imageUrl) {
setPreviewUrl(data.imageUrl)
if (data.url) {
setPreviewUrl(data.url)
cleanupTempUrl()
}
setUploadState("success")
+4 -1
View File
@@ -166,10 +166,13 @@ async function generateSitemaps() {
console.log(`Sitemaps generated successfully! Total URLs: ${staticEntries.length + allDynamicEntries.length}`)
}
// Run if called directly
// Run if called directly (CLI execution, not module import)
const isCliRun = typeof process !== "undefined" && process.argv?.[1]?.includes("generate-static")
if (isCliRun) {
generateSitemaps().catch((err) => {
console.error("Failed to generate sitemaps:", err)
process.exit(1)
})
}
export { generateSitemaps }