web-core-tcm 0.0.23 → 0.0.25

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.
Files changed (98) hide show
  1. package/package.json +38 -21
  2. package/quasar.config.ts +28 -15
  3. package/src/api/algorithm/comprehensiveAlgorithm.ts +1 -1
  4. package/src/api/algorithm/index.ts +7 -7
  5. package/src/api/algorithm/inquiriesAlgorithm.ts +4 -7
  6. package/src/api/algorithm/inspectionsAlgorithm.ts +1 -1
  7. package/src/api/algorithm/lisemsAlgorithm.ts +3 -3
  8. package/src/api/algorithm/pulsationsAlgorithm.ts +2 -3
  9. package/src/api/authorization/alova/apiDefinitions.ts +2 -2
  10. package/src/api/authorization/alova/createApis.ts +22 -7
  11. package/src/api/authorization/alova/globals.d.ts +35 -14
  12. package/src/api/authorization/alova/implement/authorization.ts +11 -9
  13. package/src/api/authorization/alova/implement/index.ts +1 -1
  14. package/src/api/authorization/alova/index.ts +4 -5
  15. package/src/api/authorization/authorization.ts +6 -6
  16. package/src/api/authorization/index.ts +1 -1
  17. package/src/api/check/alova/apiDefinitions.ts +2 -2
  18. package/src/api/check/alova/createApis.ts +22 -7
  19. package/src/api/check/alova/globals.d.ts +29 -20
  20. package/src/api/check/alova/implement/check.ts +145 -99
  21. package/src/api/check/alova/implement/index.ts +1 -1
  22. package/src/api/check/alova/index.ts +4 -5
  23. package/src/api/check/check.ts +116 -63
  24. package/src/api/check/index.ts +1 -1
  25. package/src/api/config/alova/index.ts +26 -27
  26. package/src/api/config/index.ts +59 -57
  27. package/src/api/doctor/alova/apiDefinitions.ts +2 -2
  28. package/src/api/doctor/alova/createApis.ts +22 -7
  29. package/src/api/doctor/alova/globals.d.ts +27 -18
  30. package/src/api/doctor/alova/implement/doctor.ts +38 -24
  31. package/src/api/doctor/alova/implement/index.ts +1 -1
  32. package/src/api/doctor/alova/index.ts +4 -4
  33. package/src/api/doctor/doctor.ts +18 -18
  34. package/src/api/doctor/index.ts +1 -1
  35. package/src/api/index.ts +12 -15
  36. package/src/api/metric/implement/index.ts +1 -1
  37. package/src/api/metric/implement/metric.ts +44 -34
  38. package/src/api/metric/index.ts +1 -1
  39. package/src/api/metric/metric.ts +36 -36
  40. package/src/api/oauth/alova/apiDefinitions.ts +2 -2
  41. package/src/api/oauth/alova/createApis.ts +22 -7
  42. package/src/api/oauth/alova/globals.d.ts +25 -16
  43. package/src/api/oauth/alova/implement/index.ts +1 -1
  44. package/src/api/oauth/alova/implement/oauth.ts +20 -15
  45. package/src/api/oauth/alova/index.ts +4 -5
  46. package/src/api/oauth/index.ts +1 -1
  47. package/src/api/oauth/oauth.ts +9 -5
  48. package/src/api/outpatient/alova/apiDefinitions.ts +2 -2
  49. package/src/api/outpatient/alova/createApis.ts +22 -7
  50. package/src/api/outpatient/alova/globals.d.ts +25 -16
  51. package/src/api/outpatient/alova/implement/index.ts +1 -1
  52. package/src/api/outpatient/alova/implement/outpatient.ts +76 -51
  53. package/src/api/outpatient/alova/index.ts +4 -5
  54. package/src/api/outpatient/index.ts +1 -1
  55. package/src/api/outpatient/outpatient.ts +29 -24
  56. package/src/api/patient/alova/apiDefinitions.ts +2 -2
  57. package/src/api/patient/alova/createApis.ts +22 -7
  58. package/src/api/patient/alova/globals.d.ts +56 -43
  59. package/src/api/patient/alova/implement/index.ts +1 -1
  60. package/src/api/patient/alova/implement/meta.ts +253 -224
  61. package/src/api/patient/alova/implement/patient.ts +79 -57
  62. package/src/api/patient/alova/index.ts +3 -5
  63. package/src/api/patient/core.ts +51 -49
  64. package/src/api/patient/index.ts +1 -1
  65. package/src/api/patient/meta.ts +244 -140
  66. package/src/api/patient/patient.ts +25 -25
  67. package/src/api/prescription/alova/apiDefinitions.ts +2 -2
  68. package/src/api/prescription/alova/createApis.ts +22 -7
  69. package/src/api/prescription/alova/globals.d.ts +32 -23
  70. package/src/api/prescription/alova/implement/herbal.ts +59 -39
  71. package/src/api/prescription/alova/implement/index.ts +1 -1
  72. package/src/api/prescription/alova/implement/prescription.ts +50 -33
  73. package/src/api/prescription/alova/index.ts +4 -5
  74. package/src/api/prescription/herbal.ts +17 -10
  75. package/src/api/prescription/index.ts +1 -1
  76. package/src/api/prescription/prescription.ts +35 -27
  77. package/src/api/scientist/alova/apiDefinitions.ts +2 -2
  78. package/src/api/scientist/alova/createApis.ts +22 -7
  79. package/src/api/scientist/alova/globals.d.ts +25 -16
  80. package/src/api/scientist/alova/implement/index.ts +1 -1
  81. package/src/api/scientist/alova/implement/scientist.ts +31 -20
  82. package/src/api/scientist/alova/index.ts +5 -4
  83. package/src/api/scientist/index.ts +1 -1
  84. package/src/api/scientist/scientist.ts +20 -20
  85. package/src/index.ts +3 -4
  86. package/src/layouts/UserLayout.vue +9 -7
  87. package/src/pages/LoginPage.vue +2 -5
  88. package/src/proto/types/Images_pb.ts +13 -13
  89. package/src/proto/types/WaveMap_pb.ts +13 -13
  90. package/src/router/routes.ts +2 -2
  91. package/src/util/export.ts +4 -4
  92. package/src/util/helper.ts +6 -6
  93. package/src/util/image.ts +1 -1
  94. package/src/util/number.ts +4 -4
  95. package/src/util/s256.js +1 -4
  96. package/src/util/secret.ts +1 -1
  97. package/src/util/string.ts +18 -18
  98. package/tsconfig.json +5 -1
@@ -1,20 +1,20 @@
1
- import { Patient } from '@core/api/patient/patient';
2
- import type { Page} from '@core/api/patient/core';
3
- import { Tag } from '@core/api/patient/core';
4
- import { NetworkObject, Sequence } from '@core/api/patient/core';
5
- import type { CheckState, PaymentState } from '@core/api/check/alova/globals';
6
- import { Metas } from '@core/api/patient/meta';
7
- import { Prescription } from '@core/api/prescription/prescription';
8
- import { AlovaPrescription } from '@core/api/prescription/alova/implement/prescription';
9
- import type { PrescriptionState } from '@core/api/prescription/alova/globals';
10
- import { extractPlainText } from '@core/util/RichTextUtil';
11
- import { Doctor } from '@core/api/doctor/doctor';
12
- import { Herbal } from '@core/api/prescription';
1
+ import { Patient } from 'src/api/patient/patient';
2
+ import type { Page } from 'src/api/patient/core';
3
+ import { Tag } from 'src/api/patient/core';
4
+ import { NetworkObject, Sequence } from 'src/api/patient/core';
5
+ import type { CheckState, PaymentState } from 'src/api/check/alova/globals';
6
+ import { Metas } from 'src/api/patient/meta';
7
+ import { Prescription } from 'src/api/prescription/prescription';
8
+ import { AlovaPrescription } from 'src/api/prescription/alova/implement/prescription';
9
+ import type { PrescriptionState } from 'src/api/prescription/alova/globals';
10
+ import { extractPlainText } from 'src/util/RichTextUtil';
11
+ import { Doctor } from 'src/api/doctor/doctor';
12
+ import { Herbal } from 'src/api/prescription';
13
13
  import type { IBuilder } from 'builder-pattern';
14
14
  import { Builder } from 'builder-pattern';
15
15
 
16
16
  export abstract class Check extends NetworkObject {
17
- static override builder(): IBuilder<Check>{
17
+ static override builder(): IBuilder<Check> {
18
18
  return Builder(this._default) as unknown as IBuilder<Check>;
19
19
  }
20
20
  static override default(): typeof Check {
@@ -37,51 +37,60 @@ export abstract class Check extends NetworkObject {
37
37
  draft: boolean = false;
38
38
  isEditing: boolean = false;
39
39
  metas: Metas = Metas.builder().build();
40
- constructor(){
41
- super()
42
- const prescription = Prescription.builder().build()
40
+ constructor() {
41
+ super();
42
+ const prescription = Prescription.builder().build();
43
43
  prescription.herbals.push(Herbal.builder().build());
44
- this.prescriptions.data.push(prescription)
44
+ this.prescriptions.data.push(prescription);
45
45
  }
46
46
  async of(json: CheckState) {
47
- if(json.tagsState != undefined)this.tags = await Promise.all(json.tagsState.map(item => {
48
- const clTag = new Tag()
49
- return clTag.of(item)
50
- }));
51
- if(json.id != undefined)this.id = json.id;
47
+ if (json.tagsState != undefined)
48
+ this.tags = await Promise.all(
49
+ json.tagsState.map((item) => {
50
+ const clTag = new Tag();
51
+ return clTag.of(item);
52
+ }),
53
+ );
54
+ if (json.id != undefined) this.id = json.id;
52
55
  if (json.prescriptionsState != undefined) {
53
56
  this.prescriptions = new Sequence<AlovaPrescription>();
54
- const prescriptionStates = JSON.parse(json.prescriptionsState) as PrescriptionState[]
55
- const prescription = await Promise.all(prescriptionStates.map(async item => {return new AlovaPrescription().of(item)}))
57
+ const prescriptionStates = JSON.parse(json.prescriptionsState) as PrescriptionState[];
58
+ const prescription = await Promise.all(
59
+ prescriptionStates.map(async (item) => {
60
+ return new AlovaPrescription().of(item);
61
+ }),
62
+ );
56
63
  this.prescriptions.data.push(...prescription);
57
64
  }
58
- if(this.prescriptions.data.length === 0)this.prescriptions.data.push(Prescription.builder().build())
59
- if(json.diagnosis != undefined){
60
- if(json.diagnosis.indexOf('脉证') !== 0 && json.diagnosis.indexOf('\n脉证') === -1){
61
- json.diagnosis = json.diagnosis.replaceAll('脉证','\n脉证')
65
+ if (this.prescriptions.data.length === 0)
66
+ this.prescriptions.data.push(Prescription.builder().build());
67
+ if (json.diagnosis != undefined) {
68
+ if (json.diagnosis.indexOf('脉证') !== 0 && json.diagnosis.indexOf('\n脉证') === -1) {
69
+ json.diagnosis = json.diagnosis.replaceAll('脉证', '\n脉证');
62
70
  }
63
- if(json.diagnosis.indexOf('\n方证') === -1){
64
- json.diagnosis = json.diagnosis.replaceAll('方证','\n方证')
71
+ if (json.diagnosis.indexOf('\n方证') === -1) {
72
+ json.diagnosis = json.diagnosis.replaceAll('方证', '\n方证');
65
73
  }
66
74
  this.diagnosis = extractPlainText(json.diagnosis);
67
75
  }
68
- if(json.doctorState != undefined)this.doctor = await this.doctor.of(json.doctorState)
69
- if(json.patientState != undefined)this.patient = await this.patient.of(json.patientState)
70
- if(json.createdTimestamp != undefined)this.createdTimestamp = json.createdTimestamp!;
71
- if(json.updatedTimestamp != undefined)this.updatedTimestamp = json.updatedTimestamp!;
72
- if(json.prescriptionPaymentStatus != undefined)this.prescriptionPaymentStatus = json.prescriptionPaymentStatus!;
73
- if(json.outboundStatus != undefined)this.outboundStatus = json.outboundStatus!;
74
- if(json.paymentType != undefined)this.paymentType = json.paymentType!;
75
- if(json.outpatientType != undefined)this.outpatientType = json.outpatientType!;
76
- if(json.metasState != undefined){
77
- this.metas.addMetas(await Promise.all(json.metasState.map(item => Metas.map(item))))
76
+ if (json.doctorState != undefined) this.doctor = await this.doctor.of(json.doctorState);
77
+ if (json.patientState != undefined) this.patient = await this.patient.of(json.patientState);
78
+ if (json.createdTimestamp != undefined) this.createdTimestamp = json.createdTimestamp!;
79
+ if (json.updatedTimestamp != undefined) this.updatedTimestamp = json.updatedTimestamp!;
80
+ if (json.prescriptionPaymentStatus != undefined)
81
+ this.prescriptionPaymentStatus = json.prescriptionPaymentStatus!;
82
+ if (json.outboundStatus != undefined) this.outboundStatus = json.outboundStatus!;
83
+ if (json.paymentType != undefined) this.paymentType = json.paymentType!;
84
+ if (json.outpatientType != undefined) this.outpatientType = json.outpatientType!;
85
+ if (json.metasState != undefined) {
86
+ this.metas.addMetas(await Promise.all(json.metasState.map((item) => Metas.map(item))));
78
87
  }
79
88
  return this;
80
89
  }
81
90
 
82
- state(){
83
- console.log(this)
84
- const state = { } as CheckState;
91
+ state() {
92
+ console.log(this);
93
+ const state = {} as CheckState;
85
94
  state.id = this.id;
86
95
  state.doctorState = this.doctor.state();
87
96
  state.patientState = this.patient.state();
@@ -89,15 +98,17 @@ export abstract class Check extends NetworkObject {
89
98
  state.paymentType = this.paymentType;
90
99
  // Note: We can't populate metaIds here as it would create a circular dependency
91
100
  // The metaIds should be populated by the caller if needed
92
- state.diagnosis = extractPlainText(this.diagnosis.replace('</div>','\n<div>'))
101
+ state.diagnosis = extractPlainText(this.diagnosis.replace('</div>', '\n<div>'));
93
102
  state.createdTimestamp = this.createdTimestamp;
94
103
  // Note: We'll leave prescriptions handling for the caller due to complexity
95
104
  state.diagnosis = this.diagnosis;
96
- state.tagsState = this.tags.map(item => item.state());
105
+ state.tagsState = this.tags.map((item) => item.state());
97
106
  state.createdTimestamp = this.createdTimestamp;
98
107
  state.updatedTimestamp = this.updatedTimestamp;
99
- state.prescriptionsState = JSON.stringify(this.prescriptions.data.map(item => item.state()))
100
- state.metasState = Metas.standards().flatMap(type => this.metas[type].data.map(item => item.state()))
108
+ state.prescriptionsState = JSON.stringify(this.prescriptions.data.map((item) => item.state()));
109
+ state.metasState = Metas.standards().flatMap((type) =>
110
+ this.metas[type].data.map((item) => item.state()),
111
+ );
101
112
  return state;
102
113
  }
103
114
  abstract get(): Promise<this>;
@@ -105,15 +116,55 @@ export abstract class Check extends NetworkObject {
105
116
  abstract post(): Promise<this>;
106
117
  abstract delete(): Promise<void>;
107
118
 
108
- static query(page: number, pageSize: number, sort: string, patientId?: string, doctorId?: string, startTime?: string, endTime?: string, patientName?: string, patientGender?: string, patientPhoneNumber?: string): Promise<Page<Check>> {
109
- return Check.default().query(page, pageSize, sort, patientId, doctorId, startTime, endTime, patientName, patientGender, patientPhoneNumber)
119
+ static query(
120
+ page: number,
121
+ pageSize: number,
122
+ sort: string,
123
+ patientId?: string,
124
+ doctorId?: string,
125
+ startTime?: string,
126
+ endTime?: string,
127
+ patientName?: string,
128
+ patientGender?: string,
129
+ patientPhoneNumber?: string,
130
+ ): Promise<Page<Check>> {
131
+ return Check.default().query(
132
+ page,
133
+ pageSize,
134
+ sort,
135
+ patientId,
136
+ doctorId,
137
+ startTime,
138
+ endTime,
139
+ patientName,
140
+ patientGender,
141
+ patientPhoneNumber,
142
+ );
110
143
  }
111
- static queryPayment(page: number, pageSize: number, doctorId?: string, patientId?: string, patientName?: string, patientPhone?: string, prescriptionPaymentStatus?: number, outboundStatus?: number):Promise<Page<Payment>>{
112
- return Check.default().queryPayment(page, pageSize, doctorId, patientId, patientName, patientPhone, prescriptionPaymentStatus, outboundStatus)
144
+ static queryPayment(
145
+ page: number,
146
+ pageSize: number,
147
+ doctorId?: string,
148
+ patientId?: string,
149
+ patientName?: string,
150
+ patientPhone?: string,
151
+ prescriptionPaymentStatus?: number,
152
+ outboundStatus?: number,
153
+ ): Promise<Page<Payment>> {
154
+ return Check.default().queryPayment(
155
+ page,
156
+ pageSize,
157
+ doctorId,
158
+ patientId,
159
+ patientName,
160
+ patientPhone,
161
+ prescriptionPaymentStatus,
162
+ outboundStatus,
163
+ );
113
164
  }
114
165
  }
115
- export abstract class Payment extends NetworkObject{
116
- static override builder(): IBuilder<Payment>{
166
+ export abstract class Payment extends NetworkObject {
167
+ static override builder(): IBuilder<Payment> {
117
168
  return Builder(this._default) as unknown as IBuilder<Payment>;
118
169
  }
119
170
  static override default(): typeof Payment {
@@ -132,16 +183,18 @@ export abstract class Payment extends NetworkObject{
132
183
  outboundStatus: number = 0;
133
184
  async of(json: PaymentState) {
134
185
  this.id = json.id!;
135
- this.prescription = json.prescription?json.prescription:'';
186
+ this.prescription = json.prescription ? json.prescription : '';
136
187
  this.doctorId = json.doctorId!;
137
188
  this.patientId = json.patientId!;
138
- this.patientName = json.patientName?json.patientName:'';
139
- this.patientPhone = json.patientPhone?json.patientPhone:'';
140
- this.patientGender = json.patientGender?json.patientGender:'';
141
- this.createdTimestamp = json.createdTimestamp?json.createdTimestamp:0;
142
- this.updatedTimestamp = json.updatedTimestamp?json.updatedTimestamp:0;
143
- this.prescriptionPaymentStatus = json.prescriptionPaymentStatus?json.prescriptionPaymentStatus:0;
144
- this.outboundStatus = json.outboundStatus?json.outboundStatus:0;
189
+ this.patientName = json.patientName ? json.patientName : '';
190
+ this.patientPhone = json.patientPhone ? json.patientPhone : '';
191
+ this.patientGender = json.patientGender ? json.patientGender : '';
192
+ this.createdTimestamp = json.createdTimestamp ? json.createdTimestamp : 0;
193
+ this.updatedTimestamp = json.updatedTimestamp ? json.updatedTimestamp : 0;
194
+ this.prescriptionPaymentStatus = json.prescriptionPaymentStatus
195
+ ? json.prescriptionPaymentStatus
196
+ : 0;
197
+ this.outboundStatus = json.outboundStatus ? json.outboundStatus : 0;
145
198
  return Promise.resolve(this);
146
199
  }
147
200
  state(): PaymentState {
@@ -159,6 +212,6 @@ export abstract class Payment extends NetworkObject{
159
212
  outboundStatus: this.outboundStatus,
160
213
  };
161
214
  }
162
- abstract putOutboundStatus(status: number): Promise<this>
163
- abstract putPrescriptionPaymentStatus(status: number): Promise<this>
215
+ abstract putOutboundStatus(status: number): Promise<this>;
216
+ abstract putPrescriptionPaymentStatus(status: number): Promise<this>;
164
217
  }
@@ -1,2 +1,2 @@
1
1
  export * from './check';
2
- export * from './alova/index';
2
+ export * from './alova';
@@ -1,34 +1,34 @@
1
1
  import { createClientTokenAuthentication } from 'alova/client';
2
- import { storageHelper } from '@core/util/helper';
2
+ import { storageHelper } from 'src/util/helper';
3
3
  import { jwtDecode } from 'jwt-decode';
4
4
  import type { Method } from 'alova';
5
5
 
6
6
  export const { onAuthRequired } = createClientTokenAuthentication({
7
- assignToken: method => {
7
+ assignToken: (method) => {
8
8
  if (!storageHelper.getItem('token')) {
9
9
  return;
10
10
  }
11
11
  method.config.headers.Authorization = 'Bearer ' + storageHelper.getItem('token');
12
12
  },
13
13
  visitorMeta: {
14
- isVisitor: true
14
+ isVisitor: true,
15
15
  },
16
16
  login: {
17
- metaMatches:{
18
- login: true
17
+ metaMatches: {
18
+ login: true,
19
19
  },
20
20
  handler: async (response: Response) => {
21
- if(response.status != 200)throw new Error('登录失败'+await response.text())
22
- await response.json().then(data => {
21
+ if (response.status != 200) throw new Error('登录失败' + (await response.text()));
22
+ await response.json().then((data) => {
23
23
  storageHelper.setItem('token', data.token);
24
24
  });
25
- }
25
+ },
26
26
  },
27
27
  refreshToken: {
28
28
  // 在请求前触发,将接收到method参数,并返回boolean表示token是否过期
29
29
  isExpired: () => {
30
- if(!storageHelper.getItem('token'))return false
31
- const decoded = jwtDecode(storageHelper.getItem('token'))
30
+ if (!storageHelper.getItem('token')) return false;
31
+ const decoded = jwtDecode(storageHelper.getItem('token'));
32
32
  // 如果没有 exp 声明,默认永不过期
33
33
  if (decoded.exp === undefined) return false;
34
34
 
@@ -42,31 +42,30 @@ export const { onAuthRequired } = createClientTokenAuthentication({
42
42
  // 当token过期时触发,在此函数中触发刷新token
43
43
  handler: async () => {
44
44
  // token刷新失败,跳转回登录页
45
- storageHelper.removeItem('token')
46
- window.location.href = "登录"
45
+ storageHelper.removeItem('token');
46
+ window.location.href = '登录';
47
47
  return await Promise.resolve();
48
- }
48
+ },
49
49
  },
50
50
  });
51
51
  export const responded = {
52
- onSuccess: async (response: Response,method: Method) => {
53
- if(response.status == 401){
54
- if(method.meta['Login']){
55
- throw new Error(response.status.toString())
52
+ onSuccess: async (response: Response, method: Method) => {
53
+ if (response.status == 401) {
54
+ if (method.meta['Login']) {
55
+ throw new Error(response.status.toString());
56
56
  }
57
- console.log('未登录')
58
- storageHelper.removeItem('token')
59
- window.location.href = process.env.APP_URL!
57
+ console.log('未登录');
58
+ storageHelper.removeItem('token');
59
+ window.location.href = process.env.APP_URL!;
60
60
  }
61
- if("application/octet-stream" == response.headers.get('Content-Type'))return response
62
- if(response.status == 200 || response.status == 201 || response.status == 204){
63
- const raw = await response.text()
61
+ if ('application/octet-stream' == response.headers.get('Content-Type')) return response;
62
+ if (response.status == 200 || response.status == 201 || response.status == 204) {
63
+ const raw = await response.text();
64
64
  try {
65
- return JSON.parse(raw)
66
- }
67
- catch {
65
+ return JSON.parse(raw);
66
+ } catch {
68
67
  return raw;
69
68
  }
70
69
  }
71
70
  },
72
- }
71
+ };
@@ -14,117 +14,119 @@ export enum ServiceType {
14
14
  PulsationsAlgorithm = 'PulsationsAlgorithm',
15
15
  InquiriesAlgorithm = 'InquiriesAlgorithm',
16
16
  LisemsAlgorithm = 'LisemsAlgorithm',
17
- ComprehensiveAlgorithm = 'ComprehensiveAlgorithm'
17
+ ComprehensiveAlgorithm = 'ComprehensiveAlgorithm',
18
18
  }
19
19
  //设置服务类型有哪些
20
20
  export enum EnvironmentType {
21
21
  Dev = 'Dev',
22
22
  Prod = 'Prod',
23
- Local = 'Local'
23
+ Local = 'Local',
24
24
  }
25
- export const getServiceEndpoint = (serviceType: ServiceType,env?: EnvironmentType) => {
26
- if(env == undefined){
27
- if (punycode.toUnicode(window.location.hostname).includes('测试'))env = EnvironmentType.Dev
28
- else if(window.location.hostname.includes("localhost") || window.location.hostname.includes("127.0.0.1")) env = EnvironmentType.Prod
29
- else env = EnvironmentType.Prod
25
+ export const getServiceEndpoint = (serviceType: ServiceType, env?: EnvironmentType) => {
26
+ if (env == undefined) {
27
+ if (punycode.toUnicode(window.location.hostname).includes('测试')) env = EnvironmentType.Dev;
28
+ else if (
29
+ window.location.hostname.includes('localhost') ||
30
+ window.location.hostname.includes('127.0.0.1')
31
+ )
32
+ env = EnvironmentType.Prod;
33
+ else env = EnvironmentType.Prod;
30
34
  }
31
- if(env == EnvironmentType.Prod){
35
+ if (env == EnvironmentType.Prod) {
32
36
  switch (serviceType) {
33
37
  case ServiceType.OAuth:
34
- return 'https://用户.仪联中.中国'
38
+ return 'https://用户.仪联中.中国';
35
39
  case ServiceType.OAuthRedirect:
36
- return 'https://用户.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile'
40
+ return 'https://用户.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile';
37
41
  case ServiceType.Doctor:
38
- return 'https://中医.仪联中.中国'
42
+ return 'https://中医.仪联中.中国';
39
43
  case ServiceType.Patient:
40
- return 'https://中医.仪联中.中国'
44
+ return 'https://中医.仪联中.中国';
41
45
  case ServiceType.Scientist:
42
- return 'https://中医.仪联中.中国'
46
+ return 'https://中医.仪联中.中国';
43
47
  case ServiceType.Outpatient:
44
- return 'https://中医.仪联中.中国'
48
+ return 'https://中医.仪联中.中国';
45
49
  case ServiceType.Check:
46
- return 'https://中医.仪联中.中国'
50
+ return 'https://中医.仪联中.中国';
47
51
  case ServiceType.Prescription:
48
- return 'https://中医.仪联中.中国'
52
+ return 'https://中医.仪联中.中国';
49
53
  case ServiceType.Authorization:
50
- return 'https://中医.仪联中.中国'
54
+ return 'https://中医.仪联中.中国';
51
55
  case ServiceType.InspectionsAlgorithm:
52
- return 'https://中医.仪联中.中国/望诊/算法'
56
+ return 'https://中医.仪联中.中国/望诊/算法';
53
57
  case ServiceType.PulsationsAlgorithm:
54
- return 'https://中医.仪联中.中国/切诊/算法'
58
+ return 'https://中医.仪联中.中国/切诊/算法';
55
59
  case ServiceType.InquiriesAlgorithm:
56
- return 'https://中医.仪联中.中国/问诊/算法'
60
+ return 'https://中医.仪联中.中国/问诊/算法';
57
61
  case ServiceType.LisemsAlgorithm:
58
- return 'https://中医.仪联中.中国/闻诊/算法'
62
+ return 'https://中医.仪联中.中国/闻诊/算法';
59
63
  case ServiceType.ComprehensiveAlgorithm:
60
- return 'https://中医.仪联中.中国/四诊合参/算法'
64
+ return 'https://中医.仪联中.中国/四诊合参/算法';
61
65
  }
62
- }
63
- else if(env == EnvironmentType.Dev){
66
+ } else if (env == EnvironmentType.Dev) {
64
67
  switch (serviceType) {
65
68
  case ServiceType.OAuth:
66
- return 'https://用户测试.仪联中.中国'
69
+ return 'https://用户测试.仪联中.中国';
67
70
  case ServiceType.OAuthRedirect:
68
- return 'https://用户测试.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile'
71
+ return 'https://用户测试.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile';
69
72
  case ServiceType.Doctor:
70
- return 'https://中医测试.仪联中.中国'
73
+ return 'https://中医测试.仪联中.中国';
71
74
  case ServiceType.Patient:
72
- return 'https://中医测试.仪联中.中国'
75
+ return 'https://中医测试.仪联中.中国';
73
76
  case ServiceType.Scientist:
74
- return 'https://中医测试.仪联中.中国'
77
+ return 'https://中医测试.仪联中.中国';
75
78
  case ServiceType.Outpatient:
76
- return 'https://中医测试.仪联中.中国'
79
+ return 'https://中医测试.仪联中.中国';
77
80
  case ServiceType.Check:
78
- return 'https://中医测试.仪联中.中国'
81
+ return 'https://中医测试.仪联中.中国';
79
82
  case ServiceType.Prescription:
80
- return 'https://中医测试.仪联中.中国'
83
+ return 'https://中医测试.仪联中.中国';
81
84
  case ServiceType.Authorization:
82
- return 'https://中医测试.仪联中.中国'
85
+ return 'https://中医测试.仪联中.中国';
83
86
  case ServiceType.InspectionsAlgorithm:
84
- return 'https://中医测试.仪联中.中国/望诊/算法'
87
+ return 'https://中医测试.仪联中.中国/望诊/算法';
85
88
  case ServiceType.PulsationsAlgorithm:
86
- return 'https://中医测试.仪联中.中国/切诊/算法'
89
+ return 'https://中医测试.仪联中.中国/切诊/算法';
87
90
  case ServiceType.InquiriesAlgorithm:
88
- return 'https://中医测试.仪联中.中国/问诊/算法'
91
+ return 'https://中医测试.仪联中.中国/问诊/算法';
89
92
  case ServiceType.LisemsAlgorithm:
90
- return 'https://中医测试.仪联中.中国/闻诊/算法'
93
+ return 'https://中医测试.仪联中.中国/闻诊/算法';
91
94
  case ServiceType.ComprehensiveAlgorithm:
92
- return 'https://中医测试.仪联中.中国/四诊合参/算法'
95
+ return 'https://中医测试.仪联中.中国/四诊合参/算法';
93
96
  }
94
- }
95
- else if(env == EnvironmentType.Local){
97
+ } else if (env == EnvironmentType.Local) {
96
98
  switch (serviceType) {
97
99
  case ServiceType.OAuth:
98
- return 'http://localhost:8080'
100
+ return 'http://localhost:8080';
99
101
  case ServiceType.OAuthRedirect:
100
- return 'https://用户.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile'
102
+ return 'https://用户.仪联中.中国/互联/服务/互联/授权?response_type=code&state=1223&client_id=tcm&scope=profile';
101
103
  case ServiceType.Doctor:
102
- return 'http://localhost:8080'
104
+ return 'http://localhost:8080';
103
105
  case ServiceType.Patient:
104
- return 'http://localhost:8080'
106
+ return 'http://localhost:8080';
105
107
  case ServiceType.Scientist:
106
- return 'http://localhost:8080'
108
+ return 'http://localhost:8080';
107
109
  case ServiceType.Outpatient:
108
- return 'http://localhost:8080'
110
+ return 'http://localhost:8080';
109
111
  case ServiceType.Check:
110
- return 'http://localhost:8080'
112
+ return 'http://localhost:8080';
111
113
  case ServiceType.Prescription:
112
- return 'http://localhost:8080'
114
+ return 'http://localhost:8080';
113
115
  case ServiceType.Authorization:
114
- return 'http://localhost:8080'
116
+ return 'http://localhost:8080';
115
117
  case ServiceType.InspectionsAlgorithm:
116
- return 'http://localhost:8080'
118
+ return 'http://localhost:8080';
117
119
  case ServiceType.PulsationsAlgorithm:
118
- return 'http://localhost:8080'
120
+ return 'http://localhost:8080';
119
121
  case ServiceType.InquiriesAlgorithm:
120
- return 'http://localhost:8080'
122
+ return 'http://localhost:8080';
121
123
  case ServiceType.LisemsAlgorithm:
122
- return 'http://localhost:8080'
124
+ return 'http://localhost:8080';
123
125
  case ServiceType.ComprehensiveAlgorithm:
124
- return 'http://localhost:8080'
126
+ return 'http://localhost:8080';
125
127
  }
126
128
  }
127
- throw new Error('环境错误')
128
- }
129
+ throw new Error('环境错误');
130
+ };
129
131
 
130
- export * from './alova/index';
132
+ export * from './alova';
@@ -1,6 +1,6 @@
1
1
  /// <reference types='./globals.d.ts' />
2
2
  /* tslint:disable */
3
- /* eslint-disable */
3
+
4
4
  /**
5
5
  * OpenAPI definition - version v0
6
6
  *
@@ -24,5 +24,5 @@ export default {
24
24
  'doctorStateRestful.queryDoctorStateByExactMatch': ['POST', '/医生/服务/精确匹配'],
25
25
  'doctorStateRestful.datesOfDoctor': ['GET', '/医生/服务/统计/医生/日期'],
26
26
  'doctorStateRestful.totalOfDoctor': ['GET', '/医生/服务/统计/医生/总数'],
27
- 'doctorStateRestful.totalOfDoctorByToday': ['GET', '/医生/服务/统计/医生/今日']
27
+ 'doctorStateRestful.totalOfDoctorByToday': ['GET', '/医生/服务/统计/医生/今日'],
28
28
  };
@@ -19,7 +19,11 @@ import { Method } from 'alova';
19
19
  import apiDefinitions from './apiDefinitions';
20
20
 
21
21
  const cache = Object.create(null);
22
- const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
22
+ const createFunctionalProxy = (
23
+ array: (string | symbol)[],
24
+ alovaInstance: Alova<AlovaGenerics>,
25
+ configMap: any,
26
+ ) => {
23
27
  const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
24
28
  if (cache[apiPathKey]) {
25
29
  return cache[apiPathKey];
@@ -39,7 +43,7 @@ const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<
39
43
  }
40
44
  const mergedConfig = {
41
45
  ...configMap[apiPathKey],
42
- ...config
46
+ ...config,
43
47
  };
44
48
  const [method, url] = apiItem;
45
49
  const pathParams = mergedConfig.pathParams;
@@ -49,7 +53,10 @@ const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<
49
53
  });
50
54
  delete mergedConfig.pathParams;
51
55
  let data = mergedConfig.data;
52
- if (Object.prototype.toString.call(data) === '[object Object]' && typeof FormData !== 'undefined') {
56
+ if (
57
+ Object.prototype.toString.call(data) === '[object Object]' &&
58
+ typeof FormData !== 'undefined'
59
+ ) {
53
60
  let hasBlobData = false;
54
61
  const formData = new FormData();
55
62
  for (const key in data) {
@@ -60,8 +67,14 @@ const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<
60
67
  }
61
68
  data = hasBlobData ? formData : data;
62
69
  }
63
- return new Method(method!.toUpperCase() as MethodType, alovaInstance, urlReplaced, mergedConfig, data);
64
- }
70
+ return new Method(
71
+ method!.toUpperCase() as MethodType,
72
+ alovaInstance,
73
+ urlReplaced,
74
+ mergedConfig,
75
+ data,
76
+ );
77
+ },
65
78
  });
66
79
  cache[apiPathKey] = proxy;
67
80
  return proxy;
@@ -71,7 +84,7 @@ export const createApis = (alovaInstance: Alova<AlovaGenerics>, configMap: any)
71
84
  const Apis = new Proxy({} as doctorApi, {
72
85
  get(_, property) {
73
86
  return createFunctionalProxy([property], alovaInstance, configMap);
74
- }
87
+ },
75
88
  });
76
89
  return Apis;
77
90
  };
@@ -93,7 +106,9 @@ type APISofParameters<Tag extends string, Url extends string> = Tag extends keyo
93
106
  : any;
94
107
  type MethodsConfigMap = {
95
108
  [P in keyof typeof import('./apiDefinitions').default]?: MethodConfig<
96
- P extends `${infer Tag}.${infer Url}` ? Parameters<NonNullable<APISofParameters<Tag, Url>[0]>['transform']>[0] : any
109
+ P extends `${infer Tag}.${infer Url}`
110
+ ? Parameters<NonNullable<APISofParameters<Tag, Url>[0]>['transform']>[0]
111
+ : any
97
112
  >;
98
113
  };
99
114
  export const withConfigType = <Config extends MethodsConfigMap>(config: Config) => config;