|
|
@@ -21,15 +21,43 @@ onMounted(() => {
|
|
|
const fetchTos = async () => {
|
|
|
try {
|
|
|
const res = await getTermsServiceListMax();
|
|
|
- tosContent.value = DOMPurify.sanitize(res.data.content);
|
|
|
+ // 处理获取到的内容,确保格式良好
|
|
|
+ const formattedContent = handleLineBreaks(res.data.content);
|
|
|
+ tosContent.value = DOMPurify.sanitize(formattedContent);
|
|
|
} catch (error) {
|
|
|
console.error('获取服务条款失败', error);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+// 确保文本内容中适当的换行符
|
|
|
+const handleLineBreaks = (content: string): string => {
|
|
|
+ let formattedContent = content.replace(/\s+/g, ' ');
|
|
|
+ // 在每80个非空白字符后插入一个<br>标签以强制换行
|
|
|
+ formattedContent = formattedContent.replace(/(\S{80})/g, '$1<br>');
|
|
|
+ return formattedContent;
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
.tos-container {
|
|
|
padding: 20px;
|
|
|
+ word-break: break-word; /* 强制长单词换行 */
|
|
|
+}
|
|
|
+
|
|
|
+/* 针对卡片内部内容的样式 */
|
|
|
+.tos-container div {
|
|
|
+ word-break: break-word;
|
|
|
+}
|
|
|
+
|
|
|
+/* 响应式设计 */
|
|
|
+@media (max-width: 768px) {
|
|
|
+ .tos-container {
|
|
|
+ padding: 15px; /* 减少内边距 */
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-card {
|
|
|
+ width: 100%; /* 占满父容器宽度 */
|
|
|
+ margin: 0 auto; /* 居中对齐 */
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|