UNPKG

hilink-ts

Version:

智能家居hilink扩展h5应用工具开发

697 lines (696 loc) 36.9 kB
import dayjs from "dayjs"; class Hilink { getDevCacheAll(devId, json_body, cb) { var _a, _b; window.hilinkCb.getDevCacheAll = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevCacheAll) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, "hilinkCb.getDevCacheAll"); } getDevInfo(devId, sid, json_body, cb) { var _a, _b; window.hilinkCb.getDevInfo = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevInfo) === null || _b === void 0 ? void 0 : _b.call(_a, devId, sid, json_body, "hilinkCb.getDevInfo"); } getDevInfoWithProdId(devId, sid, json_body, cb) { var _a, _b; window.hilinkCb.getDevInfoWithProdId = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevInfoWithProdId) === null || _b === void 0 ? void 0 : _b.call(_a, devId, sid, json_body, "hilinkCb.getDevInfoWithProdId"); } setDeviceInfo(devId, json_body, cb) { var _a, _b; window.hilinkCb.setDeviceInfo = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setDeviceInfo) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, "hilinkCb.setDeviceInfo"); } setMultipleDeviceInfo(devId, json_body, isParallel, isWaitAll, cb) { var _a, _b; window.hilinkCb.setMultipleDeviceInfo = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setMultipleDeviceInfo) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, isParallel, isWaitAll, "hilinkCb.setMultipleDeviceInfo"); } setDeviceInfoWithProdId(devId, json_body, cb) { var _a, _b; window.hilinkCb.setDeviceInfoWithProdId = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setDeviceInfoWithProdId) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, "hilinkCb.setDeviceInfoWithProdId"); } setLongPressDeviceInfo(devId, json_body, cb, isLongPressInProgress) { var _a, _b; window.hilinkCb.setLongPressDeviceInfo = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setLongPressDeviceInfo) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, "hilinkCb.setLongPressDeviceInfo", isLongPressInProgress); } setDeviceServiceLoop(devId, serivceId, json_body, loopFlag, intervalTime, cb) { var _a, _b; window.hilinkCb.setDeviceServiceLoop = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setDeviceServiceLoop) === null || _b === void 0 ? void 0 : _b.call(_a, devId, serivceId, json_body, loopFlag, intervalTime, "hilinkCb.setDeviceServiceLoop"); } setDeviceInfoWithoutCallback(devId, json_body) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setDeviceInfoWithoutCallback) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body); } getDevHistory(devId, pageNo, pageSize, startTime, endTime, sid, character, cb) { var _a, _b; window.hilinkCb.getDevHistory = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevHistory) === null || _b === void 0 ? void 0 : _b.call(_a, devId, pageNo + "", pageSize + "", startTime, endTime, sid, character, "hilinkCb.getDevHistory"); } deleteDeviceHistory(devId, serviceId, cursor, json_body) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteDeviceHistory) === null || _b === void 0 ? void 0 : _b.call(_a, devId, serviceId, cursor, json_body); } registerInfraredHubDevice(json_body, cb) { var _a, _b; window.hilinkCb.registerInfraredHubDevice = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.registerInfraredHubDevice) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.registerInfraredHubDevice"); } regiterInfraredHubDevice(json_body, cb) { var _a, _b; window.hilinkCb.regiterInfraredHubDevice = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.regiterInfraredHubDevice) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.regiterInfraredHubDevice"); } deleteInfraredHubDevice(devId, cb) { var _a, _b; window.hilinkCb.deleteInfraredHubDevice = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteInfraredHubDevice) === null || _b === void 0 ? void 0 : _b.call(_a, devId, "hilinkCb.deleteInfraredHubDevice"); } postDeviceExtendData(json_body, cb) { var _a, _b; window.hilinkCb.postDeviceExtendData = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.postDeviceExtendData) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.postDeviceExtendData"); } postDeviceExtendDataById(devId, cb) { var _a, _b; window.hilinkCb.postDeviceExtendDataById = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.postDeviceExtendDataById) === null || _b === void 0 ? void 0 : _b.call(_a, devId, "hilinkCb.postDeviceExtendDataById"); } getDeviceExtendData(type, cb) { var _a, _b; window.hilinkCb.getDeviceExtendData = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDeviceExtendData) === null || _b === void 0 ? void 0 : _b.call(_a, type, "hilinkCb.getDeviceExtendData"); } getDeviceExtendDataById(json_body, cb) { var _a, _b; window.hilinkCb.getDeviceExtendDataById = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDeviceExtendDataById) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.getDeviceExtendDataById"); } deleteDeviceExtendData(type, cb) { var _a, _b; window.hilinkCb.deleteDeviceExtendData = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteDeviceExtendData) === null || _b === void 0 ? void 0 : _b.call(_a, type, "hilinkCb.deleteDeviceExtendData"); } deleteDeviceExtendDataById(devId, type, cb) { var _a, _b; window.hilinkCb.deleteDeviceExtendDataById = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteDeviceExtendDataById) === null || _b === void 0 ? void 0 : _b.call(_a, devId, type, "hilinkCb.deleteDeviceExtendDataById"); } reportDeviceProfileImpermanency(devId, json_body, cb) { var _a, _b; window.hilinkCb.reportDeviceProfileImpermanency = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.reportDeviceProfileImpermanency) === null || _b === void 0 ? void 0 : _b.call(_a, devId, json_body, "hilinkCb.reportDeviceProfileImpermanency"); } deleteDevice(isAssociate, cb) { var _a, _b; window.hilinkCb.deleteDevice = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteDevice) === null || _b === void 0 ? void 0 : _b.call(_a, isAssociate, "hilinkCb.deleteDevice"); } modifyDeviceName(deviceName, cb) { var _a, _b; window.hilinkCb.modifyDeviceName = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.modifyDeviceName) === null || _b === void 0 ? void 0 : _b.call(_a, deviceName, "hilinkCb.modifyDeviceName"); } modifyDeviceRoomName(chooseRoomString, cb) { var _a, _b; window.hilinkCb.modifyDeviceRoomName = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.modifyDeviceRoomName) === null || _b === void 0 ? void 0 : _b.call(_a, chooseRoomString, "hilinkCb.modifyDeviceRoomName"); } getDeviceInfo(cb) { var _a, _b; window.hilinkCb.getDeviceInfo = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDeviceInfo) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getDeviceInfo"); } uploadObjectReq(file, additionInfo, cb) { var _a, _b; window.hilinkCb.uploadObjectReq = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.uploadObjectReq) === null || _b === void 0 ? void 0 : _b.call(_a, file, additionInfo, "hilinkCb.uploadObjectReq"); } downloadObjectReq(request, cb) { var _a, _b; window.hilinkCb.downloadObjectReq = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.downloadObjectReq) === null || _b === void 0 ? void 0 : _b.call(_a, request, "hilinkCb.downloadObjectReq"); } deleteObjectReq(request, cb) { var _a, _b; window.hilinkCb.deleteObjectReq = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteObjectReq) === null || _b === void 0 ? void 0 : _b.call(_a, request, "hilinkCb.deleteObjectReq"); } getUserList(devId, cb) { var _a, _b; window.hilinkCb.getUserList = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getUserList) === null || _b === void 0 ? void 0 : _b.call(_a, devId, "hilinkCb.getUserList"); } setUserList(userInfo, cb) { var _a, _b; window.hilinkCb.setUserList = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setUserList) === null || _b === void 0 ? void 0 : _b.call(_a, userInfo, "hilinkCb.setUserList"); } updateUserList(userInfo, cb) { var _a, _b; window.hilinkCb.updateUserList = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.updateUserList) === null || _b === void 0 ? void 0 : _b.call(_a, userInfo, "hilinkCb.updateUserList"); } getDevStatisticsDataWithQuery(devId, request, cb) { var _a, _b; window.hilinkCb.getDevStatisticsDataWithQuery = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevStatisticsDataWithQuery) === null || _b === void 0 ? void 0 : _b.call(_a, devId, request, "hilinkCb.getDevStatisticsDataWithQuery"); } getDevScalarData(devId, serviceId, characteristicName, cb) { var _a, _b; window.hilinkCb.getDevScalarData = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevScalarData) === null || _b === void 0 ? void 0 : _b.call(_a, devId, serviceId, characteristicName, "hilinkCb.getDevScalarData"); } getDeviceProfile(cb) { var _a, _b; window.hilinkCb.getDeviceProfile = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDeviceProfile) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getDeviceProfile"); } getBridgeSubclassRegisteredDevices(cb) { var _a, _b; window.hilinkCb.getBridgeSubclassRegisteredDevices = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getBridgeSubclassRegisteredDevices) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getBridgeSubclassRegisteredDevices"); } getSubDeviceUrl(productId, cb) { var _a, _b; window.hilinkCb.getSubDeviceUrl = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getSubDeviceUrl) === null || _b === void 0 ? void 0 : _b.call(_a, productId, "hilinkCb.getSubDeviceUrl"); } getHilinkConnection(deviceId, cb) { var _a, _b; window.hilinkCb.getHilinkConnection = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getHilinkConnection) === null || _b === void 0 ? void 0 : _b.call(_a, deviceId, "hilinkCb.getHilinkConnection"); } getDevInfoAll(deviceId, extendData, cb) { var _a, _b; window.hilinkCb.getDevInfoAll = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDevInfoAll) === null || _b === void 0 ? void 0 : _b.call(_a, deviceId, extendData, "hilinkCb.getDevInfoAll"); } getRoomList(cb) { var _a, _b; window.hilinkCb.getRoomList = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getRoomList) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getRoomList"); } getRules(condition, cb) { var _a, _b; window.hilinkCb.getRules = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getRules) === null || _b === void 0 ? void 0 : _b.call(_a, condition, "hilinkCb.getRules"); } getSingleRule(ruleId, cb) { var _a, _b; window.hilinkCb.getSingleRule = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getSingleRule) === null || _b === void 0 ? void 0 : _b.call(_a, ruleId, "hilinkCb.getSingleRule"); } createRule(rule, cb) { var _a, _b; window.hilinkCb.createRule = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.createRule) === null || _b === void 0 ? void 0 : _b.call(_a, rule, "hilinkCb.createRule"); } updateRule(rule, cb) { var _a, _b; window.hilinkCb.updateRule = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.updateRule) === null || _b === void 0 ? void 0 : _b.call(_a, rule, "hilinkCb.updateRule"); } deleteRules(ruleIds, cb) { var _a, _b; window.hilinkCb.deleteRules = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteRules) === null || _b === void 0 ? void 0 : _b.call(_a, ruleIds, "hilinkCb.deleteRules"); } deleteSingleRule(ruleId, cb) { var _a, _b; window.hilinkCb.deleteSingleRule = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.deleteSingleRule) === null || _b === void 0 ? void 0 : _b.call(_a, ruleId, "hilinkCb.deleteSingleRule"); } controlRuleActive(ruleId, active, cb) { var _a, _b; window.hilinkCb.controlRuleActive = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.controlRuleActive) === null || _b === void 0 ? void 0 : _b.call(_a, ruleId, active, "controlRuleActive"); } getDeviceRuleEvents(cursor, pageSize, startTime, endTime, cb) { var _a, _b; window.hilinkCb.getDeviceRuleEvents = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDeviceRuleEvents) === null || _b === void 0 ? void 0 : _b.call(_a, cursor, pageSize, startTime, endTime, "hilinkCb.getDeviceRuleEvents"); } getAutoRuleSize(cb) { var _a, _b; window.hilinkCb.getAutoRuleSize = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getAutoRuleSize) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getAutoRuleSize"); } gotoVmall(suffix) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.gotoVmall) === null || _b === void 0 ? void 0 : _b.call(_a, suffix); } gotoNative(typeString, cb) { var _a, _b; window.hilinkCb.gotoNative = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.gotoNative) === null || _b === void 0 ? void 0 : _b.call(_a, typeString, "hilinkCb.gotoNative"); } showDelayInfoDialog() { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.showDelayInfoDialog) === null || _b === void 0 ? void 0 : _b.call(_a); } jumpTo(uri, cb) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; switch (uri) { case "com.huawei.smarthome.addSmartlockActivity": window.hilinkCb.jumpToAddSmartlockActivity = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.jumpTo) === null || _b === void 0 ? void 0 : _b.call(_a, uri, "hilinkCb.jumpToAddSmartlockActivity"); case "com.huawei.smarthome.deviceNetinfoActivity": window.hilinkCb.jumpToDeviceNetinfoActivity = (res) => cb(parse(res)); return (_d = (_c = window.hilink) === null || _c === void 0 ? void 0 : _c.jumpTo) === null || _d === void 0 ? void 0 : _d.call(_c, uri, "hilinkCb.jumpToDeviceNetinfoActivity"); case "com.huawei.smarthome.deviceSettingActivity": window.hilinkCb.jumpToDeviceSettingActivity = (res) => cb(parse(res)); return (_f = (_e = window.hilink) === null || _e === void 0 ? void 0 : _e.jumpTo) === null || _f === void 0 ? void 0 : _f.call(_e, uri, "hilinkCb.jumpToDeviceSettingActivity"); case "com.huawei.smarthome.deviceinfoactivity": window.hilinkCb.jumpToDeviceinfoactivity = (res) => cb(parse(res)); return (_h = (_g = window.hilink) === null || _g === void 0 ? void 0 : _g.jumpTo) === null || _h === void 0 ? void 0 : _h.call(_g, uri, "hilinkCb.jumpToDeviceinfoactivity"); case "com.huawei.smarthome.timerPage": window.hilinkCb.jumpToTimerPage = (res) => cb(parse(res)); return (_k = (_j = window.hilink) === null || _j === void 0 ? void 0 : _j.jumpTo) === null || _k === void 0 ? void 0 : _k.call(_j, uri, "hilinkCb.jumpToTimerPage"); default: break; } } jumpToOfflineHelpActivity(deviceId, hotline, cb) { var _a, _b; window.hilinkCb.jumpToOfflineHelpActivity = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.jumpToOfflineHelpActivity) === null || _b === void 0 ? void 0 : _b.call(_a, deviceId, hotline, "hilinkCb.jumpToOfflineHelpActivity"); } jumpToSelfOfflineHelpActivity(deviceId, message, cb) { var _a, _b; window.hilinkCb.jumpToSelfOfflineHelpActivity = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.jumpToSelfOfflineHelpActivity) === null || _b === void 0 ? void 0 : _b.call(_a, deviceId, message, "hilinkCb.jumpToSelfOfflineHelpActivity"); } startApp(packageName, cb) { var _a, _b; window.hilinkCb.startApp = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.startApp) === null || _b === void 0 ? void 0 : _b.call(_a, packageName, "hilinkCb.startApp"); } jumpToH5Device(listCount, cb) { var _a, _b; window.hilinkCb.jumpToH5Device = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.jumpToH5Device) === null || _b === void 0 ? void 0 : _b.call(_a, listCount, "hilinkCb.jumpToH5Device"); } modifyTitleBar(uri, argb, cb) { var _a, _b; window.hilinkCb.modifyTitleBar = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.modifyTitleBar) === null || _b === void 0 ? void 0 : _b.call(_a, uri, argb, "hilinkCb.modifyTitleBar"); } setTitleEnable(uri, cb) { var _a, _b; window.hilinkCb.setTitleEnable = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setTitleEnable) === null || _b === void 0 ? void 0 : _b.call(_a, uri, "hilinkCb.setTitleEnable"); } setTitleVisible(uri, cb) { var _a, _b; window.hilinkCb.setTitleVisible = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setTitleVisible) === null || _b === void 0 ? void 0 : _b.call(_a, uri, "hilinkCb.setTitleVisible"); } addMessage(json_body, cb) { var _a, _b; window.hilinkCb.addMessage = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.addMessage) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.addMessage"); } removeMessage(json_body, cb) { var _a, _b; window.hilinkCb.removeMessage = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.removeMessage) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.removeMessage"); } setMessageVisible(uri, cb) { var _a, _b; window.hilinkCb.setMessageVisible = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setMessageVisible) === null || _b === void 0 ? void 0 : _b.call(_a, uri, "hilinkCb.setMessageVisible"); } changeTitleStyle(styleValue) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.changeTitleStyle) === null || _b === void 0 ? void 0 : _b.call(_a, styleValue); } showTitleBarIcons(json_body, buttonClick, isVisible, cb) { var _a, _b; window.hilinkCb.showTitleBarIcons = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.showTitleBarIcons) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, buttonClick, isVisible, "hilinkCb.showTitleBarIcons"); } getStatusBarHeight(cb) { var _a, _b; window.hilinkCb.getStatusBarHeight = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getStatusBarHeight) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getStatusBarHeight"); } toast(time, body) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.toast) === null || _b === void 0 ? void 0 : _b.call(_a, time + "", body); } getPadLandscape() { var _a, _b; return ((_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getPadLandscape) === null || _b === void 0 ? void 0 : _b.call(_a)) || -1; } finishDeviceActivity() { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.finishDeviceActivity) === null || _b === void 0 ? void 0 : _b.call(_a); } printLogDebug(isSaveLog, tag, msg) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.printLogDebug) === null || _b === void 0 ? void 0 : _b.call(_a, isSaveLog, tag, msg); } printLog(isSaveLog, tag, msg) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.printLog) === null || _b === void 0 ? void 0 : _b.call(_a, isSaveLog, tag, msg); } overrideBackPressed(enable, cb) { var _a, _b; window.hilinkCb.overrideBackPressed = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.overrideBackPressed) === null || _b === void 0 ? void 0 : _b.call(_a, enable, "hilinkCb.overrideBackPressed"); } overrideSettingClick(enable, cb) { var _a, _b; window.hilinkCb.overrideSettingClick = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.overrideSettingClick) === null || _b === void 0 ? void 0 : _b.call(_a, enable, "hilinkCb.overrideSettingClick"); } requestThirdPartConfig(json_body, cb) { var _a, _b; window.hilinkCb.requestThirdPartConfig = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.requestThirdPartConfig) === null || _b === void 0 ? void 0 : _b.call(_a, json_body, "hilinkCb.requestThirdPartConfig"); } setH5Info(key, value, cb) { var _a, _b; window.hilinkCb.setH5Info = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setH5Info) === null || _b === void 0 ? void 0 : _b.call(_a, key, value, "hilinkCb.setH5Info"); } setStorageSync(key, value, cb) { var _a, _b; window.hilinkCb.setStorageSync = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setStorageSync) === null || _b === void 0 ? void 0 : _b.call(_a, key, value, "hilinkCb.setStorageSync"); } getVersion(cb) { var _a, _b; window.hilinkCb.getVersion = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getVersion) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getVersion"); } refreshWebView() { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.refreshWebView) === null || _b === void 0 ? void 0 : _b.call(_a); } verifyPassword(cb) { var _a, _b; window.hilinkCb.verifyPassword = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.verifyPassword) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.verifyPassword"); } getAppVersionCode(cb) { var _a, _b; window.hilinkCb.getAppVersionCode = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getAppVersionCode) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getAppVersionCode"); } getUserRole(cb) { var _a, _b; window.hilinkCb.getUserRole = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getUserRole) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getUserRole"); } reportH5SingleDevBiInfo(biKey, biH5Info) { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.reportH5SingleDevBiInfo) === null || _b === void 0 ? void 0 : _b.call(_a, biKey, biH5Info); } takePhoto(fileName, cb) { var _a, _b; window.hilinkCb.takePhoto = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.takePhoto) === null || _b === void 0 ? void 0 : _b.call(_a, fileName, "hilinkCb.takePhoto"); } getAppLanguageSync() { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getAppLanguageSync) === null || _b === void 0 ? void 0 : _b.call(_a); } getDarkMode(cb) { var _a, _b, _c, _d; // IOS if (navigator.userAgent.toLocaleLowerCase().includes("like mac os x")) { window.hilinkCb.getDarkMode = cb; (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.getDarkMode) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.getDarkMode"); return; } // 安卓 其他 const mode = (_d = (_c = window.hilink) === null || _c === void 0 ? void 0 : _c.getDarkMode) === null || _d === void 0 ? void 0 : _d.call(_c); cb(mode); } setGuideDialogEnable(enabled, cb) { var _a, _b; window.hilinkCb.setGuideDialogEnable = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.setGuideDialogEnable) === null || _b === void 0 ? void 0 : _b.call(_a, enabled, "hilinkCb.setGuideDialogEnable"); } isScreenSpreaded() { var _a, _b; return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.isScreenSpreaded) === null || _b === void 0 ? void 0 : _b.call(_a); } createShortCut(deviceId, productId, deviceName, cb = () => "") { var _a, _b; window.hilinkCb.createShortCut = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.createShortCut) === null || _b === void 0 ? void 0 : _b.call(_a, deviceId, productId, deviceName, "hilinkCb.createShortCut"); } doHttpsRequest(jsonBody, cb) { var _a, _b; window.hilinkCb.doHttpsRequest = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.doHttpsRequest) === null || _b === void 0 ? void 0 : _b.call(_a, jsonBody, "hilinkCb.doHttpsRequest"); } refuseSharedDevice(cb) { var _a, _b; window.hilinkCb.refuseSharedDevice = (res) => cb(parse(res)); return (_b = (_a = window.hilink) === null || _a === void 0 ? void 0 : _a.refuseSharedDevice) === null || _b === void 0 ? void 0 : _b.call(_a, "hilinkCb.refuseSharedDevice"); } } export function deviceEventCallback(cb) { window.deviceEventCallback = (res) => cb(parse(res)); } export function init() { if (!window.deviceEventCallback) { window.deviceEventCallback = () => { }; } if (!window.onPause) { window.onPause = () => { }; } if (!window.onResume) { window.onResume = () => { }; } if (!window.onNetworkChanged) { window.onNetworkChanged = () => { }; } } /** * 转换设备数据返回JSON结构 * @param result * @returns */ export function parse(result) { // 去除object外多余的 " try { return JSON.parse(result); } catch (err) { console.warn(err); try { const _result = result .replace(/"{/g, "{") .replace(/}"/g, "}") .replace(/\\|\n|\r|\t|\f|\t/g, ""); return JSON.parse(_result); } catch (e) { console.warn(e); return { errcode: 996, msg: result }; } } } window.onDeviceEventCallback = () => { }; window.hilinkCb = { getDevCacheAll() { }, getDevInfo() { }, getDevInfoWithProdId() { }, setDeviceInfo() { }, setMultipleDeviceInfo() { }, setDeviceInfoWithProdId() { }, setLongPressDeviceInfo() { }, setDeviceServiceLoop() { }, registerInfraredHubDevice() { }, regiterInfraredHubDevice() { }, deleteInfraredHubDevice() { }, postDeviceExtendData() { }, postDeviceExtendDataById() { }, getDeviceExtendData() { }, getDeviceExtendDataById() { }, deleteDeviceExtendData() { }, deleteDeviceExtendDataById() { }, reportDeviceProfileImpermanency() { }, deleteDevice() { }, modifyDeviceName() { }, modifyDeviceRoomName() { }, getDeviceInfo() { }, uploadObjectReq() { }, downloadObjectReq() { }, deleteObjectReq() { }, getUserList() { }, setUserList() { }, updateUserList() { }, getDevStatisticsDataWithQuery() { }, getDevScalarData() { }, getDeviceProfile() { }, getBridgeSubclassRegisteredDevices() { }, getSubDeviceUrl() { }, getHilinkConnection() { }, getDevInfoAll() { }, getRoomList() { }, getRules() { }, getSingleRule() { }, createRule() { }, updateRule() { }, deleteRules() { }, deleteSingleRule() { }, controlRuleActive() { }, getDeviceRuleEvents() { }, getAutoRuleSize() { }, gotoNative() { }, jumpToTimerPage() { }, jumpToDeviceinfoactivity() { }, jumpToDeviceNetinfoActivity() { }, jumpToAddSmartlockActivity() { }, jumpToDeviceSettingActivity() { }, jumpToOfflineHelpActivity() { }, jumpToSelfOfflineHelpActivity() { }, startApp() { }, jumpToH5Device() { }, modifyTitleBar() { }, setTitleEnable() { }, setTitleVisible() { }, addMessage() { }, removeMessage() { }, setMessageVisible() { }, showTitleBarIcons() { }, getStatusBarHeight() { }, overrideBackPressed() { }, overrideSettingClick() { }, requestThirdPartConfig() { }, setH5Info() { }, setStorageSync() { }, getVersion() { }, verifyPassword() { }, getAppVersionCode() { }, getUserRole() { }, takePhoto() { }, getDarkMode() { }, setGuideDialogEnable() { }, createShortCut() { }, doHttpsRequest() { }, refuseSharedDevice() { }, getDevHistory() { }, }; export var ThemeMode; (function (ThemeMode) { // 1:正常模式 2:dark模式 ThemeMode[ThemeMode["Default"] = 1] = "Default"; ThemeMode[ThemeMode["Dark"] = 2] = "Dark"; })(ThemeMode || (ThemeMode = {})); /** * 将华为世界时间格式转换为正常北京时间格式 * 20150501T010203Z => 2015-05-01 01:02:03 * @param t */ export function t2t(t) { const matchArr = t.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/); if (!matchArr) return ""; const [_, y, mm, d, h, m, s] = matchArr; const yymm = `${y}-${mm}-${d} ${h}:${m}:${s}`; return dayjs(yymm).add(8, "hour").format("YYYY-MM-DD HH:mm:ss"); } /** * 将华为时间戳格式转为正常时间戳格式 * @param t * @returns number */ export function ts2t(t) { return Number(t) || 0; } /** * 将北京正常时间转为华为时间 * @param t * @returns */ export function t2ht(t) { return dayjs(t).subtract(8, "hour").format("YYYYMMDDTHHmmss") + "Z"; } const hilink = new Hilink(); /** * desc 获取手机信息,包含系统和屏幕 * @param option */ export function getPhoneInfo() { let type = "android"; let version = "10.0.0"; let isPad = false; let isFold = false; let isPortrait = hilink.getPadLandscape() !== 0; let isDarkMode = false; let font; let changeScreen = false; let deviceType = ""; try { let ua = navigator.userAgent.toLowerCase(); let reg, matchInfo; if (ua.indexOf("like mac os x") > 0) { reg = /os [\d._]+/gi; type = "ios"; } else if (ua.indexOf("android") > 0) { reg = /android [\d._]+/gi; type = "android"; } else if (ua.indexOf("harmony") > 0) { reg = /harmony [\d._]+/gi; type = "harmony"; } reg && (matchInfo = ua.match(reg)); version = String(matchInfo) .replace(/[^0-9|_.]/gi, "") .replace(/_/gi, "."); let isUaPad = /(?:ipad|playbook)/.test(ua) || (["android", "harmony"].indexOf(type) !== -1 && !/(?:mobile)/.test(ua)); let getPadLandscape = hilink.getPadLandscape() || 0; let isScreenSpreaded = hilink.isScreenSpreaded(); // 折叠屏展开 isPad = isUaPad || getPadLandscape === 1 || getPadLandscape === 0; let browserWidth = document.documentElement.clientWidth; if (isPad) { if (isPortrait || getPadLandscape === 1) { // 10为rem换算单位,编写样式尺寸=(设计稿尺寸/10)rem // 平板竖屏设计稿宽度为800 font = (browserWidth / 800) * 10; deviceType = "pad-S"; changeScreen = true; } else { // 平板横屏设计稿宽度为422.752 font = (browserWidth / 422.752) * 10; deviceType = "phone"; } } else { if (window.screen.width > 500 || isScreenSpreaded) { // 折叠屏设计稿宽度为677 font = (browserWidth / 677) * 10; // isFold = deviceType = "phone-FoldSreen"; changeScreen = true; } else { //手机设计稿宽度为360 font = (browserWidth / 360) * 10; deviceType = "phone"; } } document.documentElement.style.fontSize = font + "px"; hilink.getDarkMode((res) => { if (res === 2) { isDarkMode = true; } }); } catch (err) { console.log("通过 navigator.userAgent 获取系统类型和版本报错,使用默认配置android 和 10"); } return { type, version, isPad, isDarkMode, isFold, isPortrait, changeScreen, deviceType }; } export default hilink;