|
@ -89,17 +89,15 @@ export function emitBridgeEvent(event: MobileDatagram) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function registerBridgeFunc() { |
|
|
export function registerBridgeFunc() { |
|
|
// window.bridgeFunc = {
|
|
|
|
|
|
// peripheralStatus: (param: string) => {
|
|
|
|
|
|
// bridgeSub.next({ func: 'peripheralStatus', data: JSON.parse(param) });
|
|
|
|
|
|
// },
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// window.bridgeCall = (func, param) => {
|
|
|
|
|
|
// const res = window.bridgeFunc[func].call(null, param);
|
|
|
|
|
|
// console.log('res:', res);
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// window.bridgeFunc = {
|
|
|
|
|
|
// peripheralStatus: (param: string) => {
|
|
|
|
|
|
// bridgeSub.next({ func: 'peripheralStatus', data: JSON.parse(param) });
|
|
|
|
|
|
// },
|
|
|
|
|
|
// };
|
|
|
|
|
|
// window.bridgeCall = (func, param) => {
|
|
|
|
|
|
// const res = window.bridgeFunc[func].call(null, param);
|
|
|
|
|
|
// console.log('res:', res);
|
|
|
|
|
|
// };
|
|
|
// const jsFuncs = ['funcInJs'];
|
|
|
// const jsFuncs = ['funcInJs'];
|
|
|
// jsFuncs.forEach((funcName) => {
|
|
|
// jsFuncs.forEach((funcName) => {
|
|
|
// window.WebViewJavascriptBridge.registerHandler(funcName, (data, callback) => {
|
|
|
// window.WebViewJavascriptBridge.registerHandler(funcName, (data, callback) => {
|
|
@ -216,4 +214,47 @@ export default class Bridge { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static scanPeripherals() { |
|
|
|
|
|
return httpRequest<BridgeBaseResult>({ |
|
|
|
|
|
url: '/api/ble/list/start', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params: {}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
static stopScanPeripherals() { |
|
|
|
|
|
return httpRequest<BridgeBaseResult>({ |
|
|
|
|
|
url: '/api/ble/list/stop', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params: {}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
static connectPeripheral(params: { id: string }) { |
|
|
|
|
|
return httpRequest<BridgeBaseResult>({ |
|
|
|
|
|
url: '/api/ble/connect', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
static disconnectPeripheral() { |
|
|
|
|
|
return httpRequest<BridgeBaseResult>({ |
|
|
|
|
|
url: '/api/ble/disconnect', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params: {}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
static getConfig() { |
|
|
|
|
|
return httpRequest<BridgeBaseResult<{ server: string }>>({ |
|
|
|
|
|
url: '/api/system/config', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params: {}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
static saveConfig(params: { server: string }) { |
|
|
|
|
|
return httpRequest<BridgeBaseResult<{ server: string }>>({ |
|
|
|
|
|
url: '/api/system/config/save', |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
params, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |