관리자 로고 화면에서 그림 만들기 기능을 빼고 보관한 그림으로 정리

This commit is contained in:
블리어 committed 2026-12-01 06:00:05 +00:00
1 parent 5f2e2f6952
commit 9a5c920705
9 files changed
+52 -284

No files matched your search

+2 -8
View File
@@ -101,19 +101,13 @@
<section class="card"><h2>지금 쓰는 로고</h2>
<div class="logo-row"><figure><img id="cur-512" alt="" width="128" height="128"><figcaption>앱 아이콘</figcaption></figure><figure><img id="cur-mask" class="round" alt="" width="96" height="96"><figcaption>둥근 홈 화면</figcaption></figure><figure><img id="cur-logo" class="rounded" alt="" width="40" height="40"><figcaption>홈페이지 로고</figcaption></figure><figure><img id="cur-fav" alt="" width="16" height="16"><figcaption>브라우저 탭</figcaption></figure></div>
<p id="brand-source" class="small"></p></section>
<div class="two-col">
<section class="card"><h2>그림 올리기</h2><p class="small">PNG·JPG·WebP 그림을 고르면 가운데를 정사각형으로 잘라 크기별 아이콘을 만듭니다. 512px 이상인 그림을 권합니다.</p><label>그림 파일<input id="logo-file" type="file" accept="image/png,image/jpeg,image/webp"></label></section>
<section id="gen-card" class="card" hidden><h2>후보 그림 만들기</h2><p id="gen-status" class="small"></p>
<label>그림 설명<textarea id="gen-prompt" rows="6" maxlength="1500"></textarea></label>
<div class="field-row"><label>장수<select id="gen-count"><option value="1">1장</option><option value="2" selected>2장</option><option value="3">3장</option><option value="4">4장</option></select></label><label>모델<input id="gen-model" maxlength="80" autocomplete="off"></label></div>
<div class="action-row"><button id="gen-start">후보 만들기</button><button id="gen-default" type="button" class="secondary">기본 설명으로</button></div><p id="gen-progress" class="small" role="status"></p></section>
</div>
<section class="card"><h2>그림 올리기</h2><p class="small">PNG·JPG·WebP 그림을 고르면 가운데를 정사각형으로 잘라 크기별 아이콘을 만듭니다. 512px 이상인 그림을 권합니다.</p><label>그림 파일<input id="logo-file" type="file" accept="image/png,image/jpeg,image/webp"></label></section>
<section id="apply-card" class="card apply-card" hidden><h2>적용 미리보기</h2>
<div class="logo-row"><figure><canvas id="pv-512" width="512" height="512"></canvas><figcaption>앱 아이콘</figcaption></figure><figure><canvas id="pv-mask" class="round" width="512" height="512"></canvas><figcaption>둥근 홈 화면</figcaption></figure><figure><canvas id="pv-64" class="rounded" width="64" height="64"></canvas><figcaption>홈페이지 로고</figcaption></figure><figure><canvas id="pv-16" width="16" height="16"></canvas><figcaption>브라우저 탭</figcaption></figure></div>
<div class="field-row"><label>확대(가장자리 잘라내기)<input id="apply-zoom" type="range" min="100" max="140" value="100"></label><label>여백<input id="apply-pad" type="range" min="0" max="20" value="0"></label><label>홈 화면 배경색<input id="apply-bg" type="color" value="#26364d"></label></div>
<p class="small">둥근 홈 화면과 아이폰 아이콘은 투명한 곳을 배경색으로 채웁니다. 그림 바깥 모서리가 흰색이면 확대로 잘라 내세요(자동으로 맞춰 둡니다).</p>
<div class="action-row"><button id="apply-save">이 그림으로 바꾸기</button><button id="apply-cancel" type="button" class="secondary">취소</button></div></section>
<section class="card"><h2>로고 후보</h2><p class="small">만든 후보는 최근 40장까지 보관합니다. 고르기를 누르면 위 미리보기에서 확인한 뒤 바꿀 수 있습니다.</p><div id="candidate-grid" class="candidate-grid"></div></section>
<section class="card"><h2>보관한 그림</h2><p class="small">보관해 둔 로고 그림입니다. 고르기를 누르면 위 미리보기에서 확인한 뒤 바꿀 수 있습니다.</p><div id="candidate-grid" class="candidate-grid"></div></section>
</section>
<section id="view-log" class="view" hidden>
+6 -37
View File
@@ -732,7 +732,7 @@ $('comment-next').onclick = () => { boardState.comment.page++; loadComments(); }
// ------------------------------------------------------------ 로고 그림
// 크기별 PNG는 이 브라우저에서 만든다. 서버는 PNG 형식과 크기만 확인해 보관한다.
const brandState = { image: null, source: null, candidate: null, polling: null, defaults: {} };
const brandState = { image: null, source: null, candidate: null };
function refreshLogos() {
const stamp = '?t=' + Date.now();
document.querySelectorAll('img[src^="brand/logo"]').forEach(img => { img.src = 'brand/logo' + stamp; });
@@ -744,34 +744,26 @@ function refreshLogos() {
async function loadBrand() {
let data;
try { data = await api('admin/brand'); } catch (error) { failed(error); return; }
brandState.defaults = { prompt: data.defaultPrompt, model: data.defaultModel };
refreshLogos();
const c = data.custom;
$('brand-source').textContent = c ? (c.source === 'upload' ? '올린 그림' : '고른 후보') + ' · ' + c.by + ' · ' + when(c.updated) : '기본 로고(달력과 초승달)를 쓰고 있습니다.';
$('brand-source').textContent = c ? (c.source === 'upload' ? '올린 그림' : '보관한 그림') + ' · ' + c.by + ' · ' + when(c.updated) : '기본 로고(달력과 초승달)를 쓰고 있습니다.';
$('brand-reset').disabled = !c;
// 그림 만들기 키가 있을 때만 만들기 칸을 보인다. 키가 없으면 후보는 운영 도구로 넣는다.
$('gen-card').hidden = !data.gemini;
$('gen-status').textContent = data.gemini ? '설명을 고쳐 바로 후보를 만들 수 있습니다(장당 비용).' : '';
$('gen-start').disabled = !data.gemini || Boolean(brandState.polling);
if (!$('gen-prompt').value) $('gen-prompt').value = data.defaultPrompt;
if (!$('gen-model').value) $('gen-model').value = data.defaultModel;
const grid = $('candidate-grid');
grid.replaceChildren();
for (const row of data.candidates) {
const card = el('div', null, 'candidate');
const img = el('img'); img.alt = '로고 후보'; img.loading = 'lazy'; img.src = 'api/admin/brand-candidate/' + row.id;
const img = el('img'); img.alt = '보관한 로고 그림'; img.loading = 'lazy'; img.src = 'api/admin/brand-candidate/' + row.id;
const pick = el('button', '고르기'); pick.onclick = () => openApply('api/admin/brand-candidate/' + row.id, 'candidate', row.id);
const remove = el('button', '지우기', 'secondary');
remove.onclick = async () => {
if (!await confirmAction('이 후보 그림을 지울까요?', '지우기')) return;
if (!await confirmAction('이 그림을 보관한 그림에서 지울까요?', '지우기')) return;
try { await api('admin/brand-candidate-delete/' + row.id, {}); loadBrand(); } catch (error) { failed(error); }
};
const actions = el('div', null, 'action-row'); actions.append(pick, remove);
card.append(img, el('p', when(row.created) + (row.actor ? ' · ' + row.actor : '')), actions);
grid.append(card);
}
if (!data.candidates.length) grid.append(el('p', '아직 만든 후보가 없습니다.', 'small'));
if (data.running.length && !brandState.polling) pollJob(data.running[0].id);
if (!data.candidates.length) grid.append(el('p', '보관한 그림이 없습니다.', 'small'));
}
function loadImage(src) {
return new Promise((resolve, reject) => {
@@ -781,7 +773,7 @@ function loadImage(src) {
img.src = src;
});
}
// 후보 그림처럼 둥근 사각형 바깥 모서리가 흰색이면 모서리와 가장자리 가운데 색이 다르다.
// 둥근 사각형 그림의 바깥 모서리가 흰색이면 모서리와 가장자리 가운데 색이 다르다.
// 그때는 16% 확대해 모서리를 잘라 내고 배경색은 가장자리 가운데 색으로 맞춘다.
function autoFit(img) {
const canvas = document.createElement('canvas'); canvas.width = canvas.height = 100;
@@ -879,29 +871,6 @@ $('brand-reset').onclick = async () => {
if (!await confirmAction('올린 로고를 지우고 기본 로고(달력과 초승달)로 되돌릴까요?', '기본 로고로')) return;
try { await api('admin/brand-logo-reset', {}); notify('기본 로고로 되돌렸습니다.'); loadBrand(); } catch (error) { failed(error); }
};
$('gen-default').onclick = () => { $('gen-prompt').value = brandState.defaults.prompt || ''; $('gen-model').value = brandState.defaults.model || ''; };
$('gen-start').onclick = async () => {
const count = Number($('gen-count').value);
try {
const result = await api('admin/brand-generate', { prompt: $('gen-prompt').value.trim(), model: $('gen-model').value.trim(), count });
pollJob(result.job);
} catch (error) { failed(error); }
};
function pollJob(id) {
$('gen-start').disabled = true;
$('gen-progress').textContent = '후보를 만드는 중입니다. 한 장에 10~40초쯤 걸립니다.';
clearInterval(brandState.polling);
brandState.polling = setInterval(async () => {
let job;
try { job = await api('admin/brand-job/' + id); } catch (error) { clearInterval(brandState.polling); brandState.polling = null; $('gen-progress').textContent = error.message; $('gen-start').disabled = false; return; }
$('gen-progress').textContent = job.count + '장 중 ' + job.made + '장 완료' + (job.errors.length ? ' · 실패: ' + job.errors[job.errors.length - 1] : '');
if (job.state !== 'running') {
clearInterval(brandState.polling); brandState.polling = null;
if (job.state === 'done') notify(job.made + '장을 만들었습니다. 아래 후보에서 고르세요.');
loadBrand();
}
}, 3000);
}
// ------------------------------------------------------------ 작업 기록
async function loadLog() {