Browse Source

local storage

main
maochaoying 2 years ago
parent
commit
b5f5447eca
  1. 2
      config.js
  2. 19
      index.html

2
config.js

@ -1,4 +1,4 @@
const websocketAddress = "ws://localhost:8888/websocket/123";
const websocketAddress = "ws://192.168.1.138:19001";
const config = {
你好: "123",
b: "1231231",

19
index.html

@ -260,6 +260,12 @@
</body>
<script src="./config.js"></script>
<script>
window.onload = () => {
const commonI = document.querySelector("#common_id");
const commonB = document.querySelector("#common_base");
commonI.value = localStorage.getItem("id");
commonB.value = localStorage.getItem("base");
};
var ws = null;
const websocketInput = document.querySelector("#ws_connnect_input");
websocketInput.value = websocketAddress;
@ -282,6 +288,15 @@
}
});
const commonI = document.querySelector("#common_id");
const commonB = document.querySelector("#common_base");
commonI.addEventListener("input", (e) => {
localStorage.setItem("id", e.target.value);
});
commonB.addEventListener("input", (e) => {
localStorage.setItem("base", e.target.value);
});
const tabs = document.querySelector(".tabs");
const tabBars = document.querySelectorAll(".tab-bar .tab");
const tabPanels = document.querySelectorAll(".tab-content .tab-panel");
@ -397,7 +412,7 @@
const off = document.querySelector("#common_off");
const value = document.querySelector("#common_value");
const { protocol, message } = commonMessage;
return {
return JSON.stringify({
protocol,
message: {
...message,
@ -406,7 +421,7 @@
ctrlPointVal: value.value,
type,
},
};
});
};
const writeFun = () => {

Loading…
Cancel
Save