cnhis-design-vue 3.3.1-beta.53 → 3.3.1-beta.56

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.
@@ -0,0 +1,258 @@
1
+ function useWave(Recorder) {
2
+ var FrequencyHistogramView = function(set) {
3
+ return new fn(set);
4
+ };
5
+ var ViewTxt = "FrequencyHistogramView";
6
+ var fn = function(set) {
7
+ var This = this;
8
+ var o = {
9
+ scale: 2,
10
+ fps: 20,
11
+ lineCount: 30,
12
+ widthRatio: 0.6,
13
+ spaceWidth: 0,
14
+ minHeight: 0,
15
+ position: -1,
16
+ mirrorEnable: false,
17
+ stripeEnable: true,
18
+ stripeHeight: 3,
19
+ stripeMargin: 6,
20
+ fallDuration: 1e3,
21
+ stripeFallDuration: 3500,
22
+ linear: [0, "rgba(0,187,17,1)", 0.5, "rgba(255,215,0,1)", 1, "rgba(255,102,0,1)"],
23
+ stripeLinear: null,
24
+ shadowBlur: 0,
25
+ shadowColor: "#bbb",
26
+ stripeShadowBlur: -1,
27
+ stripeShadowColor: "",
28
+ onDraw: function(frequencyData, sampleRate) {
29
+ }
30
+ };
31
+ for (var k in set) {
32
+ o[k] = set[k];
33
+ }
34
+ This.set = set = o;
35
+ var elem = set.elem;
36
+ if (elem) {
37
+ if (typeof elem == "string") {
38
+ elem = document.querySelector(elem);
39
+ } else if (elem.length) {
40
+ elem = elem[0];
41
+ }
42
+ }
43
+ if (elem) {
44
+ set.width = elem.offsetWidth;
45
+ set.height = elem.offsetHeight;
46
+ }
47
+ var scale = set.scale;
48
+ var width = set.width * scale;
49
+ var height = set.height * scale;
50
+ if (!width || !height) {
51
+ throw new Error(ViewTxt + "\u65E0\u5BBD\u9AD8");
52
+ }
53
+ var thisElem = This.elem = document.createElement("div");
54
+ var lowerCss = ["", "transform-origin:0 0;", "transform:scale(" + 1 / scale + ");"];
55
+ thisElem.innerHTML = '<div style="width:' + set.width + "px;height:" + set.height + 'px;overflow:hidden"><div style="width:' + width + "px;height:" + height + "px;" + lowerCss.join("-webkit-") + lowerCss.join("-ms-") + lowerCss.join("-moz-") + lowerCss.join("") + '"><canvas/></div></div>';
56
+ var canvas = This.canvas = thisElem.querySelector("canvas");
57
+ This.ctx = canvas.getContext("2d");
58
+ canvas.width = width;
59
+ canvas.height = height;
60
+ if (elem) {
61
+ elem.innerHTML = "";
62
+ elem.appendChild(thisElem);
63
+ }
64
+ if (!Recorder.LibFFT) {
65
+ throw new Error("\u9700\u8981lib.fft.js\u652F\u6301");
66
+ }
67
+ This.fft = Recorder.LibFFT(1024);
68
+ This.lastH = [];
69
+ This.stripesH = [];
70
+ };
71
+ fn.prototype = FrequencyHistogramView.prototype = {
72
+ genLinear: function(ctx, colors, from, to) {
73
+ var rtv = ctx.createLinearGradient(0, from, 0, to);
74
+ for (var i = 0; i < colors.length; ) {
75
+ rtv.addColorStop(colors[i++], colors[i++]);
76
+ }
77
+ return rtv;
78
+ },
79
+ input: function(pcmData, powerLevel, sampleRate) {
80
+ var This = this;
81
+ This.sampleRate = sampleRate;
82
+ This.pcmData = pcmData;
83
+ This.pcmPos = 0;
84
+ This.inputTime = Date.now();
85
+ This.schedule();
86
+ },
87
+ schedule: function() {
88
+ var This = this, set = This.set;
89
+ var interval = Math.floor(1e3 / set.fps);
90
+ if (!This.timer) {
91
+ This.timer = setInterval(function() {
92
+ This.schedule();
93
+ }, interval);
94
+ }
95
+ var now = Date.now();
96
+ var drawTime = This.drawTime || 0;
97
+ if (now - This.inputTime > set.stripeFallDuration * 1.3) {
98
+ clearInterval(This.timer);
99
+ This.timer = 0;
100
+ return;
101
+ }
102
+ if (now - drawTime < interval) {
103
+ return;
104
+ }
105
+ This.drawTime = now;
106
+ var bufferSize = This.fft.bufferSize;
107
+ var pcm = This.pcmData;
108
+ var pos = This.pcmPos;
109
+ var arr = new Int16Array(bufferSize);
110
+ for (var i = 0; i < bufferSize && pos < pcm.length; i++, pos++) {
111
+ arr[i] = pcm[pos];
112
+ }
113
+ This.pcmPos = pos;
114
+ var frequencyData = This.fft.transform(arr);
115
+ This.draw(frequencyData, This.sampleRate);
116
+ },
117
+ draw: function(frequencyData, sampleRate) {
118
+ var This = this, set = This.set;
119
+ var ctx = This.ctx;
120
+ var scale = set.scale;
121
+ var width = set.width * scale;
122
+ var height = set.height * scale;
123
+ var lineCount = set.lineCount;
124
+ var bufferSize = This.fft.bufferSize;
125
+ var position = set.position;
126
+ var posAbs = Math.abs(set.position);
127
+ var originY = position == 1 ? 0 : height;
128
+ var heightY = height;
129
+ if (posAbs < 1) {
130
+ heightY = heightY / 2;
131
+ originY = heightY;
132
+ heightY = Math.floor(heightY * (1 + posAbs));
133
+ originY = Math.floor(position > 0 ? originY * (1 - posAbs) : originY * (1 + posAbs));
134
+ }
135
+ var lastH = This.lastH;
136
+ var stripesH = This.stripesH;
137
+ var speed = Math.ceil(heightY / (set.fallDuration / (1e3 / set.fps)));
138
+ var stripeSpeed = Math.ceil(heightY / (set.stripeFallDuration / (1e3 / set.fps)));
139
+ var stripeMargin = set.stripeMargin * scale;
140
+ var Y0 = 1 << (Math.round(Math.log(bufferSize) / Math.log(2) + 3) << 1);
141
+ var logY0 = Math.log(Y0) / Math.log(10);
142
+ var dBmax = 20 * Math.log(32767) / Math.log(10);
143
+ var fftSize = bufferSize / 2;
144
+ var fftSize5k = Math.min(fftSize, Math.floor(fftSize * 5e3 / (sampleRate / 2)));
145
+ var fftSize5kIsAll = fftSize5k == fftSize;
146
+ var line80 = fftSize5kIsAll ? lineCount : Math.round(lineCount * 0.8);
147
+ var fftSizeStep1 = fftSize5k / line80;
148
+ var fftSizeStep2 = fftSize5kIsAll ? 0 : (fftSize - fftSize5k) / (lineCount - line80);
149
+ var fftIdx = 0;
150
+ for (var i = 0; i < lineCount; i++) {
151
+ var start = Math.ceil(fftIdx);
152
+ if (i < line80) {
153
+ fftIdx += fftSizeStep1;
154
+ } else {
155
+ fftIdx += fftSizeStep2;
156
+ }
157
+ var end = Math.min(Math.ceil(fftIdx), fftSize);
158
+ var maxAmp = 0;
159
+ for (var j = start; j < end; j++) {
160
+ maxAmp = Math.max(maxAmp, Math.abs(frequencyData[j]));
161
+ }
162
+ var dB = maxAmp > Y0 ? Math.floor((Math.log(maxAmp) / Math.log(10) - logY0) * 17) : 0;
163
+ var h = heightY * Math.min(dB / dBmax, 1);
164
+ lastH[i] = (lastH[i] || 0) - speed;
165
+ if (h < lastH[i]) {
166
+ h = lastH[i];
167
+ }
168
+ if (h < 0) {
169
+ h = 0;
170
+ }
171
+ lastH[i] = h;
172
+ var shi = stripesH[i] || 0;
173
+ if (h && h + stripeMargin > shi) {
174
+ stripesH[i] = h + stripeMargin;
175
+ } else {
176
+ var sh = shi - stripeSpeed;
177
+ if (sh < 0) {
178
+ sh = 0;
179
+ }
180
+ stripesH[i] = sh;
181
+ }
182
+ }
183
+ ctx.clearRect(0, 0, width, height);
184
+ var linear1 = This.genLinear(ctx, set.linear, originY, originY - heightY);
185
+ var stripeLinear1 = set.stripeLinear && This.genLinear(ctx, set.stripeLinear, originY, originY - heightY) || linear1;
186
+ var linear2 = This.genLinear(ctx, set.linear, originY, originY + heightY);
187
+ var stripeLinear2 = set.stripeLinear && This.genLinear(ctx, set.stripeLinear, originY, originY + heightY) || linear2;
188
+ ctx.shadowBlur = set.shadowBlur * scale;
189
+ ctx.shadowColor = set.shadowColor;
190
+ var mirrorEnable = set.mirrorEnable;
191
+ var mirrorCount = mirrorEnable ? lineCount * 2 - 1 : lineCount;
192
+ var widthRatio = set.widthRatio;
193
+ var spaceWidth = set.spaceWidth * scale;
194
+ if (spaceWidth != 0) {
195
+ widthRatio = (width - spaceWidth * (mirrorCount + 1)) / width;
196
+ }
197
+ var lineWidth = Math.max(1 * scale, Math.floor(width * widthRatio / mirrorCount));
198
+ var spaceFloat = (width - mirrorCount * lineWidth) / (mirrorCount + 1);
199
+ var minHeight = set.minHeight * scale;
200
+ var mirrorSubX = spaceFloat + lineWidth / 2;
201
+ var XFloat = mirrorEnable ? width / 2 - mirrorSubX : 0;
202
+ for (var i = 0, xFloat = XFloat, x, y, h; i < lineCount; i++) {
203
+ xFloat += spaceFloat;
204
+ x = Math.floor(xFloat);
205
+ h = Math.max(lastH[i], minHeight);
206
+ if (originY != 0) {
207
+ y = originY - h;
208
+ ctx.fillStyle = linear1;
209
+ ctx.fillRect(x, y, lineWidth, h);
210
+ }
211
+ if (originY != height) {
212
+ ctx.fillStyle = linear2;
213
+ ctx.fillRect(x, originY, lineWidth, h);
214
+ }
215
+ xFloat += lineWidth;
216
+ }
217
+ if (set.stripeEnable) {
218
+ var stripeShadowBlur = set.stripeShadowBlur;
219
+ ctx.shadowBlur = (stripeShadowBlur == -1 ? set.shadowBlur : stripeShadowBlur) * scale;
220
+ ctx.shadowColor = set.stripeShadowColor || set.shadowColor;
221
+ var stripeHeight = set.stripeHeight * scale;
222
+ for (var i = 0, xFloat = XFloat, x, y, h; i < lineCount; i++) {
223
+ xFloat += spaceFloat;
224
+ x = Math.floor(xFloat);
225
+ h = stripesH[i];
226
+ if (originY != 0) {
227
+ y = originY - h - stripeHeight;
228
+ if (y < 0) {
229
+ y = 0;
230
+ }
231
+ ctx.fillStyle = stripeLinear1;
232
+ ctx.fillRect(x, y, lineWidth, stripeHeight);
233
+ }
234
+ if (originY != height) {
235
+ y = originY + h;
236
+ if (y + stripeHeight > height) {
237
+ y = height - stripeHeight;
238
+ }
239
+ ctx.fillStyle = stripeLinear2;
240
+ ctx.fillRect(x, y, lineWidth, stripeHeight);
241
+ }
242
+ xFloat += lineWidth;
243
+ }
244
+ }
245
+ if (mirrorEnable) {
246
+ var srcW = Math.floor(width / 2);
247
+ ctx.save();
248
+ ctx.scale(-1, 1);
249
+ ctx.drawImage(This.canvas, Math.ceil(width / 2), 0, srcW, height, -srcW, 0, srcW, height);
250
+ ctx.restore();
251
+ }
252
+ set.onDraw(frequencyData, sampleRate);
253
+ }
254
+ };
255
+ Recorder[ViewTxt] = FrequencyHistogramView;
256
+ }
257
+
258
+ export { useWave };
@@ -11,13 +11,19 @@ import { getIndex, isEffectiveNode, getTime, getScaleNumberList } from '../../ut
11
11
  import { cloneDeep, isString, last, range } from 'lodash-es';
12
12
  import '../../constants/index.js';
13
13
  import '@vueuse/shared';
14
- import { format } from 'date-fns';
14
+ import { format, getHours, getMinutes } from 'date-fns';
15
15
  import 'naive-ui';
16
16
  import '../surgicalAnesthesia/useTop.js';
17
17
  import '@vueuse/core';
18
18
  import '../surgicalAnesthesia/useOther.js';
19
19
  import '../../../../../shared/utils/index.js';
20
20
 
21
+ function getCurrentTime(lastTime, range2) {
22
+ return lastTime + 1 > range2[1] ? range2[0] : lastTime + 1;
23
+ }
24
+ function isStartTimeHalfOrLater(startTime) {
25
+ return getMinutes(startTime) >= 30;
26
+ }
21
27
  function useBirthProcess(canvas, propItems, emits, pointTipProps, pointMenuProps) {
22
28
  const {
23
29
  computedX,
@@ -764,6 +770,7 @@ function useBirthProcess(canvas, propItems, emits, pointTipProps, pointMenuProps
764
770
  const processTimeList = range(processTimeRange[0], processTimeRange[1] + 1);
765
771
  const timeTextList = [];
766
772
  const processTimeTextList = [];
773
+ const firstTime = getHours(new Date(startTime2));
767
774
  const halfYCellHeight = yCellHeight / 2;
768
775
  for (let i = 0; i < grid.mainXCell; i++) {
769
776
  if (show) {
@@ -772,7 +779,7 @@ function useBirthProcess(canvas, propItems, emits, pointTipProps, pointMenuProps
772
779
  } = style;
773
780
  const baseLeft = originX + (textAlign === "center" ? xCellWidth / 2 : 0);
774
781
  const left = i === 0 && textAlign !== "center" ? baseLeft + 5 : baseLeft;
775
- const currentTime = i === 0 ? +startTime2.slice(11, 13) : getCurrentTime(last(timeList), timeRange);
782
+ const currentTime = i === 0 ? isStartTimeHalfOrLater(startTime2) && textAlign === "center" ? firstTime + 1 : firstTime : getCurrentTime(last(timeList), timeRange);
776
783
  timeList.push(currentTime);
777
784
  const top = position === "top" ? originY - halfYCellHeight : endY + halfYCellHeight;
778
785
  timeTextList.push(drawText([left + i * xCellWidth, top], {
@@ -819,9 +826,6 @@ function useBirthProcess(canvas, propItems, emits, pointTipProps, pointMenuProps
819
826
  canvas.value.sendToBack(group);
820
827
  }
821
828
  }
822
- function getCurrentTime(lastTime, range2) {
823
- return lastTime + 1 > range2[1] ? range2[0] : lastTime + 1;
824
- }
825
829
  function drawYScale() {
826
830
  drawColumn(leftScales);
827
831
  drawColumn(rightScales, "right");
@@ -105,6 +105,8 @@ export { useScrollLoading } from '../shared/hooks/useScrollLoading.js';
105
105
  export { vFlexibleResize } from '../shared/directive/flexibleResize.js';
106
106
  export { useGuide } from './guide/src/useGuide.js';
107
107
  export { DragScroll, useDragScroll } from './drag-scroll/src/index.js';
108
+ import './audio-sdk/src/utils/recorder/index.js';
109
+ export { default as CRecorder } from './audio-sdk/src/utils/recorder/recorder.js';
108
110
  export { useAnchor } from './form-render/src/hooks/useAnchor.js';
109
111
  export { BusinessCollector, useBusinessBinding } from './form-render/src/hooks/useBusinessBinding.js';
110
112
  export { ContextCollector, useChangeContext } from './form-render/src/hooks/useChangeContext.js';
@@ -1,5 +1,5 @@
1
1
  var name = "@cnhis-design-vue/shared";
2
- var version = "3.3.1-beta.53";
2
+ var version = "3.3.1-beta.56";
3
3
  var main = "index.ts";
4
4
  var peerDependencies = {
5
5
  "naive-ui": "^2.30.0",
@@ -122,7 +122,7 @@ const charMap = {
122
122
  "(": 5.17,
123
123
  ")": 5.17,
124
124
  "-": 7.51,
125
- "+": 7.51,
125
+ "+": 8.8,
126
126
  "/": 4.11,
127
127
  "\\": 4.11,
128
128
  "%": 12.68,
@@ -130,7 +130,8 @@ const charMap = {
130
130
  "\uFF1B": 13.95,
131
131
  "\u3001": 13.95,
132
132
  "\uFF0C": 13.95,
133
- "\u3002": 13.95
133
+ "\u3002": 13.95,
134
+ ":": 4.03
134
135
  };
135
136
  const numberReg = /\d/;
136
137
  const chineseReg = /[\u4e00-\u9fa5():,。]/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.3.1-beta.53",
3
+ "version": "3.3.1-beta.56",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -50,7 +50,6 @@
50
50
  "min-dom": "^3.2.1",
51
51
  "moment": "^2.29.1",
52
52
  "naive-ui": "^2.34.0",
53
- "recorder-core": "^1.2.23070100",
54
53
  "socket.io-client": "^4.7.3",
55
54
  "sockjs-client": "^1.6.1",
56
55
  "sortablejs": "^1.15.0",