Files
device-voice-h5/tests/mock-h5-browser-init.js
luo da95a914e3
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m59s
fix: some
2026-10-13 14:53:19 +08:00

20 lines
784 B
JavaScript

// Load with agent-browser --init-script when checking the local preview.
if (location.hostname === '127.0.0.1' && location.port === '48138') {
localStorage.setItem('token', 'mock-session');
localStorage.setItem('identifier', 'A');
localStorage.setItem('customerAssetPhoneState', JSON.stringify({
type: 'object',
data: {
token: 'mock-session', identifier: 'A', customerPhone: '13800000001',
assetPhoneBound: false, assetPhoneIsOwn: false, needBindPhone: false
}
}));
const originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (method, url, ...rest) {
if (typeof url === 'string' && url.includes('/api/c/v1/')) {
url = location.origin + '/__mock/' + url.split('/api/c/v1/')[1];
}
return originalOpen.call(this, method, url, ...rest);
};
}