v1.4.6: 사이트 설정 이미지 저장 흐름·홈 커버 라이트/다크 분리
- 로고 업로드는 파일 URL만 폼에 반영하고 기타 설정 저장 시 DB에 반영 - 메인 화면 커버 라이트·다크 이미지 필드 추가 및 테마별 HomeHero 교체 - home_cover_dark_image_url 마이그레이션 및 미디어 사용 현황 보정
This commit is contained in:
@@ -100,6 +100,7 @@ const mapSiteSettingsRow = (row) => ({
|
||||
copyrightText: row.copyright_text,
|
||||
showPostUpdatedAt: Boolean(row.show_post_updated_at),
|
||||
homeCoverImageUrl: row.home_cover_image_url || '',
|
||||
homeCoverDarkImageUrl: row.home_cover_dark_image_url || '',
|
||||
homeCoverTitle: row.home_cover_title || '',
|
||||
homeCoverText: row.home_cover_text || '',
|
||||
announcementEnabled: Boolean(row.announcement_enabled),
|
||||
@@ -829,6 +830,7 @@ export const updateSiteSettings = async (input) => {
|
||||
copyright_text,
|
||||
show_post_updated_at,
|
||||
home_cover_image_url,
|
||||
home_cover_dark_image_url,
|
||||
home_cover_title,
|
||||
home_cover_text,
|
||||
announcement_enabled,
|
||||
@@ -849,6 +851,7 @@ export const updateSiteSettings = async (input) => {
|
||||
${input.copyrightText},
|
||||
${input.showPostUpdatedAt ? true : false},
|
||||
${input.homeCoverImageUrl || ''},
|
||||
${input.homeCoverDarkImageUrl || ''},
|
||||
${input.homeCoverTitle || ''},
|
||||
${input.homeCoverText || ''},
|
||||
${input.announcementEnabled ? true : false},
|
||||
@@ -869,6 +872,7 @@ export const updateSiteSettings = async (input) => {
|
||||
copyright_text = EXCLUDED.copyright_text,
|
||||
show_post_updated_at = EXCLUDED.show_post_updated_at,
|
||||
home_cover_image_url = EXCLUDED.home_cover_image_url,
|
||||
home_cover_dark_image_url = EXCLUDED.home_cover_dark_image_url,
|
||||
home_cover_title = EXCLUDED.home_cover_title,
|
||||
home_cover_text = EXCLUDED.home_cover_text,
|
||||
announcement_enabled = EXCLUDED.announcement_enabled,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { join } from 'node:path'
|
||||
import { createError, readMultipartFormData } from 'h3'
|
||||
import sharp from 'sharp'
|
||||
import { requireAdminSession } from '../../../../utils/admin-auth'
|
||||
import { updateSiteLogo } from '../../../../repositories/content-repository'
|
||||
import { upsertMediaMetadataCategory } from '../../../../utils/media-library'
|
||||
|
||||
const allowedImageTypes = new Set(['image/jpeg', 'image/png', 'image/webp'])
|
||||
@@ -46,7 +45,7 @@ const createSystemAssetSuffix = () => {
|
||||
/**
|
||||
* 사이트 로고 업로드 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Promise<Object>} 수정된 사이트 설정
|
||||
* @returns {Promise<{ logoUrl: string, faviconUrl: string }>} 업로드된 로고 URL
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdminSession(event)
|
||||
@@ -126,8 +125,8 @@ export default defineEventHandler(async (event) => {
|
||||
await upsertMediaMetadataCategory(logoUrl, '시스템')
|
||||
await upsertMediaMetadataCategory(faviconUrl, '시스템')
|
||||
|
||||
return updateSiteLogo({
|
||||
return {
|
||||
logoUrl,
|
||||
faviconUrl
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -21,6 +21,7 @@ export const adminSiteSettingsInputSchema = z.object({
|
||||
copyrightText: z.string().trim().min(1),
|
||||
showPostUpdatedAt: z.boolean().optional().default(false),
|
||||
homeCoverImageUrl: z.string().trim().max(500).optional().default(''),
|
||||
homeCoverDarkImageUrl: z.string().trim().max(500).optional().default(''),
|
||||
homeCoverTitle: z.string().trim().max(120).optional().default(''),
|
||||
homeCoverText: z.string().trim().max(280).optional().default(''),
|
||||
announcementEnabled: z.boolean().optional().default(false),
|
||||
|
||||
@@ -526,6 +526,34 @@ const getSiteSettingsMediaUsage = (url, siteSettings) => {
|
||||
})
|
||||
}
|
||||
|
||||
if (siteSettings.homeCoverImageUrl === url) {
|
||||
usages.push({
|
||||
type: 'settings',
|
||||
typeLabel: '사이트 설정',
|
||||
id: 'home-cover-light',
|
||||
title: '메인 화면 라이트 이미지',
|
||||
adminUrl: '/admin/settings',
|
||||
publicUrl: '/',
|
||||
status: 'system',
|
||||
location: 'homeCoverImageUrl',
|
||||
label: '메인 화면 라이트 이미지'
|
||||
})
|
||||
}
|
||||
|
||||
if (siteSettings.homeCoverDarkImageUrl === url) {
|
||||
usages.push({
|
||||
type: 'settings',
|
||||
typeLabel: '사이트 설정',
|
||||
id: 'home-cover-dark',
|
||||
title: '메인 화면 다크 이미지',
|
||||
adminUrl: '/admin/settings',
|
||||
publicUrl: '/',
|
||||
status: 'system',
|
||||
location: 'homeCoverDarkImageUrl',
|
||||
label: '메인 화면 다크 이미지'
|
||||
})
|
||||
}
|
||||
|
||||
return usages
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export const getDefaultSiteSettings = () => {
|
||||
copyrightText: `©${new Date().getFullYear()} ${title}`,
|
||||
showPostUpdatedAt: false,
|
||||
homeCoverImageUrl: '',
|
||||
homeCoverDarkImageUrl: '',
|
||||
homeCoverTitle: '',
|
||||
homeCoverText: '',
|
||||
announcementEnabled: false,
|
||||
|
||||
Reference in New Issue
Block a user