llj
2026-01-27 bbae990ed1f4574fa954753faeae159052d03fba
utils/common.js
@@ -340,7 +340,7 @@
            })
        })
    }
   //没有添加锁的异步查询
    async doRequest2Async({
        url,
        data,
@@ -385,16 +385,17 @@
        innerAudioContext.play(); // 播放音频
        innerAudioContext.onPlay(() => {
            //console.log('开始播放');
            console.log('开始播放');
        });
        innerAudioContext.onError((res) => {
            console.log(res.errMsg);
            console.log(res.errCode);
        });
        innerAudioContext.onPause(function() {
            //console.log('播放暂停,销毁');
            console.log('播放暂停,销毁');
            innerAudioContext.destroy();
        })
        });
    }
    // playSound(e) {
    //     // 全局维护一个音频实例,防止缓存溢出
@@ -458,6 +459,55 @@
            return handler(key, match);
        });
    }
    fieldListFilterRole({FieldList, ExcludeKeys = [] ,RoleList = null}) {
        if(!RoleList) {
            RoleList = [
                /^[a-zA-Z]+$/,
                /id$/i
            ]
        }
        if(!Array.isArray(RoleList)){
            return {
                status: false,
                data: null,
                Message: "过滤字段列表失败,规则必须是数组。"
            }
        }
        let FieldListCache = Array(...FieldList)
        RoleList.forEach(role => {
            FieldListCache = FieldListCache.filter(elem => !role.test(elem.ColmCols))
        })
        FieldListCache = FieldListCache.filter(elem => !ExcludeKeys.includes(elem.ColmCols))
        return {
            status: true,
            data: FieldListCache,
            Message: ""
        }
    }
    emptyValueFilter(item, fieldList){
        return fieldList.filter(e => {
            return item[e.ColmCols]
        })
    }
    httpFormatWs(httpUrl=this.serverUrl) {
        if(httpUrl.indexOf("http://") === 0){
            httpUrl = httpUrl.replace("http://", "")
            httpUrl = "ws://" + httpUrl.split(":")[0]+":8089/ws"
        }else if(httpUrl.indexOf("https://") === 0) {
            httpUrl = httpUrl.replace("https://", "")
            httpUrl = "wss://" + httpUrl.split(":")[0]+":8089/ws"
        }else{
            // 提示传入连接错误
        }
        return httpUrl
    }
}
export const CommonUtils = new commonUtils()