Commit 28d41209 authored by yuwenwen's avatar yuwenwen

移动端动态换行展示

parent 1eff28d9
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<image class="avatar" v-if="form.avatar" :src="form.avatar"></image> <image class="avatar" v-if="form.avatar" :src="form.avatar"></image>
<image class="avatar" v-else src="/static/images/default-avatar.png"></image> <image class="avatar" v-else src="/static/images/default-avatar.png"></image>
<view class="user-name">{{form.nickName}}</view> <view class="user-name">{{form.nickName}}</view>
<image v-if="deleteable || userInfo.bbsAdmin || form.isSelf==1" class="more-icon" @click.stop="handleDelDynamics" <image v-if="deleteable || userInfo.bbsAdmin || form.isSelf==1" class="more-icon"
src="/static/images/more-icon.png"></image> @click.stop="handleDelDynamics" src="/static/images/more-icon.png"></image>
<image v-else class="more-icon" 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" <view class="del-btn" v-if="showDelBtn" @click.stop="handleDel"
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<view class="topic-box-common" @click.stop="toTopicDetailPage(name,index)"># {{name}}</view> <view class="topic-box-common" @click.stop="toTopicDetailPage(name,index)"># {{name}}</view>
</template> </template>
</view> </view>
<view class="dynamic-content-box" > <view class="dynamic-content-box">
<rich-text v-if="preNodes.length > 0" :nodes="preNodes" class="text"></rich-text> <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"> <view class="imgs" v-if="form.type=='IMAGE'&&form.attachments && form.attachments.length > 0">
...@@ -109,7 +109,8 @@ ...@@ -109,7 +109,8 @@
</view> </view>
<view class="operation-text"> <view class="operation-text">
<view v-if="item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选</view> <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> </view>
<view class="content"> <view class="content">
...@@ -142,7 +143,9 @@ ...@@ -142,7 +143,9 @@
import PublishComment from './PublishComment.vue'; import PublishComment from './PublishComment.vue';
import VideoPreview from './VideoPreview.vue'; import VideoPreview from './VideoPreview.vue';
import emotions from '@/utils/emjo'; import emotions from '@/utils/emjo';
import { getUserInfo } from '@/utils/auth'; import {
getUserInfo
} from '@/utils/auth';
export default { export default {
name: "Dynamic-Item", name: "Dynamic-Item",
data() { data() {
...@@ -155,7 +158,7 @@ ...@@ -155,7 +158,7 @@
showDelBtn: false, showDelBtn: false,
preNodes: [], preNodes: [],
emotions, emotions,
userInfo:{} userInfo: {}
}; };
}, },
components: { components: {
...@@ -250,12 +253,26 @@ ...@@ -250,12 +253,26 @@
} }
} }
// 提取文本 // 提取文本并按换行符分割
const text = content.slice(0, nextEmotionIndex); const text = content.slice(0, nextEmotionIndex);
nodes.push({ if (text) {
type: 'text', const textParts = text.split('\n'); // 按换行符分割
text: text 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); content = content.slice(nextEmotionIndex);
} }
} }
...@@ -313,7 +330,7 @@ ...@@ -313,7 +330,7 @@
uni.showToast({ uni.showToast({
title: '投票成功' title: '投票成功'
}) })
this.$emit('refreshCurrent',this.form.id) this.$emit('refreshCurrent', this.form.id)
} }
}) })
}, },
...@@ -341,14 +358,14 @@ ...@@ -341,14 +358,14 @@
}); });
}, },
// 预览图片 // 预览图片
preview(list,index) { preview(list, index) {
let urls = list.map((item)=>{ let urls = list.map((item) => {
return item.url; return item.url;
}) })
if(urls.length > 0){ if (urls.length > 0) {
uni.previewImage({ uni.previewImage({
urls: urls, 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