feat: add the global constant "__UNI_PLATFORM__"
This commit is contained in:
parent
8db5470522
commit
c214ebedfb
14
global.d.ts
vendored
Normal file
14
global.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
declare const __UNI_PLATFORM__:
|
||||||
|
| 'h5'
|
||||||
|
| 'app'
|
||||||
|
| 'mp-alipay'
|
||||||
|
| 'mp-baidu'
|
||||||
|
| 'mp-jd'
|
||||||
|
| 'mp-kuaishou'
|
||||||
|
| 'mp-lark'
|
||||||
|
| 'mp-qq'
|
||||||
|
| 'mp-toutiao'
|
||||||
|
| 'mp-weixin'
|
||||||
|
| 'quickapp-webview'
|
||||||
|
| 'quickapp-webview-huawei'
|
||||||
|
| 'quickapp-webview-union'
|
@ -17,6 +17,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text-center text-4xl main-title-color mt-4">unibest</view>
|
<view class="text-center text-4xl main-title-color mt-4">unibest</view>
|
||||||
<view class="text-center text-2xl mt-2 mb-8">最好用的 uniapp 开发模板</view>
|
<view class="text-center text-2xl mt-2 mb-8">最好用的 uniapp 开发模板</view>
|
||||||
|
|
||||||
<view class="text-justify max-w-100 m-auto text-4 indent mb-2">{{ description }}</view>
|
<view class="text-justify max-w-100 m-auto text-4 indent mb-2">{{ description }}</view>
|
||||||
<view class="mt-8 text-center">
|
<view class="mt-8 text-center">
|
||||||
<text class="text-green-400">在线文档:</text>
|
<text class="text-green-400">在线文档:</text>
|
||||||
@ -40,12 +41,21 @@
|
|||||||
</a>
|
</a>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="text-center py-4" v-if="isH5">当前平台是 - h5</view>
|
||||||
|
<view class="text-center py-4" v-else-if="isApp">当前平台是 - app</view>
|
||||||
|
<view class="text-center py-4" v-else>当前平台是 - {{ platform }}</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// 获取屏幕边界到安全区域距离
|
// 获取屏幕边界到安全区域距离
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
|
const platform = __UNI_PLATFORM__
|
||||||
|
const isH5 = __UNI_PLATFORM__ === 'h5'
|
||||||
|
const isApp = __UNI_PLATFORM__ === 'app'
|
||||||
|
const isMP = __UNI_PLATFORM__.startsWith('mp-')
|
||||||
|
const isQuickApp = __UNI_PLATFORM__.startsWith('quickapp-')
|
||||||
|
|
||||||
const author = ref('菲鸽')
|
const author = ref('菲鸽')
|
||||||
const description = ref(
|
const description = ref(
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
"@dcloudio/types",
|
"@dcloudio/types",
|
||||||
"@types/wechat-miniprogram",
|
"@types/wechat-miniprogram",
|
||||||
"@uni-helper/uni-app-types",
|
"@uni-helper/uni-app-types",
|
||||||
"wot-design-uni/global.d.ts"
|
"wot-design-uni/global.d.ts",
|
||||||
|
"./global.d.ts"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
|
@ -108,7 +108,9 @@ export default ({ command, mode }) => {
|
|||||||
// TODO: 缓存每次压缩过的图片,已经压缩过的不再压缩
|
// TODO: 缓存每次压缩过的图片,已经压缩过的不再压缩
|
||||||
imagemin(mode === 'production'),
|
imagemin(mode === 'production'),
|
||||||
],
|
],
|
||||||
|
define: {
|
||||||
|
__UNI_PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
|
||||||
|
},
|
||||||
css: {
|
css: {
|
||||||
postcss: {
|
postcss: {
|
||||||
plugins: [
|
plugins: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user