|
@@ -0,0 +1,21 @@
|
|
|
|
+import { compose, initial } from "@dage/service";
|
|
|
|
+
|
|
|
|
+initial({
|
|
|
|
+ fetch: window.fetch.bind(window),
|
|
|
|
+ baseURL: "https://count.4dage.com",
|
|
|
|
+ interceptor: compose(async (request, next) => {
|
|
|
|
+ const response = await next();
|
|
|
|
+ const { showError = true } = request.meta;
|
|
|
|
+
|
|
|
|
+ if (response.code !== 0) {
|
|
|
|
+ const message = response.__raw__.data.msg ?? "系统出差中";
|
|
|
|
+ // 错误信息映射
|
|
|
|
+ response.errorMessage = message;
|
|
|
|
+ if (showError) {
|
|
|
|
+ showMessage(message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return response;
|
|
|
|
+ }),
|
|
|
|
+});
|