Commit 244570548406c6a5a0934bc2b2c29b5665b9152f

Authored by ww
1 parent b7a78283

fix: socket receive message the previous data is lost

... ... @@ -144,9 +144,11 @@
144 144
145 145 if (!hasDeviceAttr()) return;
146 146
  147 + const keys = props.attr ? props.attr : unref(deviceAttrs).join();
  148 +
147 149 const res = await getDeviceHistoryInfo({
148 150 entityId: props.deviceDetail.tbDeviceId,
149   - keys: unref(deviceAttrs).join(),
  151 + keys,
150 152 startTs: Date.now() - 1 * 24 * 60 * 60 * 1000,
151 153 endTs: Date.now(),
152 154 agg: AggregateDataEnum.NONE,
... ...
... ... @@ -42,6 +42,7 @@
42 42 attr: undefined as string | undefined,
43 43 originData: [] as DataSource[],
44 44 dataSource: [] as DataSource[],
  45 + message: {} as ReceiveMessage['data'],
45 46 sendValue: {
46 47 tsSubCmds: [
47 48 {
... ... @@ -123,8 +124,14 @@
123 124 if (value) {
124 125 const { data } = value;
125 126 const keys = Object.keys(data);
126   - socketInfo.originData = socketInfo.dataSource = keys.map((key) => {
127   - const [time, value] = data[key].at(0) || [];
  127 + keys.forEach((key) => {
  128 + socketInfo.message[key] = value.data[key];
  129 + });
  130 +
  131 + const allKeys = Object.keys(socketInfo.message);
  132 +
  133 + socketInfo.originData = socketInfo.dataSource = allKeys.map((key) => {
  134 + const [time, value] = socketInfo.message[key].at(0) || [];
128 135 return { key, value, time };
129 136 });
130 137
... ...