Showing
2 changed files
with
37 additions
and
1 deletions
| @@ -4,7 +4,8 @@ import { BreakPointType, Logger } from 'wdKit'; | @@ -4,7 +4,8 @@ import { BreakPointType, Logger } from 'wdKit'; | ||
| 4 | import { CompUtils } from '../../utils/CompUtils'; | 4 | import { CompUtils } from '../../utils/CompUtils'; |
| 5 | import { ProcessUtils } from 'wdRouter'; | 5 | import { ProcessUtils } from 'wdRouter'; |
| 6 | import { EmptyComponent } from '../view/EmptyComponent'; | 6 | import { EmptyComponent } from '../view/EmptyComponent'; |
| 7 | -import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | 7 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; |
| 8 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 8 | 9 | ||
| 9 | const TAG = 'Zh_Carousel_Layout-01'; | 10 | const TAG = 'Zh_Carousel_Layout-01'; |
| 10 | 11 | ||
| @@ -163,6 +164,11 @@ export struct ZhCarouselLayout01 { | @@ -163,6 +164,11 @@ export struct ZhCarouselLayout01 { | ||
| 163 | struct CarouselLayout01CardView { | 164 | struct CarouselLayout01CardView { |
| 164 | private item: ContentDTO = {} as ContentDTO; | 165 | private item: ContentDTO = {} as ContentDTO; |
| 165 | private length: number = 1; // 轮播图数量 | 166 | private length: number = 1; // 轮播图数量 |
| 167 | + @State loadImg: boolean = false; | ||
| 168 | + | ||
| 169 | + async aboutToAppear(): Promise<void> { | ||
| 170 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 171 | + } | ||
| 166 | 172 | ||
| 167 | build() { | 173 | build() { |
| 168 | Stack() { | 174 | Stack() { |
| @@ -170,6 +176,12 @@ struct CarouselLayout01CardView { | @@ -170,6 +176,12 @@ struct CarouselLayout01CardView { | ||
| 170 | .width(CommonConstants.FULL_PARENT) | 176 | .width(CommonConstants.FULL_PARENT) |
| 171 | .height(CommonConstants.FULL_PARENT) | 177 | .height(CommonConstants.FULL_PARENT) |
| 172 | .objectFit(ImageFit.Cover) | 178 | .objectFit(ImageFit.Cover) |
| 179 | + .visibility(this.loadImg ? Visibility.Visible : Visibility.None) | ||
| 180 | + | ||
| 181 | + Row() | ||
| 182 | + .width(CommonConstants.FULL_PARENT) | ||
| 183 | + .height(CommonConstants.FULL_PARENT) | ||
| 184 | + .visibility(this.loadImg ? Visibility.None : Visibility.Visible) | ||
| 173 | 185 | ||
| 174 | Row() | 186 | Row() |
| 175 | .width(CommonConstants.FULL_PARENT) | 187 | .width(CommonConstants.FULL_PARENT) |
| 1 | +import { NetworkUtil, SPHelper } from 'wdKit'; | ||
| 2 | +import { SpConstants } from 'wdConstant'; | ||
| 3 | + | ||
| 4 | +async function onlyWifiLoadImg() : Promise<boolean> { | ||
| 5 | + let loadImageOnlyWifiSwitch = await SPHelper.default.get(SpConstants.SETTING_WIFI_IMAGE_SWITCH, '') || false; | ||
| 6 | + let isNetConnected = NetworkUtil.isNetConnected(); | ||
| 7 | + let netWorkStatus = NetworkUtil.getNetworkType(); | ||
| 8 | + | ||
| 9 | + if (isNetConnected) { | ||
| 10 | + if (netWorkStatus === NetworkUtil.TYPE_WIFI) { | ||
| 11 | + return true; | ||
| 12 | + } else { | ||
| 13 | + if (loadImageOnlyWifiSwitch) { | ||
| 14 | + return false | ||
| 15 | + } else { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } else { | ||
| 20 | + return false; | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +export { onlyWifiLoadImg } |
-
Please register or login to post a comment