@vyr/cli 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bin/default/index.js +4 -0
- package/.bin/install/index.js +2 -0
- package/.entry/app.js +362 -362
- package/build/css/{9786.6bfee4ca.css → 2357.20584c43.css} +1 -1
- package/build/css/{6151.e4de2b69.css → 4011.fc069ae3.css} +1 -1
- package/build/css/{6881.972ad8f8.css → 6881.c7cb44c0.css} +1 -1
- package/build/css/768.6c925006.css +1 -0
- package/build/css/{3745.5e7a01f4.css → 9160.6a744205.css} +1 -1
- package/build/css/{4537.9b4ae552.css → 918.1da69a00.css} +2 -2
- package/build/css/login.c49ecb09.css +1 -0
- package/build/fonts/iconfont.0d8d5af4.woff +0 -0
- package/build/fonts/{iconfont.10345b2b.ttf → iconfont.49814d77.ttf} +0 -0
- package/build/index.html +1 -1
- package/build/js/1015.6b930e6b.js +1 -0
- package/build/js/1018.feb3213b.js +1 -0
- package/build/js/150.2368d63c.js +1 -0
- package/build/js/1508.ad60597c.js +1 -0
- package/build/js/{4582.71b3bbe1.js → 1541.ab4dcc45.js} +100 -100
- package/build/js/2132.d99fd402.js +1 -0
- package/build/js/215.0003a521.js +1 -0
- package/build/js/2357.990ebfbc.js +1 -0
- package/build/js/{2546.9fd3dc42.js → 2546.3383e2b7.js} +1 -1
- package/build/js/2596.6b885678.js +1 -0
- package/build/js/288.deb7db30.js +1 -0
- package/build/js/3312.be721fac.js +1 -0
- package/build/js/344.f9b8faec.js +1 -0
- package/build/js/3553.5a3a5f4c.js +1 -0
- package/build/js/4011.4f960789.js +1 -0
- package/build/js/4939.c2476b74.js +1 -0
- package/build/js/5547.b25a8b2e.js +1 -0
- package/build/js/677.fbdce394.js +1 -0
- package/build/js/6881.52ca7073.js +1 -0
- package/build/js/7320.9345566b.js +1 -0
- package/build/js/768.cf51599f.js +1 -0
- package/build/js/7769.95421d48.js +1 -0
- package/build/js/7907.8ff46377.js +1 -0
- package/build/js/7928.6c142786.js +1 -0
- package/build/js/7963.33f8605d.js +1 -0
- package/build/js/8637.348bcf40.js +1 -0
- package/build/js/9127.9dbc1ccb.js +1 -0
- package/build/js/9160.294ecd13.js +1 -0
- package/build/js/918.164497d1.js +3 -0
- package/build/js/931.f5b2dd0e.js +1 -0
- package/build/js/9751.1c059f35.js +1 -0
- package/build/js/chunk-vendors.94bb9e3c.js +300 -0
- package/build/js/index.49e6e2f0.js +1 -0
- package/build/js/login.0e6f1e5f.js +1 -0
- package/build/js/preview.c1d85328.js +1 -0
- package/build/login.html +1 -1
- package/build/preview.html +1 -1
- package/output/auto-provider-plugin/loader.js +2 -1
- package/output/auto-provider-plugin/package.json +1 -1
- package/output/builtin/build/component/CodeEditor.vue.d.ts +1 -0
- package/output/builtin/build/component/DatasetItem.vue.d.ts +2 -1
- package/output/builtin/build/component/HeaderSearch.vue.d.ts +13 -0
- package/output/builtin/build/component/index.d.ts +2 -1
- package/output/builtin/build/locale/LanguageProvider.d.ts +34 -32
- package/output/builtin/build/option/index.d.ts +9 -1
- package/output/builtin/build/service/footer/action/AddDirAction.d.ts +0 -1
- package/output/builtin/package.json +1 -1
- package/output/class-wrapper-plugin/package.json +1 -1
- package/output/declare/package.json +2 -2
- package/output/design/package.json +5 -3
- package/output/design/src/components/Dialog.vue +2 -2
- package/output/design/src/components/DynamicDialog.vue +35 -29
- package/output/design/src/components/Scroll.vue +1 -1
- package/output/design/src/components/Select.vue +9 -1
- package/output/design/src/components/composables/useSearch.ts +1 -0
- package/output/design/src/components/utils/Confirm.ts +1 -1
- package/output/design/src/components/utils/DynamicDialog.ts +12 -2
- package/output/design/src/font/demo_index.html +26 -3
- package/output/design/src/font/iconfont.css +7 -3
- package/output/design/src/font/iconfont.js +1 -1
- package/output/design/src/font/iconfont.json +7 -0
- package/output/design/src/font/iconfont.ttf +0 -0
- package/output/design/src/font/iconfont.woff +0 -0
- package/output/design/src/font/iconfont.woff2 +0 -0
- package/output/design/src/index.ts +6 -0
- package/output/design/src/theme/global.less +6 -0
- package/output/engine/package.json +2 -2
- package/output/engine/src/Engine.ts +2 -2
- package/output/engine/src/asset/Asset.ts +2 -2
- package/output/engine/src/descriptor/Descriptor.ts +1 -1
- package/output/engine/src/graphics/Graphics.ts +1 -1
- package/output/engine/src/interpreter/Interpreter.ts +1 -1
- package/output/engine/src/utils/http.ts +8 -1
- package/output/locale/package.json +1 -1
- package/output/remote/package.json +1 -1
- package/output/rollup-config-plugin/package.json +1 -1
- package/output/runtime/build/data/global.d.ts +6 -0
- package/output/runtime/build/data/header.d.ts +4 -0
- package/output/runtime/package.json +1 -1
- package/output/service/package.json +1 -1
- package/output/service-asset/package.json +1 -1
- package/output/service-asset/src/AssetService.ts +2 -3
- package/output/service-example/package.json +1 -1
- package/output/service-example/src/ExampleService.ts +3 -4
- package/output/service-graph/package.json +1 -1
- package/output/service-rpc/package.json +5 -3
- package/output/service-rpc/src/RpcService.ts +9 -9
- package/output/service-rpc/src/asset/add.ts +1 -1
- package/output/service-rpc/src/asset/close.ts +1 -1
- package/output/service-rpc/src/asset/copy.ts +1 -1
- package/output/service-rpc/src/asset/create.ts +1 -1
- package/output/service-rpc/src/asset/cut.ts +1 -1
- package/output/service-rpc/src/asset/delete.ts +1 -1
- package/output/service-rpc/src/asset/dragdrap.ts +1 -1
- package/output/service-rpc/src/asset/initialize.ts +1 -1
- package/output/service-rpc/src/asset/open.ts +1 -1
- package/output/service-rpc/src/asset/remove.ts +1 -1
- package/output/service-rpc/src/asset/rename.ts +1 -1
- package/output/service-rpc/src/asset/select.ts +1 -1
- package/output/service-rpc/src/asset/update.ts +1 -1
- package/output/service-rpc/src/dep/add.ts +1 -1
- package/output/service-rpc/src/dep/create.ts +1 -1
- package/output/service-rpc/src/dep/delete.ts +1 -1
- package/output/service-rpc/src/dep/remove.ts +1 -1
- package/output/service-rpc/src/dep/update.ts +1 -1
- package/output/service-rpc/src/domain/Entity.ts +7 -0
- package/output/service-rpc/src/example/apply.ts +1 -1
- package/output/service-rpc/src/example/create.ts +1 -1
- package/output/service-rpc/src/example/delete.ts +1 -1
- package/output/service-rpc/src/example/initialize.ts +1 -1
- package/output/service-rpc/src/example/list.ts +1 -1
- package/output/service-rpc/src/index.ts +1 -1
- package/output/service-rpc/src/locale/LanguageProvider.ts +5 -1
- package/output/service-rpc/src/request/index.ts +50 -0
- package/output/service-rpc/src/rpc/confirm.ts +1 -1
- package/output/service-rpc/src/rpc/connection.ts +1 -1
- package/output/service-rpc/src/rpc/disconnect.ts +1 -1
- package/output/service-rpc/src/rpc/getUser.ts +1 -1
- package/output/service-rpc/src/rpc/login.ts +1 -1
- package/output/service-rpc/src/rpc/logout.ts +1 -1
- package/output/service-rpc/src/rpc/redo.ts +1 -1
- package/output/service-rpc/src/rpc/undo.ts +1 -1
- package/output/service-rpc/src/scene/add.ts +1 -1
- package/output/service-rpc/src/scene/create.ts +1 -1
- package/output/service-rpc/src/scene/delete.ts +1 -1
- package/output/service-rpc/src/scene/download.ts +1 -1
- package/output/service-rpc/src/scene/dragdrap.ts +1 -1
- package/output/service-rpc/src/scene/initialize.ts +1 -1
- package/output/service-rpc/src/scene/record.ts +1 -1
- package/output/service-rpc/src/scene/remove.ts +1 -1
- package/output/service-rpc/src/scene/switch.ts +1 -1
- package/output/service-rpc/src/scene/update.ts +1 -1
- package/output/service-rpc/src/sidebar/switch.ts +1 -1
- package/output/service-scene/package.json +1 -1
- package/output/service-scene/src/SceneService.ts +2 -3
- package/output/var-rename-plugin/package.json +1 -1
- package/package.json +80 -1
- package/patches/knex+2.5.1.patch +26 -0
- package/build/css/1111.e408e6d4.css +0 -1
- package/build/css/login.b74658d1.css +0 -1
- package/build/fonts/iconfont.4a13a979.woff +0 -0
- package/build/js/1018.41064c0f.js +0 -1
- package/build/js/1111.be6e2c40.js +0 -1
- package/build/js/1124.74dc01cf.js +0 -1
- package/build/js/150.e7f9045d.js +0 -1
- package/build/js/1780.599a4f56.js +0 -1
- package/build/js/2132.0f13c789.js +0 -1
- package/build/js/2328.91f4fab2.js +0 -1
- package/build/js/3553.c58039ca.js +0 -1
- package/build/js/3745.4b658c7d.js +0 -1
- package/build/js/3785.0e5bac50.js +0 -1
- package/build/js/4537.0c0b1621.js +0 -3
- package/build/js/5547.e7e03105.js +0 -1
- package/build/js/6151.73bf0dca.js +0 -1
- package/build/js/6166.a11b6605.js +0 -1
- package/build/js/677.1be417ae.js +0 -1
- package/build/js/6881.110a38eb.js +0 -1
- package/build/js/7713.7dac62b2.js +0 -1
- package/build/js/7769.da192016.js +0 -1
- package/build/js/7928.00d662e4.js +0 -1
- package/build/js/8637.8a669454.js +0 -1
- package/build/js/8743.ae6b01fb.js +0 -1
- package/build/js/931.b906c8b3.js +0 -1
- package/build/js/9399.6f01e6fb.js +0 -1
- package/build/js/94.043c5ab1.js +0 -1
- package/build/js/9751.062a0ec7.js +0 -1
- package/build/js/9786.e8445259.js +0 -1
- package/build/js/9947.e172d61d.js +0 -1
- package/build/js/chunk-vendors.3148df9e.js +0 -300
- package/build/js/index.ab116b9c.js +0 -1
- package/build/js/login.2480f0b4.js +0 -1
- package/build/js/preview.191ab535.js +0 -1
- /package/build/css/{1124.b91daf98.css → 215.b91daf98.css} +0 -0
- /package/build/css/{8743.b91daf98.css → 2596.b91daf98.css} +0 -0
- /package/build/js/{110.e2819667.js → 110.132cb06d.js} +0 -0
- /package/build/js/{1349.5011b482.js → 1349.581acd13.js} +0 -0
- /package/build/js/{1402.e4936bfb.js → 1402.41e93cca.js} +0 -0
- /package/build/js/{1877.f14acfa1.js → 1877.f7dfcbbb.js} +0 -0
- /package/build/js/{2318.441a2db7.js → 2318.aa9ea4c9.js} +0 -0
- /package/build/js/{250.4513f7c1.js → 250.ee102b58.js} +0 -0
- /package/build/js/{3085.42a6da4f.js → 3085.89eae237.js} +0 -0
- /package/build/js/{4263.f1987228.js → 4263.33a52188.js} +0 -0
- /package/build/js/{4530.2a2c0560.js → 4530.46216301.js} +0 -0
- /package/build/js/{5639.a09657c9.js → 5639.fd7fc4f3.js} +0 -0
- /package/build/js/{6357.fc8796e2.js → 6357.92e3bda6.js} +0 -0
- /package/build/js/{7195.e082572c.js → 7195.20386308.js} +0 -0
- /package/build/js/{8657.f0bd7f1f.js → 8657.0480062d.js} +0 -0
- /package/build/js/{9044.f58e5368.js → 9044.a0d33e3e.js} +0 -0
- /package/build/js/{9170.4182d4a8.js → 9170.00c77288.js} +0 -0
- /package/build/js/{9620.ce105b9b.js → 9620.edd4c694.js} +0 -0
|
@@ -12,11 +12,17 @@ interface ScriptOption {
|
|
|
12
12
|
getDefaultInput(): any;
|
|
13
13
|
getPropertyOptions?: () => ScriptPropertyOptionsGetters;
|
|
14
14
|
}
|
|
15
|
+
interface interfaceOption {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
15
19
|
declare class Template {
|
|
16
20
|
visible: boolean;
|
|
17
21
|
}
|
|
18
22
|
declare class Global {
|
|
19
23
|
readonly scripts: ScriptOption[];
|
|
20
24
|
readonly template: Template;
|
|
25
|
+
readonly interfaces: interfaceOption[];
|
|
26
|
+
setInterfaces(interfaces: interfaceOption[]): void;
|
|
21
27
|
}
|
|
22
28
|
export { ScriptPropertyOptions, ScriptPropertyOptionsGetters, ScriptOption, Global, };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
1
|
import { Service } from '@vyr/service'
|
|
3
2
|
import { DraggableData, DraggableEndType, } from '@vyr/declare'
|
|
4
3
|
import { runtime } from '@vyr/runtime'
|
|
5
4
|
import { Descriptor, DeserializationObject } from '@vyr/engine'
|
|
6
|
-
import { RpcService, Message, VirtualNode } from '@vyr/service-rpc'
|
|
5
|
+
import { RpcService, Message, VirtualNode, request } from '@vyr/service-rpc'
|
|
7
6
|
import { AssetMethodProvider } from "./AssetMethodProvider"
|
|
8
7
|
|
|
9
8
|
class AssetService extends Service {
|
|
@@ -109,7 +108,7 @@ class AssetService extends Service {
|
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
async read(url: string) {
|
|
112
|
-
const res = await
|
|
111
|
+
const res = await request.get<string>(url, { responseType: 'text' })
|
|
113
112
|
return res.data
|
|
114
113
|
}
|
|
115
114
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
1
|
import { runtime } from '@vyr/runtime'
|
|
3
|
-
import { Message, RpcService } from '@vyr/service-rpc'
|
|
2
|
+
import { Message, RpcService, request } from '@vyr/service-rpc'
|
|
4
3
|
import { Service } from '@vyr/service'
|
|
5
4
|
import { AssetService } from '@vyr/service-asset'
|
|
6
5
|
import { ExampleMethodProvider } from './ExampleMethodProvider'
|
|
@@ -41,12 +40,12 @@ class ExampleService extends Service {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
async download(example: string, name: string) {
|
|
44
|
-
const res = await
|
|
43
|
+
const res = await request.get('/download/example', { params: { example }, responseType: 'blob' })
|
|
45
44
|
AssetService.save(name, res.data)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
async upload(formData: FormData) {
|
|
49
|
-
await
|
|
48
|
+
await request.post<string>('/upload/example', formData)
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyr/service-rpc-universal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"@vyr/engine": "0.0.26",
|
|
10
|
+
"camelcase-keys": "^10.0.1",
|
|
11
|
+
"decamelize-keys": "^2.0.1",
|
|
12
|
+
"moment": "^2.30.1"
|
|
11
13
|
},
|
|
12
14
|
"files": [
|
|
13
15
|
"package.json",
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
1
|
import { Serialization, Listener } from '@vyr/engine'
|
|
3
2
|
import { Service } from '@vyr/service'
|
|
4
3
|
import { path, tokenKey, topic, Confirm, Message } from '@vyr/service-rpc-universal'
|
|
4
|
+
import { request } from './request'
|
|
5
5
|
|
|
6
6
|
interface RpcServiceConfig {
|
|
7
7
|
token: string
|
|
8
|
-
notify: (msg: string) => void
|
|
9
|
-
confirm: (options: Partial<Confirm>, value?: string) => Promise<Confirm>
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
const _logout = () => {
|
|
@@ -17,10 +15,14 @@ const _logout = () => {
|
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
class RpcService extends Service {
|
|
18
|
+
static notify = (msg: string) => { }
|
|
19
|
+
static confirm = async (options: Partial<Confirm>, value?: string) => {
|
|
20
|
+
return options as Confirm
|
|
21
|
+
}
|
|
20
22
|
|
|
21
23
|
static async login(name: string, password: string) {
|
|
22
24
|
const data = new Message.rpc.login.RequestMessage(name, password)
|
|
23
|
-
const res = await
|
|
25
|
+
const res = await request.post<InstanceType<typeof Message['rpc']['login']['NoticeMessage']>>(Message.rpc.login.Method, data)
|
|
24
26
|
window.localStorage.setItem(tokenKey, res.data.params.token)
|
|
25
27
|
|
|
26
28
|
const location = new URL(window.location.href)
|
|
@@ -30,7 +32,7 @@ class RpcService extends Service {
|
|
|
30
32
|
|
|
31
33
|
static async getUser() {
|
|
32
34
|
const data = new Message.rpc.getUser.RequestMessage()
|
|
33
|
-
const res = await
|
|
35
|
+
const res = await request.get<InstanceType<typeof Message['rpc']['getUser']['NoticeMessage']>>(Message.rpc.getUser.Method, data)
|
|
34
36
|
return res.data.params.user
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -42,21 +44,19 @@ class RpcService extends Service {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
private _listener = new Listener<{ [k: string]: (msg: Message) => void }>()
|
|
45
|
-
private confirm
|
|
46
47
|
private socket: any
|
|
47
48
|
private needTrigger = false
|
|
48
49
|
private msgQueue: Message[] = []
|
|
49
50
|
|
|
50
51
|
constructor(name: string, config: RpcServiceConfig) {
|
|
51
52
|
super(name)
|
|
52
|
-
this.confirm = config.confirm
|
|
53
53
|
const params = { path, extraHeaders: { authorization: 'Bearer ' + config.token }, autoConnect: false }
|
|
54
54
|
//@ts-ignore
|
|
55
55
|
this.socket = new window.io(location.href, params)
|
|
56
56
|
|
|
57
57
|
this.socket.on(topic, (content: string) => {
|
|
58
58
|
const msg = Serialization.parse(content) as Message
|
|
59
|
-
if (msg.message !== undefined) return
|
|
59
|
+
if (msg.message !== undefined) return RpcService.notify(msg.message)
|
|
60
60
|
this._delayTrigger(msg)
|
|
61
61
|
})
|
|
62
62
|
this.socket.on('disconnect', () => {
|
|
@@ -67,7 +67,7 @@ class RpcService extends Service {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
private _onConfirm = async (msg: InstanceType<typeof Message['rpc']['confirm']['NoticeMessage']>) => {
|
|
70
|
-
const result = await
|
|
70
|
+
const result = await RpcService.confirm(msg.params.config)
|
|
71
71
|
msg.params.config.value = result.value
|
|
72
72
|
msg.params.config.success = result.success
|
|
73
73
|
this.send(msg)
|
|
@@ -2,7 +2,7 @@ import { DeserializationObject } from '@vyr/engine'
|
|
|
2
2
|
import { IMessage } from '../IMessage'
|
|
3
3
|
import { VirtualNode } from '../VirtualNode'
|
|
4
4
|
|
|
5
|
-
const Method = '/
|
|
5
|
+
const Method = '/vyr/asset.initialize'
|
|
6
6
|
|
|
7
7
|
class RequestMessage extends IMessage {
|
|
8
8
|
method = Method
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import camelcaseKeys from 'camelcase-keys'
|
|
2
|
+
import decamelizeKeys from 'decamelize-keys'
|
|
3
|
+
|
|
1
4
|
abstract class Entity {
|
|
2
5
|
static primaryKey: string
|
|
3
6
|
static dateFormat = 'YYYY-MM-DD HH:mm:ss'
|
|
7
|
+
/**下划线转驼峰 */
|
|
8
|
+
static camelcaseKeys = (data: any) => camelcaseKeys(data, { deep: true })
|
|
9
|
+
/**驼峰转下划线 */
|
|
10
|
+
static decamelizeKeys = (data: any) => decamelizeKeys(data, { deep: true })
|
|
4
11
|
|
|
5
12
|
abstract toVO(): Entity
|
|
6
13
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { LanguageProvider } from '@vyr/locale'
|
|
2
2
|
|
|
3
3
|
interface ZhCNLanguageProvider extends LanguageProvider {
|
|
4
|
-
|
|
4
|
+
'request.error.general': string
|
|
5
|
+
'request.error.401': string
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
const zhCnLanguageProvider: ZhCNLanguageProvider = {
|
|
8
9
|
id: 'zh_CN',
|
|
9
10
|
name: '@vyr/service-rpc',
|
|
11
|
+
|
|
12
|
+
'request.error.general': '服务错误,请稍后重试!',
|
|
13
|
+
'request.error.401': '无效的会话,或者会话已过期,请重新登录。'
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
|
2
|
+
import { language } from '../locale';
|
|
3
|
+
import { RpcService } from '../RpcService';
|
|
4
|
+
|
|
5
|
+
const request = axios.create({
|
|
6
|
+
baseURL: '',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
// 请求拦截器
|
|
10
|
+
request.interceptors.request.use(
|
|
11
|
+
(config: InternalAxiosRequestConfig) => {
|
|
12
|
+
const token = RpcService.getToken()
|
|
13
|
+
|
|
14
|
+
if (token) {
|
|
15
|
+
config.headers['Authorization'] = 'Bearer ' + token;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// FormData数据去请求头Content-Type
|
|
19
|
+
if (config.data instanceof FormData) {
|
|
20
|
+
delete config.headers['Content-Type'];
|
|
21
|
+
}
|
|
22
|
+
return config;
|
|
23
|
+
},
|
|
24
|
+
(error: any) => {
|
|
25
|
+
return Promise.reject(error);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// 响应拦截器
|
|
30
|
+
request.interceptors.response.use(
|
|
31
|
+
(response: AxiosResponse) => {
|
|
32
|
+
return response
|
|
33
|
+
},
|
|
34
|
+
(error: any) => {
|
|
35
|
+
let message = language.get('request.error.general')
|
|
36
|
+
const { response, status } = error;
|
|
37
|
+
|
|
38
|
+
if (status === 401) {
|
|
39
|
+
message = language.get('request.error.401')
|
|
40
|
+
} else if (response.data !== null && typeof response.data === 'object') {
|
|
41
|
+
if (response.data.message) message = response.data.message
|
|
42
|
+
}
|
|
43
|
+
RpcService.notify(message)
|
|
44
|
+
return Promise.reject(error);
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
request
|
|
50
|
+
}
|