feat(ECR-044): RhythmConfig 写面闭环并 Closed
复用 admin.explore.write、POST/PUT+审计、C端 GET /rhythm/configs、 H5 无 active 空态/失败回退;migration 000053。ExploreConfig Loop STOP,禁自动 ECR-045。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,6 +21,8 @@ export function useLifeRhythmPage() {
|
||||
const loading = ref(false)
|
||||
const needBirth = ref(true)
|
||||
const error = ref('')
|
||||
/** Fail-open: true until proven empty; API error keeps generation. */
|
||||
const configAvailable = ref(true)
|
||||
const report = ref<GrowthReport | null>(null)
|
||||
const paying = ref(false)
|
||||
const tab = ref<'overview' | 'wuxing' | 'tips' | 'term'>('overview')
|
||||
@@ -107,7 +109,21 @@ export function useLifeRhythmPage() {
|
||||
scheduleDayRefresh()
|
||||
}
|
||||
|
||||
async function refreshConfigGate() {
|
||||
try {
|
||||
const res = await api.getRhythmConfigs()
|
||||
configAvailable.value = (res.items || []).length > 0
|
||||
} catch {
|
||||
configAvailable.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function generate(y: number, m: number, d: number) {
|
||||
if (!configAvailable.value) {
|
||||
error.value = '节律配置暂未开放'
|
||||
needBirth.value = true
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
needBirth.value = false
|
||||
@@ -127,6 +143,10 @@ export function useLifeRhythmPage() {
|
||||
}
|
||||
|
||||
async function start() {
|
||||
if (!configAvailable.value) {
|
||||
error.value = '节律配置暂未开放'
|
||||
return
|
||||
}
|
||||
const y = Number(year.value)
|
||||
const m = Number(month.value)
|
||||
const d = Number(day.value)
|
||||
@@ -140,6 +160,7 @@ export function useLifeRhythmPage() {
|
||||
|
||||
async function load() {
|
||||
if (!(await ensureAccount(router, route.fullPath))) return
|
||||
await refreshConfigGate()
|
||||
const reportId = String(route.query.report_id || '')
|
||||
if (reportId) {
|
||||
loading.value = true
|
||||
@@ -156,6 +177,11 @@ export function useLifeRhythmPage() {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!configAvailable.value) {
|
||||
needBirth.value = true
|
||||
report.value = null
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const cached = await loadSelfLatest('rhythm')
|
||||
@@ -220,6 +246,7 @@ export function useLifeRhythmPage() {
|
||||
return {
|
||||
loading,
|
||||
needBirth,
|
||||
configAvailable,
|
||||
error,
|
||||
report,
|
||||
paying,
|
||||
|
||||
@@ -11,8 +11,15 @@
|
||||
</template>
|
||||
|
||||
<div class="body">
|
||||
<div v-if="!configAvailable && !report" class="empty-gate">
|
||||
<HomeToolIcon name="rhythm" :size="56" />
|
||||
<p class="empty-title">节律配置暂未开放</p>
|
||||
<p class="empty-sub">运营尚未启用节律配置,请稍后再来</p>
|
||||
<button class="cta-off" type="button" disabled>生成我的节律</button>
|
||||
</div>
|
||||
|
||||
<RhythmIntro
|
||||
v-if="needBirth && !report"
|
||||
v-else-if="needBirth && !report"
|
||||
v-model:year="year"
|
||||
v-model:month="month"
|
||||
v-model:day="day"
|
||||
@@ -60,6 +67,7 @@ import { useLifeRhythmPage } from '../composables/useLifeRhythmPage'
|
||||
const {
|
||||
loading,
|
||||
needBirth,
|
||||
configAvailable,
|
||||
error,
|
||||
report,
|
||||
paying,
|
||||
@@ -103,4 +111,35 @@ const {
|
||||
margin-top: 2px;
|
||||
}
|
||||
.body { padding: 8px 16px 88px; }
|
||||
.empty-gate {
|
||||
text-align: center;
|
||||
padding: 28px 16px 12px;
|
||||
}
|
||||
.empty-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
margin-top: 10px;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.empty-sub {
|
||||
font-size: 13px;
|
||||
color: rgba(0, 0, 0, 0.42);
|
||||
margin-top: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.cta-off {
|
||||
margin-top: 16px;
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
padding: 13px;
|
||||
border: none;
|
||||
border-radius: 22px;
|
||||
color: #fff;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
background: linear-gradient(135deg, #ff7a6e, var(--color-primary));
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user