공개 상단 어나운스 바와 관리자 맞춤 설정을 추가하고, 스팸 필터에서 가입 금지 닉네임을 관리·검증한다. POST 설정 읽기 모드 비활성 토글과 설정 내비 아이콘 틀을 반영한다. Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
/**
|
|
* 어나운스 바 배경색 프리셋
|
|
* @type {ReadonlyArray<{ id: string, label: string, value: string, textColor: string }>}
|
|
*/
|
|
export const ANNOUNCEMENT_BACKGROUND_PRESETS = [
|
|
{ id: 'black', label: '검정', value: '#15171a', textColor: '#ffffff' },
|
|
{ id: 'white', label: '흰색', value: '#ffffff', textColor: '#15171a' },
|
|
{ id: 'accent', label: '브랜드', value: '#ff4f2e', textColor: '#ffffff' }
|
|
]
|
|
|
|
/** @type {string} 기본 어나운스 바 배경색 */
|
|
export const DEFAULT_ANNOUNCEMENT_BACKGROUND_COLOR = '#15171a'
|
|
|
|
/**
|
|
* 어나운스 바 배경색이 허용 프리셋인지 확인한다.
|
|
* @param {string} value - hex 색상
|
|
* @returns {boolean} 허용 여부
|
|
*/
|
|
export const isValidAnnouncementBackgroundColor = (value) => {
|
|
const normalized = (value || '').trim().toLowerCase()
|
|
return ANNOUNCEMENT_BACKGROUND_PRESETS.some((preset) => preset.value.toLowerCase() === normalized)
|
|
}
|
|
|
|
/**
|
|
* 어나운스 바 배경색에 맞는 전경색을 반환한다.
|
|
* @param {string} backgroundColor - hex 배경색
|
|
* @returns {string} 전경 hex 색상
|
|
*/
|
|
export const getAnnouncementBarTextColor = (backgroundColor) => {
|
|
const normalized = (backgroundColor || '').trim().toLowerCase()
|
|
const preset = ANNOUNCEMENT_BACKGROUND_PRESETS.find((item) => item.value.toLowerCase() === normalized)
|
|
if (preset) {
|
|
return preset.textColor
|
|
}
|
|
|
|
return '#ffffff'
|
|
}
|
|
|
|
/**
|
|
* 어나운스 링크를 정리한다. 빈 값은 링크 미사용.
|
|
* @param {string} url - 입력 URL
|
|
* @returns {string} 정리된 URL 또는 빈 문자열
|
|
*/
|
|
export const normalizeAnnouncementUrl = (url) => {
|
|
const trimmed = (url || '').trim()
|
|
if (!trimmed) {
|
|
return ''
|
|
}
|
|
|
|
if (trimmed.startsWith('/')) {
|
|
return trimmed
|
|
}
|
|
|
|
try {
|
|
const parsed = new URL(trimmed)
|
|
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
|
return parsed.toString()
|
|
}
|
|
} catch {
|
|
return ''
|
|
}
|
|
|
|
return ''
|
|
}
|