memi-board 0.62.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +1,80 @@
1
1
  <script setup lang="ts">
2
- import { computed, onBeforeUnmount, ref, watch } from 'vue'
2
+ import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue'
3
3
  import { Cropper } from 'vue-advanced-cropper'
4
4
  import 'vue-advanced-cropper/dist/style.css'
5
5
  import { useMemiBoardBannerGeneration, useMemiBoardI18n } from 'memi-board/runtime'
6
- import type { BoardBanner } from 'memi-board/runtime'
6
+ import type { BoardBanner, BoardBannerKind } from 'memi-board/runtime'
7
7
 
8
- const props = defineProps<{ banner?: BoardBanner | null, disabled?: boolean, boardId: string, title: string, description?: string }>()
9
- const emit = defineEmits<{ change: [file: File | null], busy: [value: boolean] }>()
8
+ const props = defineProps<{
9
+ banner?: BoardBanner | null
10
+ mobileBanner?: BoardBanner | null
11
+ disabled?: boolean
12
+ boardId: string
13
+ title: string
14
+ description?: string
15
+ }>()
16
+ const emit = defineEmits<{ change: [kind: BoardBannerKind, file: File | null], busy: [value: boolean] }>()
10
17
  const { t, aiEnabled } = useMemiBoardI18n()
11
18
  const { generateBanner } = useMemiBoardBannerGeneration()
12
- const generating = ref(false)
19
+
20
+ /** Output size and crop ratio for each banner slot. */
21
+ const SLOTS: Record<BoardBannerKind, { width: number, height: number, aspect: string }> = {
22
+ desktop: { width: 2400, height: 300, aspect: 'aspect-[8/1]' },
23
+ mobile: { width: 1200, height: 400, aspect: 'aspect-[3/1]' },
24
+ }
25
+ const KINDS: BoardBannerKind[] = ['desktop', 'mobile']
26
+
27
+ const generating = ref<BoardBannerKind | null>(null)
13
28
  const additionalRequest = ref('')
14
29
  let disposed = false
15
- const busy = computed(() => props.disabled || generating.value)
30
+ const busy = computed(() => props.disabled || generating.value !== null)
16
31
  const input = ref<HTMLInputElement | null>(null)
17
32
  const cropper = ref<InstanceType<typeof Cropper> | null>(null)
18
33
  const open = ref(false)
34
+ const activeKind = ref<BoardBannerKind>('desktop')
19
35
  const source = ref('')
20
- const localPreview = ref<string | null>(null)
36
+ /** undefined = saved image, '' = removed, blob URL = staged image. */
37
+ const localPreview = reactive<Record<BoardBannerKind, string | undefined>>({ desktop: undefined, mobile: undefined })
21
38
  const cropPreview = ref('')
22
39
  const processing = ref(false)
23
40
  const error = ref('')
24
- const preview = computed(() => localPreview.value ?? props.banner?.url ?? '')
41
+ const activeSlot = computed(() => SLOTS[activeKind.value])
42
+
43
+ function savedUrl(kind: BoardBannerKind) {
44
+ return (kind === 'desktop' ? props.banner : props.mobileBanner)?.url ?? ''
45
+ }
46
+ function previewOf(kind: BoardBannerKind) {
47
+ return localPreview[kind] ?? savedUrl(kind)
48
+ }
25
49
 
26
50
  function releaseSource() {
27
51
  if (source.value) URL.revokeObjectURL(source.value)
28
52
  source.value = ''
29
53
  cropPreview.value = ''
30
54
  }
31
- function releasePreview() {
32
- if (localPreview.value) URL.revokeObjectURL(localPreview.value)
33
- localPreview.value = null
55
+ function releasePreview(kind: BoardBannerKind) {
56
+ const url = localPreview[kind]
57
+ if (url) URL.revokeObjectURL(url)
58
+ localPreview[kind] = undefined
34
59
  }
35
- watch(() => props.banner, releasePreview)
60
+ watch(() => props.banner, () => releasePreview('desktop'))
61
+ watch(() => props.mobileBanner, () => releasePreview('mobile'))
36
62
  watch(open, value => { if (!value) releaseSource() })
37
63
  onBeforeUnmount(() => {
38
64
  disposed = true
39
65
  if (generating.value) emit('busy', false)
40
66
  releaseSource()
41
- releasePreview()
67
+ KINDS.forEach(releasePreview)
42
68
  })
43
69
 
44
- async function generate() {
70
+ function openCrop(kind: BoardBannerKind, blob: Blob) {
71
+ releaseSource()
72
+ activeKind.value = kind
73
+ source.value = URL.createObjectURL(blob)
74
+ open.value = true
75
+ }
76
+
77
+ async function generate(kind: BoardBannerKind) {
45
78
  if (busy.value || !aiEnabled.value) return
46
79
  error.value = ''
47
80
  if (!props.title.trim()) {
@@ -49,17 +82,15 @@ async function generate() {
49
82
  return
50
83
  }
51
84
  const context = { boardId: props.boardId, title: props.title, description: props.description ?? '', additionalRequest: additionalRequest.value }
52
- generating.value = true
85
+ generating.value = kind
53
86
  emit('busy', true)
54
87
  try {
55
- const blob = await generateBanner(context)
88
+ const blob = await generateBanner({ ...context, kind })
56
89
  if (disposed) return
57
90
  if (props.boardId !== context.boardId || props.title !== context.title || (props.description ?? '') !== context.description || additionalRequest.value !== context.additionalRequest) {
58
91
  throw new Error(t('settings.banner.contextChanged'))
59
92
  }
60
- releaseSource()
61
- source.value = URL.createObjectURL(blob)
62
- open.value = true
93
+ openCrop(kind, blob)
63
94
  }
64
95
  catch (cause) {
65
96
  if (!disposed) {
@@ -69,11 +100,16 @@ async function generate() {
69
100
  }
70
101
  }
71
102
  finally {
72
- generating.value = false
103
+ generating.value = null
73
104
  if (!disposed) emit('busy', false)
74
105
  }
75
106
  }
76
107
 
108
+ function pick(kind: BoardBannerKind) {
109
+ activeKind.value = kind
110
+ input.value?.click()
111
+ }
112
+
77
113
  function select(event: Event) {
78
114
  const target = event.target as HTMLInputElement
79
115
  const file = target.files?.[0]
@@ -84,17 +120,16 @@ function select(event: Event) {
84
120
  error.value = t('settings.banner.invalid')
85
121
  return
86
122
  }
87
- releaseSource()
88
- source.value = URL.createObjectURL(file)
89
- open.value = true
123
+ openCrop(activeKind.value, file)
90
124
  }
91
125
 
92
126
  function updatePreview({ canvas }: { canvas?: HTMLCanvasElement | null }) {
93
127
  if (!canvas) return
128
+ const { width, height } = activeSlot.value
94
129
  const thumbnail = document.createElement('canvas')
95
- thumbnail.width = 960
96
- thumbnail.height = 120
97
- thumbnail.getContext('2d')?.drawImage(canvas, 0, 0, 960, 120)
130
+ thumbnail.width = width / 2.5
131
+ thumbnail.height = height / 2.5
132
+ thumbnail.getContext('2d')?.drawImage(canvas, 0, 0, thumbnail.width, thumbnail.height)
98
133
  cropPreview.value = thumbnail.toDataURL('image/jpeg', 0.8)
99
134
  }
100
135
 
@@ -102,23 +137,25 @@ async function confirm() {
102
137
  if (processing.value || props.disabled) return
103
138
  const { canvas } = cropper.value?.getResult() ?? {}
104
139
  if (!canvas) return
140
+ const kind = activeKind.value
141
+ const { width, height } = SLOTS[kind]
105
142
  processing.value = true
106
143
  error.value = ''
107
144
  try {
108
145
  const output = document.createElement('canvas')
109
- output.width = 2400
110
- output.height = 300
146
+ output.width = width
147
+ output.height = height
111
148
  const ctx = output.getContext('2d')
112
149
  if (!ctx) throw new Error('Canvas unavailable')
113
150
  ctx.fillStyle = '#fff'
114
- ctx.fillRect(0, 0, output.width, output.height)
115
- ctx.drawImage(canvas, 0, 0, output.width, output.height)
151
+ ctx.fillRect(0, 0, width, height)
152
+ ctx.drawImage(canvas, 0, 0, width, height)
116
153
  const blob = await new Promise<Blob | null>(resolve => output.toBlob(resolve, 'image/jpeg', 0.9))
117
154
  if (!blob) throw new Error('Image encoding failed')
118
- const file = new File([blob], 'banner.jpg', { type: 'image/jpeg' })
119
- releasePreview()
120
- localPreview.value = URL.createObjectURL(file)
121
- emit('change', file)
155
+ const file = new File([blob], `banner-${kind}.jpg`, { type: 'image/jpeg' })
156
+ releasePreview(kind)
157
+ localPreview[kind] = URL.createObjectURL(file)
158
+ emit('change', kind, file)
122
159
  open.value = false
123
160
  }
124
161
  catch {
@@ -127,23 +164,19 @@ async function confirm() {
127
164
  finally { processing.value = false }
128
165
  }
129
166
 
130
- function remove() {
131
- releasePreview()
132
- localPreview.value = ''
133
- emit('change', null)
167
+ function remove(kind: BoardBannerKind) {
168
+ releasePreview(kind)
169
+ localPreview[kind] = ''
170
+ emit('change', kind, null)
134
171
  }
135
172
  </script>
136
173
 
137
174
  <template>
138
- <section class="flex flex-col gap-3">
175
+ <section class="flex flex-col gap-4">
139
176
  <div>
140
177
  <p class="text-sm font-medium">{{ t('settings.banner.label') }}</p>
141
178
  <p class="mt-1 text-xs leading-relaxed text-muted">{{ t('settings.banner.help') }}</p>
142
179
  </div>
143
- <img v-if="preview" :src="preview" :alt="t('settings.banner.preview')" width="2400" height="300" class="aspect-[8/1] w-full rounded-xl border border-default object-cover">
144
- <div v-else class="flex aspect-[8/1] items-center justify-center rounded-xl border border-dashed border-default bg-elevated/40" aria-hidden="true">
145
- <UIcon name="i-lucide-image" class="size-6 text-dimmed" />
146
- </div>
147
180
  <UFormField v-if="aiEnabled" :label="t('settings.banner.requestLabel')" :description="t('settings.banner.requestHelp')">
148
181
  <UTextarea
149
182
  v-model="additionalRequest"
@@ -156,15 +189,35 @@ function remove() {
156
189
  autoresize
157
190
  />
158
191
  </UFormField>
159
- <div class="flex flex-wrap gap-2">
160
- <input ref="input" type="file" accept="image/jpeg,image/png,image/webp" class="hidden" :disabled="busy" :aria-label="t('settings.banner.select')" @change="select">
161
- <UButton icon="i-lucide-image-plus" color="neutral" variant="outline" size="sm" :disabled="busy" :label="t('settings.banner.select')" @click="input?.click()" />
162
- <UButton v-if="aiEnabled" icon="i-lucide-sparkles" color="primary" variant="soft" size="sm" :loading="generating" :disabled="busy || !title.trim()" :label="t('settings.banner.generate')" @click="generate" />
163
- <UButton v-if="preview" icon="i-lucide-trash-2" color="neutral" variant="ghost" size="sm" :disabled="busy" :label="t('settings.banner.remove')" @click="remove" />
192
+ <input ref="input" type="file" accept="image/jpeg,image/png,image/webp" class="hidden" :disabled="busy" :aria-label="t('settings.banner.select')" @change="select">
193
+ <div v-for="kind in KINDS" :key="kind" class="flex flex-col gap-2">
194
+ <div class="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5">
195
+ <p class="text-sm font-medium">{{ t(`settings.banner.${kind}`) }}</p>
196
+ <p class="text-xs text-muted">{{ t(`settings.banner.${kind}Help`) }}</p>
197
+ </div>
198
+ <div :class="kind === 'mobile' ? 'w-full max-w-sm' : 'w-full'">
199
+ <img
200
+ v-if="previewOf(kind)"
201
+ :src="previewOf(kind)"
202
+ :alt="t('settings.banner.preview')"
203
+ :width="SLOTS[kind].width"
204
+ :height="SLOTS[kind].height"
205
+ class="w-full rounded-xl border border-default object-cover"
206
+ :class="SLOTS[kind].aspect"
207
+ >
208
+ <div v-else class="flex items-center justify-center rounded-xl border border-dashed border-default bg-elevated/40" :class="SLOTS[kind].aspect" aria-hidden="true">
209
+ <UIcon :name="kind === 'mobile' ? 'i-lucide-smartphone' : 'i-lucide-monitor'" class="size-6 text-dimmed" />
210
+ </div>
211
+ </div>
212
+ <div class="flex flex-wrap gap-2">
213
+ <UButton icon="i-lucide-image-plus" color="neutral" variant="outline" size="sm" :disabled="busy" :label="t('settings.banner.select')" @click="pick(kind)" />
214
+ <UButton v-if="aiEnabled" icon="i-lucide-sparkles" color="primary" variant="soft" size="sm" :loading="generating === kind" :disabled="busy || !title.trim()" :label="t('settings.banner.generate')" @click="generate(kind)" />
215
+ <UButton v-if="previewOf(kind)" icon="i-lucide-trash-2" color="neutral" variant="ghost" size="sm" :disabled="busy" :label="t('settings.banner.remove')" @click="remove(kind)" />
216
+ </div>
164
217
  </div>
165
218
  <p v-if="aiEnabled" class="text-xs text-muted">{{ generating ? t('settings.banner.generating') : t('settings.banner.generateHelp') }}</p>
166
219
  <p v-if="error" role="alert" class="text-sm text-error">{{ error }}</p>
167
- <UModal v-model:open="open" :title="t('settings.banner.crop')" :description="t('settings.banner.help')" :dismissible="!processing" :ui="{ content: 'sm:max-w-3xl' }">
220
+ <UModal v-model:open="open" :title="`${t('settings.banner.crop')} · ${t(`settings.banner.${activeKind}`)}`" :description="t(`settings.banner.${activeKind}Help`)" :dismissible="!processing" :ui="{ content: 'sm:max-w-3xl' }">
168
221
  <template #body>
169
222
  <ClientOnly>
170
223
  <Cropper
@@ -172,8 +225,8 @@ function remove() {
172
225
  ref="cropper"
173
226
  :src="source"
174
227
  class="h-72 w-full overflow-hidden rounded-xl bg-muted sm:h-96"
175
- :stencil-props="{ aspectRatio: 8 }"
176
- :canvas="{ maxWidth: 2400, maxHeight: 300 }"
228
+ :stencil-props="{ aspectRatio: activeSlot.width / activeSlot.height }"
229
+ :canvas="{ maxWidth: activeSlot.width, maxHeight: activeSlot.height }"
177
230
  image-restriction="stencil"
178
231
  @change="updatePreview"
179
232
  @error="error = t('settings.banner.failed')"
@@ -185,7 +238,7 @@ function remove() {
185
238
  </div>
186
239
  <p v-if="error" role="alert" class="mt-3 text-sm text-error">{{ error }}</p>
187
240
  <p class="mb-2 mt-4 text-xs font-medium text-muted">{{ t('settings.banner.preview') }}</p>
188
- <img v-if="cropPreview" :src="cropPreview" :alt="t('settings.banner.preview')" class="aspect-[8/1] w-full rounded-lg object-cover">
241
+ <img v-if="cropPreview" :src="cropPreview" :alt="t('settings.banner.preview')" class="w-full rounded-lg object-cover" :class="[activeSlot.aspect, activeKind === 'mobile' ? 'max-w-sm' : '']">
189
242
  </template>
190
243
  <template #footer>
191
244
  <div class="flex w-full justify-end gap-2">
@@ -3,7 +3,7 @@ import MemiBoardSurface from './BoardSurface.vue'
3
3
  import { useMemiBoardStorage } from 'memi-board/storage'
4
4
  import { computed, onMounted, ref, watch } from 'vue'
5
5
  import { boardCopyIsTranslated, boardTranslationLocales, MEMI_BOARD_LOCALES, memiBoardEnabledLocales, useMemiBoardAuth, useMemiBoardPostTranslations, useMemiBoardI18n, useMemiBoardSettings, useMemiBoardUsers } from 'memi-board/runtime'
6
- import type { BoardCategory, BoardEditorType, BoardListView, BoardVisibility, BoardWriteRole } from 'memi-board/runtime'
6
+ import type { BoardBannerFiles, BoardCategory, BoardEditorType, BoardListView, BoardVisibility, BoardWriteRole } from 'memi-board/runtime'
7
7
  import MemiBoardCustomFieldEditor from './CustomFieldEditor.vue'
8
8
  import MemiBoardOptionCards from './OptionCards.vue'
9
9
  import MemiBoardBannerEditor from './BannerEditor.vue'
@@ -107,8 +107,8 @@ const translatedDraft = ref(false)
107
107
  const saved = ref(false)
108
108
  const error = ref('')
109
109
  const bannerBusy = ref(false)
110
- const bannerFile = ref<File | null | undefined>()
111
- const { uploadBoardBanner, deleteAttachment } = useMemiBoardStorage()
110
+ const bannerFiles = ref<BoardBannerFiles>({})
111
+ const { applyBoardBannerFiles, deleteAttachment } = useMemiBoardStorage()
112
112
 
113
113
  function emptyDraft(id: string): BoardCategory {
114
114
  return {
@@ -159,7 +159,7 @@ function toDraft(category: BoardCategory): BoardCategory {
159
159
  // 카테고리 전환·최초 로드 시에만 draft를 서버 값으로 맞춘다.
160
160
  // 저장 직후 onSnapshot 갱신으로 draft.description 이 비워지거나 입력 중이던 값이 덮이지 않게 한다.
161
161
  watch(() => props.categoryId, (id) => {
162
- bannerFile.value = undefined
162
+ bannerFiles.value = {}
163
163
  translatedDraft.value = false
164
164
  if (source.value) draft.value = toDraft(source.value)
165
165
  else if (canCreate.value) draft.value = emptyDraft(id)
@@ -219,7 +219,7 @@ async function save() {
219
219
  saved.value = false
220
220
  error.value = ''
221
221
  const snapshot = { ...draft.value, autoTranslate: draft.value.autoTranslate === true }
222
- let uploadedPath: string | undefined
222
+ let uploadedPaths: string[] = []
223
223
  let translateFailed = false
224
224
  if (translationEnabled.value && snapshot.autoTranslate) {
225
225
  try {
@@ -236,12 +236,9 @@ async function save() {
236
236
  }
237
237
  try {
238
238
  const order = isNew.value ? categories.value.length : (snapshot.order ?? 0)
239
- if (bannerFile.value !== undefined) {
240
- snapshot.banner = bannerFile.value ? await uploadBoardBanner(snapshot.id, bannerFile.value) : null
241
- uploadedPath = snapshot.banner?.path
242
- }
239
+ uploadedPaths = await applyBoardBannerFiles(snapshot, bannerFiles.value)
243
240
  await saveCategory(snapshot, order)
244
- bannerFile.value = undefined
241
+ bannerFiles.value = {}
245
242
  snapshot.order = order
246
243
  snapshot.visibilityTransition = undefined
247
244
  // 저장 성공 직후 draft 유지 (스냅샷 오기 전에 watch가 비우지 않도록)
@@ -252,7 +249,7 @@ async function save() {
252
249
  if (translateFailed) error.value = t('settings.autoTranslate.failed', { count: translationCount(snapshot) })
253
250
  }
254
251
  catch (cause) {
255
- if (uploadedPath) await deleteAttachment({ path: uploadedPath }).catch(() => {})
252
+ await Promise.all(uploadedPaths.map(path => deleteAttachment({ path }).catch(() => {})))
256
253
  error.value = cause instanceof Error ? cause.message : t('settings.error.saveFailed')
257
254
  }
258
255
  finally {
@@ -278,12 +275,13 @@ async function save() {
278
275
  <MemiBoardBannerEditor
279
276
  :key="draft.id"
280
277
  :banner="draft.banner"
278
+ :mobile-banner="draft.mobileBanner"
281
279
  :board-id="draft.id"
282
280
  :title="draft.label"
283
281
  :description="draft.description"
284
282
  @busy="bannerBusy = $event"
285
283
  :disabled="saving || translating"
286
- @change="bannerFile = $event; saved = false"
284
+ @change="(kind, file) => { bannerFiles = { ...bannerFiles, [kind]: file }; saved = false }"
287
285
  />
288
286
  <div class="grid gap-2 sm:grid-cols-[9rem_1fr] sm:items-center">
289
287
  <div><p class="text-sm font-medium">{{ t('settings.id.label') }}</p><p class="text-xs text-muted">{{ t('settings.id.help') }}</p></div>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { ref } from 'vue'
2
3
  import { CUSTOM_FIELD_LABEL_MAX, CUSTOM_FIELD_MAX, CUSTOM_FIELD_PLACEHOLDER_MAX, useMemiBoardI18n } from 'memi-board/runtime'
3
4
  import type { BoardCustomField } from 'memi-board/runtime'
4
5
 
@@ -12,6 +13,44 @@ function add() {
12
13
  emit('dirty')
13
14
  }
14
15
 
16
+ function move(from: number, to: number) {
17
+ if (from === to || to < 0 || to >= fields.value.length) return
18
+ const next = [...fields.value]
19
+ const [field] = next.splice(from, 1)
20
+ next.splice(to, 0, field!)
21
+ fields.value = next
22
+ emit('dirty')
23
+ }
24
+
25
+ /** Rows are draggable only while the grip is pressed, so text in the inputs stays selectable. */
26
+ const armed = ref<number | null>(null)
27
+ const dragging = ref<number | null>(null)
28
+ const over = ref<number | null>(null)
29
+
30
+ function dragStart(event: DragEvent, index: number) {
31
+ dragging.value = index
32
+ event.dataTransfer?.setData('text/plain', String(index))
33
+ if (event.dataTransfer) event.dataTransfer.effectAllowed = 'move'
34
+ }
35
+
36
+ function dragOver(event: DragEvent, index: number) {
37
+ if (dragging.value === null) return
38
+ event.preventDefault()
39
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'move'
40
+ over.value = index
41
+ }
42
+
43
+ function drop(index: number) {
44
+ if (dragging.value !== null) move(dragging.value, index)
45
+ dragEnd()
46
+ }
47
+
48
+ function dragEnd() {
49
+ armed.value = null
50
+ dragging.value = null
51
+ over.value = null
52
+ }
53
+
15
54
  function remove(index: number) {
16
55
  fields.value = fields.value.filter((_, item) => item !== index)
17
56
  emit('dirty')
@@ -25,6 +64,7 @@ function remove(index: number) {
25
64
  <p class="text-xs text-muted">{{ t('settings.customFields.help') }}</p>
26
65
  </div>
27
66
  <div v-if="fields.length" class="hidden gap-2 text-xs text-muted sm:flex">
67
+ <span class="w-8 shrink-0" />
28
68
  <div class="grid min-w-0 flex-1 grid-cols-3 gap-2">
29
69
  <span>{{ t('settings.customFields.key') }}</span>
30
70
  <span>{{ t('settings.customFields.name') }}</span>
@@ -32,7 +72,51 @@ function remove(index: number) {
32
72
  </div>
33
73
  <span class="w-8 shrink-0" />
34
74
  </div>
35
- <div v-for="(field, index) in fields" :key="index" class="flex items-center gap-2">
75
+ <div
76
+ v-for="(field, index) in fields"
77
+ :key="index"
78
+ class="flex items-center gap-2 rounded-md transition-opacity"
79
+ :class="[dragging === index ? 'opacity-40' : '', over === index && dragging !== null && dragging !== index ? 'ring-2 ring-primary/50' : '']"
80
+ :draggable="armed === index"
81
+ @dragstart="dragStart($event, index)"
82
+ @dragover="dragOver($event, index)"
83
+ @dragleave="over === index && (over = null)"
84
+ @drop.prevent="drop(index)"
85
+ @dragend="dragEnd"
86
+ >
87
+ <div class="flex shrink-0 flex-col sm:hidden">
88
+ <UButton
89
+ icon="i-lucide-chevron-up"
90
+ color="neutral"
91
+ variant="ghost"
92
+ size="xs"
93
+ :disabled="index === 0"
94
+ :aria-label="t('settings.customFields.moveUp')"
95
+ @click="move(index, index - 1)"
96
+ />
97
+ <UButton
98
+ icon="i-lucide-chevron-down"
99
+ color="neutral"
100
+ variant="ghost"
101
+ size="xs"
102
+ :disabled="index === fields.length - 1"
103
+ :aria-label="t('settings.customFields.moveDown')"
104
+ @click="move(index, index + 1)"
105
+ />
106
+ </div>
107
+ <UTooltip :text="t('settings.customFields.drag')" :delay-duration="200">
108
+ <UButton
109
+ class="hidden shrink-0 cursor-grab active:cursor-grabbing sm:inline-flex"
110
+ icon="i-lucide-grip-vertical"
111
+ color="neutral"
112
+ variant="ghost"
113
+ :aria-label="t('settings.customFields.drag')"
114
+ @pointerdown="armed = index"
115
+ @pointerup="dragging === null && (armed = null)"
116
+ @keydown.up.prevent="move(index, index - 1)"
117
+ @keydown.down.prevent="move(index, index + 1)"
118
+ />
119
+ </UTooltip>
36
120
  <div class="grid min-w-0 flex-1 grid-cols-1 gap-2 sm:grid-cols-3">
37
121
  <UInput
38
122
  v-model="field.key"
@@ -191,6 +191,14 @@ onBeforeUnmount(() => {
191
191
  if (clock) clearInterval(clock)
192
192
  })
193
193
  // 카테고리 설정값은 게시판을 처음 열 때 보여줄 방식일 뿐 — 화면에서 자유롭게 바꿔 볼 수 있다.
194
+ /** Phone (3:1) and desktop (8:1) banners; each falls back to the other when only one is set. */
195
+ const listBanner = computed(() => {
196
+ const board = getBoard(resolvedBoardId.value)
197
+ const desktop = board?.banner?.url || board?.mobileBanner?.url
198
+ const mobile = board?.mobileBanner?.url || desktop
199
+ return desktop && mobile ? { desktop, mobile, hasMobile: Boolean(board?.mobileBanner?.url) } : null
200
+ })
201
+
194
202
  // props.view가 오면(호스트가 전환 버튼을 직접 배치) 그 값을 그대로 따르고, 없으면 내부에서 관리한다.
195
203
  const boardListView = computed(() =>
196
204
  getBoard(resolvedBoardId.value)?.listView ?? 'default',
@@ -256,14 +264,17 @@ function postTo(post: PostModel): string | undefined {
256
264
  />
257
265
  </div>
258
266
  </div>
259
- <img
260
- v-if="getBoard(resolvedBoardId)?.banner?.url"
261
- :src="getBoard(resolvedBoardId)?.banner?.url"
262
- alt=""
263
- width="2400"
264
- height="300"
265
- class="mb-2 aspect-[8/1] w-full rounded-xl object-cover"
266
- >
267
+ <picture v-if="listBanner" class="block">
268
+ <source media="(min-width: 640px)" :srcset="listBanner.desktop">
269
+ <img
270
+ :src="listBanner.mobile"
271
+ alt=""
272
+ :width="listBanner.hasMobile ? 1200 : 2400"
273
+ :height="listBanner.hasMobile ? 400 : 300"
274
+ class="mb-2 w-full rounded-xl object-cover object-center sm:aspect-[8/1]"
275
+ :class="listBanner.hasMobile ? 'aspect-[3/1]' : 'aspect-[8/1]'"
276
+ >
277
+ </picture>
267
278
  <!-- 테스트용 목록 뷰 전환 UI.
268
279
  <div v-else-if="view === undefined" class="flex justify-end">
269
280
  <MemiBoardListViewSwitch :model-value="viewMode" @update:model-value="setViewMode" />
@@ -3,7 +3,7 @@ import MemiBoardSurface from './BoardSurface.vue'
3
3
  import { useMemiBoardStorage } from 'memi-board/storage'
4
4
  import { computed, onMounted, reactive, ref, watch } from 'vue'
5
5
  import { BOARD_NAME_MAX, boardCopyIsTranslated, boardTranslationLocales, MEMI_BOARD_LOCALES, memiBoardEnabledLocales, slugify, useMemiBoardAppSettings, useMemiBoardAuth, useMemiBoardI18n, useMemiBoardSettings, useMemiBoardUsers } from 'memi-board/runtime'
6
- import type { BoardCategory, BoardEditorType, BoardListView, BoardVisibility, BoardWriteRole } from 'memi-board/runtime'
6
+ import type { BoardBannerFiles, BoardCategory, BoardEditorType, BoardListView, BoardVisibility, BoardWriteRole } from 'memi-board/runtime'
7
7
  import MemiBoardCustomFieldEditor from './CustomFieldEditor.vue'
8
8
  import MemiBoardOptionCards from './OptionCards.vue'
9
9
  import MemiBoardBannerEditor from './BannerEditor.vue'
@@ -161,8 +161,8 @@ const deletingId = ref<string | null>(null)
161
161
  const ordering = ref(false)
162
162
  const error = ref('')
163
163
  const bannerBusy = ref(false)
164
- const bannerFiles = reactive<Record<string, File | null | undefined>>({})
165
- const { uploadBoardBanner, deleteAttachment } = useMemiBoardStorage()
164
+ const bannerFiles = reactive<Record<string, BoardBannerFiles>>({})
165
+ const { applyBoardBannerFiles, deleteAttachment } = useMemiBoardStorage()
166
166
  const deleteConfirm = ref('')
167
167
  const deletingAll = ref(false)
168
168
  const deleteDone = ref(false)
@@ -381,8 +381,9 @@ async function save(category: BoardCategory, index: number) {
381
381
  error.value = ''
382
382
  savedId.value = null
383
383
  savingId.value = category.id
384
- let uploadedPath: string | undefined
384
+ let uploadedPaths: string[] = []
385
385
  const previousBanner = category.banner
386
+ const previousMobileBanner = category.mobileBanner
386
387
  category.autoTranslate = category.autoTranslate === true
387
388
  let translateFailed = false
388
389
  if (translationEnabled.value && category.autoTranslate) {
@@ -400,11 +401,7 @@ async function save(category: BoardCategory, index: number) {
400
401
  }
401
402
  try {
402
403
  const order = props.categoryId ? (category.order ?? index) : index
403
- if (bannerFiles[category.id] !== undefined) {
404
- const file = bannerFiles[category.id]
405
- category.banner = file ? await uploadBoardBanner(category.id, file) : null
406
- uploadedPath = category.banner?.path
407
- }
404
+ uploadedPaths = await applyBoardBannerFiles(category, bannerFiles[category.id])
408
405
  await saveCategory(category, order)
409
406
  delete bannerFiles[category.id]
410
407
  category.order = order
@@ -415,7 +412,8 @@ async function save(category: BoardCategory, index: number) {
415
412
  }
416
413
  catch (cause) {
417
414
  category.banner = previousBanner
418
- if (uploadedPath) await deleteAttachment({ path: uploadedPath }).catch(() => {})
415
+ category.mobileBanner = previousMobileBanner
416
+ await Promise.all(uploadedPaths.map(path => deleteAttachment({ path }).catch(() => {})))
419
417
  error.value = cause instanceof Error ? cause.message : t('settings.error.saveFailed')
420
418
  }
421
419
  finally {
@@ -787,12 +785,13 @@ async function runDeleteAll() {
787
785
  <div class="flex flex-col gap-5 border-t border-default px-4 py-4">
788
786
  <MemiBoardBannerEditor
789
787
  :banner="category.banner"
788
+ :mobile-banner="category.mobileBanner"
790
789
  :board-id="category.id"
791
790
  :title="category.label"
792
791
  :description="category.description"
793
792
  @busy="bannerBusy = $event"
794
793
  :disabled="savingId === category.id || translatingId === category.id"
795
- @change="bannerFiles[category.id] = $event; savedId = null"
794
+ @change="(kind, file) => { bannerFiles[category.id] = { ...bannerFiles[category.id], [kind]: file }; savedId = null }"
796
795
  />
797
796
  <div class="grid gap-2 sm:grid-cols-[9rem_1fr] sm:items-center">
798
797
  <div><p class="text-sm font-medium">{{ t('settings.id.label') }}</p><p class="text-xs text-muted">{{ t('settings.id.help') }}</p></div>
package/dist/storage.js CHANGED
@@ -1,4 +1,4 @@
1
- import { T as e, Z as t, a as n, c as r, h as i, n as a } from "./commentImages-DVrG0nFm.js";
1
+ import { T as e, Z as t, a as n, c as r, h as i, n as a } from "./commentImages-xb5Y4ySe.js";
2
2
  import { useFirebaseApp as o } from "vuefire";
3
3
  import { getAuth as s } from "firebase/auth";
4
4
  import { deleteObject as c, getDownloadURL as l, getStorage as u, ref as d, uploadBytes as f, uploadBytesResumable as p } from "firebase/storage";
@@ -175,8 +175,17 @@ function x() {
175
175
  throw await c(n).catch(() => {}), e;
176
176
  }
177
177
  }
178
+ async function D(e, t) {
179
+ let n = [];
180
+ try {
181
+ return t?.desktop !== void 0 && (e.banner = t.desktop ? await E(e.id, t.desktop) : null, e.banner && n.push(e.banner.path)), t?.mobile !== void 0 && (e.mobileBanner = t.mobile ? await E(e.id, t.mobile) : null, e.mobileBanner && n.push(e.mobileBanner.path)), n;
182
+ } catch (e) {
183
+ throw await Promise.all(n.map((e) => c(d(u(h), e)).catch(() => {}))), e;
184
+ }
185
+ }
178
186
  return {
179
187
  uploadBoardBanner: E,
188
+ applyBoardBannerFiles: D,
180
189
  uploadAttachment: y,
181
190
  deleteAttachment: x,
182
191
  uploadCommentImage: S,