| | |
| | | return axios.create({ |
| | | baseURL: MAIN_URL, |
| | | timeout: 1200000, |
| | | headers: { 'Content-Type': 'application/json;charset=utf-8 ' }, |
| | | headers: { |
| | | 'Content-Type': 'application/x-www-form-urlencoded', |
| | | }, |
| | | ...option, |
| | | }); |
| | | }; |
| | |
| | | responseType: 'stream', |
| | | }); |
| | | const decoder = new TextDecoder(); |
| | | const encoder = new TextEncoder(); |
| | | const readStream = async (stream: ReadableStream, cb: (value) => void): Promise<any> => { |
| | | const reader = stream.getReader(); |
| | | let lastValue = ''; |
| | |
| | | // const txt = decoder.decode(Uint8Array.from([...lastValue, ...value])); |
| | | const txt = decoder.decode(value); |
| | | const txtArr = txt.split('\n'); |
| | | txtArr[0] =lastValue+ txtArr[0] |
| | | txtArr[0] = lastValue + txtArr[0]; |
| | | txtArr.forEach((value, index, array) => { |
| | | // 一般不会出现连续换行,只可能最后一个是换行 |
| | | if (index === array.length - 1) { |
| | | lastValue =value; |
| | | |
| | | lastValue = value; |
| | | } else { |
| | | const decodeValue = decodeURIComponent(value); |
| | | fullValue += decodeValue; |