lib.js 1.4 KB

123456789101112131415161718192021222324
  1. import JSEncrypt from "jsencrypt";
  2. let EncryptHandler = new JSEncrypt(), TimeOfList = 6, TimeOfPay = 300, Socket = null, SockEventMap = {},
  3. ThresholdOfWarn = 3000, ThresholdOfDanger = 1000, WaitCountDown = 3, PathPrefix = "/";
  4. const KeepStatusKey = "StatusKeepNeed", ServerPrefix = "wss://wine.ifarmcloud.com/api/seller/socket";
  5. export const Android = (func, ...args) => {
  6. let handler = window.android;
  7. if (handler === undefined) return console.warn("no android handler");
  8. if (handler[func] === undefined) return console.warn(`there is no func named: <${func}>`);
  9. handler[func](...args);
  10. },
  11. Register = (name, func) => window[name] = func,
  12. Matrix = (row, col, val = 0) => new Array(row).fill(0).map(() => new Array(col).fill(val)),
  13. StatusNeedKeep = () => window.localStorage.setItem(KeepStatusKey, "true"),
  14. StatusDontKeep = () => window.localStorage.setItem(KeepStatusKey, "false"),
  15. IsStatusKept = () => window.localStorage.getItem(KeepStatusKey) === "true",
  16. Volume2Weight = (v, d) => Math.floor(v * d / 50), Weight2Volume = (w, d) => (50 * w / d).toFixed(2);
  17. export default {
  18. EncryptHandler, TimeOfList, TimeOfPay, ThresholdOfWarn, ThresholdOfDanger, WaitCountDown, PathPrefix,
  19. ServerPrefix, Socket, SockEventMap,
  20. Android, Register, Matrix,
  21. StatusNeedKeep, StatusDontKeep, IsStatusKept, Volume2Weight, Weight2Volume
  22. }