🐛(layer): 严格要求 type 的类型

This commit is contained in:
就眠儀式 2022-06-26 00:00:46 +08:00
parent a4094f5d8a
commit 3d7c45b6e9
2 changed files with 13 additions and 11 deletions

View File

@ -60,6 +60,8 @@ export interface LayModalProps {
| 1 | 1
| 2 | 2
| 3 | 3
| 4
| 5
| "dialog" | "dialog"
| "page" | "page"
| "iframe" | "iframe"
@ -159,10 +161,10 @@ const _l: Ref<string> = ref(offset.value[1]);
const firstOpenDelayCalculation = function () { const firstOpenDelayCalculation = function () {
nextTick(async () => { nextTick(async () => {
area.value = getArea(layero.value); area.value = getArea(layero.value);
if (props.type === "drawer") { if (type == 4) {
area.value = calculateDrawerArea(props.offset, props.area); area.value = calculateDrawerArea(props.offset, props.area);
} }
if (props.type === "photos") { if (type == 5) {
// @ts-ignore // @ts-ignore
area.value = await calculatePhotosArea( area.value = await calculatePhotosArea(
props.imgList[props.startIndex].src, props.imgList[props.startIndex].src,
@ -357,7 +359,7 @@ const boxClasses = computed(() => {
type === 1 ? "layui-layer-page" : "", type === 1 ? "layui-layer-page" : "",
type === 2 ? "layui-layer-iframe" : "", type === 2 ? "layui-layer-iframe" : "",
type === 3 ? "layui-layer-loading" : "", type === 3 ? "layui-layer-loading" : "",
type === 4 ? "layui-layer-photos" : "", type === 5 ? "layui-layer-photos" : "",
props.isMessage ? "layui-layer-msg" : "", props.isMessage ? "layui-layer-msg" : "",
props.isMessage && !props.icon ? "layui-layer-hui" : "", props.isMessage && !props.icon ? "layui-layer-hui" : "",
props.skin, props.skin,
@ -602,14 +604,14 @@ defineExpose({ reset, open, close });
</template> </template>
<Iframe v-if="type === 2" :src="props.content"></Iframe> <Iframe v-if="type === 2" :src="props.content"></Iframe>
<Photos <Photos
v-if="type === 4" v-if="type === 5"
:imgList="props.imgList" :imgList="props.imgList"
:startIndex="props.startIndex" :startIndex="props.startIndex"
@resetCalculationPohtosArea="resetCalculationPohtosArea" @resetCalculationPohtosArea="resetCalculationPohtosArea"
></Photos> ></Photos>
</div> </div>
<!-- 工具栏 --> <!-- 工具栏 -->
<span class="layui-layer-setwin" v-if="type != 3 && type != 4"> <span class="layui-layer-setwin" v-if="type != 3 && type != 5">
<a <a
v-if="maxmin && !max" v-if="maxmin && !max"
class="layui-layer-min" class="layui-layer-min"

View File

@ -110,21 +110,21 @@ export function calculateOffset(offset: any, area: any, type: any) {
// 窗体类型 // 窗体类型
export function calculateType(modalType: number | string) { export function calculateType(modalType: number | string) {
if (modalType === "dialog" || modalType === 0 || modalType === "0") { if (modalType === "dialog" || modalType == 0) {
return 0; return 0;
} else if ( } else if (
modalType === "page" || modalType === "page" ||
modalType === "drawer" || modalType === "drawer" ||
modalType === 1 || modalType == 1 ||
modalType === "1" modalType == 4
) { ) {
return 1; return 1;
} else if (modalType === "iframe" || modalType === 2 || modalType === "2") { } else if (modalType === "iframe" || modalType == 2) {
return 2; return 2;
} else if (modalType === "loading" || modalType === 3 || modalType === "3") { } else if (modalType === "loading" || modalType == 3) {
return 3; return 3;
} else if (modalType === "photos") { } else if (modalType === "photos") {
return 4; return 5;
} }
return 0; return 0;
} }