🐛(component): 修复 ident 属性带来的 typescript 警告

This commit is contained in:
就眠儀式
2022-10-13 17:21:40 +08:00
parent a2bcc81db5
commit 3de170d454
6 changed files with 48 additions and 28 deletions

View File

@@ -3,10 +3,11 @@ export function indentHandle(obj: {
indent: boolean | string;
level: number;
basePadding?: number;
isTree?: boolean;
}) {
const { indent, level, basePadding = 0 } = obj;
const { indent, level, basePadding = 0, isTree } = obj;
const least: number = level - 1; // 第一层不缩进
if (indent && least > 0) {
if (isTree && indent && least > 0) {
const px =
typeof indent === "boolean"
? `${basePadding + 10 * least}px` // css样式表对<a>设定了23基础边距

View File

@@ -46,7 +46,7 @@ const needTooltip = computed(
<li
class="layui-nav-item"
:class="[selectedKey === id ? 'layui-this' : '']"
:style="isTree && indentHandle({ indent, level })"
:style="indentHandle({ indent, level, isTree })"
@click="selectHandle()"
>
<template v-if="needTooltip">

View File

@@ -75,13 +75,7 @@ const openHandle = function () {
<a
href="javascript:void(0)"
@click="openHandle()"
:style="
indentHandle({
indent,
level,
basePadding: 23,
})
"
:style="indentHandle({indent,level,basePadding: 23,isTree})"
>
<!-- 图标 -->
<i v-if="slots.icon" class="layui-sub-menu-icon">

View File

@@ -130,7 +130,14 @@ const props = withDefaults(defineProps<LayUploadProps>(), {
const slot = useSlots();
const slots = slot.default && slot.default();
const context = getCurrentInstance();
const emit = defineEmits(["choose","before","done","error","cutdone","cutcancel"]);
const emit = defineEmits([
"choose",
"before",
"done",
"error",
"cutdone",
"cutcancel",
]);
const isDragEnter = ref(false);
const activeUploadFiles = ref<any[]>([]);
@@ -140,7 +147,7 @@ let _cropper: any = null;
let computedCutLayerOption: ComputedRef<LayerModal>;
if (props.cutOptions && props.cutOptions.layerOption) {
if (props.cutOptions && props.cutOptions.layerOption) {
computedCutLayerOption = computed(() =>
Object.assign(defaultCutLayerOption, props.cutOptions.layerOption)
);
@@ -227,13 +234,24 @@ const localUpload = (option: localUploadOption, callback: Function) => {
xhr.onreadystatechange = function () {
let currentTimeStamp = new Date().valueOf();
if (xhr.readyState === 1) {
if ((xhr.status >= 200 && xhr.status <= 300) || xhr.status === 304 || xhr.status == 0) {
if (
(xhr.status >= 200 && xhr.status <= 300) ||
xhr.status === 304 ||
xhr.status == 0
) {
let successText = "上传开始";
emit("before",Object.assign({ currentTimeStamp, msg: successText, ...option }));
emit(
"before",
Object.assign({ currentTimeStamp, msg: successText, ...option })
);
}
} else if (xhr.readyState === 4) {
let successText = xhr.responseText ? xhr.responseText : uploadSuccess;
if ((xhr.status >= 200 && xhr.status <= 300) || xhr.status === 304 || xhr.status == 0) {
if (
(xhr.status >= 200 && xhr.status <= 300) ||
xhr.status === 304 ||
xhr.status == 0
) {
let data = xhr.responseText;
emit("done", { currentTimeStamp, msg: successText, data: data });
}
@@ -349,23 +367,23 @@ const clickOrgInput = () => {
const dragRef = ref();
function dragEnter(e: any){
e.stopPropagation();
e.preventDefault();
function dragEnter(e: any) {
e.stopPropagation();
e.preventDefault();
}
function dragOver(e: any){
e.stopPropagation();
e.preventDefault();
function dragOver(e: any) {
e.stopPropagation();
e.preventDefault();
}
onMounted(() => {
nextTick(() => {
dragRef.value.addEventListener("dragenter",dragEnter,false);
dragRef.value.addEventListener("dragover",dragOver,false);
dragRef.value.addEventListener("drop",uploadChange,false);
})
})
dragRef.value.addEventListener("dragenter", dragEnter, false);
dragRef.value.addEventListener("dragover", dragOver, false);
dragRef.value.addEventListener("drop", uploadChange, false);
});
});
</script>
<template>
@@ -399,7 +417,13 @@ onMounted(() => {
v-else
ref="dragRef"
class="layui-upload-drag"
:class="disabled ? 'layui-upload-drag-disable' : isDragEnter ? 'layui-upload-drag-draging' : ''"
:class="
disabled
? 'layui-upload-drag-disable'
: isDragEnter
? 'layui-upload-drag-draging'
: ''
"
@click.stop="chooseFile"
>
<i class="layui-icon"></i>