// 是否手机端
export const isMobile = () => {
    const stauts = navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i);
    return !!stauts;
}

// 获取路由中的路径，参数等
export const getRoute = () => {
    return window.location;
}

// 表单必填项校验
export const formValidate = (fields: string[], data: any) => {
    for (let i = 0; i < fields.length; i++) {
        const item = fields[i];
        // 字符
        if (typeof data[item] === 'string' && !data[item]) {
            return false;
        }
        // 数组
        if (Array.isArray(data[item]) && !data[item].length) {
            return false;
        }
    }
    return true;
}

// 判断两个对象里的值是否相等
export const isEqual = (object1: any, object2: any) => {
    const keys1 = Object.keys(object1);
    const keys2 = Object.keys(object2);
    return true;
}


// 过滤对象中的空值
export const filterObjectField = (obj: any) => {
    const newObj = {};
    for (const key in obj) {
        if (obj[key] !== '' || obj[key] !== null || obj[key] !== undefined) {
            newObj[key] = obj[key];
        }
    }
    return newObj;
}
