Commit 28d41209 authored by yuwenwen's avatar yuwenwen

移动端动态换行展示

parent 1eff28d9
......@@ -5,8 +5,8 @@
<image class="avatar" v-if="form.avatar" :src="form.avatar"></image>
<image class="avatar" v-else src="/static/images/default-avatar.png"></image>
<view class="user-name">{{form.nickName}}</view>
<image v-if="deleteable || userInfo.bbsAdmin || form.isSelf==1" class="more-icon" @click.stop="handleDelDynamics"
src="/static/images/more-icon.png"></image>
<image v-if="deleteable || userInfo.bbsAdmin || form.isSelf==1" class="more-icon"
@click.stop="handleDelDynamics" src="/static/images/more-icon.png"></image>
<image v-else class="more-icon" src="/static/images/more-icon.png"></image>
<!-- 删除按钮 -->
<view class="del-btn" v-if="showDelBtn" @click.stop="handleDel"
......@@ -18,7 +18,7 @@
<view class="topic-box-common" @click.stop="toTopicDetailPage(name,index)"># {{name}}</view>
</template>
</view>
<view class="dynamic-content-box" >
<view class="dynamic-content-box">
<rich-text v-if="preNodes.length > 0" :nodes="preNodes" class="text"></rich-text>
<view class="imgs" v-if="form.type=='IMAGE'&&form.attachments && form.attachments.length > 0">
......@@ -109,7 +109,8 @@
</view>
<view class="operation-text">
<view v-if="item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选</view>
<view style="color: #bbb;" v-if="item.isSelf==1 || userInfo.bbsAdmin" @click.stop="handleDelete(item)">删除</view>
<view style="color: #bbb;" v-if="item.isSelf==1 || userInfo.bbsAdmin"
@click.stop="handleDelete(item)">删除</view>
</view>
</view>
<view class="content">
......@@ -142,7 +143,9 @@
import PublishComment from './PublishComment.vue';
import VideoPreview from './VideoPreview.vue';
import emotions from '@/utils/emjo';
import { getUserInfo } from '@/utils/auth';
import {
getUserInfo
} from '@/utils/auth';
export default {
name: "Dynamic-Item",
data() {
......@@ -155,7 +158,7 @@
showDelBtn: false,
preNodes: [],
emotions,
userInfo:{}
userInfo: {}
};
},
components: {
......@@ -250,12 +253,26 @@
}
}
// 提取文本
// 提取文本并按换行符分割
const text = content.slice(0, nextEmotionIndex);
nodes.push({
type: 'text',
text: text
});
if (text) {
const textParts = text.split('\n'); // 按换行符分割
textParts.forEach((part, idx) => {
if (part) {
// 添加普通文本节点
nodes.push({
type: 'text',
text: part
});
}
// 除了最后一部分,每个分割后都加<br/>
if (idx < textParts.length - 1) {
nodes.push({
name: 'br' // 添加<br/>标签实现换行
});
}
});
}
content = content.slice(nextEmotionIndex);
}
}
......@@ -313,7 +330,7 @@
uni.showToast({
title: '投票成功'
})
this.$emit('refreshCurrent',this.form.id)
this.$emit('refreshCurrent', this.form.id)
}
})
},
......@@ -341,14 +358,14 @@
});
},
// 预览图片
preview(list,index) {
let urls = list.map((item)=>{
preview(list, index) {
let urls = list.map((item) => {
return item.url;
})
if(urls.length > 0){
if (urls.length > 0) {
uni.previewImage({
urls: urls,
current:index
current: index
});
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment