Commit ab32e25f by cen Committed by chenwq1

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

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