fix(systemconfig): 首页入口展示开关与发布选项编码修复

This commit is contained in:
yml2213
2026-10-22 20:25:57 +08:00
parent 51855a0e17
commit 2ce3320d5f
16 changed files with 591 additions and 54 deletions
@@ -38,6 +38,33 @@
gap: 10px;
}
.home-entry-switch-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 14px 16px;
border: 1px solid #e5edf8;
border-radius: 8px;
background: #f8fbff;
}
.home-entry-switch-row > div {
display: grid;
gap: 4px;
}
.home-entry-switch-row strong {
color: #111827;
font-size: 14px;
}
.home-entry-switch-row span {
color: #6b7280;
font-size: 12px;
line-height: 1.5;
}
.welcome-config-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -17,15 +17,21 @@ import {
type HomeBannerSlide,
} from '@/features/listings/api/homeConfig'
import type { OrderAgreements } from '@/features/orders/api/orders'
import { fetchSystemConfigs, type SystemConfig } from '@/features/admin/api/systemConfigs'
import {
fetchSystemConfigs,
updateSystemConfig,
type SystemConfig,
} from '@/features/admin/api/systemConfigs'
import { parseRenterGrowthConfig } from '@/features/admin/api/renterGrowth'
import {
parseSmsBusinessTemplatesConfig,
smsNodeMetas,
} from '@/features/admin/api/smsNodeTemplates'
import { formatDateTime } from '@/shared/utils/time'
import { readError } from '@/shared/utils/error'
import { safeParseJSON } from '@/shared/utils/json'
import { formatSystemConfigSelectValue } from '@/shared/utils/systemConfigOptions'
import { ElMessage } from 'element-plus'
// 导入重构后的 Dialog 子组件
import PublishOptionsDialog from '../components/PublishOptionsDialog.vue'
@@ -120,6 +126,14 @@ const awRecycleConfig = computed(
const cooperationFeedbackConfig = computed(
() => configs.value.find(item => item.key === 'mobile.cooperation_feedback') || null
)
const homeEntriesEnabledConfig = computed(
() => configs.value.find(item => item.key === 'mobile.home_entries_enabled') || null
)
const homeEntriesDisplayEnabled = computed(() => {
const raw = homeEntriesEnabledConfig.value?.value.trim().toLowerCase() || ''
return raw === 'true' || raw === '1'
})
const homeEntriesSwitchSaving = ref(false)
const listingPublishAgreementsConfig = computed(
() => configs.value.find(item => item.key === 'listing.publish_agreements') || null
)
@@ -167,6 +181,7 @@ const regularConfigs = computed(() =>
item.key !== 'mobile.home_banners' &&
item.key !== 'mobile.aw_recycle' &&
item.key !== 'mobile.cooperation_feedback' &&
item.key !== 'mobile.home_entries_enabled' &&
item.key !== 'listing.publish_agreements' &&
item.key !== 'order.agreements' &&
item.key !== 'profile.post_rental_notice' &&
@@ -216,6 +231,7 @@ const homeStats = computed(() => {
const awRecycleStats = computed(() => {
const item = parseAWRecycle(awRecycleConfig.value?.value || '')
if (!homeEntriesDisplayEnabled.value) return { enabledLabel: '已隐藏' }
return {
enabledLabel: item.enabled ? (item.image_url ? '已配置图' : '已开启') : '已隐藏',
}
@@ -223,6 +239,7 @@ const awRecycleStats = computed(() => {
const cooperationFeedbackStats = computed(() => {
const item = parseCooperationFeedback(cooperationFeedbackConfig.value?.value || '')
if (!homeEntriesDisplayEnabled.value) return { enabledLabel: '已隐藏' }
return {
enabledLabel: item.enabled ? (item.image_url ? '已配置图' : '已开启') : '已隐藏',
}
@@ -288,6 +305,25 @@ async function loadConfigs() {
}
}
async function handleHomeEntriesDisplayChange(value: string | number | boolean) {
const row = homeEntriesEnabledConfig.value
if (!row || homeEntriesSwitchSaving.value) return
const next = value === true || value === 1 || value === 'true'
homeEntriesSwitchSaving.value = true
try {
await updateSystemConfig(row.key, {
value: next ? 'true' : 'false',
description: row.description,
})
await loadConfigs()
ElMessage.success(next ? '首页业务入口已恢复展示' : '首页业务入口已隐藏')
} catch (error) {
ElMessage.error(readError(error, '保存失败'))
} finally {
homeEntriesSwitchSaving.value = false
}
}
function systemConfigByKey(key: string, fallbackValue: string, description: string): SystemConfig {
const existing = configs.value.find(item => item.key === key)
if (existing) return existing
@@ -654,7 +690,11 @@ function formatConfigValue(row: SystemConfig) {
<section
v-if="
homeAnnouncementsConfig || homeBannersConfig || awRecycleConfig || cooperationFeedbackConfig
homeAnnouncementsConfig ||
homeBannersConfig ||
awRecycleConfig ||
cooperationFeedbackConfig ||
homeEntriesEnabledConfig
"
class="publish-config-panel"
>
@@ -685,6 +725,23 @@ function formatConfigValue(row: SystemConfig) {
>
</div>
</div>
<div class="home-entry-switch-row">
<div>
<strong>首页业务入口展示</strong>
<span
>总开关关闭后,PC
与移动端同时隐藏「AW炫彩回收」「合作与反馈」;开启后按各入口自己的启用状态展示。</span
>
</div>
<el-switch
:model-value="homeEntriesDisplayEnabled"
:loading="homeEntriesSwitchSaving"
:disabled="!homeEntriesEnabledConfig || homeEntriesSwitchSaving"
active-text="展示"
inactive-text="隐藏"
@change="handleHomeEntriesDisplayChange"
/>
</div>
<div class="publish-stat-grid home-stat-grid">
<div class="publish-stat">
<strong>{{ homeStats.announcementCount }}</strong>