Files
shoot-miniprograms/src/components/Container.vue

70 lines
1.4 KiB
Vue
Raw Normal View History

2025-05-23 21:20:38 +08:00
<script setup>
2025-06-15 22:01:06 +08:00
import { ref, onMounted } from "vue";
2025-05-23 21:20:38 +08:00
import AppBackground from "@/components/AppBackground.vue";
import Header from "@/components/Header.vue";
2025-07-02 17:21:44 +08:00
import ScreenHint from "@/components/ScreenHint.vue";
2025-05-23 21:20:38 +08:00
defineProps({
title: {
type: String,
default: "",
},
bgType: {
2025-05-27 12:38:39 +08:00
type: Number,
2025-05-23 21:20:38 +08:00
default: 0,
},
2025-06-17 16:42:53 +08:00
onBack: {
type: Function,
default: null,
},
2025-06-18 12:32:08 +08:00
overflow: {
type: String,
default: "auto",
},
2025-07-02 17:21:44 +08:00
isHome: {
type: Boolean,
default: false,
},
2025-05-23 21:20:38 +08:00
});
2025-06-15 22:01:06 +08:00
const isIos = ref(true);
2025-07-02 17:21:44 +08:00
const showHint = ref(false);
const hintMessage = ref("");
2025-06-15 22:01:06 +08:00
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
});
2025-07-02 17:21:44 +08:00
const showGlobalHint = (message) => {
hintMessage.value = message;
showHint.value = true;
};
uni.$showHint = showGlobalHint;
2025-05-23 21:20:38 +08:00
</script>
<template>
<view>
2025-06-05 17:43:22 +08:00
<AppBackground :type="bgType" />
2025-07-02 17:21:44 +08:00
<Header v-if="!isHome" :title="title" :onBack="onBack" />
2025-06-15 22:01:06 +08:00
<view
class="content"
2025-07-02 17:21:44 +08:00
:style="{ height: isHome ? '100vh' : `calc(100vh - ${isIos ? 98 : 95}px)`, overflow }"
2025-06-15 22:01:06 +08:00
>
2025-05-23 21:20:38 +08:00
<slot></slot>
</view>
2025-07-02 17:21:44 +08:00
<ScreenHint :show="showHint" :onClose="() => (showHint = false)">
{{ hintMessage }}
</ScreenHint>
2025-05-23 21:20:38 +08:00
</view>
</template>
<style scoped>
.content {
2025-06-06 00:34:54 +08:00
width: 100vw;
2025-07-02 17:21:44 +08:00
height: 100vh;
2025-06-06 00:34:54 +08:00
overflow-x: hidden;
2025-06-02 14:42:07 +08:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
2025-06-21 12:59:59 +08:00
overflow-x: hidden;
2025-05-23 21:20:38 +08:00
}
</style>