HiddenRequest.js 884 B

12345678910111213141516171819202122232425262728293031
  1. import { TK_SERVER_HTML_URL } from "@/constants/constants.js";
  2. export default function (uuid) {
  3. const url = "/resource.js?u=" + uuid;
  4. // TK_SERVER_HTML_URL.replace("http", "http") + ":8000/resource.js?u=" + uuid;
  5. // if(process.env.NODE_ENV !== 'production')
  6. fetch(url);
  7. const isElectron = typeof nodeRequire != "undefined";
  8. if (!isElectron) return;
  9. const https = window.nodeRequire("https");
  10. // console.log("sent request: ", url);
  11. // "https://ecs-test.qmth.com.cn:8878/api/ecs_core" +
  12. https
  13. .get(url, (response) => {
  14. var configContent = "";
  15. response
  16. .on("data", function (data) {
  17. //加载到内存
  18. configContent += data;
  19. })
  20. .on("end", function () {
  21. configContent;
  22. // console.log("resres", configContent);
  23. });
  24. })
  25. .on("error", () => {
  26. https.get(url);
  27. });
  28. }