添加全局提示
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { ref, onMounted } from "vue";
|
||||
import AppBackground from "@/components/AppBackground.vue";
|
||||
import Header from "@/components/Header.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
@@ -19,30 +20,45 @@ defineProps({
|
||||
type: String,
|
||||
default: "auto",
|
||||
},
|
||||
isHome: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
const isIos = ref(true);
|
||||
const showHint = ref(false);
|
||||
const hintMessage = ref("");
|
||||
onMounted(() => {
|
||||
const deviceInfo = uni.getDeviceInfo();
|
||||
isIos.value = deviceInfo.osName === "ios";
|
||||
});
|
||||
const showGlobalHint = (message) => {
|
||||
hintMessage.value = message;
|
||||
showHint.value = true;
|
||||
};
|
||||
uni.$showHint = showGlobalHint;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<AppBackground :type="bgType" />
|
||||
<Header :title="title" :onBack="onBack" />
|
||||
<Header v-if="!isHome" :title="title" :onBack="onBack" />
|
||||
<view
|
||||
class="content"
|
||||
:style="{ height: `calc(100vh - ${isIos ? 98 : 95}px)`, overflow }"
|
||||
:style="{ height: isHome ? '100vh' : `calc(100vh - ${isIos ? 98 : 95}px)`, overflow }"
|
||||
>
|
||||
<slot></slot>
|
||||
</view>
|
||||
<ScreenHint :show="showHint" :onClose="() => (showHint = false)">
|
||||
{{ hintMessage }}
|
||||
</ScreenHint>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user