orion-design 0.1.29 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Throne/index.js +30 -14
- package/dist/Throne/index.js.map +1 -1
- package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
- package/dist/components/Button/index.js +40 -33
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Flex/index.js +122 -89
- package/dist/components/Flex/index.js.map +1 -1
- package/dist/components/Form/Form.js +2 -2
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/LovInput/LovInput.js +2 -2
- package/dist/components/Form/LovInput/LovInput.js.map +1 -1
- package/dist/components/Form/LovInput/hooks/useLov.js +5 -5
- package/dist/components/Form/LovInput/hooks/useLov.js.map +1 -1
- package/dist/components/Form/LovInput/index.js +4 -4
- package/dist/components/Form/hooks/FormItemValidateTrigger.js +2 -2
- package/dist/components/Form/hooks/FormItemValidateTrigger.js.map +1 -1
- package/dist/components/Form/hooks/index.js +128 -66
- package/dist/components/Form/hooks/index.js.map +1 -1
- package/dist/components/Form/index.js +836 -656
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/Form/utils/index.js +30 -18
- package/dist/components/Form/utils/index.js.map +1 -1
- package/dist/components/LovTable/LovPagetable.vue.d.ts +28 -0
- package/dist/components/LovTable/index.d.ts +14 -0
- package/dist/components/LovTable/index.js +179 -105
- package/dist/components/LovTable/index.js.map +1 -1
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Modal/ModalLocator.vue.d.ts +20 -0
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.js +127 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +18 -0
- package/dist/components/Modal/types.js +7 -0
- package/dist/components/Modal/types.js.map +1 -0
- package/dist/components/Modal/useModal.d.ts +1 -3
- package/dist/components/Modal/useModal.js +5 -4
- package/dist/components/Modal/useModal.js.map +1 -1
- package/dist/components/Pagetable/Pagetable.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnButtongroup.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnDate.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnDiy.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnLink.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnMultiselect.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnNumber.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnSingleselect.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnString.d.ts +13 -0
- package/dist/components/Pagetable/hooks/useColumns.js +88 -74
- package/dist/components/Pagetable/hooks/useColumns.js.map +1 -1
- package/dist/components/Pagetable/index.d.ts +9 -0
- package/dist/components/Pagetable/index.js +697 -491
- package/dist/components/Pagetable/index.js.map +1 -1
- package/dist/components/Pagetable/utils/index.js +92 -54
- package/dist/components/Pagetable/utils/index.js.map +1 -1
- package/dist/components/Querytable/hooks/useColumns.js +82 -74
- package/dist/components/Querytable/hooks/useColumns.js.map +1 -1
- package/dist/components/Querytable/index.js +579 -469
- package/dist/components/Querytable/index.js.map +1 -1
- package/dist/components/Querytable/utils/index.js +92 -54
- package/dist/components/Querytable/utils/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.js +100 -74
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/Tabs/constants.js +2 -2
- package/dist/components/Tabs/constants.js.map +1 -1
- package/dist/components/Tabs/index.js +603 -358
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/tab-bar.js +6 -6
- package/dist/components/Tabs/tab-bar.js.map +1 -1
- package/dist/components/Tabs/tab-pane.js +3 -3
- package/dist/components/Tabs/tab-pane.js.map +1 -1
- package/dist/components/_constants/aria.js +2 -2
- package/dist/components/_constants/aria.js.map +1 -1
- package/dist/components/_constants/event.js +6 -4
- package/dist/components/_constants/event.js.map +1 -1
- package/dist/components/_constants/index.js +6 -6
- package/dist/components/_hooks/index.js +7 -7
- package/dist/components/_hooks/use-namespace/index.js +74 -39
- package/dist/components/_hooks/use-namespace/index.js.map +1 -1
- package/dist/components/_hooks/use-ordered-children/index.js +29 -19
- package/dist/components/_hooks/use-ordered-children/index.js.map +1 -1
- package/dist/components/_util/arrays.js +9 -5
- package/dist/components/_util/arrays.js.map +1 -1
- package/dist/components/_util/browser.js +6 -6
- package/dist/components/_util/browser.js.map +1 -1
- package/dist/components/_util/classNames.js +22 -17
- package/dist/components/_util/classNames.js.map +1 -1
- package/dist/components/_util/dom/aria.js +74 -39
- package/dist/components/_util/dom/aria.js.map +1 -1
- package/dist/components/_util/dom/element.js +9 -8
- package/dist/components/_util/dom/element.js.map +1 -1
- package/dist/components/_util/dom/event.js +14 -7
- package/dist/components/_util/dom/event.js.map +1 -1
- package/dist/components/_util/dom/index.js +36 -36
- package/dist/components/_util/dom/position.js +49 -25
- package/dist/components/_util/dom/position.js.map +1 -1
- package/dist/components/_util/dom/scroll.js +103 -61
- package/dist/components/_util/dom/scroll.js.map +1 -1
- package/dist/components/_util/dom/style.js +65 -50
- package/dist/components/_util/dom/style.js.map +1 -1
- package/dist/components/_util/easings.js +8 -4
- package/dist/components/_util/easings.js.map +1 -1
- package/dist/components/_util/error.js +12 -11
- package/dist/components/_util/error.js.map +1 -1
- package/dist/components/_util/functions.js +3 -3
- package/dist/components/_util/i18n.js +2 -2
- package/dist/components/_util/i18n.js.map +1 -1
- package/dist/components/_util/index.js +137 -137
- package/dist/components/_util/isValid.js +4 -2
- package/dist/components/_util/isValid.js.map +1 -1
- package/dist/components/_util/objects.js +18 -14
- package/dist/components/_util/objects.js.map +1 -1
- package/dist/components/_util/props-util/index.js +46 -20
- package/dist/components/_util/props-util/index.js.map +1 -1
- package/dist/components/_util/props-util/initDefaultProps.js +18 -10
- package/dist/components/_util/props-util/initDefaultProps.js.map +1 -1
- package/dist/components/_util/raf.js +5 -4
- package/dist/components/_util/raf.js.map +1 -1
- package/dist/components/_util/rand.js +4 -3
- package/dist/components/_util/rand.js.map +1 -1
- package/dist/components/_util/strings.js +9 -8
- package/dist/components/_util/strings.js.map +1 -1
- package/dist/components/_util/throttleByRaf.js +16 -10
- package/dist/components/_util/throttleByRaf.js.map +1 -1
- package/dist/components/_util/type.js +41 -38
- package/dist/components/_util/type.js.map +1 -1
- package/dist/components/_util/types.js +41 -22
- package/dist/components/_util/types.js.map +1 -1
- package/dist/components/_util/typescript.js +2 -2
- package/dist/components/_util/typescript.js.map +1 -1
- package/dist/components/_util/util.js +85 -43
- package/dist/components/_util/util.js.map +1 -1
- package/dist/components/_util/vue/global-node.js +27 -15
- package/dist/components/_util/vue/global-node.js.map +1 -1
- package/dist/components/_util/vue/icon.js +29 -25
- package/dist/components/_util/vue/icon.js.map +1 -1
- package/dist/components/_util/vue/index.js +41 -41
- package/dist/components/_util/vue/install.js +35 -18
- package/dist/components/_util/vue/install.js.map +1 -1
- package/dist/components/_util/vue/props/index.js +6 -6
- package/dist/components/_util/vue/props/runtime.js +46 -30
- package/dist/components/_util/vue/props/runtime.js.map +1 -1
- package/dist/components/_util/vue/refs.js +12 -6
- package/dist/components/_util/vue/refs.js.map +1 -1
- package/dist/components/_util/vue/size.js +5 -3
- package/dist/components/_util/vue/size.js.map +1 -1
- package/dist/components/_util/vue/validator.js +5 -4
- package/dist/components/_util/vue/validator.js.map +1 -1
- package/dist/components/_util/vue/vnode.js +100 -54
- package/dist/components/_util/vue/vnode.js.map +1 -1
- package/dist/components/_util/vue-types/index.js +231 -220
- package/dist/components/_util/vue-types/index.js.map +1 -1
- package/dist/components/components.js +20 -20
- package/dist/components/index.js +38 -35
- package/dist/components/index.js.map +1 -1
- package/dist/components-8oZ2kpUC.js +27 -0
- package/dist/components-8oZ2kpUC.js.map +1 -0
- package/dist/components-B3d9m_tn.js +27 -0
- package/dist/components-B3d9m_tn.js.map +1 -0
- package/dist/error/OrionError.js +8 -4
- package/dist/error/OrionError.js.map +1 -1
- package/dist/functions-BeMkokbY.js +63 -0
- package/dist/functions-BeMkokbY.js.map +1 -0
- package/dist/index-BOKLZnqH.js +54 -0
- package/dist/index-BOKLZnqH.js.map +1 -0
- package/dist/index-D1m0KTpK.js +69 -0
- package/dist/index-D1m0KTpK.js.map +1 -0
- package/dist/index-DR5ZP7mD.js +160 -0
- package/dist/index-DR5ZP7mD.js.map +1 -0
- package/dist/index-DkwIULcN.js +200 -0
- package/dist/index-DkwIULcN.js.map +1 -0
- package/dist/index.css +797 -1
- package/dist/index.js +36 -36
- package/dist/print/LodopFuncs.js +101 -43
- package/dist/print/LodopFuncs.js.map +1 -1
- package/dist/print/index.js +200 -108
- package/dist/print/index.js.map +1 -1
- package/dist/request/ErrorHandlerChain.js +17 -14
- package/dist/request/ErrorHandlerChain.js.map +1 -1
- package/dist/request/RequestFilterChain.js +16 -13
- package/dist/request/RequestFilterChain.js.map +1 -1
- package/dist/request/ResponseParserChain.js +17 -14
- package/dist/request/ResponseParserChain.js.map +1 -1
- package/dist/request/disivion/DateSerializer.js +47 -22
- package/dist/request/disivion/DateSerializer.js.map +1 -1
- package/dist/request/disivion/DivisionErrorHandler.js +40 -25
- package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
- package/dist/request/disivion/DivisionResponseParser.js +16 -10
- package/dist/request/disivion/DivisionResponseParser.js.map +1 -1
- package/dist/request/disivion/index.js +305 -201
- package/dist/request/disivion/index.js.map +1 -1
- package/dist/request/error/BizExceptionResponseError.js +11 -5
- package/dist/request/error/BizExceptionResponseError.js.map +1 -1
- package/dist/request/error/ExceptionResponseError.js +11 -5
- package/dist/request/error/ExceptionResponseError.js.map +1 -1
- package/dist/request/error/ResponseError.js +9 -4
- package/dist/request/error/ResponseError.js.map +1 -1
- package/dist/request/error/SessionExceptionResponseError.js +11 -5
- package/dist/request/error/SessionExceptionResponseError.js.map +1 -1
- package/dist/request/index.js +11 -11
- package/dist/utils/DateUtil.js +48 -33
- package/dist/utils/DateUtil.js.map +1 -1
- package/dist/utils/NumberUtil.js +6 -6
- package/dist/utils/NumberUtil.js.map +1 -1
- package/dist/utils/cloneDeep.js +2 -2
- package/dist/utils/delay.js +3 -3
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/functions.js +3 -3
- package/dist/utils/index.js +12 -12
- package/dist/utils/md5.js +191 -93
- package/dist/utils/md5.js.map +1 -1
- package/dist/utils/uuid.js +35 -25
- package/dist/utils/uuid.js.map +1 -1
- package/dist/version/index.js +2 -2
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +2 -2
- package/dist/version/version.js.map +1 -1
- package/package.json +1 -1
- package/dist/components-J6-qau6Y.js +0 -73
- package/dist/components-J6-qau6Y.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DateSerializer.js","sources":["../../../src/request/disivion/DateSerializer.ts"],"sourcesContent":["import dayjs from 'dayjs'\r\n\r\nexport default class DateSerializer {\r\n private format: string \r\n\r\n constructor(format = 'YYYY-MM-DD HH:mm:ss.SSS') {\r\n this.format = format\r\n }\r\n\r\n serialize(data: Record<string, unknown>) {\r\n const format = this.format\r\n\r\n function objTransfer(data: any): Record<any, unknown> {\r\n const result: Record<any, unknown> = {}\r\n Object.keys(data).forEach((key) => {\r\n const value = data[key]\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n result[key] = dayjs(value).format(format)\r\n } else if (value && value instanceof Object && !Array.isArray(value)) {\r\n result[key] = objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n result[key] = arrayTransfer(value)\r\n } else {\r\n result[key] = value\r\n }\r\n })\r\n return result\r\n }\r\n function arrayTransfer(data: Array<unknown>): Array<unknown> {\r\n return data.map((value) => {\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n return dayjs(value).format(format)\r\n } else if (value && value instanceof Object && !Array.isArray(value)) {\r\n return objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n return arrayTransfer(value)\r\n } else {\r\n return value\r\n }\r\n })\r\n }\r\n\r\n Object.keys(data).forEach((key) => {\r\n const value = data[key]\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n data[key] = dayjs(value).format(this.format)\r\n } else if (value && typeof value == 'object' && !Array.isArray(value)) {\r\n data[key] = objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n data[key] = arrayTransfer(value)\r\n }\r\n })\r\n }\r\n}\r\n"],"names":["
|
1
|
+
{"version":3,"file":"DateSerializer.js","sources":["../../../src/request/disivion/DateSerializer.ts"],"sourcesContent":["import dayjs from 'dayjs'\r\n\r\nexport default class DateSerializer {\r\n private format: string \r\n\r\n constructor(format = 'YYYY-MM-DD HH:mm:ss.SSS') {\r\n this.format = format\r\n }\r\n\r\n serialize(data: Record<string, unknown>) {\r\n const format = this.format\r\n\r\n function objTransfer(data: any): Record<any, unknown> {\r\n const result: Record<any, unknown> = {}\r\n Object.keys(data).forEach((key) => {\r\n const value = data[key]\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n result[key] = dayjs(value).format(format)\r\n } else if (value && value instanceof Object && !Array.isArray(value)) {\r\n result[key] = objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n result[key] = arrayTransfer(value)\r\n } else {\r\n result[key] = value\r\n }\r\n })\r\n return result\r\n }\r\n function arrayTransfer(data: Array<unknown>): Array<unknown> {\r\n return data.map((value) => {\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n return dayjs(value).format(format)\r\n } else if (value && value instanceof Object && !Array.isArray(value)) {\r\n return objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n return arrayTransfer(value)\r\n } else {\r\n return value\r\n }\r\n })\r\n }\r\n\r\n Object.keys(data).forEach((key) => {\r\n const value = data[key]\r\n if (value instanceof Date || dayjs.isDayjs(value)) {\r\n data[key] = dayjs(value).format(this.format)\r\n } else if (value && typeof value == 'object' && !Array.isArray(value)) {\r\n data[key] = objTransfer(value)\r\n } else if (value && Array.isArray(value)) {\r\n data[key] = arrayTransfer(value)\r\n }\r\n })\r\n }\r\n}\r\n"],"names":["data"],"mappings":";;;;AAEA,MAAqB,eAAe;AAAA,EAGlC,YAAY,SAAS,2BAA2B;AAFxC;AAGN,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,UAAU,MAA+B;AACvC,UAAM,SAAS,KAAK;AAEpB,aAAS,YAAYA,OAAiC;AACpD,YAAM,SAA+B,CAAA;AACrC,aAAO,KAAKA,KAAI,EAAE,QAAQ,CAAC,QAAQ;AAC3B,cAAA,QAAQA,MAAK,GAAG;AACtB,YAAI,iBAAiB,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACjD,iBAAO,GAAG,IAAI,MAAM,KAAK,EAAE,OAAO,MAAM;AAAA,QAAA,WAC/B,SAAS,iBAAiB,UAAU,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC7D,iBAAA,GAAG,IAAI,YAAY,KAAK;AAAA,QACtB,WAAA,SAAS,MAAM,QAAQ,KAAK,GAAG;AACjC,iBAAA,GAAG,IAAI,cAAc,KAAK;AAAA,QAAA,OAC5B;AACL,iBAAO,GAAG,IAAI;AAAA,QAChB;AAAA,MAAA,CACD;AACM,aAAA;AAAA,IACT;AACA,aAAS,cAAcA,OAAsC;AACpDA,aAAAA,MAAK,IAAI,CAAC,UAAU;AACzB,YAAI,iBAAiB,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACjD,iBAAO,MAAM,KAAK,EAAE,OAAO,MAAM;AAAA,QAAA,WACxB,SAAS,iBAAiB,UAAU,CAAC,MAAM,QAAQ,KAAK,GAAG;AACpE,iBAAO,YAAY,KAAK;AAAA,QACf,WAAA,SAAS,MAAM,QAAQ,KAAK,GAAG;AACxC,iBAAO,cAAc,KAAK;AAAA,QAAA,OACrB;AACE,iBAAA;AAAA,QACT;AAAA,MAAA,CACD;AAAA,IACH;AAEA,WAAO,KAAK,IAAI,EAAE,QAAQ,CAAC,QAAQ;AAC3B,YAAA,QAAQ,KAAK,GAAG;AACtB,UAAI,iBAAiB,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACjD,aAAK,GAAG,IAAI,MAAM,KAAK,EAAE,OAAO,KAAK,MAAM;AAAA,MAAA,WAClC,SAAS,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,KAAK,GAAG;AAChE,aAAA,GAAG,IAAI,YAAY,KAAK;AAAA,MACpB,WAAA,SAAS,MAAM,QAAQ,KAAK,GAAG;AACnC,aAAA,GAAG,IAAI,cAAc,KAAK;AAAA,MACjC;AAAA,IAAA,CACD;AAAA,EACH;AACF;"}
|
@@ -1,37 +1,52 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
function
|
6
|
-
return new Promise((
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
})
|
1
|
+
import ResponseError from "../error/ResponseError.js";
|
2
|
+
import ExceptionResponseError from "../error/ExceptionResponseError.js";
|
3
|
+
import BizExceptionResponseError from "../error/BizExceptionResponseError.js";
|
4
|
+
import SessionExceptionResponseError from "../error/SessionExceptionResponseError.js";
|
5
|
+
function readBlob(blob) {
|
6
|
+
return new Promise((resolve) => {
|
7
|
+
const reader = new FileReader();
|
8
|
+
reader.addEventListener("loadend", () => {
|
9
|
+
resolve(reader.result);
|
10
|
+
});
|
11
|
+
reader.readAsText(blob);
|
11
12
|
});
|
12
13
|
}
|
13
|
-
class
|
14
|
+
class DivisionErrorHandler {
|
14
15
|
constructor() {
|
15
16
|
}
|
16
|
-
async handle(
|
17
|
-
if (
|
18
|
-
const
|
19
|
-
if (
|
20
|
-
const
|
21
|
-
let
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
async handle(error, chain) {
|
18
|
+
if (error instanceof ResponseError) {
|
19
|
+
const response = error.response;
|
20
|
+
if (response.status == 200) {
|
21
|
+
const rawData = response.data;
|
22
|
+
let jsonData;
|
23
|
+
if (rawData instanceof Blob) {
|
24
|
+
jsonData = await readBlob(rawData);
|
25
|
+
jsonData = JSON.parse(jsonData);
|
26
|
+
jsonData = JSON.parse(jsonData);
|
27
|
+
} else {
|
28
|
+
jsonData = rawData;
|
29
|
+
}
|
30
|
+
const { success, errorcode, data, errortext } = jsonData;
|
31
|
+
if (errorcode === "-1") {
|
32
|
+
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
33
|
+
} else if (errorcode === "-2") {
|
34
|
+
throw new BizExceptionResponseError(errortext, error, response, jsonData);
|
35
|
+
} else if (errorcode === "-3") {
|
36
|
+
throw new SessionExceptionResponseError(errortext, error, response, jsonData);
|
37
|
+
} else {
|
38
|
+
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
39
|
+
}
|
25
40
|
} else {
|
26
|
-
let
|
27
|
-
throw new
|
41
|
+
let errortext = "'" + response.config.url + "' " + response.status + " " + response.statusText;
|
42
|
+
throw new ExceptionResponseError(errortext, error, response, null);
|
28
43
|
}
|
29
44
|
}
|
30
|
-
throw
|
45
|
+
throw error;
|
31
46
|
}
|
32
47
|
}
|
33
48
|
export {
|
34
|
-
|
35
|
-
|
49
|
+
DivisionErrorHandler as default,
|
50
|
+
readBlob
|
36
51
|
};
|
37
52
|
//# sourceMappingURL=DivisionErrorHandler.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DivisionErrorHandler.js","sources":["../../../src/request/disivion/DivisionErrorHandler.ts"],"sourcesContent":["// import { Modal } from 'dw-neit-antd'\r\n// import SobekThrone from '../../throne/SobekThrone'\r\n// import SobekMsgBox from '../../msgbox/SobekMsgBox'\r\n\r\nimport type ErrorHandlerChain from '../ErrorHandlerChain'\r\n\r\nimport ResponseError from '../error/ResponseError'\r\nimport ExceptionResponseError from '../error/ExceptionResponseError'\r\nimport BizExceptionResponseError from '../error/BizExceptionResponseError'\r\nimport SessionExceptionResponseError from '../error/SessionExceptionResponseError'\r\n\r\nexport function readBlob(blob: Blob): Promise<string> {\r\n return new Promise((resolve) => {\r\n const reader = new FileReader()\r\n reader.addEventListener('loadend', () => {\r\n resolve(reader.result as string)\r\n })\r\n reader.readAsText(blob)\r\n })\r\n}\r\n\r\nexport default class DivisionErrorHandler {\r\n constructor() {}\r\n\r\n async handle(error: Error, chain: ErrorHandlerChain) {\r\n if (error instanceof ResponseError) {\r\n const response = error.response\r\n if (response.status == 200) {\r\n const rawData = response.data\r\n let jsonData\r\n\r\n if (rawData instanceof Blob) {\r\n // 文件下载抛异常JSON,在Blob里面\r\n jsonData = await readBlob(rawData)\r\n jsonData = JSON.parse(jsonData)\r\n jsonData = JSON.parse(jsonData)\r\n } else {\r\n // 普通请求的异常JSON\r\n jsonData = rawData\r\n }\r\n\r\n const { success, errorcode, data, errortext } = jsonData\r\n if (errorcode === '-1') {\r\n throw new ExceptionResponseError(errortext, error, response, jsonData)\r\n } else if (errorcode === '-2') {\r\n throw new BizExceptionResponseError(errortext, error, response, jsonData)\r\n } else if (errorcode === '-3') {\r\n throw new SessionExceptionResponseError(errortext, error, response, jsonData)\r\n } else {\r\n throw new ExceptionResponseError(errortext, error, response, jsonData)\r\n }\r\n } else {\r\n let errortext = \"'\" + response.config.url + \"' \" + response.status + ' ' + response.statusText\r\n throw new ExceptionResponseError(errortext, error, response, null)\r\n }\r\n }\r\n\r\n throw error\r\n }\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"DivisionErrorHandler.js","sources":["../../../src/request/disivion/DivisionErrorHandler.ts"],"sourcesContent":["// import { Modal } from 'dw-neit-antd'\r\n// import SobekThrone from '../../throne/SobekThrone'\r\n// import SobekMsgBox from '../../msgbox/SobekMsgBox'\r\n\r\nimport type ErrorHandlerChain from '../ErrorHandlerChain'\r\n\r\nimport ResponseError from '../error/ResponseError'\r\nimport ExceptionResponseError from '../error/ExceptionResponseError'\r\nimport BizExceptionResponseError from '../error/BizExceptionResponseError'\r\nimport SessionExceptionResponseError from '../error/SessionExceptionResponseError'\r\n\r\nexport function readBlob(blob: Blob): Promise<string> {\r\n return new Promise((resolve) => {\r\n const reader = new FileReader()\r\n reader.addEventListener('loadend', () => {\r\n resolve(reader.result as string)\r\n })\r\n reader.readAsText(blob)\r\n })\r\n}\r\n\r\nexport default class DivisionErrorHandler {\r\n constructor() {}\r\n\r\n async handle(error: Error, chain: ErrorHandlerChain) {\r\n if (error instanceof ResponseError) {\r\n const response = error.response\r\n if (response.status == 200) {\r\n const rawData = response.data\r\n let jsonData\r\n\r\n if (rawData instanceof Blob) {\r\n // 文件下载抛异常JSON,在Blob里面\r\n jsonData = await readBlob(rawData)\r\n jsonData = JSON.parse(jsonData)\r\n jsonData = JSON.parse(jsonData)\r\n } else {\r\n // 普通请求的异常JSON\r\n jsonData = rawData\r\n }\r\n\r\n const { success, errorcode, data, errortext } = jsonData\r\n if (errorcode === '-1') {\r\n throw new ExceptionResponseError(errortext, error, response, jsonData)\r\n } else if (errorcode === '-2') {\r\n throw new BizExceptionResponseError(errortext, error, response, jsonData)\r\n } else if (errorcode === '-3') {\r\n throw new SessionExceptionResponseError(errortext, error, response, jsonData)\r\n } else {\r\n throw new ExceptionResponseError(errortext, error, response, jsonData)\r\n }\r\n } else {\r\n let errortext = \"'\" + response.config.url + \"' \" + response.status + ' ' + response.statusText\r\n throw new ExceptionResponseError(errortext, error, response, null)\r\n }\r\n }\r\n\r\n throw error\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;AAWO,SAAS,SAAS,MAA6B;AAC7C,SAAA,IAAI,QAAQ,CAAC,YAAY;AACxB,UAAA,SAAS,IAAI;AACZ,WAAA,iBAAiB,WAAW,MAAM;AACvC,cAAQ,OAAO,MAAgB;AAAA,IAAA,CAChC;AACD,WAAO,WAAW,IAAI;AAAA,EAAA,CACvB;AACH;AAEA,MAAqB,qBAAqB;AAAA,EACxC,cAAc;AAAA,EAAC;AAAA,EAEf,MAAM,OAAO,OAAc,OAA0B;AACnD,QAAI,iBAAiB,eAAe;AAClC,YAAM,WAAW,MAAM;AACnB,UAAA,SAAS,UAAU,KAAK;AAC1B,cAAM,UAAU,SAAS;AACrB,YAAA;AAEJ,YAAI,mBAAmB,MAAM;AAEhB,qBAAA,MAAM,SAAS,OAAO;AACtB,qBAAA,KAAK,MAAM,QAAQ;AACnB,qBAAA,KAAK,MAAM,QAAQ;AAAA,QAAA,OACzB;AAEM,qBAAA;AAAA,QACb;AAEA,cAAM,EAAE,SAAS,WAAW,MAAM,cAAc;AAChD,YAAI,cAAc,MAAM;AACtB,gBAAM,IAAI,uBAAuB,WAAW,OAAO,UAAU,QAAQ;AAAA,QAAA,WAC5D,cAAc,MAAM;AAC7B,gBAAM,IAAI,0BAA0B,WAAW,OAAO,UAAU,QAAQ;AAAA,QAAA,WAC/D,cAAc,MAAM;AAC7B,gBAAM,IAAI,8BAA8B,WAAW,OAAO,UAAU,QAAQ;AAAA,QAAA,OACvE;AACL,gBAAM,IAAI,uBAAuB,WAAW,OAAO,UAAU,QAAQ;AAAA,QACvE;AAAA,MAAA,OACK;AACD,YAAA,YAAY,MAAM,SAAS,OAAO,MAAM,OAAO,SAAS,SAAS,MAAM,SAAS;AACpF,cAAM,IAAI,uBAAuB,WAAW,OAAO,UAAU,IAAI;AAAA,MACnE;AAAA,IACF;AAEM,UAAA;AAAA,EACR;AACF;"}
|
@@ -1,15 +1,21 @@
|
|
1
|
-
class
|
2
|
-
parse(
|
3
|
-
const
|
4
|
-
if (!
|
5
|
-
return
|
6
|
-
|
7
|
-
if (
|
8
|
-
return
|
9
|
-
|
1
|
+
class DivisionResponseParser {
|
2
|
+
parse(response, chain) {
|
3
|
+
const contentType = response.headers["content-type"];
|
4
|
+
if (!contentType) {
|
5
|
+
return chain.doParse(response, chain);
|
6
|
+
}
|
7
|
+
if (contentType.indexOf("application/json") === -1) {
|
8
|
+
return chain.doParse(response, chain);
|
9
|
+
}
|
10
|
+
const { success, errorcode, data, errortext } = typeof response.data === "string" ? JSON.parse(response.data) : response.data;
|
11
|
+
if (success === true) {
|
12
|
+
return chain.doParse(data, chain);
|
13
|
+
} else {
|
14
|
+
throw new Error(errortext);
|
15
|
+
}
|
10
16
|
}
|
11
17
|
}
|
12
18
|
export {
|
13
|
-
|
19
|
+
DivisionResponseParser as default
|
14
20
|
};
|
15
21
|
//# sourceMappingURL=DivisionResponseParser.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DivisionResponseParser.js","sources":["../../../src/request/disivion/DivisionResponseParser.ts"],"sourcesContent":["import type { AxiosResponse } from 'axios'\r\nimport type ResponseParserChain from '../ResponseParserChain'\r\n\r\nexport default class DivisionResponseParser {\r\n parse(response: AxiosResponse, chain: ResponseParserChain) {\r\n // server 端不响应内容\r\n const contentType = response.headers['content-type']\r\n if (!contentType) {\r\n return chain.doParse(response, chain)\r\n }\r\n\r\n // server 端响应的不是 application/json 协议\r\n if (contentType.indexOf('application/json') === -1) {\r\n return chain.doParse(response, chain)\r\n }\r\n\r\n // data为string时,兼容ie\r\n const { success, errorcode, data, errortext } = typeof response.data === 'string' ? JSON.parse(response.data) : response.data\r\n if (success === true) {\r\n return chain.doParse(data, chain)\r\n } else {\r\n throw new Error(errortext)\r\n }\r\n }\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"DivisionResponseParser.js","sources":["../../../src/request/disivion/DivisionResponseParser.ts"],"sourcesContent":["import type { AxiosResponse } from 'axios'\r\nimport type ResponseParserChain from '../ResponseParserChain'\r\n\r\nexport default class DivisionResponseParser {\r\n parse(response: AxiosResponse, chain: ResponseParserChain) {\r\n // server 端不响应内容\r\n const contentType = response.headers['content-type']\r\n if (!contentType) {\r\n return chain.doParse(response, chain)\r\n }\r\n\r\n // server 端响应的不是 application/json 协议\r\n if (contentType.indexOf('application/json') === -1) {\r\n return chain.doParse(response, chain)\r\n }\r\n\r\n // data为string时,兼容ie\r\n const { success, errorcode, data, errortext } = typeof response.data === 'string' ? JSON.parse(response.data) : response.data\r\n if (success === true) {\r\n return chain.doParse(data, chain)\r\n } else {\r\n throw new Error(errortext)\r\n }\r\n }\r\n}\r\n"],"names":[],"mappings":"AAGA,MAAqB,uBAAuB;AAAA,EAC1C,MAAM,UAAyB,OAA4B;AAEnD,UAAA,cAAc,SAAS,QAAQ,cAAc;AACnD,QAAI,CAAC,aAAa;AACT,aAAA,MAAM,QAAQ,UAAU,KAAK;AAAA,IACtC;AAGA,QAAI,YAAY,QAAQ,kBAAkB,MAAM,IAAI;AAC3C,aAAA,MAAM,QAAQ,UAAU,KAAK;AAAA,IACtC;AAGA,UAAM,EAAE,SAAS,WAAW,MAAM,cAAc,OAAO,SAAS,SAAS,WAAW,KAAK,MAAM,SAAS,IAAI,IAAI,SAAS;AACzH,QAAI,YAAY,MAAM;AACb,aAAA,MAAM,QAAQ,MAAM,KAAK;AAAA,IAAA,OAC3B;AACC,YAAA,IAAI,MAAM,SAAS;AAAA,IAC3B;AAAA,EACF;AACF;"}
|