Files
orion-visor/orion-visor-ui/src/mock/index.ts

44 lines
955 B
TypeScript
Raw Normal View History

2023-07-24 10:05:07 +08:00
import Mock from 'mockjs';
2023-07-29 13:11:19 +08:00
// import './user';
2023-07-24 10:05:07 +08:00
import '@/views/dashboard/workplace/mock';
2024-08-23 01:44:05 +08:00
// Mock XHR
interface XHR {
responseType: string;
timeout: number;
withCredentials: boolean;
onabort: () => void;
onerror: () => void;
onload: () => void;
onloadend: () => void;
onloadstart: () => void;
onprogress: () => void;
onreadystatechange: () => void;
ontimeout: () => void;
}
// Mock XHR Custom
interface XHRCustom extends XHR {
custom: XHRCustom;
xhr: XHR;
match: boolean;
}
// @ts-ignore
Mock.XHR.prototype.send = (() => {
// @ts-ignore
const _send = Mock.XHR.prototype.send;
return function (this: XHRCustom) {
if (!this.match) {
this.custom.xhr.responseType = this.responseType || '';
this.custom.xhr.timeout = this.timeout || 0;
this.custom.xhr.withCredentials = this.withCredentials || false;
}
return _send.apply(this, arguments);
};
})();
2023-07-24 10:05:07 +08:00
Mock.setup({
timeout: '600-1000',
});