Commit ab32e25f by cen Committed by chenwq1

refactor: 优化组件代码和数据处理逻辑

- 移除不必要的条件编译指令
- 重构数据处理逻辑,确保字符串处理的安全性
- 更新输入处理方式,使用统一的输入事件处理函数
- 改进日期格式化函数,增强可读性和复用性
1 parent cd6af975
<template>
<layout-root>
<!-- #endif -->
<view class="page-container container">
<HomeFrame ref="homeRef"
:show-footer="true"
......@@ -97,7 +96,6 @@
</view>
</PackageDetailPopup>
</view>
<!-- #ifdef APP -->
</layout-root>
</template>
......@@ -335,10 +333,22 @@ async function getBoutiquePackageList(): Promise<void> {
for (const element of arr) {
const e = element as UTSJSONObject;
if (e != null) {
e.scriptIntroduction = ((e.scriptIntroduction ?? "") as string).replace(/<\/?br\s*\/?>|\\n|\n/g, "<br>");
e.content = ((e.content ?? "") as string).replace(/<\/?br\s*\/?>|\\n|\n/g, "<br>");
if (e.marketPrice != null) e.marketPrice = Number.parseFloat((e.marketPrice as any).toString()).toString();
if (e.packagePrice != null) e.packagePrice = Number.parseFloat((e.packagePrice as any).toString()).toString();
let intro = e.scriptIntroduction as null | string;
if (intro == null) intro = "";
intro = intro.replace(/<\/?br\s*\/?>|\\n|\n/g, "<br>");
e.scriptIntroduction = intro;
let content = e.content as null | string;
if (content == null) content = "";
content = content.replace(/<\/?br\s*\/?>|\\n|\n/g, "<br>");
e.content = content;
if (e.marketPrice != null) {
e.marketPrice = Number.parseFloat((e.marketPrice as any).toString()).toString();
}
if (e.packagePrice != null) {
e.packagePrice = Number.parseFloat((e.packagePrice as any).toString()).toString();
}
list.push(e);
}
}
......
<template>
<!-- #ifdef APP -->
<layout-root>
<!-- #endif -->
<view class="page-container">
<HomeFrame ref="homeRef" :show-footer="true">
<template #home>
......@@ -31,9 +29,7 @@
</template>
</HomeFrame>
</view>
<!-- #ifdef APP -->
</layout-root>
<!-- #endif -->
</template>
<script setup lang="uts">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!