web-core-tcm 0.0.23 → 0.0.24
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/package.json +41 -21
- package/.editorconfig +0 -7
- package/.github/workflows/test.yml +0 -29
- package/.prettierrc.json +0 -5
- package/.vscode/extensions.json +0 -15
- package/.vscode/settings.json +0 -9
- package/eslint.config.js +0 -83
- package/index.html +0 -24
- package/postcss.config.js +0 -29
- package/public/favicon.ico +0 -0
- package/public/icons/favicon-128x128.png +0 -0
- package/public/icons/favicon-16x16.png +0 -0
- package/public/icons/favicon-32x32.png +0 -0
- package/public/icons/favicon-96x96.png +0 -0
- package/quasar.config.ts +0 -220
- package/src/App.vue +0 -7
- package/src/api/algorithm/comprehensiveAlgorithm.ts +0 -20
- package/src/api/algorithm/index.ts +0 -50
- package/src/api/algorithm/inquiriesAlgorithm.ts +0 -19
- package/src/api/algorithm/inspectionsAlgorithm.ts +0 -11
- package/src/api/algorithm/lisemsAlgorithm.ts +0 -16
- package/src/api/algorithm/pulsationsAlgorithm.ts +0 -9
- package/src/api/authorization/alova/apiDefinitions.ts +0 -23
- package/src/api/authorization/alova/createApis.ts +0 -99
- package/src/api/authorization/alova/globals.d.ts +0 -373
- package/src/api/authorization/alova/implement/authorization.ts +0 -12
- package/src/api/authorization/alova/implement/index.ts +0 -1
- package/src/api/authorization/alova/index.ts +0 -23
- package/src/api/authorization/authorization.ts +0 -16
- package/src/api/authorization/index.ts +0 -2
- package/src/api/check/alova/apiDefinitions.ts +0 -30
- package/src/api/check/alova/createApis.ts +0 -99
- package/src/api/check/alova/globals.d.ts +0 -1248
- package/src/api/check/alova/implement/check.ts +0 -119
- package/src/api/check/alova/implement/index.ts +0 -1
- package/src/api/check/alova/index.ts +0 -23
- package/src/api/check/check.ts +0 -164
- package/src/api/check/index.ts +0 -2
- package/src/api/config/alova/index.ts +0 -72
- package/src/api/config/index.ts +0 -130
- package/src/api/device/device.js +0 -58
- package/src/api/doctor/alova/apiDefinitions.ts +0 -28
- package/src/api/doctor/alova/createApis.ts +0 -99
- package/src/api/doctor/alova/globals.d.ts +0 -550
- package/src/api/doctor/alova/implement/doctor.ts +0 -37
- package/src/api/doctor/alova/implement/index.ts +0 -1
- package/src/api/doctor/alova/index.ts +0 -23
- package/src/api/doctor/doctor.ts +0 -53
- package/src/api/doctor/index.ts +0 -2
- package/src/api/index.ts +0 -15
- package/src/api/metric/implement/index.ts +0 -1
- package/src/api/metric/implement/metric.ts +0 -98
- package/src/api/metric/index.ts +0 -2
- package/src/api/metric/metric.ts +0 -114
- package/src/api/oauth/alova/apiDefinitions.ts +0 -26
- package/src/api/oauth/alova/createApis.ts +0 -99
- package/src/api/oauth/alova/globals.d.ts +0 -451
- package/src/api/oauth/alova/implement/index.ts +0 -1
- package/src/api/oauth/alova/implement/oauth.ts +0 -19
- package/src/api/oauth/alova/index.ts +0 -22
- package/src/api/oauth/index.ts +0 -2
- package/src/api/oauth/oauth.ts +0 -15
- package/src/api/outpatient/alova/apiDefinitions.ts +0 -27
- package/src/api/outpatient/alova/createApis.ts +0 -99
- package/src/api/outpatient/alova/globals.d.ts +0 -676
- package/src/api/outpatient/alova/implement/index.ts +0 -1
- package/src/api/outpatient/alova/implement/outpatient.ts +0 -66
- package/src/api/outpatient/alova/index.ts +0 -23
- package/src/api/outpatient/index.ts +0 -2
- package/src/api/outpatient/outpatient.ts +0 -62
- package/src/api/patient/alova/apiDefinitions.ts +0 -41
- package/src/api/patient/alova/createApis.ts +0 -99
- package/src/api/patient/alova/globals.d.ts +0 -1677
- package/src/api/patient/alova/implement/index.ts +0 -2
- package/src/api/patient/alova/implement/meta.ts +0 -488
- package/src/api/patient/alova/implement/patient.ts +0 -77
- package/src/api/patient/alova/index.ts +0 -24
- package/src/api/patient/core.ts +0 -131
- package/src/api/patient/index.ts +0 -4
- package/src/api/patient/meta.ts +0 -466
- package/src/api/patient/patient.ts +0 -98
- package/src/api/prescription/alova/apiDefinitions.ts +0 -29
- package/src/api/prescription/alova/createApis.ts +0 -99
- package/src/api/prescription/alova/globals.d.ts +0 -959
- package/src/api/prescription/alova/implement/herbal.ts +0 -48
- package/src/api/prescription/alova/implement/index.ts +0 -2
- package/src/api/prescription/alova/implement/prescription.ts +0 -45
- package/src/api/prescription/alova/index.ts +0 -23
- package/src/api/prescription/herbal.ts +0 -44
- package/src/api/prescription/index.ts +0 -3
- package/src/api/prescription/prescription.ts +0 -68
- package/src/api/scientist/alova/apiDefinitions.ts +0 -27
- package/src/api/scientist/alova/createApis.ts +0 -99
- package/src/api/scientist/alova/globals.d.ts +0 -438
- package/src/api/scientist/alova/implement/index.ts +0 -1
- package/src/api/scientist/alova/implement/scientist.ts +0 -29
- package/src/api/scientist/alova/index.ts +0 -23
- package/src/api/scientist/index.ts +0 -2
- package/src/api/scientist/scientist.ts +0 -49
- package/src/assets/quasar-logo-vertical.svg +0 -15
- package/src/boot/.gitkeep +0 -0
- package/src/components/ExampleComponent.vue +0 -37
- package/src/components/models.ts +0 -8
- package/src/css/app.scss +0 -1
- package/src/css/quasar.variables.scss +0 -25
- package/src/env.d.ts +0 -7
- package/src/index.ts +0 -4
- package/src/layouts/UserLayout.vue +0 -106
- package/src/pages/LoginPage.vue +0 -32
- package/src/proto/Images.proto +0 -7
- package/src/proto/WaveMap.proto +0 -10
- package/src/proto/index.ts +0 -2
- package/src/proto/types/Images_pb.ts +0 -48
- package/src/proto/types/WaveMap_pb.ts +0 -59
- package/src/router/index.ts +0 -37
- package/src/router/routes.ts +0 -14
- package/src/util/RichTextUtil.ts +0 -5
- package/src/util/datetime.ts +0 -43
- package/src/util/export.ts +0 -46
- package/src/util/helper.ts +0 -159
- package/src/util/image.ts +0 -28
- package/src/util/number.ts +0 -146
- package/src/util/s256.js +0 -30
- package/src/util/secret.ts +0 -60
- package/src/util/string.ts +0 -121
- package/tsconfig.json +0 -3
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Herbal } from '@core/api/prescription/herbal';
|
|
2
|
-
import type { Doctor } from '@core/api/doctor/doctor';
|
|
3
|
-
|
|
4
|
-
export class AlovaHerbal extends Herbal{
|
|
5
|
-
static override query(page: number = 0, pageSize: number = 9999999, owner?: Doctor, name?: string, price?: number) {
|
|
6
|
-
const ownerState = owner?.state()
|
|
7
|
-
return prescriptionApi.herbalRestful.queryHerbalState({
|
|
8
|
-
data: {
|
|
9
|
-
...(ownerState && { ownerState }),
|
|
10
|
-
...(name && { name }),
|
|
11
|
-
...(price !== undefined && { price }),
|
|
12
|
-
page: page,
|
|
13
|
-
pageSize
|
|
14
|
-
},
|
|
15
|
-
async transform(res) {
|
|
16
|
-
return {
|
|
17
|
-
data: (await Promise.all(res.content!.map(item => new AlovaHerbal().of(item)))) as Herbal[],
|
|
18
|
-
total: res.totalElements!,
|
|
19
|
-
page: res.number!,
|
|
20
|
-
pageSize: res.size!,
|
|
21
|
-
pageCount: res.totalPages!,
|
|
22
|
-
isLastPage: res.last!
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
}).send();
|
|
26
|
-
}
|
|
27
|
-
async put() {
|
|
28
|
-
return this.of(await prescriptionApi.herbalRestful.putHerbalState({
|
|
29
|
-
pathParams: {
|
|
30
|
-
id: this.id,
|
|
31
|
-
},
|
|
32
|
-
data: this.state(),
|
|
33
|
-
}).send(true));
|
|
34
|
-
}
|
|
35
|
-
async post() {
|
|
36
|
-
return this.of(await prescriptionApi.herbalRestful.postHerbalState({
|
|
37
|
-
data: this.state(),
|
|
38
|
-
}).send(true))
|
|
39
|
-
}
|
|
40
|
-
async delete() {
|
|
41
|
-
void prescriptionApi.herbalRestful.deleteHerbalState({
|
|
42
|
-
pathParams: {
|
|
43
|
-
id: this.id,
|
|
44
|
-
},
|
|
45
|
-
}).send()
|
|
46
|
-
return Promise.resolve()
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Prescription } from '@core/api/prescription/prescription';
|
|
2
|
-
import type { Doctor } from '@core/api/doctor/doctor';
|
|
3
|
-
|
|
4
|
-
export class AlovaPrescription extends Prescription{
|
|
5
|
-
static override query(page: number = 0, pageSize: number = 9999999,owner?: Doctor, name?: string) {
|
|
6
|
-
const ownerState = owner?.state()
|
|
7
|
-
return prescriptionApi.prescriptionRestful.queryPrescriptionState({
|
|
8
|
-
data: {
|
|
9
|
-
...(ownerState && { ownerState }),
|
|
10
|
-
...(name && { name }),
|
|
11
|
-
page: page,
|
|
12
|
-
pageSize
|
|
13
|
-
},
|
|
14
|
-
async transform(res) {
|
|
15
|
-
return {
|
|
16
|
-
data: await Promise.all(res.content!.map(item => new AlovaPrescription().of(item))),
|
|
17
|
-
total: res.totalElements!,
|
|
18
|
-
page: res.number!,
|
|
19
|
-
pageSize: res.size!,
|
|
20
|
-
pageCount: res.totalPages!,
|
|
21
|
-
isLastPage: res.last!
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}).send();
|
|
25
|
-
}
|
|
26
|
-
//put
|
|
27
|
-
override async put() {
|
|
28
|
-
return this.of(await prescriptionApi.prescriptionRestful.putPrescriptionState({pathParams: {id: this.id},data: this.state()}).send())
|
|
29
|
-
}
|
|
30
|
-
//post
|
|
31
|
-
override async post() {
|
|
32
|
-
return this.of(await prescriptionApi.prescriptionRestful.postPrescriptionState({
|
|
33
|
-
data: this.state()
|
|
34
|
-
}).send());
|
|
35
|
-
}
|
|
36
|
-
//delete
|
|
37
|
-
override async delete() {
|
|
38
|
-
await prescriptionApi.prescriptionRestful.deletePrescriptionState({
|
|
39
|
-
pathParams: {
|
|
40
|
-
id: this.id
|
|
41
|
-
}
|
|
42
|
-
}).send()
|
|
43
|
-
return this
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createAlova } from 'alova';
|
|
2
|
-
import fetchAdapter from 'alova/fetch';
|
|
3
|
-
import { createApis, withConfigType, mountApis } from './createApis';
|
|
4
|
-
import { onAuthRequired, responded } from '@core/api/config/alova';
|
|
5
|
-
import { getServiceEndpoint, ServiceType } from '@core/api/config';
|
|
6
|
-
|
|
7
|
-
export const alovaInstance = createAlova({
|
|
8
|
-
baseURL: getServiceEndpoint(ServiceType.Prescription),
|
|
9
|
-
requestAdapter: fetchAdapter(),
|
|
10
|
-
beforeRequest: onAuthRequired(() => {}),
|
|
11
|
-
cacheFor: null,
|
|
12
|
-
responded: responded
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const $$userConfigMap = withConfigType({});
|
|
16
|
-
|
|
17
|
-
const Apis = createApis(alovaInstance, $$userConfigMap);
|
|
18
|
-
|
|
19
|
-
mountApis(Apis);
|
|
20
|
-
|
|
21
|
-
export default Apis;
|
|
22
|
-
|
|
23
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Page} from '@core/api/patient/core';
|
|
2
|
-
import { NetworkObject } from '@core/api/patient/core';
|
|
3
|
-
import type { HerbalState } from '@core/api/prescription/alova/globals';
|
|
4
|
-
import type { IBuilder } from 'builder-pattern';
|
|
5
|
-
import { Builder } from 'builder-pattern';
|
|
6
|
-
import { Doctor } from '@core/api/doctor/doctor';
|
|
7
|
-
|
|
8
|
-
export abstract class Herbal extends NetworkObject {
|
|
9
|
-
static override builder(): IBuilder<Herbal>{
|
|
10
|
-
return Builder(this._default) as unknown as IBuilder<Herbal>;
|
|
11
|
-
}
|
|
12
|
-
static override default(): typeof Herbal {
|
|
13
|
-
return this._default as unknown as typeof Herbal;
|
|
14
|
-
}
|
|
15
|
-
id: string = '';
|
|
16
|
-
name: string = '';
|
|
17
|
-
price: number = 0;
|
|
18
|
-
weight: number = 0;
|
|
19
|
-
owner: Doctor = Doctor.builder().build();
|
|
20
|
-
|
|
21
|
-
override async of(json: HerbalState) {
|
|
22
|
-
if (json.id != undefined) this.id = json.id;
|
|
23
|
-
if (json.name != undefined) this.name = json.name;
|
|
24
|
-
if (json.price != undefined) this.price = json.price;
|
|
25
|
-
if (json.weight != undefined) this.weight = json.weight;
|
|
26
|
-
if (json.ownerState != undefined) this.owner = await Doctor.builder().build().of(json.ownerState);
|
|
27
|
-
return this
|
|
28
|
-
}
|
|
29
|
-
override state() {
|
|
30
|
-
return {
|
|
31
|
-
id: this.id,
|
|
32
|
-
name: this.name,
|
|
33
|
-
price: this.price,
|
|
34
|
-
weight: this.weight,
|
|
35
|
-
ownerState: this.owner.state(),
|
|
36
|
-
} as HerbalState
|
|
37
|
-
}
|
|
38
|
-
static query(page: number = 0, pageSize: number = 9999999, owner?: Doctor, name?: string, price?: number): Promise<Page<Herbal>>{
|
|
39
|
-
return Herbal.default().query(page, pageSize, owner, name, price)
|
|
40
|
-
}
|
|
41
|
-
abstract put(): Promise<this>;
|
|
42
|
-
abstract post(): Promise<this>;
|
|
43
|
-
abstract delete(): Promise<void>;
|
|
44
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Herbal } from '@core/api/prescription/herbal';
|
|
2
|
-
import type { PrescriptionState } from '@core/api/prescription/alova/globals';
|
|
3
|
-
import type { Page } from '@core/api/patient/core';
|
|
4
|
-
import { NetworkObject } from '@core/api/patient/core';
|
|
5
|
-
import type { IBuilder } from 'builder-pattern';
|
|
6
|
-
import { Builder } from 'builder-pattern';
|
|
7
|
-
import { Doctor } from '@core/api/doctor/doctor';
|
|
8
|
-
|
|
9
|
-
export abstract class Prescription extends NetworkObject{
|
|
10
|
-
static override builder(): IBuilder<Prescription>{
|
|
11
|
-
return Builder(this._default) as unknown as IBuilder<Prescription>;
|
|
12
|
-
}
|
|
13
|
-
static override default(): typeof Prescription {
|
|
14
|
-
return this._default as unknown as typeof Prescription;
|
|
15
|
-
}
|
|
16
|
-
id: string = '';
|
|
17
|
-
createdTimestamp: string = '';
|
|
18
|
-
updatedTimestamp: string = '';
|
|
19
|
-
name: string = '匿名药方';
|
|
20
|
-
owner: Doctor = Doctor.builder().build();
|
|
21
|
-
totalAmount: number = 0;
|
|
22
|
-
useAmount: number = 0;
|
|
23
|
-
craftType: string = '自煎';
|
|
24
|
-
useWay: string[] = ['煎服'];
|
|
25
|
-
useTime: string[] = ['早上','晚上'];
|
|
26
|
-
herbals: Herbal[] = [];
|
|
27
|
-
override async of(json: PrescriptionState) {
|
|
28
|
-
if(json.id != undefined)this.id = json.id;
|
|
29
|
-
if(json.createdTimestamp != undefined)this.createdTimestamp = json.createdTimestamp;
|
|
30
|
-
if(json.updatedTimestamp != undefined)this.updatedTimestamp = json.updatedTimestamp;
|
|
31
|
-
if(json.name != undefined)this.name = json.name;
|
|
32
|
-
if(json.ownerState != undefined)this.owner = await Doctor.builder().build().of(json.ownerState);
|
|
33
|
-
if(json.totalAmount != undefined)this.totalAmount = json.totalAmount;
|
|
34
|
-
if(json.useAmount != undefined)this.useAmount = json.useAmount;
|
|
35
|
-
if(json.craftType != undefined)this.craftType = json.craftType;
|
|
36
|
-
if(json.useWay != undefined)this.useWay = json.useWay;
|
|
37
|
-
if(json.useTime != undefined)this.useTime = json.useTime;
|
|
38
|
-
if (json.herbalsState != undefined){
|
|
39
|
-
this.herbals = await Promise.all(json.herbalsState.map(item => Herbal.builder().build().of(item)));
|
|
40
|
-
}
|
|
41
|
-
return Promise.resolve(this);
|
|
42
|
-
}
|
|
43
|
-
override state(): PrescriptionState {
|
|
44
|
-
return {
|
|
45
|
-
id: this.id,
|
|
46
|
-
createdTimestamp: this.createdTimestamp,
|
|
47
|
-
updatedTimestamp: this.updatedTimestamp,
|
|
48
|
-
name: this.name,
|
|
49
|
-
ownerState: this.owner.state(),
|
|
50
|
-
totalAmount: this.totalAmount,
|
|
51
|
-
useAmount: this.useAmount,
|
|
52
|
-
craftType: this.craftType,
|
|
53
|
-
useWay: this.useWay,
|
|
54
|
-
useTime: this.useTime,
|
|
55
|
-
herbalsState: this.herbals.map(herbal => herbal.state())
|
|
56
|
-
} as PrescriptionState
|
|
57
|
-
}
|
|
58
|
-
static query(page: number = 0, pageSize: number = 9999999,owner?: Doctor, name?: string): Promise<Page<Prescription>>{
|
|
59
|
-
return Prescription.default().query(page, pageSize,owner, name)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//put
|
|
63
|
-
abstract put(): Promise<this>
|
|
64
|
-
//post
|
|
65
|
-
abstract post(): Promise<this>
|
|
66
|
-
//delete
|
|
67
|
-
abstract delete(): Promise<this>
|
|
68
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types='./globals.d.ts' />
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/**
|
|
5
|
-
* OpenAPI definition - version v0
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* OpenAPI version: 3.1.0
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* NOTE: This file is auto generated by the alova's vscode plugin.
|
|
13
|
-
*
|
|
14
|
-
* https://alova.js.org/devtools/vscode
|
|
15
|
-
*
|
|
16
|
-
* **Do not edit the file manually.**
|
|
17
|
-
*/
|
|
18
|
-
export default {
|
|
19
|
-
'scientistStateRestful.getScientistState': ['GET', '/科研/服务/{id}'],
|
|
20
|
-
'scientistStateRestful.putScientistState': ['PUT', '/科研/服务/{id}'],
|
|
21
|
-
'scientistStateRestful.deleteScientistState': ['DELETE', '/科研/服务/{id}'],
|
|
22
|
-
'scientistStateRestful.queryScientistState': ['GET', '/科研/服务'],
|
|
23
|
-
'scientistStateRestful.postScientistState': ['POST', '/科研/服务'],
|
|
24
|
-
'scientistStateRestful.datesOfScientist': ['GET', '/科研/服务/统计/科研/日期'],
|
|
25
|
-
'scientistStateRestful.totalOfScientist': ['GET', '/科研/服务/统计/科研/总数'],
|
|
26
|
-
'scientistStateRestful.todayOfScientistByToday': ['GET', '/科研/服务/统计/科研/今日']
|
|
27
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* OpenAPI definition - version v0
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* OpenAPI version: 3.1.0
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* NOTE: This file is auto generated by the alova's vscode plugin.
|
|
12
|
-
*
|
|
13
|
-
* https://alova.js.org/devtools/vscode
|
|
14
|
-
*
|
|
15
|
-
* **Do not edit the file manually.**
|
|
16
|
-
*/
|
|
17
|
-
import type { Alova, MethodType, AlovaGenerics, AlovaMethodCreateConfig } from 'alova';
|
|
18
|
-
import { Method } from 'alova';
|
|
19
|
-
import apiDefinitions from './apiDefinitions';
|
|
20
|
-
|
|
21
|
-
const cache = Object.create(null);
|
|
22
|
-
const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
|
|
23
|
-
const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
|
|
24
|
-
if (cache[apiPathKey]) {
|
|
25
|
-
return cache[apiPathKey];
|
|
26
|
-
}
|
|
27
|
-
// create a new proxy instance
|
|
28
|
-
const proxy = new Proxy(function () {}, {
|
|
29
|
-
get(_, property) {
|
|
30
|
-
// record the target property, so that it can get the completed accessing paths
|
|
31
|
-
const newArray = [...array, property];
|
|
32
|
-
// always return a new proxy to continue recording accessing paths.
|
|
33
|
-
return createFunctionalProxy(newArray, alovaInstance, configMap);
|
|
34
|
-
},
|
|
35
|
-
apply(_, __, [config]) {
|
|
36
|
-
const apiItem = apiDefinitions[apiPathKey];
|
|
37
|
-
if (!apiItem) {
|
|
38
|
-
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
|
|
39
|
-
}
|
|
40
|
-
const mergedConfig = {
|
|
41
|
-
...configMap[apiPathKey],
|
|
42
|
-
...config
|
|
43
|
-
};
|
|
44
|
-
const [method, url] = apiItem;
|
|
45
|
-
const pathParams = mergedConfig.pathParams;
|
|
46
|
-
const urlReplaced = url!.replace(/\{([^}]+)\}/g, (_, key) => {
|
|
47
|
-
const pathParam = pathParams[key];
|
|
48
|
-
return pathParam;
|
|
49
|
-
});
|
|
50
|
-
delete mergedConfig.pathParams;
|
|
51
|
-
let data = mergedConfig.data;
|
|
52
|
-
if (Object.prototype.toString.call(data) === '[object Object]' && typeof FormData !== 'undefined') {
|
|
53
|
-
let hasBlobData = false;
|
|
54
|
-
const formData = new FormData();
|
|
55
|
-
for (const key in data) {
|
|
56
|
-
formData.append(key, data[key]);
|
|
57
|
-
if (data[key] instanceof Blob) {
|
|
58
|
-
hasBlobData = true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
data = hasBlobData ? formData : data;
|
|
62
|
-
}
|
|
63
|
-
return new Method(method!.toUpperCase() as MethodType, alovaInstance, urlReplaced, mergedConfig, data);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
cache[apiPathKey] = proxy;
|
|
67
|
-
return proxy;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const createApis = (alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
|
|
71
|
-
const Apis = new Proxy({} as scientistApi, {
|
|
72
|
-
get(_, property) {
|
|
73
|
-
return createFunctionalProxy([property], alovaInstance, configMap);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return Apis;
|
|
77
|
-
};
|
|
78
|
-
export const mountApis = (Apis: scientistApi) => {
|
|
79
|
-
// define global variable `Apis`
|
|
80
|
-
(globalThis as any).scientistApi = Apis;
|
|
81
|
-
};
|
|
82
|
-
type MethodConfig<T> = AlovaMethodCreateConfig<
|
|
83
|
-
(typeof import('./index'))['alovaInstance'] extends Alova<infer AG> ? AG : any,
|
|
84
|
-
any,
|
|
85
|
-
T
|
|
86
|
-
>;
|
|
87
|
-
type APISofParameters<Tag extends string, Url extends string> = Tag extends keyof scientistApi
|
|
88
|
-
? Url extends keyof scientistApi[Tag]
|
|
89
|
-
? scientistApi[Tag][Url] extends (...args: any) => any
|
|
90
|
-
? Parameters<scientistApi[Tag][Url]>
|
|
91
|
-
: any
|
|
92
|
-
: any
|
|
93
|
-
: any;
|
|
94
|
-
type MethodsConfigMap = {
|
|
95
|
-
[P in keyof typeof import('./apiDefinitions').default]?: MethodConfig<
|
|
96
|
-
P extends `${infer Tag}.${infer Url}` ? Parameters<NonNullable<APISofParameters<Tag, Url>[0]>['transform']>[0] : any
|
|
97
|
-
>;
|
|
98
|
-
};
|
|
99
|
-
export const withConfigType = <Config extends MethodsConfigMap>(config: Config) => config;
|