Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(network): xhr request enable responseType (#5346)
Evan Huec5ddfc5f264
diff --git a/packages/network/src/services/http/implementations/xhr.ts b/packages/network/src/services/http/implementations/xhr.tsindex 73b18eb858..3972b0fb7d 100644--- a/packages/network/src/services/http/implementations/xhr.ts+++ b/packages/network/src/services/http/implementations/xhr.ts@@ -43,6 +43,8 @@ export class XHRHTTPImplementation implements IHTTPImplementation {const urlWithParams = request.getUrlWithParams();const fetchParams = parseFetchParamsFromRequest(request);+ const { responseType } = request;+xhr.open(request.method, urlWithParams);if (request.withCredentials) {xhr.withCredentials = true;@@ -53,7 +55,6 @@ export class XHRHTTPImplementation implements IHTTPImplementation {}let responseHeader: Nullable<ResponseHeader>;-const buildResponseHeader = () => {if (responseHeader) {return responseHeader;@@ -66,7 +67,6 @@ export class XHRHTTPImplementation implements IHTTPImplementation {const onLoadHandler = () => {const { headers, statusText, status } = buildResponseHeader();- const { responseType } = request;let body: any = null;let error: any = null;@@ -94,6 +94,13 @@ export class XHRHTTPImplementation implements IHTTPImplementation {}}+ if (responseType === 'blob' && !(body instanceof Blob)) {+ // If the responseType is blob, we should convert the response to a Blob object.+ // If the response is not a Blob object, we will make success as false to emit a HTTPResponseError.+ success = false;+ error = new Error('Response is not a Blob object');+ }+if (success) {observer.next(new HTTPResponse({@@ -132,6 +139,8 @@ export class XHRHTTPImplementation implements IHTTPImplementation {observer.error(e);};+ xhr.responseType = responseType || '';+xhr.addEventListener('load', onLoadHandler);xhr.addEventListener('error', onErrorHandler);xhr.addEventListener('abort', onErrorHandler);diff --git a/packages/ui/src/views/components/ribbon/Ribbon.tsx b/packages/ui/src/views/components/ribbon/Ribbon.tsxindex 0a8b31dd51..5d9d8b598b 100644--- a/packages/ui/src/views/components/ribbon/Ribbon.tsx+++ b/packages/ui/src/views/components/ribbon/Ribbon.tsx@@ -88,7 +88,7 @@ export function Ribbon(props: IRibbonProps) {const ribbon = menuManagerService.getMenuByPositionKey(MenuManagerPosition.RIBBON);// Collect all hidden$ Observables and their corresponding paths- const hiddenObservaleMap: Observable<boolean>[] = [];+ const hiddenObservableMap: Observable<boolean>[] = [];const hiddenKeyMap: string[] = [];for (const group of ribbon) {if (group.children) {@@ -96,7 +96,7 @@ export function Ribbon(props: IRibbonProps) {if (item.children) {for (const child of item.children) {if (child.item?.hidden$) {- hiddenObservaleMap.push(child.item.hidden$);+ hiddenObservableMap.push(child.item.hidden$);hiddenKeyMap.push(`${group.key}/${item.key}/${child.key}`);}}@@ -106,7 +106,7 @@ export function Ribbon(props: IRibbonProps) {}// Only get the current value once, not continuously subscribe- combineLatest(hiddenObservaleMap)+ combineLatest(hiddenObservableMap).subscribe((hiddenMap) => {const newRibbon: IMenuSchema[] = [];