Files
happy-life-star/mini-program/src/pages/main/ScriptDetailView.vue
T
peanut 21c07ba450 fix(mini-program): 修复剧本详情页内容超出屏幕和间距问题
修复内容:
1. 信息卡片右侧超出屏幕:
   - .info-value 添加 flex:1 + overflow: hidden + word-break: break-all
   - 长文本自动换行,不会超出屏幕
   - .info-label 添加 flex-shrink: 0 防止被压缩
   - .info-row 添加 min-width: 0 防止 flex 子项溢出

2. 卡片顶部与 header 无间距:
   - .detail-content padding 顶部从 0 改为 20rpx

3. 正文区域右侧超出:
   - .full-content 添加 overflow: hidden + word-break: break-all
   - Markdown 内容自动换行
2026-04-07 22:56:20 +08:00

265 lines
6.1 KiB
Vue

<template>
<view class="detail-view">
<!-- 状态栏占位 -->
<view :style="{ height: statusBarHeight + 'px' }" class="status-bar-placeholder"></view>
<view class="detail-header">
<view class="header-left" @click="goBack">
<text class="back-icon"></text>
<text class="back-text">返回</text>
</view>
<text class="detail-title">{{ script?.title || '剧本详情' }}</text>
</view>
<scroll-view class="detail-content" scroll-y>
<view class="content-container">
<!-- 基本信息卡片 -->
<view class="info-card glass-card">
<view class="info-row">
<text class="info-label">主题</text>
<text class="info-value">{{ script?.theme || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">风格</text>
<text class="info-value">{{ script?.style || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">篇幅</text>
<text class="info-value">{{ script?.length || '-' }}</text>
</view>
</view>
<!-- 完整内容 -->
<view class="full-content glass-card">
<view class="content-header">
<text class="content-icon">📖</text>
<text class="content-label">完整剧本</text>
</view>
<Markdown :content="fullContent" />
</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useAppStore } from '../../stores/app.js'
import Markdown from '../../components/Markdown.vue'
const store = useAppStore()
const script = ref(null)
const fullContent = ref('')
const statusBarHeight = ref(0)
const scripts = computed(() => store.scripts || [])
onMounted(() => {
// 获取状态栏高度(从 App.vue 存储的全局值)
statusBarHeight.value = uni.getStorageSync('statusBarHeight') || 20
// 获取剧本 ID
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const scriptId = currentPage.options.id
// 从 store 获取剧本详情
if (scriptId) {
script.value = scripts.value.find(s => s.id === scriptId)
// 优先读取 content 字段(转换后的格式),兼容 plotJson.fullContent
if (script.value?.content) {
fullContent.value = script.value.content
} else if (script.value?.plotJson?.fullContent) {
fullContent.value = script.value.plotJson.fullContent
} else {
fullContent.value = '暂无完整内容'
}
}
})
const goBack = () => {
uni.navigateBack()
}
</script>
<style scoped>
.detail-view {
display: flex;
flex-direction: column;
height: 100%;
background: linear-gradient(180deg, #0F071A 0%, #1A0B2E 50%, #0F071A 100%);
}
/* 状态栏占位 */
.status-bar-placeholder {
width: 100%;
flex-shrink: 0;
background: transparent;
}
/* ==================== 顶部导航栏 ==================== */
.detail-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 32rpx 24rpx;
background: rgba(168, 85, 247, 0.1);
border-bottom: 1px solid rgba(168, 85, 247, 0.2);
flex-shrink: 0;
position: relative;
}
.header-left {
display: flex;
align-items: center;
gap: 8rpx;
padding: 8rpx 16rpx;
border-radius: 24rpx;
background: rgba(168, 85, 247, 0.15);
border: 1px solid rgba(168, 85, 247, 0.2);
z-index: 10;
flex-shrink: 0;
}
.back-icon {
font-size: 32rpx;
color: #C084FC;
font-weight: 600;
}
.back-text {
font-size: 24rpx;
color: rgba(243, 232, 255, 0.8);
}
.detail-title {
font-size: 32rpx;
font-weight: 500;
color: rgba(243, 232, 255, 0.9);
font-family: 'Cinzel', 'Inter', serif;
flex: 1;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-left: 8rpx;
margin-right: 8rpx;
}
/* ==================== 滚动内容区 ==================== */
.detail-content {
flex: 1;
overflow-y: auto;
padding: 20rpx 32rpx 32rpx;
}
.content-container {
display: flex;
flex-direction: column;
gap: 32rpx;
padding-bottom: 40rpx;
}
/* ==================== 信息卡片 ==================== */
.info-card {
padding: 32rpx;
background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(232, 121, 249, 0.08));
border: 1px solid rgba(168, 85, 247, 0.25);
border-radius: 40rpx;
box-shadow: inset 0 0 20rpx rgba(168, 85, 247, 0.05),
0 4rpx 20rpx rgba(168, 85, 247, 0.08);
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16rpx 0;
border-bottom: 1px solid rgba(168, 85, 247, 0.1);
min-width: 0;
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
font-size: 22rpx;
color: rgba(192, 132, 252, 0.7);
font-weight: 600;
letter-spacing: 2rpx;
text-transform: uppercase;
flex-shrink: 0;
}
.info-value {
flex: 1;
text-align: right;
margin-left: 16rpx;
overflow: hidden;
word-break: break-all;
color: rgba(243, 232, 255, 0.9);
font-size: 26rpx;
line-height: 1.5;
}
/* ==================== 完整内容卡片 ==================== */
.full-content {
padding: 40rpx 32rpx;
background: rgba(168, 85, 247, 0.08);
border: 1px solid rgba(168, 85, 247, 0.2);
border-radius: 40rpx;
min-height: 400rpx;
overflow: hidden;
word-break: break-all;
}
.content-header {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 32rpx;
padding-bottom: 20rpx;
border-bottom: 2rpx solid rgba(168, 85, 247, 0.2);
}
.content-icon {
font-size: 36rpx;
filter: drop-shadow(0 0 8rpx rgba(192, 132, 252, 0.6));
}
.content-label {
font-size: 26rpx;
color: rgba(192, 132, 252, 0.8);
font-weight: 600;
letter-spacing: 4rpx;
text-transform: uppercase;
}
/* Markdown 内容间距调整 */
.full-content .markdown-container {
gap: 24rpx;
}
.full-content .markdown-h3 {
margin-top: 32rpx;
margin-bottom: 16rpx;
font-size: 32rpx;
}
.full-content .markdown-h4 {
margin-top: 24rpx;
margin-bottom: 12rpx;
}
.full-content .markdown-p {
font-size: 26rpx;
line-height: 1.8;
color: rgba(243, 232, 255, 0.85);
}
.full-content .markdown-hr {
margin: 40rpx 0;
}
</style>