1. 海报
This commit is contained in:
@@ -13,6 +13,17 @@
|
||||
<a-button size="small" @click="openPreview">
|
||||
<i class="fa-solid fa-eye mr-1 text-[#a88c6b]"></i>预览请柬
|
||||
</a-button>
|
||||
<a-dropdown>
|
||||
<a-button size="small">
|
||||
<i class="fa-solid fa-scroll mr-1 text-[#a88c6b]"></i>预览海报 <i class="fa-solid fa-chevron-down ml-1 text-[10px]"></i>
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="male" @click="openPosterPreview('male')">男方 /hb-n</a-menu-item>
|
||||
<a-menu-item key="female" @click="openPosterPreview('female')">女方 /hb-nv</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
<a-button
|
||||
v-if="isConfigTab"
|
||||
type="primary"
|
||||
@@ -399,6 +410,85 @@
|
||||
</a-card>
|
||||
</a-tab-pane>
|
||||
|
||||
<!-- 海报(独立 poster_configs:男方 /hb-n、女方 /hb-nv) -->
|
||||
<a-tab-pane key="poster" tab="海报">
|
||||
<a-card v-if="activeTab === 'poster'" :bordered="false" class="!shadow-sm">
|
||||
<a-alert
|
||||
type="info"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
message="海报配置独立存储。男方前台 /hb-n,女方前台 /hb-nv"
|
||||
/>
|
||||
<a-tabs v-model:activeKey="posterSideTab" size="small" type="card" class="mb-3">
|
||||
<a-tab-pane key="male" tab="男方海报" />
|
||||
<a-tab-pane key="female" tab="女方海报" />
|
||||
</a-tabs>
|
||||
<a-form layout="vertical" :class="{ 'opacity-60 pointer-events-none': posterLoading }">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<a-form-item label="启用海报页">
|
||||
<a-switch v-model:checked="posterCfg.enabled" />
|
||||
</a-form-item>
|
||||
<a-form-item label="显示跳转请柬按钮">
|
||||
<a-switch v-model:checked="posterCfg.showInviteButton" />
|
||||
</a-form-item>
|
||||
<a-form-item label="按钮文案">
|
||||
<a-input v-model:value="posterCfg.inviteButtonText" :disabled="!posterCfg.showInviteButton" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-6">
|
||||
<a-form-item label="进页 Loading">
|
||||
<a-select v-model:value="posterCfg.loadingEffect">
|
||||
<a-select-option v-for="opt in LOADING_EFFECTS" :key="opt.value" :value="opt.value">{{ opt.label }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="打开页面过场">
|
||||
<a-select v-model:value="posterCfg.enterEffect">
|
||||
<a-select-option v-for="opt in ENTER_EFFECTS" :key="opt.value" :value="opt.value">{{ opt.label }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="跳转路径">
|
||||
<a-input v-model:value="posterCfg.invitePath" placeholder="/" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
<a-form-item label="顶部照片">
|
||||
<image-field v-model="posterCfg.heroImg" label="海报顶图" @pick="openUpload(u => posterCfg.heroImg = u)" :uploading="uploading" />
|
||||
</a-form-item>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-6">
|
||||
<a-form-item :label="posterSideTab === 'female' ? '女儿称谓 / 姓名' : '儿子称谓 / 姓名'">
|
||||
<div class="flex gap-2">
|
||||
<a-input v-model:value="posterCfg.sonLabel" class="!w-[100px]" :placeholder="posterSideTab === 'female' ? '女儿:' : '儿子:'" />
|
||||
<a-input v-model:value="posterCfg.sonName" placeholder="姓名" />
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="posterSideTab === 'female' ? '女婿称谓 / 姓名' : '儿媳称谓 / 姓名'">
|
||||
<div class="flex gap-2">
|
||||
<a-input v-model:value="posterCfg.daughterInLawLabel" class="!w-[100px]" :placeholder="posterSideTab === 'female' ? '女婿:' : '儿媳:'" />
|
||||
<a-input v-model:value="posterCfg.daughterInLawName" placeholder="姓名" />
|
||||
</div>
|
||||
</a-form-item>
|
||||
</div>
|
||||
<a-form-item label="主标题">
|
||||
<a-input v-model:value="posterCfg.title" placeholder="婚礼邀请函" />
|
||||
</a-form-item>
|
||||
<a-form-item label="正文(每行一条)">
|
||||
<a-textarea v-model:value="posterLinesText" :rows="10" placeholder="每行一条正文" />
|
||||
</a-form-item>
|
||||
<a-form-item label="底部文案">
|
||||
<a-input v-model:value="posterCfg.footer" />
|
||||
</a-form-item>
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<a-button type="primary" :loading="posterSaving" @click="onSavePosterConfig"
|
||||
class="!bg-[#a88c6b] hover:!bg-[#967b5c] !border-[#a88c6b]">
|
||||
<i class="fa-solid fa-floppy-disk mr-1"></i>保存海报配置
|
||||
</a-button>
|
||||
<a-button @click="openPosterPreview(posterSideTab)">
|
||||
<i class="fa-solid fa-eye mr-1"></i>打开 {{ posterSideTab === 'female' ? '/hb-nv' : '/hb-n' }} 预览
|
||||
</a-button>
|
||||
</div>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane key="photos" tab="相册页管理">
|
||||
<div class="admin-panel !p-4 mb-3">
|
||||
<div class="flex justify-between items-center gap-3 flex-wrap">
|
||||
@@ -731,12 +821,17 @@ import { CanvasRenderer } from 'echarts/renderers'
|
||||
import {
|
||||
getConfigSection, saveConfigSection, uploadImage, getRsvpList, getUploadConfig, saveUploadConfig,
|
||||
getDanmakuList, updateDanmakuStatus, getVisitStats, getVisitList,
|
||||
getPosterConfig, savePosterConfig,
|
||||
} from '@/api/wedding'
|
||||
import { useAdminStore } from '@/stores/admin'
|
||||
import ImageField from '@/components/ImageField.vue'
|
||||
import { BORDER_STYLES, borderClass } from '@/composables/borderStyles'
|
||||
import { resolveDanmakuSwatch } from '@/utils/danmakuColors'
|
||||
import { getSlotResizeSpecs, resizeSlotToFile, probeResizedMeta, metaHasFileSize } from '@/composables/resizeImage'
|
||||
import {
|
||||
defaultPosterBundle, normalizePosterBundle, normalizePosterConfig,
|
||||
LOADING_EFFECTS, ENTER_EFFECTS, POSTER_SIDES,
|
||||
} from '@/composables/posterDefaults'
|
||||
|
||||
echarts.use([PieChart, TooltipComponent, LegendComponent, CanvasRenderer])
|
||||
|
||||
@@ -745,7 +840,7 @@ const adminStore = useAdminStore()
|
||||
|
||||
const TAB_KEY = 'wedding_admin_active_tab'
|
||||
const CONFIG_SECTIONS = ['basic', 'copy', 'visual', 'music', 'photos', 'schedule']
|
||||
const VALID_TABS = ['overview', ...CONFIG_SECTIONS, 'upload', 'rsvp', 'danmaku']
|
||||
const VALID_TABS = ['overview', ...CONFIG_SECTIONS, 'upload', 'poster', 'rsvp', 'danmaku']
|
||||
|
||||
const SECTION_KEYS = {
|
||||
basic: ['groom', 'bride', 'date', 'lunar', 'calendarDate', 'hotel', 'address', 'heroImg', 'endImg'],
|
||||
@@ -774,6 +869,8 @@ const uploading = ref(false)
|
||||
const resizingPage = ref(false)
|
||||
const resizeProgress = ref('')
|
||||
const uploadConfigSaving = ref(false)
|
||||
const posterSaving = ref(false)
|
||||
const posterLoading = ref(false)
|
||||
const tabLoading = ref(false)
|
||||
const rsvpLoading = ref(false)
|
||||
const rsvpList = ref([])
|
||||
@@ -791,6 +888,22 @@ let regionChart = null
|
||||
|
||||
const cfg = reactive(defaultConfig())
|
||||
const uploadCfg = reactive(defaultUploadConfig())
|
||||
const posterSideTab = ref('male')
|
||||
const posterBundle = reactive(defaultPosterBundle())
|
||||
const posterCfg = computed(() => posterBundle[posterSideTab.value] || posterBundle.male)
|
||||
const posterLinesText = computed({
|
||||
get: () => {
|
||||
const lines = posterCfg.value?.lines
|
||||
return Array.isArray(lines) ? lines.join('\n') : ''
|
||||
},
|
||||
set: (v) => {
|
||||
const side = posterSideTab.value
|
||||
if (!posterBundle[side]) posterBundle[side] = normalizePosterConfig(null, side)
|
||||
posterBundle[side].lines = String(v || '')
|
||||
.split('\n')
|
||||
.map((s) => s.trimEnd())
|
||||
},
|
||||
})
|
||||
const currentPhotoIndex = computed(() => Math.min(Number(activePhotoTab.value) || 0, Math.max(cfg.photoPages.length - 1, 0)))
|
||||
const isConfigTab = computed(() => CONFIG_SECTIONS.includes(activeTab.value))
|
||||
const visitPagination = computed(() => ({
|
||||
@@ -1206,6 +1319,36 @@ async function onSaveUploadConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPosterConfig() {
|
||||
posterLoading.value = true
|
||||
try {
|
||||
const res = await getPosterConfig()
|
||||
const bundle = normalizePosterBundle(res.data || {})
|
||||
posterBundle.male = bundle.male
|
||||
posterBundle.female = bundle.female
|
||||
} catch (e) {
|
||||
message.error(e?.message || '海报配置加载失败')
|
||||
} finally {
|
||||
posterLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onSavePosterConfig() {
|
||||
posterSaving.value = true
|
||||
try {
|
||||
const payload = normalizePosterBundle(posterBundle)
|
||||
const res = await savePosterConfig(payload)
|
||||
const bundle = normalizePosterBundle(res.data || payload)
|
||||
posterBundle.male = bundle.male
|
||||
posterBundle.female = bundle.female
|
||||
message.success('海报配置已保存')
|
||||
} catch (e) {
|
||||
message.error(e?.message || '海报配置保存失败')
|
||||
} finally {
|
||||
posterSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function pickSectionData(section) {
|
||||
const keys = SECTION_KEYS[section] || []
|
||||
const data = {}
|
||||
@@ -1390,6 +1533,10 @@ async function onTabActivate(tab) {
|
||||
await loadUploadConfig()
|
||||
return
|
||||
}
|
||||
if (tab === 'poster') {
|
||||
await loadPosterConfig()
|
||||
return
|
||||
}
|
||||
if (tab === 'rsvp') {
|
||||
await loadRsvp()
|
||||
return
|
||||
@@ -1400,6 +1547,10 @@ async function onTabActivate(tab) {
|
||||
}
|
||||
|
||||
function openPreview() { window.open('/', '_blank') }
|
||||
function openPosterPreview(side = 'male') {
|
||||
const meta = POSTER_SIDES.find((s) => s.key === side) || POSTER_SIDES[0]
|
||||
window.open(meta.route, '_blank')
|
||||
}
|
||||
|
||||
function onLogout() {
|
||||
adminStore.logout()
|
||||
|
||||
Reference in New Issue
Block a user