Skip to content

Commit

Permalink
fix(style): use css env as bottom-padding
Browse files Browse the repository at this point in the history
Deprecate `isNewIPhone` function and related.
  • Loading branch information
j10ccc committed Oct 13, 2024
1 parent 901bd0d commit 02f3c99
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 60 deletions.
7 changes: 2 additions & 5 deletions src/components/BottomPanel/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@
border-top-left-radius: 1rem;
z-index: 3000;
background: var(--wjh-color-background-frame);
}

.bottom-bar-ios {
padding-bottom: 2rem;
}
padding-bottom: env(safe-area-inset-bottom);
}
6 changes: 1 addition & 5 deletions src/components/BottomPanel/index.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<template>
<view
class="bottom-panel"
:class="{ 'bottom-bar-ios': isNewIPhone() }"
>
<view class="bottom-panel">
<slot />
</view>
</template>

<script setup lang="ts">
import { isNewIPhone } from "@/utils";
import "./index.scss";
</script>
5 changes: 1 addition & 4 deletions src/components/PopView/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
<view
class="wjh-pop-view-body"
:class="positionClass"
:style="isNewIPhone()
&& positionClass === 'bottom'
? 'padding-bottom: 2rem' : '' "
:style="positionClass === 'bottom' && 'padding-bottom: env(safe-area-inset-bottom)'"
>
<slot />
</view>
</view>
</template>

<script setup lang="ts">
import { isNewIPhone } from "@/utils";
import "./index.scss";
import { computed, toRefs } from "vue";
Expand Down
8 changes: 2 additions & 6 deletions src/pages/lostfound/ContactMe/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
gap: 8Px;
align-items: center;
z-index: 1000;
padding-bottom: env(safe-area-inset-bottom);
@include shadow;

.arrow {
Expand All @@ -26,9 +27,4 @@
color: var(--wjh-color-primary-dark);
line-height: 150%;
}
}

.ios {
padding-bottom: 2rem;
}

}
3 changes: 1 addition & 2 deletions src/pages/lostfound/ContactMe/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import styles from "./index.module.scss";
import { isNewIPhone } from "@/utils";
import Taro from "@tarojs/taro";
const emit = defineEmits(["showHelp"]);
Expand Down Expand Up @@ -42,7 +41,7 @@ function handleTapHelp() {
</script>

<template>
<view :class="[styles.container, isNewIPhone() ? styles.ios : undefined]">
<view :class="[styles.container]">
<view :class="styles.arrow" @tap="handleClick" />
<text @tap="handleClick">
点击查看相关业务服务组织的联系方式
Expand Down
8 changes: 2 additions & 6 deletions src/pages/suit/ContactMe/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
gap: 8Px;
align-items: center;
z-index: 1000;
padding-bottom: env(safe-area-inset-bottom);
@include shadow;

.arrow {
Expand All @@ -26,9 +27,4 @@
color: var(--wjh-color-primary-dark);
line-height: 150%;
}
}

.ios {
padding-bottom: 2rem;
}

}
3 changes: 1 addition & 2 deletions src/pages/suit/ContactMe/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import styles from "./index.module.scss";
import { isNewIPhone } from "@/utils";
import Taro from "@tarojs/taro";
const emit = defineEmits(["showHelp"]);
Expand Down Expand Up @@ -39,7 +38,7 @@ function handleTapHelp() {
</script>

<template>
<view :class="[styles.container, isNewIPhone() ? styles.ios : undefined]">
<view :class="styles.container">
<view :class="styles.arrow" @tap="handleClick" />
<text @tap="handleClick">
点击查看学生事务大厅的联系方式
Expand Down
27 changes: 0 additions & 27 deletions src/utils/effects.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
import Taro from "@tarojs/taro";

/**
* 适配苹果手机的大小
* @returns
*/

export function isNewIPhone(): boolean {
const info = Taro.getSystemInfoSync();
if (!info.model) return false;
const isNewIphone = info.model.match(
"(iPhone X|iPhone XS|iPhone 11|iPhone 12|iPhone 13|iPhone 14|iPhone 15)"
)?.length;
return isNewIphone !== undefined && isNewIphone > 0;
}

export function scrollViewHeight(top = true, bottom = true) {
let topHeight = "0px";
let bottomHeight = "0px";
if (top) topHeight = isNewIPhone() ? "87px" : "60px";
if (bottom) bottomHeight = isNewIPhone() ? "88px" : "64px";
return {
height: `calc(100vh - ${topHeight} - ${bottomHeight})`
};
}

/**
* 实验室页面 精弘网络copyright
*/

export function getCopyRight() {
const currentYear = new Date().getFullYear();
return `精弘网络@${currentYear}`;
Expand Down
4 changes: 1 addition & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cookiesToString, ejectCookies } from "./cookie";
import { getCopyRight, isNewIPhone, scrollViewHeight } from "./effects";
import { getCopyRight } from "./effects";
import { fetch } from "./fetch";
import { checkBind } from "./checkBind";
import { checkNotification } from "./checkNotification";
Expand All @@ -13,8 +13,6 @@ export {
FetchResult,
ejectCookies,
cookiesToString,
isNewIPhone,
scrollViewHeight,
getCopyRight,
fetch,
checkBind,
Expand Down

0 comments on commit 02f3c99

Please sign in to comment.