refactor: platform 环境
This commit is contained in:
parent
965a87279a
commit
b17de63bec
@ -22,7 +22,7 @@
|
||||
|
||||
<view class="text-center py-4">
|
||||
当前平台是:
|
||||
<text class="text-red-500">{{ platform }}</text>
|
||||
<text class="text-red-500">{{ PLATFORM.platform }}</text>
|
||||
</view>
|
||||
<view class="desc">测试设计稿样式</view>
|
||||
<view class="desc">设计稿是750px,css里面全部写rpx 即可</view>
|
||||
@ -30,14 +30,12 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import PLATFORM from '@/utils/platform'
|
||||
|
||||
// 获取屏幕边界到安全区域距离
|
||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
|
||||
const platform = __UNI_PLATFORM__
|
||||
const isH5 = __UNI_PLATFORM__ === 'h5'
|
||||
const isApp = __UNI_PLATFORM__ === 'app'
|
||||
const isMp = __UNI_PLATFORM__.startsWith('mp-')
|
||||
console.log(platform, isH5, isApp, isMp)
|
||||
console.log(PLATFORM)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
17
src/utils/platform.ts
Normal file
17
src/utils/platform.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: 菲鸽
|
||||
* @Date: 2024-03-28 19:13:55
|
||||
* @Last Modified by: 菲鸽
|
||||
* @Last Modified time: 2024-03-28 19:24:55
|
||||
*/
|
||||
export const platform = __UNI_PLATFORM__
|
||||
export const isH5 = __UNI_PLATFORM__ === 'h5'
|
||||
export const isApp = __UNI_PLATFORM__ === 'app'
|
||||
export const isMp = __UNI_PLATFORM__.startsWith('mp-')
|
||||
const PLATFORM = {
|
||||
platform,
|
||||
isH5,
|
||||
isApp,
|
||||
isMp,
|
||||
}
|
||||
export default PLATFORM
|
Loading…
x
Reference in New Issue
Block a user