wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
    <view class="p-4 bg-gray-50 min-h-screen">
        <!-- 标题 -->
        <view class="text-center text-2xl font-bold text-gray-900 mb-2">
            {{ item.title }}
        </view>
 
        <!-- 发布时间 -->
        <view class="text-center text-sm text-gray-500 mb-4">
            {{ item.createTime }}
        </view>
 
        <!-- 消息类别 -->
        <view class="text-center text-base text-gray-700 mb-6">
            消息类别:{{ item.category }}
        </view>
 
        <!-- 富文本内容 -->
        <view class="bg-white rounded-lg shadow max-w-full">
            <rich-text :nodes="item.content"></rich-text>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                item: {
                    title: '',
                    createTime: '',
                    category: '',
                    content: ''
                }
            };
        },
        onLoad(options) {
            if (options.data) {
                try {
                    this.item = JSON.parse(decodeURIComponent(options.data));
 
                    // 处理 item.content,为 <img> 标签添加内联样式
                    this.item.content = this.item.content.replace(
                        /<img([^>]*?)>/g,
                        `<img$1 style="max-width: 100%; height: auto; display: block;">`
                    );
                    console.log('接收到的 item:', this.item);
                } catch (e) {
                    console.error('解析传参出错:', e);
                }
            }
        }
    };
</script>
 
<style scoped>
    /* 页面基础布局 */
    .min-h-screen {
        min-height: 100vh;
    }
 
    .max-w-full {
        max-width: 100%;
    }
 
    .bg-gray-50 {
        background-color: #f9fafb;
    }
 
    .bg-white {
        background-color: #ffffff;
    }
 
    .p-4 {
        padding: 1rem;
    }
 
    /* 文字样式 */
    .text-center {
        text-align: center;
    }
 
    .text-2xl {
        font-size: 1.5rem;
        line-height: 2rem;
    }
 
    .text-base {
        font-size: 1rem;
        line-height: 1.5rem;
    }
 
    .text-sm {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
 
    .font-bold {
        font-weight: 700;
    }
 
    .font-semibold {
        font-weight: 600;
    }
 
    .text-gray-900 {
        color: #111827;
    }
 
    .text-gray-700 {
        color: #374151;
    }
 
    .text-gray-500 {
        color: #6b7280;
    }
 
    /* 间距 */
    .mb-2 {
        margin-bottom: 0.5rem;
    }
 
    .mb-4 {
        margin-bottom: 1rem;
    }
 
    .mb-6 {
        margin-bottom: 1.5rem;
    }
 
    /* 容器样式 */
    .rounded-lg {
        border-radius: 0.5rem;
    }
 
    .shadow {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1),
            0 1px 2px rgba(0, 0, 0, 0.06);
    }
</style>