|
@@ -128,6 +128,7 @@ const open = async () => {
|
|
|
if(!ret.data.width){ret.data.width= 1920};
|
|
|
if(!ret.data.height){ret.data.height= 1080};
|
|
|
meta2d.open(ret.data);
|
|
|
+ getRealTimeData()
|
|
|
}
|
|
|
} else {
|
|
|
let data: any = await localforage.getItem(localStorageName);
|
|
@@ -149,6 +150,36 @@ const open = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const getRealTimeData = () => {
|
|
|
+ meta2d.store.data.https = [
|
|
|
+ {
|
|
|
+ http: `${import.meta.env.VITE_BASE_API}/api-dashboard/api/iot/getRTDData`,
|
|
|
+ method: 'POST',
|
|
|
+ httpTimeInterval: 1000,
|
|
|
+ httpHeaders: {
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
+ Authorization: 'Bearer ' + import.meta.env.VITE_TEMP_TOKEN
|
|
|
+ },
|
|
|
+ body: {
|
|
|
+ dataPoint: meta2d.store.data.dataPoints
|
|
|
+ } as unknown as BodyInit
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ meta2d.socketFn = (e) => {
|
|
|
+ const { data, code, msg } = JSON.parse(e)
|
|
|
+
|
|
|
+ if (code !== 0) {
|
|
|
+ console.error(msg)
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+
|
|
|
+ return data
|
|
|
+ }
|
|
|
+
|
|
|
+ meta2d.connectHttp()
|
|
|
+}
|
|
|
+
|
|
|
const opened = () => {
|
|
|
meta2d.store.options.shadowColor = '#0000'
|
|
|
meta2d.canvas.parentElement.style.background = meta2d.store.data.background|| meta2d.store.theme[meta2d.store.data.theme].background;
|